From cdc02034cfd4ba5f94bf26ee9e9c23609a9c47a4 Mon Sep 17 00:00:00 2001 From: Jo-Philipp Wich Date: Wed, 1 Nov 2023 14:07:48 +0100 Subject: [PATCH] nl80211: fix maybe uninitialized variable MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When compiling with optimizations, gcc reports: .../nl80211.c: In function ‘uc_nl_convert_rta_vht_mcs’: .../nl80211.c:1310:31: error: ‘max_idx’ may be used uninitialized [-Werror=maybe-uninitialized] 1310 | for (j = 0; j <= max_idx; j++) | ~~^~~~~~~~~~ Slightly refactor the code to avoid this issue. Signed-off-by: Jo-Philipp Wich --- lib/nl80211.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/nl80211.c b/lib/nl80211.c index 49aea323..6455ec00 100644 --- a/lib/nl80211.c +++ b/lib/nl80211.c @@ -1285,7 +1285,7 @@ uc_nl_convert_rta_vht_mcs(const uc_nl_attr_spec_t *spec, struct nl_msg *msg, str { uc_value_t *mcs_obj, *mcs_set, *mcs_entry, *mcs_idx; size_t i, j, max_idx; - uint16_t u16; + uint16_t u16; uint8_t *mcs; if (!nla_check_len(tb[spec->attr], 16)) @@ -1302,7 +1302,7 @@ uc_nl_convert_rta_vht_mcs(const uc_nl_attr_spec_t *spec, struct nl_msg *msg, str case 0: max_idx = 7; break; case 1: max_idx = 8; break; case 2: max_idx = 9; break; - case 3: continue; + default: continue; } mcs_idx = ucv_array_new_length(vm, max_idx + 1); @@ -1329,7 +1329,7 @@ uc_nl_convert_rta_vht_mcs(const uc_nl_attr_spec_t *spec, struct nl_msg *msg, str case 0: max_idx = 7; break; case 1: max_idx = 8; break; case 2: max_idx = 9; break; - case 3: continue; + default: continue; } mcs_idx = ucv_array_new_length(vm, max_idx + 1);