From: Uwe Hermann Date: Sat, 21 Mar 2015 17:26:52 +0000 (+0100) Subject: Minor cosmetics, cleanups. X-Git-Tag: libsigrok-0.4.0~582 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=1a8639164e4e44a43fe1558e30823606f7b607b3;p=libsigrok.git Minor cosmetics, cleanups. --- diff --git a/src/drivers.c b/src/drivers.c index 6eac4589..aef0a68a 100644 --- a/src/drivers.c +++ b/src/drivers.c @@ -214,7 +214,8 @@ SR_PRIV struct sr_dev_driver **drivers_lists[] = { (DRVS) { ¢er_309_driver_info, &voltcraft_k204_driver_info, - NULL}, + NULL + }, #endif #ifdef HAVE_HW_CHRONOVU_LA (DRVS) {&chronovu_la_driver_info, NULL}, @@ -241,7 +242,8 @@ SR_PRIV struct sr_dev_driver **drivers_lists[] = { (DRVS) { &gmc_mh_1x_2x_rs232_driver_info, &gmc_mh_2x_bd232_driver_info, - NULL}, + NULL + }, #endif #ifdef HAVE_HW_HAMEG_HMO (DRVS) {&hameg_hmo_driver_info, NULL}, @@ -271,7 +273,8 @@ SR_PRIV struct sr_dev_driver **drivers_lists[] = { (DRVS) { &mic_98581_driver_info, &mic_98583_driver_info, - NULL}, + NULL + }, #endif #ifdef HAVE_HW_MOTECH_LPS_30X (DRVS) {&motech_lps_301_driver_info, NULL}, @@ -280,7 +283,8 @@ SR_PRIV struct sr_dev_driver **drivers_lists[] = { (DRVS) { &norma_dmm_driver_info, &siemens_b102x_driver_info, - NULL}, + NULL + }, #endif #ifdef HAVE_HW_OPENBENCH_LOGIC_SNIFFER (DRVS) {&ols_driver_info, NULL}, @@ -337,7 +341,8 @@ SR_PRIV struct sr_dev_driver **drivers_lists[] = { &voltcraft_vc960_driver_info, &tenma_72_7745_driver_info, &tenma_72_7750_driver_info, - NULL}, + NULL + }, #endif #ifdef HAVE_HW_UNI_T_UT32X (DRVS) {&uni_t_ut32x_driver_info, NULL}, @@ -354,4 +359,3 @@ SR_PRIV struct sr_dev_driver **drivers_lists[] = { NULL, }; /** @endcond */ - diff --git a/src/hardware/center-3xx/api.c b/src/hardware/center-3xx/api.c index 3827c639..adf56bd9 100644 --- a/src/hardware/center-3xx/api.c +++ b/src/hardware/center-3xx/api.c @@ -240,20 +240,19 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) /* Driver-specific API function wrappers */ #define HW_INIT(X) \ static int init_##X(struct sr_dev_driver *d, \ - struct sr_context *sr_ctx) { \ - (void) d; return init(sr_ctx, X); } + struct sr_context *sr_ctx) { (void)d; return init(sr_ctx, X); } #define HW_CLEANUP(X) \ static int cleanup_##X(const struct sr_dev_driver *d) { \ - (void) d; return cleanup(X); } + (void)d; return cleanup(X); } #define HW_SCAN(X) \ static GSList *scan_##X(struct sr_dev_driver *d, GSList *options) { \ - (void) d; return scan(options, X); } + (void)d; return scan(options, X); } #define HW_DEV_LIST(X) \ static GSList *dev_list_##X(const struct sr_dev_driver *d) { \ - (void) d; return dev_list(X); } + (void)d; return dev_list(X); } #define HW_DEV_CLEAR(X) \ static int dev_clear_##X(const struct sr_dev_driver *d) { \ - (void) d; return dev_clear(X); } + (void)d; return dev_clear(X); } #define HW_DEV_ACQUISITION_START(X) \ static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \ void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); } diff --git a/src/hardware/fx2lafw/api.c b/src/hardware/fx2lafw/api.c index 1fb2235f..5e1f6643 100644 --- a/src/hardware/fx2lafw/api.c +++ b/src/hardware/fx2lafw/api.c @@ -598,9 +598,8 @@ static int receive_data(int fd, int revents, void *cb_data) (void)fd; (void)revents; - (void)cb_data; - drvc = (struct drv_context *) cb_data; + drvc = (struct drv_context *)cb_data; tv.tv_sec = tv.tv_usec = 0; libusb_handle_events_timeout(drvc->sr_ctx->libusb_ctx, &tv); diff --git a/src/hardware/gmc-mh-1x-2x/api.c b/src/hardware/gmc-mh-1x-2x/api.c index 13918c63..bf0b3691 100644 --- a/src/hardware/gmc-mh-1x-2x/api.c +++ b/src/hardware/gmc-mh-1x-2x/api.c @@ -66,7 +66,6 @@ static const uint32_t devopts_bd[] = { * Need to implement device-specific lists. */ -/** Init driver. */ static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) { return std_init(sr_ctx, di, LOG_PREFIX); @@ -237,8 +236,9 @@ static GSList *scan_1x_2x_rs232(struct sr_dev_driver *di, GSList *options) return devices; } -/** Scan for Metrahit 2x in a bidirectional mode using Gossen Metrawatt 'BD 232' interface. - * +/** + * Scan for Metrahit 2x in a bidirectional mode using Gossen Metrawatt + * 'BD 232' interface. */ static GSList *scan_2x_bd232(struct sr_dev_driver *di, GSList *options) { @@ -354,7 +354,6 @@ exit_err: return NULL; } -/** Driver device list function */ static GSList *dev_list(const struct sr_dev_driver *di) { return ((struct drv_context *)(di->priv))->instances; @@ -383,7 +382,6 @@ static int cleanup(const struct sr_dev_driver *di) return std_dev_clear(di, NULL); } -/** Get value of configuration item */ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { @@ -415,7 +413,7 @@ static int config_get(uint32_t key, GVariant **data, const struct sr_dev_inst *s return ret; } -/** Implementation of config_list, auxiliary function for common parts, */ +/** Implementation of config_list, auxiliary function for common parts. */ static int config_list_common(uint32_t key, GVariant **data, const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { diff --git a/src/hardware/mic-985xx/api.c b/src/hardware/mic-985xx/api.c index 5a70df00..df9cc22e 100644 --- a/src/hardware/mic-985xx/api.c +++ b/src/hardware/mic-985xx/api.c @@ -249,19 +249,19 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) /* Driver-specific API function wrappers */ #define HW_INIT(X) \ static int init_##X(struct sr_dev_driver *di, struct sr_context *sr_ctx) { \ - (void) di; return init(sr_ctx, X); } + (void)di; return init(sr_ctx, X); } #define HW_CLEANUP(X) \ static int cleanup_##X(const struct sr_dev_driver *di) { \ - (void) di; return cleanup(X); } + (void)di; return cleanup(X); } #define HW_SCAN(X) \ static GSList *scan_##X(struct sr_dev_driver *di, GSList *options) { \ - (void) di; return scan(options, X); } + (void)di; return scan(options, X); } #define HW_DEV_LIST(X) \ static GSList *dev_list_##X(const struct sr_dev_driver *di) { \ - (void) di; return dev_list(X); } + (void)di; return dev_list(X); } #define HW_DEV_CLEAR(X) \ static int dev_clear_##X(const struct sr_dev_driver *di) { \ - (void) di; return dev_clear(X); } + (void)di; return dev_clear(X); } #define HW_CONFIG_LIST(X) \ static int config_list_##X(uint32_t key, GVariant **data, \ const struct sr_dev_inst *sdi, const struct sr_channel_group *cg) { \ diff --git a/src/hardware/serial-dmm/api.c b/src/hardware/serial-dmm/api.c index fb446de4..08099753 100644 --- a/src/hardware/serial-dmm/api.c +++ b/src/hardware/serial-dmm/api.c @@ -53,7 +53,7 @@ static int init(struct sr_dev_driver *di, struct sr_context *sr_ctx) static GSList *scan(struct sr_dev_driver *di, GSList *options) { - struct dmm_info *dmm = (struct dmm_info *) di; + struct dmm_info *dmm; struct sr_config *src; GSList *l, *devices; const char *conn, *serialcomm; @@ -65,6 +65,8 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) size_t len; uint8_t buf[128]; + dmm = (struct dmm_info *)di; + conn = serialcomm = NULL; for (l = options; l; l = l->next) { src = l->data; diff --git a/src/hardware/serial-dmm/protocol.c b/src/hardware/serial-dmm/protocol.c index 119d0403..6128e493 100644 --- a/src/hardware/serial-dmm/protocol.c +++ b/src/hardware/serial-dmm/protocol.c @@ -41,12 +41,14 @@ static void log_dmm_packet(const uint8_t *buf) static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, void *info) { - struct dmm_info *dmm = (struct dmm_info *) sdi->driver; + struct dmm_info *dmm; float floatval; struct sr_datafeed_packet packet; struct sr_datafeed_analog analog; struct dev_context *devc; + dmm = (struct dmm_info *)sdi->driver; + log_dmm_packet(buf); devc = sdi->priv; @@ -75,11 +77,13 @@ static void handle_packet(const uint8_t *buf, struct sr_dev_inst *sdi, /** Request packet, if required. */ SR_PRIV int req_packet(struct sr_dev_inst *sdi) { - struct dmm_info *dmm = (struct dmm_info *) sdi->driver; + struct dmm_info *dmm; struct dev_context *devc; struct sr_serial_dev_inst *serial; int ret; + dmm = (struct dmm_info *)sdi->driver; + if (!dmm->packet_request) return SR_OK; @@ -106,11 +110,13 @@ SR_PRIV int req_packet(struct sr_dev_inst *sdi) static void handle_new_data(struct sr_dev_inst *sdi, void *info) { - struct dmm_info *dmm = (struct dmm_info *) sdi->driver; + struct dmm_info *dmm; struct dev_context *devc; int len, i, offset = 0; struct sr_serial_dev_inst *serial; + dmm = (struct dmm_info *)sdi->driver; + devc = sdi->priv; serial = sdi->conn; @@ -165,7 +171,7 @@ int receive_data(int fd, int revents, void *cb_data) if (!(devc = sdi->priv)) return TRUE; - dmm = (struct dmm_info *) sdi->driver; + dmm = (struct dmm_info *)sdi->driver; if (revents == G_IO_IN) { /* Serial data arrived. */ diff --git a/src/hardware/uni-t-dmm/api.c b/src/hardware/uni-t-dmm/api.c index 6f08e735..e964279d 100644 --- a/src/hardware/uni-t-dmm/api.c +++ b/src/hardware/uni-t-dmm/api.c @@ -415,19 +415,19 @@ static int dev_acquisition_stop(struct sr_dev_inst *sdi, void *cb_data) /* Driver-specific API function wrappers */ #define HW_INIT(X) \ static int init_##X(struct sr_dev_driver *di, struct sr_context *sr_ctx) { \ - (void) di; return init(sr_ctx, X); } + (void)di; return init(sr_ctx, X); } #define HW_CLEANUP(X) \ static int cleanup_##X(const struct sr_dev_driver *di) { \ - (void) di; return cleanup(X); } + (void)di; return cleanup(X); } #define HW_SCAN(X) \ static GSList *scan_##X(struct sr_dev_driver *di, GSList *options) { \ - (void) di; return scan(options, X); } + (void)di; return scan(options, X); } #define HW_DEV_LIST(X) \ static GSList *dev_list_##X(const struct sr_dev_driver *di) { \ - (void) di; return dev_list(X); } + (void)di; return dev_list(X); } #define HW_DEV_CLEAR(X) \ static int dev_clear_##X(const struct sr_dev_driver *di) { \ - (void) di; return dev_clear(X); } + (void)di; return dev_clear(X); } #define HW_DEV_ACQUISITION_START(X) \ static int dev_acquisition_start_##X(const struct sr_dev_inst *sdi, \ void *cb_data) { return dev_acquisition_start(sdi, cb_data, X); } diff --git a/src/hwdriver.c b/src/hwdriver.c index a9561d3e..d11bcccc 100644 --- a/src/hwdriver.c +++ b/src/hwdriver.c @@ -269,14 +269,15 @@ SR_API struct sr_dev_driver **sr_driver_list(void) struct sr_dev_driver ***lists, **drivers; GArray *array; - if (!combined_list) { - array = g_array_new(TRUE, FALSE, sizeof(struct sr_dev_driver *)); - for (lists = drivers_lists; *lists; lists++) - for (drivers = *lists; *drivers; drivers++) - g_array_append_val(array, *drivers); - combined_list = (struct sr_dev_driver **) array->data; - g_array_free(array, FALSE); - } + if (combined_list) + return combined_list; + + array = g_array_new(TRUE, FALSE, sizeof(struct sr_dev_driver *)); + for (lists = drivers_lists; *lists; lists++) + for (drivers = *lists; *drivers; drivers++) + g_array_append_val(array, *drivers); + combined_list = (struct sr_dev_driver **)array->data; + g_array_free(array, FALSE); return combined_list; }