Skip to content

Commit

Permalink
nl80211: fix maybe uninitialized variable
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
jow- committed Nov 1, 2023
1 parent a69b5c8 commit cdc0203
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions lib/nl80211.c
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit cdc0203

Please sign in to comment.