From: Gerhard Sittig Date: Sun, 4 Feb 2018 15:18:03 +0000 (+0100) Subject: beaglelogic: silence compiler warning X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=57a88297dd0c57eb9eab2d79bdf681ddcca29f00;p=libsigrok.git beaglelogic: silence compiler warning Explicitly assign NULL to param to avoid the "may be used uninitialized" warning reported in bug #1094. Behaviour remains unchanged. All references to the variable were under "if (!conn)", and the assigning arm of the branch checked for "if (!param)" after assignment. So the error could not happen, but compilers may not have noticed depending on the width of their scope during compilation. Move the initialization of 'conn' closer to the conditional assignment, such that all paths are seen in one spot during maintenance. This fixes bug #1094. --- diff --git a/src/hardware/beaglelogic/api.c b/src/hardware/beaglelogic/api.c index 5a7068c4..2ad649eb 100644 --- a/src/hardware/beaglelogic/api.c +++ b/src/hardware/beaglelogic/api.c @@ -65,11 +65,12 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) struct sr_config *src; struct sr_dev_inst *sdi; struct dev_context *devc; - const char *conn = NULL; + const char *conn; gchar **params; int i, maxch; maxch = NUM_CHANNELS; + conn = NULL; for (l = options; l; l = l->next) { src = l->data; if (src->key == SR_CONF_NUM_LOGIC_CHANNELS) @@ -80,6 +81,7 @@ static GSList *scan(struct sr_dev_driver *di, GSList *options) /* Probe for /dev/beaglelogic if not connecting via TCP */ if (!conn) { + params = NULL; if (!g_file_test(BEAGLELOGIC_DEV_NODE, G_FILE_TEST_EXISTS)) return NULL; } else {