From: Uwe Hermann Date: Tue, 11 Jul 2017 19:30:30 +0000 (+0200) Subject: clear_helper(): Use a cast to shorten all implementations. X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3553451f1ed45d92bff11952cb131ac6a891b69f;p=libsigrok.git clear_helper(): Use a cast to shorten all implementations. --- diff --git a/src/hardware/asix-sigma/api.c b/src/hardware/asix-sigma/api.c index cf02b1e5..98d5180b 100644 --- a/src/hardware/asix-sigma/api.c +++ b/src/hardware/asix-sigma/api.c @@ -59,18 +59,14 @@ static const int32_t trigger_matches[] = { }; #endif -static void clear_helper(void *priv) +static void clear_helper(struct dev_context *devc) { - struct dev_context *devc; - - devc = priv; - ftdi_deinit(&devc->ftdic); } static int dev_clear(const struct sr_dev_driver *di) { - return std_dev_clear_with_callback(di, clear_helper); + return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } static GSList *scan(struct sr_dev_driver *di, GSList *options) diff --git a/src/hardware/chronovu-la/api.c b/src/hardware/chronovu-la/api.c index d6ed20d9..2c4ec3db 100644 --- a/src/hardware/chronovu-la/api.c +++ b/src/hardware/chronovu-la/api.c @@ -43,19 +43,15 @@ static const int32_t trigger_matches[] = { SR_TRIGGER_FALLING, }; -static void clear_helper(void *priv) +static void clear_helper(struct dev_context *devc) { - struct dev_context *devc; - - devc = priv; - ftdi_free(devc->ftdic); g_free(devc->final_buf); } static int dev_clear(const struct sr_dev_driver *di) { - return std_dev_clear_with_callback(di, clear_helper); + return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } static int add_device(int model, struct libusb_device_descriptor *des, diff --git a/src/hardware/demo/api.c b/src/hardware/demo/api.c index 6549b5d7..f88b4c2e 100644 --- a/src/hardware/demo/api.c +++ b/src/hardware/demo/api.c @@ -180,14 +180,11 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return std_scan_complete(di, g_slist_append(NULL, sdi)); } -static void clear_helper(void *priv) +static void clear_helper(struct dev_context *devc) { - struct dev_context *devc; GHashTableIter iter; void *value; - devc = priv; - /* Analog generators. */ g_hash_table_iter_init(&iter, devc->ch_ag); while (g_hash_table_iter_next(&iter, NULL, &value)) @@ -197,7 +194,7 @@ static void clear_helper(void *priv) static int dev_clear(const struct sr_dev_driver *di) { - return std_dev_clear_with_callback(di, clear_helper); + return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, diff --git a/src/hardware/ftdi-la/api.c b/src/hardware/ftdi-la/api.c index 6b545afb..6eb2353d 100644 --- a/src/hardware/ftdi-la/api.c +++ b/src/hardware/ftdi-la/api.c @@ -240,17 +240,14 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return std_scan_complete(di, devices); } -static void clear_helper(void *priv) +static void clear_helper(struct dev_context *devc) { - struct dev_context *devc; - - devc = priv; g_free(devc->data_buf); } static int dev_clear(const struct sr_dev_driver *di) { - return std_dev_clear_with_callback(di, clear_helper); + return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } static int dev_open(struct sr_dev_inst *sdi) diff --git a/src/hardware/fx2lafw/api.c b/src/hardware/fx2lafw/api.c index d824b022..48df729e 100644 --- a/src/hardware/fx2lafw/api.c +++ b/src/hardware/fx2lafw/api.c @@ -345,17 +345,14 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return std_scan_complete(di, devices); } -static void clear_helper(void *priv) +static void clear_helper(struct dev_context *devc) { - struct dev_context *devc; - - devc = priv; g_slist_free(devc->enabled_analog_channels); } static int dev_clear(const struct sr_dev_driver *di) { - return std_dev_clear_with_callback(di, clear_helper); + return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } static int dev_open(struct sr_dev_inst *sdi) diff --git a/src/hardware/hameg-hmo/api.c b/src/hardware/hameg-hmo/api.c index 7e062b8d..22fcbc54 100644 --- a/src/hardware/hameg-hmo/api.c +++ b/src/hardware/hameg-hmo/api.c @@ -110,21 +110,16 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return sr_scpi_scan(di->context, options, hmo_probe_serial_device); } -static void clear_helper(void *priv) +static void clear_helper(struct dev_context *devc) { - struct dev_context *devc; - - devc = priv; - hmo_scope_state_free(devc->model_state); - g_free(devc->analog_groups); g_free(devc->digital_groups); } static int dev_clear(const struct sr_dev_driver *di) { - return std_dev_clear_with_callback(di, clear_helper); + return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } static int dev_open(struct sr_dev_inst *sdi) diff --git a/src/hardware/hantek-6xxx/api.c b/src/hardware/hantek-6xxx/api.c index aa0977ad..6bdcdb1f 100644 --- a/src/hardware/hantek-6xxx/api.c +++ b/src/hardware/hantek-6xxx/api.c @@ -156,17 +156,14 @@ static int configure_channels(const struct sr_dev_inst *sdi) return SR_OK; } -static void clear_helper(void *priv) +static void clear_helper(struct dev_context *devc) { - struct dev_context *devc; - - devc = priv; g_slist_free(devc->enabled_channels); } static int dev_clear(const struct sr_dev_driver *di) { - return std_dev_clear_with_callback(di, clear_helper); + return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } static GSList *scan(struct sr_dev_driver *di, GSList *options) diff --git a/src/hardware/hantek-dso/api.c b/src/hardware/hantek-dso/api.c index ea07b546..4b911c28 100644 --- a/src/hardware/hantek-dso/api.c +++ b/src/hardware/hantek-dso/api.c @@ -232,18 +232,15 @@ static int configure_channels(const struct sr_dev_inst *sdi) return SR_OK; } -static void clear_helper(void *priv) +static void clear_helper(struct dev_context *devc) { - struct dev_context *devc; - - devc = priv; g_free(devc->triggersource); g_slist_free(devc->enabled_channels); } static int dev_clear(const struct sr_dev_driver *di) { - return std_dev_clear_with_callback(di, clear_helper); + return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } static GSList *scan(struct sr_dev_driver *di, GSList *options) diff --git a/src/hardware/hung-chang-dso-2100/api.c b/src/hardware/hung-chang-dso-2100/api.c index 505649dd..484f8768 100644 --- a/src/hardware/hung-chang-dso-2100/api.c +++ b/src/hardware/hung-chang-dso-2100/api.c @@ -218,10 +218,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return std_scan_complete(di, devices); } -static void clear_helper(void *priv) +static void clear_helper(struct dev_context *devc) { - struct dev_context *devc = priv; - g_slist_free(devc->enabled_channel); } @@ -238,7 +236,7 @@ static int dev_clear(const struct sr_dev_driver *di) } } - return std_dev_clear_with_callback(di, clear_helper); + return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } static int dev_open(struct sr_dev_inst *sdi) diff --git a/src/hardware/ikalogic-scanalogic2/api.c b/src/hardware/ikalogic-scanalogic2/api.c index 2078b801..6c336cb1 100644 --- a/src/hardware/ikalogic-scanalogic2/api.c +++ b/src/hardware/ikalogic-scanalogic2/api.c @@ -152,19 +152,15 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return std_scan_complete(di, devices); } -static void clear_helper(void *priv) +static void clear_helper(struct dev_context *devc) { - struct dev_context *devc; - - devc = priv; - libusb_free_transfer(devc->xfer_in); libusb_free_transfer(devc->xfer_out); } static int dev_clear(const struct sr_dev_driver *di) { - return std_dev_clear_with_callback(di, clear_helper); + return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } static int dev_open(struct sr_dev_inst *sdi) diff --git a/src/hardware/ikalogic-scanaplus/api.c b/src/hardware/ikalogic-scanaplus/api.c index dd5d09ff..e9c6af04 100644 --- a/src/hardware/ikalogic-scanaplus/api.c +++ b/src/hardware/ikalogic-scanaplus/api.c @@ -43,12 +43,8 @@ static const char *channel_names[] = { /* Note: The IKALOGIC ScanaPLUS always samples at 100MHz. */ static const uint64_t samplerates[1] = { SR_MHZ(100) }; -static void clear_helper(void *priv) +static void clear_helper(struct dev_context *devc) { - struct dev_context *devc; - - devc = priv; - ftdi_free(devc->ftdic); g_free(devc->compressed_buf); g_free(devc->sample_buf); @@ -56,7 +52,7 @@ static void clear_helper(void *priv) static int dev_clear(const struct sr_dev_driver *di) { - return std_dev_clear_with_callback(di, clear_helper); + return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } static GSList *scan(struct sr_dev_driver *di, GSList *options) diff --git a/src/hardware/lecroy-xstream/api.c b/src/hardware/lecroy-xstream/api.c index e00154b9..34b50b7a 100644 --- a/src/hardware/lecroy-xstream/api.c +++ b/src/hardware/lecroy-xstream/api.c @@ -115,20 +115,15 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return sr_scpi_scan(di->context, options, probe_serial_device); } -static void clear_helper(void *priv) +static void clear_helper(struct dev_context *devc) { - struct dev_context *devc; - - devc = priv; - lecroy_xstream_state_free(devc->model_state); - g_free(devc->analog_groups); } static int dev_clear(const struct sr_dev_driver *di) { - return std_dev_clear_with_callback(di, clear_helper); + return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } static int dev_open(struct sr_dev_inst *sdi) diff --git a/src/hardware/pipistrello-ols/api.c b/src/hardware/pipistrello-ols/api.c index 4440be67..545dcd14 100644 --- a/src/hardware/pipistrello-ols/api.c +++ b/src/hardware/pipistrello-ols/api.c @@ -189,19 +189,15 @@ err_free_ftdi_buf: return NULL; } -static void clear_helper(void *priv) +static void clear_helper(struct dev_context *devc) { - struct dev_context *devc; - - devc = priv; - ftdi_free(devc->ftdic); g_free(devc->ftdi_buf); } static int dev_clear(const struct sr_dev_driver *di) { - return std_dev_clear_with_callback(di, clear_helper); + return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, diff --git a/src/hardware/rigol-ds/api.c b/src/hardware/rigol-ds/api.c index 221b1234..37a1984d 100644 --- a/src/hardware/rigol-ds/api.c +++ b/src/hardware/rigol-ds/api.c @@ -275,12 +275,10 @@ static const struct rigol_ds_model supported_models[] = { static struct sr_dev_driver rigol_ds_driver_info; -static void clear_helper(void *priv) +static void clear_helper(struct dev_context *devc) { - struct dev_context *devc; unsigned int i; - devc = priv; g_free(devc->data); g_free(devc->buffer); for (i = 0; i < ARRAY_SIZE(devc->coupling); i++) @@ -292,7 +290,7 @@ static void clear_helper(void *priv) static int dev_clear(const struct sr_dev_driver *di) { - return std_dev_clear_with_callback(di, clear_helper); + return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } static struct sr_dev_inst *probe_device(struct sr_scpi_dev_inst *scpi) diff --git a/src/hardware/scpi-pps/api.c b/src/hardware/scpi-pps/api.c index 3642b31e..6b73f121 100644 --- a/src/hardware/scpi-pps/api.c +++ b/src/hardware/scpi-pps/api.c @@ -288,18 +288,15 @@ static int dev_close(struct sr_dev_inst *sdi) return sr_scpi_close(scpi); } -static void clear_helper(void *priv) +static void clear_helper(struct dev_context *devc) { - struct dev_context *devc; - - devc = priv; g_free(devc->channels); g_free(devc->channel_groups); } static int dev_clear(const struct sr_dev_driver *di) { - return std_dev_clear_with_callback(di, clear_helper); + return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, diff --git a/src/hardware/yokogawa-dlm/api.c b/src/hardware/yokogawa-dlm/api.c index cace9e58..76703d86 100644 --- a/src/hardware/yokogawa-dlm/api.c +++ b/src/hardware/yokogawa-dlm/api.c @@ -121,21 +121,16 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) return sr_scpi_scan(di->context, options, probe_usbtmc_device); } -static void clear_helper(void *priv) +static void clear_helper(struct dev_context *devc) { - struct dev_context *devc; - - devc = priv; - dlm_scope_state_destroy(devc->model_state); - g_free(devc->analog_groups); g_free(devc->digital_groups); } static int dev_clear(const struct sr_dev_driver *di) { - return std_dev_clear_with_callback(di, clear_helper); + return std_dev_clear_with_callback(di, (std_dev_clear_callback)clear_helper); } static int dev_open(struct sr_dev_inst *sdi)