From: Uwe Hermann Date: Sun, 27 Mar 2016 21:16:59 +0000 (+0200) Subject: Consistently don't check sdi->priv in dev_acquisition_start(). X-Git-Tag: libsigrok-0.5.0~482 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=208c1d35435626a11afa1ab301b2071b2a4e187b;p=libsigrok.git Consistently don't check sdi->priv in dev_acquisition_start(). Most drivers already assume this to be != NULL anyway, and the check should probably be in the API wrappers anyway. --- diff --git a/src/hardware/agilent-dmm/api.c b/src/hardware/agilent-dmm/api.c index 594b1b73..dd39322c 100644 --- a/src/hardware/agilent-dmm/api.c +++ b/src/hardware/agilent-dmm/api.c @@ -235,11 +235,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } - + devc = sdi->priv; devc->cb_data = cb_data; std_session_send_df_header(cb_data, LOG_PREFIX); diff --git a/src/hardware/appa-55ii/api.c b/src/hardware/appa-55ii/api.c index 86f78543..e033f5d3 100644 --- a/src/hardware/appa-55ii/api.c +++ b/src/hardware/appa-55ii/api.c @@ -225,8 +225,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { struct sr_serial_dev_inst *serial; struct dev_context *devc; @@ -235,11 +234,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } - + devc = sdi->priv; devc->session_cb_data = cb_data; /* diff --git a/src/hardware/arachnid-labs-re-load-pro/api.c b/src/hardware/arachnid-labs-re-load-pro/api.c index 86d34a47..1c351ffe 100644 --- a/src/hardware/arachnid-labs-re-load-pro/api.c +++ b/src/hardware/arachnid-labs-re-load-pro/api.c @@ -352,7 +352,6 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) return SR_ERR_DEV_CLOSED; devc = sdi->priv; - serial = sdi->conn; /* Send the 'monitor ' command (doesn't have a reply). */ diff --git a/src/hardware/atten-pps3xxx/api.c b/src/hardware/atten-pps3xxx/api.c index efe06acc..c90ab12d 100644 --- a/src/hardware/atten-pps3xxx/api.c +++ b/src/hardware/atten-pps3xxx/api.c @@ -460,8 +460,7 @@ static int dev_close(struct sr_dev_inst *sdi) return std_serial_dev_close(sdi); } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { struct dev_context *devc; struct sr_serial_dev_inst *serial; diff --git a/src/hardware/beaglelogic/api.c b/src/hardware/beaglelogic/api.c index 6e881889..eb0d186a 100644 --- a/src/hardware/beaglelogic/api.c +++ b/src/hardware/beaglelogic/api.c @@ -337,13 +337,13 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * #define BUFUNIT_TIMEOUT_MS(devc) (100 + ((devc->bufunitsize * 1000) / \ (uint32_t)(devc->cur_samplerate))) -static int dev_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { - (void)cb_data; struct dev_context *devc = sdi->priv; struct sr_trigger *trigger; + (void)cb_data; + if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; diff --git a/src/hardware/brymen-bm86x/api.c b/src/hardware/brymen-bm86x/api.c index 71de86d1..4098b926 100644 --- a/src/hardware/brymen-bm86x/api.c +++ b/src/hardware/brymen-bm86x/api.c @@ -249,8 +249,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { struct dev_context *devc; diff --git a/src/hardware/brymen-dmm/api.c b/src/hardware/brymen-dmm/api.c index c0ee0b47..3700515f 100644 --- a/src/hardware/brymen-dmm/api.c +++ b/src/hardware/brymen-dmm/api.c @@ -202,11 +202,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } - + devc = sdi->priv; devc->cb_data = cb_data; /* diff --git a/src/hardware/cem-dt-885x/api.c b/src/hardware/cem-dt-885x/api.c index ff2edb12..b9a7cb68 100644 --- a/src/hardware/cem-dt-885x/api.c +++ b/src/hardware/cem-dt-885x/api.c @@ -386,11 +386,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } - + devc = sdi->priv; devc->cb_data = cb_data; devc->state = ST_INIT; devc->num_samples = 0; diff --git a/src/hardware/chronovu-la/api.c b/src/hardware/chronovu-la/api.c index 4ea1440a..5914ef21 100644 --- a/src/hardware/chronovu-la/api.c +++ b/src/hardware/chronovu-la/api.c @@ -515,10 +515,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } + devc = sdi->priv; if (!devc->ftdic) { sr_err("devc->ftdic was NULL."); diff --git a/src/hardware/colead-slm/api.c b/src/hardware/colead-slm/api.c index 2841304a..b75af7f6 100644 --- a/src/hardware/colead-slm/api.c +++ b/src/hardware/colead-slm/api.c @@ -179,11 +179,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } - + devc = sdi->priv; devc->cb_data = cb_data; std_session_send_df_header(cb_data, LOG_PREFIX); diff --git a/src/hardware/fluke-dmm/api.c b/src/hardware/fluke-dmm/api.c index 599f1115..a7b2e14d 100644 --- a/src/hardware/fluke-dmm/api.c +++ b/src/hardware/fluke-dmm/api.c @@ -259,11 +259,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } - + devc = sdi->priv; devc->cb_data = cb_data; std_session_send_df_header(cb_data, LOG_PREFIX); diff --git a/src/hardware/gmc-mh-1x-2x/api.c b/src/hardware/gmc-mh-1x-2x/api.c index 639cce03..d4e44b25 100644 --- a/src/hardware/gmc-mh-1x-2x/api.c +++ b/src/hardware/gmc-mh-1x-2x/api.c @@ -466,12 +466,10 @@ static int dev_acquisition_start_1x_2x_rs232(const struct sr_dev_inst *sdi, struct dev_context *devc; struct sr_serial_dev_inst *serial; - if (!sdi || !cb_data || !(devc = sdi->priv)) - return SR_ERR_BUG; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; + devc = sdi->priv; devc->cb_data = cb_data; devc->settings_ok = FALSE; devc->buflen = 0; @@ -496,12 +494,10 @@ static int dev_acquisition_start_2x_bd232(const struct sr_dev_inst *sdi, struct dev_context *devc; struct sr_serial_dev_inst *serial; - if (!sdi || !cb_data || !(devc = sdi->priv)) - return SR_ERR_BUG; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; + devc = sdi->priv; devc->cb_data = cb_data; devc->settings_ok = FALSE; devc->buflen = 0; diff --git a/src/hardware/hung-chang-dso-2100/api.c b/src/hardware/hung-chang-dso-2100/api.c index e76b9a51..9f2d56a0 100644 --- a/src/hardware/hung-chang-dso-2100/api.c +++ b/src/hardware/hung-chang-dso-2100/api.c @@ -686,8 +686,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { struct dev_context *devc = sdi->priv; int ret; diff --git a/src/hardware/ikalogic-scanaplus/api.c b/src/hardware/ikalogic-scanaplus/api.c index dd457c80..c445b993 100644 --- a/src/hardware/ikalogic-scanaplus/api.c +++ b/src/hardware/ikalogic-scanaplus/api.c @@ -358,8 +358,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) - return SR_ERR_BUG; + devc = sdi->priv; if (!devc->ftdic) return SR_ERR_BUG; diff --git a/src/hardware/kecheng-kc-330b/api.c b/src/hardware/kecheng-kc-330b/api.c index e299a339..df11489d 100644 --- a/src/hardware/kecheng-kc-330b/api.c +++ b/src/hardware/kecheng-kc-330b/api.c @@ -413,8 +413,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { struct sr_dev_driver *di = sdi->driver; struct drv_context *drvc; diff --git a/src/hardware/kern-scale/api.c b/src/hardware/kern-scale/api.c index 6801abfe..b5e5c280 100644 --- a/src/hardware/kern-scale/api.c +++ b/src/hardware/kern-scale/api.c @@ -191,11 +191,8 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) - return SR_ERR_BUG; - + devc = sdi->priv; devc->cb_data = cb_data; - serial = sdi->conn; sr_spew("Set O1 mode (continuous values, stable and unstable ones)."); diff --git a/src/hardware/maynuo-m97/api.c b/src/hardware/maynuo-m97/api.c index 46b3e0ea..4b92446e 100644 --- a/src/hardware/maynuo-m97/api.c +++ b/src/hardware/maynuo-m97/api.c @@ -453,8 +453,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return ret; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { struct dev_context *devc; struct sr_modbus_dev_inst *modbus; diff --git a/src/hardware/norma-dmm/api.c b/src/hardware/norma-dmm/api.c index 59715ec4..3e6eab78 100644 --- a/src/hardware/norma-dmm/api.c +++ b/src/hardware/norma-dmm/api.c @@ -254,12 +254,10 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) struct dev_context *devc; struct sr_serial_dev_inst *serial; - if (!sdi || !cb_data || !(devc = sdi->priv)) - return SR_ERR_BUG; - if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; + devc = sdi->priv; devc->cb_data = cb_data; std_session_send_df_header(cb_data, LOG_PREFIX); diff --git a/src/hardware/openbench-logic-sniffer/api.c b/src/hardware/openbench-logic-sniffer/api.c index d4cd1c2d..af1ce784 100644 --- a/src/hardware/openbench-logic-sniffer/api.c +++ b/src/hardware/openbench-logic-sniffer/api.c @@ -463,8 +463,7 @@ static int set_trigger(const struct sr_dev_inst *sdi, int stage) return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { struct dev_context *devc; struct sr_serial_dev_inst *serial; diff --git a/src/hardware/pipistrello-ols/api.c b/src/hardware/pipistrello-ols/api.c index d015d7d5..865c3bf6 100644 --- a/src/hardware/pipistrello-ols/api.c +++ b/src/hardware/pipistrello-ols/api.c @@ -535,8 +535,7 @@ static int disable_trigger(const struct sr_dev_inst *sdi, int stage) return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { struct dev_context *devc; uint32_t samplecount, readcount, delaycount; diff --git a/src/hardware/serial-dmm/api.c b/src/hardware/serial-dmm/api.c index 03af2d58..f53381bf 100644 --- a/src/hardware/serial-dmm/api.c +++ b/src/hardware/serial-dmm/api.c @@ -219,11 +219,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } - + devc = sdi->priv; devc->cb_data = cb_data; /* diff --git a/src/hardware/teleinfo/api.c b/src/hardware/teleinfo/api.c index 667ce33d..1becb31e 100644 --- a/src/hardware/teleinfo/api.c +++ b/src/hardware/teleinfo/api.c @@ -202,11 +202,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("sdi->priv was NULL."); - return SR_ERR_BUG; - } - + devc = sdi->priv; devc->session_cb_data = cb_data; /* diff --git a/src/hardware/tondaj-sl-814/api.c b/src/hardware/tondaj-sl-814/api.c index 07a8ecae..979a8bea 100644 --- a/src/hardware/tondaj-sl-814/api.c +++ b/src/hardware/tondaj-sl-814/api.c @@ -161,8 +161,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { struct dev_context *devc; struct sr_serial_dev_inst *serial; diff --git a/src/hardware/uni-t-dmm/api.c b/src/hardware/uni-t-dmm/api.c index ffafcd08..f3416c26 100644 --- a/src/hardware/uni-t-dmm/api.c +++ b/src/hardware/uni-t-dmm/api.c @@ -194,9 +194,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) struct dev_context *devc; devc = sdi->priv; - devc->cb_data = cb_data; - devc->starttime = g_get_monotonic_time(); std_session_send_df_header(sdi, LOG_PREFIX); diff --git a/src/hardware/uni-t-ut32x/api.c b/src/hardware/uni-t-ut32x/api.c index 2c63c279..ea57ed03 100644 --- a/src/hardware/uni-t-ut32x/api.c +++ b/src/hardware/uni-t-ut32x/api.c @@ -271,8 +271,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { struct sr_dev_driver *di = sdi->driver; struct drv_context *drvc; diff --git a/src/hardware/zeroplus-logic-cube/api.c b/src/hardware/zeroplus-logic-cube/api.c index ab4c3cc4..ca3d5ad2 100644 --- a/src/hardware/zeroplus-logic-cube/api.c +++ b/src/hardware/zeroplus-logic-cube/api.c @@ -512,8 +512,7 @@ static int config_list(uint32_t key, GVariant **data, const struct sr_dev_inst * return SR_OK; } -static int dev_acquisition_start(const struct sr_dev_inst *sdi, - void *cb_data) +static int dev_acquisition_start(const struct sr_dev_inst *sdi, void *cb_data) { struct dev_context *devc; struct sr_usb_dev_inst *usb; @@ -538,10 +537,7 @@ static int dev_acquisition_start(const struct sr_dev_inst *sdi, if (sdi->status != SR_ST_ACTIVE) return SR_ERR_DEV_CLOSED; - if (!(devc = sdi->priv)) { - sr_err("%s: sdi->priv was NULL", __func__); - return SR_ERR_ARG; - } + devc = sdi->priv; if (analyzer_add_triggers(sdi) != SR_OK) { sr_err("Failed to configure triggers.");