From: Gerhard Sittig Date: Sun, 16 Jun 2019 08:14:58 +0000 (+0200) Subject: serial_bt: silence compiler warning (unused value) X-Git-Url: https://sigrok.org/gitweb/?p=libsigrok.git;a=commitdiff_plain;h=819277b5d87dfe3038f72d1d6560412553fbd415;hp=5e03750144d2d1afb0f3656200337e2a16c9c487 serial_bt: silence compiler warning (unused value) Drop assignments of values to variables which never took effect. Drop assignments which strictly speaking were not required, but were added in the past to silence warnings in different compiler versions. ../src/serial_bt.c:168:2: warning: Value stored to 'type' is never read type = SER_BT_CONN_UNKNOWN; ../src/serial_bt.c:507:2: warning: Value stored to 'now_us' is never read now_us = 0; /* Silence a (false) compiler warning. */ Shuffle variable declarations into the rough order in which they are used in the function's body. --- diff --git a/src/serial_bt.c b/src/serial_bt.c index 9d7cfb2b..ea3531d3 100644 --- a/src/serial_bt.c +++ b/src/serial_bt.c @@ -142,9 +142,9 @@ static int ser_bt_parse_conn_spec( uint16_t *read_hdl, uint16_t *write_hdl, uint16_t *cccd_hdl, uint16_t *cccd_val) { + char **fields, *field; enum ser_bt_conn_t type; const char *addr; - char **fields, *field; if (conn_type) *conn_type = SER_BT_CONN_UNKNOWN; @@ -161,9 +161,6 @@ static int ser_bt_parse_conn_spec( if (cccd_val) *cccd_val = 0; - type = SER_BT_CONN_UNKNOWN; - addr = NULL; - if (!serial || !spec || !spec[0]) return SR_ERR_ARG; @@ -498,7 +495,6 @@ static int ser_bt_read(struct sr_serial_dev_inst *serial, * where to stop reception. */ deadline_us = 0; - now_us = 0; /* Silence a (false) compiler warning. */ if (timeout_ms) { now_us = g_get_monotonic_time(); deadline_us = now_us + timeout_ms * 1000;