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.
This commit is contained in:
Uwe Hermann 2011-11-24 22:57:48 +01:00
parent cc8a7d250c
commit cb93f8a927
10 changed files with 38 additions and 36 deletions

View File

@ -69,8 +69,8 @@ void sr_datastore_put(struct sr_datastore *ds, void *data, unsigned int length,
gpointer chunk; gpointer chunk;
/* Avoid compiler warnings. */ /* Avoid compiler warnings. */
in_unitsize = in_unitsize; (void)in_unitsize;
probelist = probelist; (void)probelist;
if (ds->chunklist == NULL) if (ds->chunklist == NULL)
chunk = new_chunk(&ds); chunk = new_chunk(&ds);

View File

@ -400,7 +400,7 @@ static int hw_init(const char *deviceinfo)
struct sigma *sigma; struct sigma *sigma;
/* Avoid compiler warnings. */ /* Avoid compiler warnings. */
deviceinfo = deviceinfo; (void)deviceinfo;
if (!(sigma = g_try_malloc(sizeof(struct sigma)))) { if (!(sigma = g_try_malloc(sizeof(struct sigma)))) {
sr_err("sigma: %s: sigma malloc failed", __func__); 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; uint64_t running_msec;
struct timeval tv; struct timeval tv;
fd = fd; /* Avoid compiler warnings. */
revents = revents; (void)fd;
(void)revents;
numchunks = (sigma->state.stoppos + 511) / 512; 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 triggerinout triggerinout_conf;
struct triggerlut lut; struct triggerlut lut;
session_data = session_data; /* Avoid compiler warnings. */
(void)session_data;
if (!(sdi = sr_get_device_instance(device_instances, device_index))) if (!(sdi = sr_get_device_instance(device_instances, device_index)))
return SR_ERR; return SR_ERR;
@ -1361,7 +1363,8 @@ static void hw_stop_acquisition(int device_index, gpointer session_data)
sigma = sdi->priv; sigma = sdi->priv;
session_data = session_data; /* Avoid compiler warnings. */
(void)session_data;
/* Stop acquisition. */ /* Stop acquisition. */
sigma_set_register(WRITE_MODE, 0x11, sigma); sigma_set_register(WRITE_MODE, 0x11, sigma);

View File

@ -470,7 +470,7 @@ static int hw_init(const char *deviceinfo)
sr_spew("la8: entering %s", __func__); sr_spew("la8: entering %s", __func__);
/* Avoid compiler errors. */ /* Avoid compiler errors. */
deviceinfo = deviceinfo; (void)deviceinfo;
/* Allocate memory for our private driver context. */ /* Allocate memory for our private driver context. */
if (!(la8 = g_try_malloc(sizeof(struct la8)))) { 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; struct la8 *la8;
/* Avoid compiler errors. */ /* Avoid compiler errors. */
fd = fd; (void)fd;
revents = revents; (void)revents;
if (!(sdi = session_data)) { if (!(sdi = session_data)) {
sr_err("la8: %s: user_data was NULL", __func__); sr_err("la8: %s: user_data was NULL", __func__);

View File

@ -130,7 +130,7 @@ static int hw_init(const char *deviceinfo)
struct sr_device_instance *sdi; struct sr_device_instance *sdi;
/* Avoid compiler warnings. */ /* Avoid compiler warnings. */
deviceinfo = deviceinfo; (void)deviceinfo;
sdi = sr_device_instance_new(0, SR_ST_ACTIVE, DEMONAME, NULL, NULL); sdi = sr_device_instance_new(0, SR_ST_ACTIVE, DEMONAME, NULL, NULL);
if (!sdi) { if (!sdi) {
@ -146,7 +146,7 @@ static int hw_init(const char *deviceinfo)
static int hw_opendev(int device_index) static int hw_opendev(int device_index)
{ {
/* Avoid compiler warnings. */ /* Avoid compiler warnings. */
device_index = device_index; (void)device_index;
/* Nothing needed so far. */ /* Nothing needed so far. */
@ -156,7 +156,7 @@ static int hw_opendev(int device_index)
static int hw_closedev(int device_index) static int hw_closedev(int device_index)
{ {
/* Avoid compiler warnings. */ /* Avoid compiler warnings. */
device_index = device_index; (void)device_index;
/* Nothing needed so far. */ /* 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) static int hw_get_status(int device_index)
{ {
/* Avoid compiler warnings. */ /* Avoid compiler warnings. */
device_index = device_index; (void)device_index;
return SR_ST_ACTIVE; return SR_ST_ACTIVE;
} }
@ -218,7 +218,7 @@ static int hw_set_configuration(int device_index, int capability, void *value)
char *stropt; char *stropt;
/* Avoid compiler warnings. */ /* Avoid compiler warnings. */
device_index = device_index; (void)device_index;
if (capability == SR_HWCAP_PROBECONFIG) { if (capability == SR_HWCAP_PROBECONFIG) {
/* Nothing to do, but must be supported */ /* Nothing to do, but must be supported */
@ -359,8 +359,8 @@ static int receive_data(int fd, int revents, void *session_data)
gsize z; gsize z;
/* Avoid compiler warnings. */ /* Avoid compiler warnings. */
fd = fd; (void)fd;
revents = revents; (void)revents;
do { do {
g_io_channel_read_chars(channels[0], 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) static void hw_stop_acquisition(int device_index, gpointer session_data)
{ {
/* Avoid compiler warnings. */ /* Avoid compiler warnings. */
device_index = device_index; (void)device_index;
session_data = session_data; (void)session_data;
/* Stop generate thread. */ /* Stop generate thread. */
thread_running = 0; thread_running = 0;

View File

@ -979,7 +979,7 @@ static void hw_stop_acquisition(int device_index, gpointer session_device_id)
struct sr_datafeed_packet packet; struct sr_datafeed_packet packet;
/* Avoid compiler warnings. */ /* Avoid compiler warnings. */
device_index = device_index; (void)device_index;
packet.type = SR_DF_END; packet.type = SR_DF_END;
sr_session_bus(session_device_id, &packet); sr_session_bus(session_device_id, &packet);

View File

@ -292,7 +292,7 @@ static int hw_init(const char *deviceinfo)
int err, devcnt, i, j; int err, devcnt, i, j;
/* Avoid compiler warnings. */ /* Avoid compiler warnings. */
deviceinfo = deviceinfo; (void)deviceinfo;
if (libusb_init(&usb_context) != 0) { if (libusb_init(&usb_context) != 0) {
sr_warn("Failed to initialize USB."); sr_warn("Failed to initialize USB.");
@ -554,9 +554,9 @@ static int receive_data(int fd, int revents, void *user_data)
struct timeval tv; struct timeval tv;
/* Avoid compiler warnings. */ /* Avoid compiler warnings. */
fd = fd; (void)fd;
revents = revents; (void)revents;
user_data = user_data; (void)user_data;
tv.tv_sec = tv.tv_usec = 0; tv.tv_sec = tv.tv_usec = 0;
libusb_handle_events_timeout(usb_context, &tv); 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; struct sr_datafeed_packet packet;
/* Avoid compiler warnings. */ /* Avoid compiler warnings. */
device_index = device_index; (void)device_index;
packet.type = SR_DF_END; packet.type = SR_DF_END;
sr_session_bus(session_data, &packet); sr_session_bus(session_data, &packet);

View File

@ -284,7 +284,7 @@ static int hw_init(const char *deviceinfo)
int err, devcnt, i; int err, devcnt, i;
/* Avoid compiler warnings. */ /* Avoid compiler warnings. */
deviceinfo = deviceinfo; (void)deviceinfo;
if (libusb_init(&usb_context) != 0) { if (libusb_init(&usb_context) != 0) {
sr_warn("Failed to initialize USB."); sr_warn("Failed to initialize USB.");

View File

@ -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) void sr_usb_device_instance_free(struct sr_usb_device_instance *usb)
{ {
/* Avoid compiler warnings. */ /* Avoid compiler warnings. */
usb = usb; (void)usb;
/* Nothing to do for this device instance type. */ /* Nothing to do for this device instance type. */
} }

View File

@ -31,7 +31,7 @@ static int data(struct sr_output *o, const char *data_in, uint64_t length_in,
char *outbuf; char *outbuf;
/* Prevent compiler warnings. */ /* Prevent compiler warnings. */
o = o; (void)o;
if (!data_in) { if (!data_in) {
sr_warn("binary output: %s: data_in was NULL", __func__); sr_warn("binary output: %s: data_in was NULL", __func__);

View File

@ -70,9 +70,9 @@ static int feed_chunk(int fd, int revents, void *session_data)
void *buf; void *buf;
int ret, got_data; int ret, got_data;
/* avoid compiler warning */ /* Avoid compiler warnings. */
fd = fd; (void)fd;
revents = revents; (void)revents;
sr_dbg("session_driver: feed chunk"); 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) static int hw_get_status(int device_index)
{ {
/* Avoid compiler warnings. */
/* avoid compiler warning */ (void)device_index;
device_index = device_index;
if (devices) if (devices)
return SR_OK; return SR_OK;
@ -238,8 +237,8 @@ static int hw_start_acquisition(int device_index, gpointer session_device_id)
struct sr_datafeed_packet *packet; struct sr_datafeed_packet *packet;
int err; int err;
/* avoid compiler warning */ /* Avoid compiler warnings. */
session_device_id = session_device_id; (void)session_device_id;
if (!(vdevice = get_vdevice_by_index(device_index))) if (!(vdevice = get_vdevice_by_index(device_index)))
return SR_ERR; return SR_ERR;