From 7b4aea4aa6572c593ef0177f4d105944c2ca1713 Mon Sep 17 00:00:00 2001 From: Pau Espin Pedrol Date: Tue, 1 Feb 2022 11:55:59 +0100 Subject: xua_asp_fsm: Fix gcc false positive warning MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As of GCC 11.1.0, it starts printing a warning about uninitialized variable. It is a false positive since tmode is really only used in the case where traffic_mode is not zero, in which case tmode is set. Let's restrict the scope of tmode to fix the issue and also make it clearer where the variable is used. """ In file included from /git/libosmo-sccp/src/xua_asp_fsm.c:25: /git/libosmo-sccp/src/xua_asp_fsm.c: In function ‘xua_asp_fsm_inactive’: /git/libosmo-sccp/include/osmocom/sigtran/osmo_ss7.h:274:16: error: ‘tmode’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 274 | return get_value_string(osmo_ss7_as_traffic_mode_vals, mode); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /git/libosmo-sccp/src/xua_asp_fsm.c:476:39: note: ‘tmode’ was declared here 476 | enum osmo_ss7_as_traffic_mode tmode; | """ Change-Id: I4fc38724aba3a3f178ba0b45444e1394db44d039 --- src/xua_asp_fsm.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/xua_asp_fsm.c b/src/xua_asp_fsm.c index 5fe1d80..a93dbd2 100644 --- a/src/xua_asp_fsm.c +++ b/src/xua_asp_fsm.c @@ -473,7 +473,6 @@ static void xua_asp_fsm_inactive(struct osmo_fsm_inst *fi, uint32_t event, void struct osmo_ss7_as *as; struct xua_msg *xua_in; uint32_t traf_mode = 0; - enum osmo_ss7_as_traffic_mode tmode; struct xua_msg_part *part; int i; @@ -515,7 +514,6 @@ static void xua_asp_fsm_inactive(struct osmo_fsm_inst *fi, uint32_t event, void peer_send_error(fi, M3UA_ERR_UNSUPP_TRAF_MOD_TYP); return; } - tmode = osmo_ss7_tmode_from_xua(traf_mode); } if ((part = xua_msg_find_tag(xua_in, M3UA_IEI_ROUTE_CTX))) { for (i = 0; i < part->len / sizeof(uint32_t); i++) { @@ -529,6 +527,7 @@ static void xua_asp_fsm_inactive(struct osmo_fsm_inst *fi, uint32_t event, void } if (traf_mode) { /* if the peer has specified a traffic mode at all */ + enum osmo_ss7_as_traffic_mode tmode = osmo_ss7_tmode_from_xua(traf_mode); llist_for_each_entry(as, &asp->inst->as_list, list) { if (!osmo_ss7_as_has_asp(as, asp)) continue; -- cgit v1.2.3