From: Uwe Hermann Date: Thu, 24 Nov 2011 21:57:48 +0000 (+0100) Subject: Other method to avoid "unused var" compiler warnings. X-Git-Tag: libsigrok-0.1.0~222 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=cb93f8a927e6fb2cb1d89176766c5c9c398db5c3;p=libsigrok.git Other method to avoid "unused var" compiler warnings. The '(void)varname' method is nicer than 'varname = varname' and also prevents warnings when compiling sigrok with clang instead of gcc. --- diff --git a/datastore.c b/datastore.c index 11ae0e15..774ec08c 100644 --- a/datastore.c +++ b/datastore.c @@ -69,8 +69,8 @@ void sr_datastore_put(struct sr_datastore *ds, void *data, unsigned int length, gpointer chunk; /* Avoid compiler warnings. */ - in_unitsize = in_unitsize; - probelist = probelist; + (void)in_unitsize; + (void)probelist; if (ds->chunklist == NULL) chunk = new_chunk(&ds); diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index 71cb2fdd..e6a109c6 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -400,7 +400,7 @@ static int hw_init(const char *deviceinfo) struct sigma *sigma; /* Avoid compiler warnings. */ - deviceinfo = deviceinfo; + (void)deviceinfo; if (!(sigma = g_try_malloc(sizeof(struct sigma)))) { sr_err("sigma: %s: sigma malloc failed", __func__); @@ -997,8 +997,9 @@ static int receive_data(int fd, int revents, void *session_data) uint64_t running_msec; struct timeval tv; - fd = fd; - revents = revents; + /* Avoid compiler warnings. */ + (void)fd; + (void)revents; numchunks = (sigma->state.stoppos + 511) / 512; @@ -1245,7 +1246,8 @@ static int hw_start_acquisition(int device_index, gpointer session_data) struct triggerinout triggerinout_conf; struct triggerlut lut; - session_data = session_data; + /* Avoid compiler warnings. */ + (void)session_data; if (!(sdi = sr_get_device_instance(device_instances, device_index))) return SR_ERR; @@ -1361,7 +1363,8 @@ static void hw_stop_acquisition(int device_index, gpointer session_data) sigma = sdi->priv; - session_data = session_data; + /* Avoid compiler warnings. */ + (void)session_data; /* Stop acquisition. */ sigma_set_register(WRITE_MODE, 0x11, sigma); diff --git a/hardware/chronovu-la8/chronovu-la8.c b/hardware/chronovu-la8/chronovu-la8.c index 1eb52a2e..20ffec9d 100644 --- a/hardware/chronovu-la8/chronovu-la8.c +++ b/hardware/chronovu-la8/chronovu-la8.c @@ -470,7 +470,7 @@ static int hw_init(const char *deviceinfo) sr_spew("la8: entering %s", __func__); /* Avoid compiler errors. */ - deviceinfo = deviceinfo; + (void)deviceinfo; /* Allocate memory for our private driver context. */ if (!(la8 = g_try_malloc(sizeof(struct la8)))) { @@ -981,8 +981,8 @@ static int receive_data(int fd, int revents, void *session_data) struct la8 *la8; /* Avoid compiler errors. */ - fd = fd; - revents = revents; + (void)fd; + (void)revents; if (!(sdi = session_data)) { sr_err("la8: %s: user_data was NULL", __func__); diff --git a/hardware/demo/demo.c b/hardware/demo/demo.c index c06a814a..1492dadf 100644 --- a/hardware/demo/demo.c +++ b/hardware/demo/demo.c @@ -130,7 +130,7 @@ static int hw_init(const char *deviceinfo) struct sr_device_instance *sdi; /* Avoid compiler warnings. */ - deviceinfo = deviceinfo; + (void)deviceinfo; sdi = sr_device_instance_new(0, SR_ST_ACTIVE, DEMONAME, NULL, NULL); if (!sdi) { @@ -146,7 +146,7 @@ static int hw_init(const char *deviceinfo) static int hw_opendev(int device_index) { /* Avoid compiler warnings. */ - device_index = device_index; + (void)device_index; /* Nothing needed so far. */ @@ -156,7 +156,7 @@ static int hw_opendev(int device_index) static int hw_closedev(int device_index) { /* Avoid compiler warnings. */ - device_index = device_index; + (void)device_index; /* Nothing needed so far. */ @@ -202,7 +202,7 @@ static void *hw_get_device_info(int device_index, int device_info_id) static int hw_get_status(int device_index) { /* Avoid compiler warnings. */ - device_index = device_index; + (void)device_index; return SR_ST_ACTIVE; } @@ -218,7 +218,7 @@ static int hw_set_configuration(int device_index, int capability, void *value) char *stropt; /* Avoid compiler warnings. */ - device_index = device_index; + (void)device_index; if (capability == SR_HWCAP_PROBECONFIG) { /* Nothing to do, but must be supported */ @@ -359,8 +359,8 @@ static int receive_data(int fd, int revents, void *session_data) gsize z; /* Avoid compiler warnings. */ - fd = fd; - revents = revents; + (void)fd; + (void)revents; do { g_io_channel_read_chars(channels[0], @@ -471,8 +471,8 @@ static int hw_start_acquisition(int device_index, gpointer session_data) static void hw_stop_acquisition(int device_index, gpointer session_data) { /* Avoid compiler warnings. */ - device_index = device_index; - session_data = session_data; + (void)device_index; + (void)session_data; /* Stop generate thread. */ thread_running = 0; diff --git a/hardware/openbench-logic-sniffer/ols.c b/hardware/openbench-logic-sniffer/ols.c index 57881f83..2edb6acb 100644 --- a/hardware/openbench-logic-sniffer/ols.c +++ b/hardware/openbench-logic-sniffer/ols.c @@ -979,7 +979,7 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id) struct sr_datafeed_packet packet; /* Avoid compiler warnings. */ - device_index = device_index; + (void)device_index; packet.type = SR_DF_END; sr_session_bus(session_device_id, &packet); diff --git a/hardware/saleae-logic/saleae-logic.c b/hardware/saleae-logic/saleae-logic.c index a1ab755b..44fe0a4a 100644 --- a/hardware/saleae-logic/saleae-logic.c +++ b/hardware/saleae-logic/saleae-logic.c @@ -292,7 +292,7 @@ static int hw_init(const char *deviceinfo) int err, devcnt, i, j; /* Avoid compiler warnings. */ - deviceinfo = deviceinfo; + (void)deviceinfo; if (libusb_init(&usb_context) != 0) { sr_warn("Failed to initialize USB."); @@ -554,9 +554,9 @@ static int receive_data(int fd, int revents, void *user_data) struct timeval tv; /* Avoid compiler warnings. */ - fd = fd; - revents = revents; - user_data = user_data; + (void)fd; + (void)revents; + (void)user_data; tv.tv_sec = tv.tv_usec = 0; libusb_handle_events_timeout(usb_context, &tv); @@ -780,7 +780,7 @@ static void hw_stop_acquisition(int device_index, gpointer session_data) struct sr_datafeed_packet packet; /* Avoid compiler warnings. */ - device_index = device_index; + (void)device_index; packet.type = SR_DF_END; sr_session_bus(session_data, &packet); diff --git a/hardware/zeroplus-logic-cube/zeroplus.c b/hardware/zeroplus-logic-cube/zeroplus.c index e48bf5e6..749925f9 100644 --- a/hardware/zeroplus-logic-cube/zeroplus.c +++ b/hardware/zeroplus-logic-cube/zeroplus.c @@ -284,7 +284,7 @@ static int hw_init(const char *deviceinfo) int err, devcnt, i; /* Avoid compiler warnings. */ - deviceinfo = deviceinfo; + (void)deviceinfo; if (libusb_init(&usb_context) != 0) { sr_warn("Failed to initialize USB."); diff --git a/hwplugin.c b/hwplugin.c index 43e6ef79..cd8fad13 100644 --- a/hwplugin.c +++ b/hwplugin.c @@ -218,7 +218,7 @@ struct sr_usb_device_instance *sr_usb_device_instance_new(uint8_t bus, void sr_usb_device_instance_free(struct sr_usb_device_instance *usb) { /* Avoid compiler warnings. */ - usb = usb; + (void)usb; /* Nothing to do for this device instance type. */ } diff --git a/output/output_binary.c b/output/output_binary.c index e5c1e4ad..98ad3ad9 100644 --- a/output/output_binary.c +++ b/output/output_binary.c @@ -31,7 +31,7 @@ static int data(struct sr_output *o, const char *data_in, uint64_t length_in, char *outbuf; /* Prevent compiler warnings. */ - o = o; + (void)o; if (!data_in) { sr_warn("binary output: %s: data_in was NULL", __func__); diff --git a/session_driver.c b/session_driver.c index b7cd5f14..27821861 100644 --- a/session_driver.c +++ b/session_driver.c @@ -70,9 +70,9 @@ static int feed_chunk(int fd, int revents, void *session_data) void *buf; int ret, got_data; - /* avoid compiler warning */ - fd = fd; - revents = revents; + /* Avoid compiler warnings. */ + (void)fd; + (void)revents; sr_dbg("session_driver: feed chunk"); @@ -183,9 +183,8 @@ static void *hw_get_device_info(int device_index, int device_info_id) static int hw_get_status(int device_index) { - - /* avoid compiler warning */ - device_index = device_index; + /* Avoid compiler warnings. */ + (void)device_index; if (devices) return SR_OK; @@ -238,8 +237,8 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id) struct sr_datafeed_packet *packet; int err; - /* avoid compiler warning */ - session_device_id = session_device_id; + /* Avoid compiler warnings. */ + (void)session_device_id; if (!(vdevice = get_vdevice_by_index(device_index))) return SR_ERR;