Clean up array insertion to skip unnecessary memmove
The previous elements need to be moved only if we are inserting the new network in the middle of the list. While the memmove of zero bytes at the end of the array does not cause real problems, some static analyzers complain about this, so in addition to slightly optimized implementation, this removes some analyzer warnings, too. Signed-hostap: Jouni Malinen <j@w1.fi>
This commit is contained in:
parent
f4b2d69b07
commit
2c60ca7391
1 changed files with 5 additions and 4 deletions
|
@ -1659,13 +1659,14 @@ int wpa_config_add_prio_network(struct wpa_config *config,
|
|||
return -1;
|
||||
|
||||
for (prio = 0; prio < config->num_prio; prio++) {
|
||||
if (nlist[prio]->priority < ssid->priority)
|
||||
if (nlist[prio]->priority < ssid->priority) {
|
||||
os_memmove(&nlist[prio + 1], &nlist[prio],
|
||||
(config->num_prio - prio) *
|
||||
sizeof(struct wpa_ssid *));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
os_memmove(&nlist[prio + 1], &nlist[prio],
|
||||
(config->num_prio - prio) * sizeof(struct wpa_ssid *));
|
||||
|
||||
nlist[prio] = ssid;
|
||||
config->num_prio++;
|
||||
config->pssid = nlist;
|
||||
|
|
Loading…
Reference in a new issue