diff options
author | Jo-Philipp Wich <jo@mein.io> | 2023-11-01 14:07:48 +0100 |
---|---|---|
committer | Jo-Philipp Wich <jo@mein.io> | 2023-11-01 14:14:22 +0100 |
commit | cdc02034cfd4ba5f94bf26ee9e9c23609a9c47a4 (patch) | |
tree | cdf2289284c99077dbeebf045d461ebe34ac5f61 | |
parent | a69b5c8c416342a7855da19dfdc264a078f30848 (diff) |
nl80211: fix maybe uninitialized variable
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 <jo@mein.io>
-rw-r--r-- | lib/nl80211.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/nl80211.c b/lib/nl80211.c index 49aea32..6455ec0 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); |