diff options
author | Jouni Malinen <j@w1.fi> | 2012-02-19 16:44:30 +0200 |
---|---|---|
committer | Jouni Malinen <j@w1.fi> | 2012-02-19 16:44:30 +0200 |
commit | 2c60ca73912fe30344df072ca6447f1a4dcdb67b (patch) | |
tree | 8cef4df9b6ae30f481ebd4fdcfc1a263b8390784 | |
parent | f4b2d69b0760767f1667e801ef1c34642e21b60c (diff) | |
download | external_wpa_supplicant_8_ti-2c60ca73912fe30344df072ca6447f1a4dcdb67b.zip external_wpa_supplicant_8_ti-2c60ca73912fe30344df072ca6447f1a4dcdb67b.tar.gz external_wpa_supplicant_8_ti-2c60ca73912fe30344df072ca6447f1a4dcdb67b.tar.bz2 |
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>
-rw-r--r-- | wpa_supplicant/config.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/wpa_supplicant/config.c b/wpa_supplicant/config.c index 7ba2df6..72387f8 100644 --- a/wpa_supplicant/config.c +++ b/wpa_supplicant/config.c @@ -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; |