From: Avraham Stern <avraham.stern@xxxxxxxxx> Use int_array_add_unique() instead of the dedicated add_freq(), which now can be removed. This also allows removing some local variables that are no longer needed. Signed-off-by: Avraham Stern <avraham.stern@xxxxxxxxx> Reviewed-by: Otcheretianski, Andrei <andrei.otcheretianski@xxxxxxxxx> Signed-off-by: Benjamin Berg <benjamin.berg@xxxxxxxxx> --- wpa_supplicant/wnm_sta.c | 21 +++++++-------------- wpa_supplicant/wpa_supplicant.c | 14 -------------- wpa_supplicant/wpa_supplicant_i.h | 1 - 3 files changed, 7 insertions(+), 29 deletions(-) diff --git a/wpa_supplicant/wnm_sta.c b/wpa_supplicant/wnm_sta.c index 881c0af6fc..4eac401227 100644 --- a/wpa_supplicant/wnm_sta.c +++ b/wpa_supplicant/wnm_sta.c @@ -1225,8 +1225,6 @@ static int chan_supported(struct wpa_supplicant *wpa_s, int freq) static void wnm_set_scan_freqs(struct wpa_supplicant *wpa_s) { - int *freqs; - int num_freqs = 0; unsigned int i; if (!wpa_s->wnm_neighbor_report_elements) @@ -1238,10 +1236,6 @@ static void wnm_set_scan_freqs(struct wpa_supplicant *wpa_s) os_free(wpa_s->next_scan_freqs); wpa_s->next_scan_freqs = NULL; - freqs = os_calloc(wpa_s->wnm_num_neighbor_report + 1, sizeof(int)); - if (freqs == NULL) - return; - for (i = 0; i < wpa_s->wnm_num_neighbor_report; i++) { struct neighbor_report *nei; @@ -1255,22 +1249,21 @@ static void wnm_set_scan_freqs(struct wpa_supplicant *wpa_s) "WNM: Unknown neighbor operating frequency for " MACSTR " - scan all channels", MAC2STR(nei->bssid)); - os_free(freqs); + os_free(wpa_s->next_scan_freqs); + wpa_s->next_scan_freqs = NULL; return; } if (chan_supported(wpa_s, nei->freq)) - add_freq(freqs, &num_freqs, nei->freq); + int_array_add_unique(&wpa_s->next_scan_freqs, + nei->freq); } - if (num_freqs == 0) { - os_free(freqs); + if (!wpa_s->next_scan_freqs) return; - } wpa_printf(MSG_DEBUG, - "WNM: Scan %d frequencies based on transition candidate list", - num_freqs); - wpa_s->next_scan_freqs = freqs; + "WNM: Scan %zd frequencies based on transition candidate list", + int_array_len(wpa_s->next_scan_freqs)); } diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index baadc44c0c..14d1e52d6e 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -8764,20 +8764,6 @@ void wpa_supplicant_update_config(struct wpa_supplicant *wpa_s) } -void add_freq(int *freqs, int *num_freqs, int freq) -{ - int i; - - for (i = 0; i < *num_freqs; i++) { - if (freqs[i] == freq) - return; - } - - freqs[*num_freqs] = freq; - (*num_freqs)++; -} - - void wpas_connection_failed(struct wpa_supplicant *wpa_s, const u8 *bssid, const u8 **link_bssids) { diff --git a/wpa_supplicant/wpa_supplicant_i.h b/wpa_supplicant/wpa_supplicant_i.h index d8bfcfede9..29d2d80fb9 100644 --- a/wpa_supplicant/wpa_supplicant_i.h +++ b/wpa_supplicant/wpa_supplicant_i.h @@ -1762,7 +1762,6 @@ int wpas_update_random_addr(struct wpa_supplicant *wpa_s, enum wpas_mac_addr_style style, struct wpa_ssid *ssid); int wpas_update_random_addr_disassoc(struct wpa_supplicant *wpa_s); -void add_freq(int *freqs, int *num_freqs, int freq); int wpas_get_op_chan_phy(int freq, const u8 *ies, size_t ies_len, u8 *op_class, u8 *chan, u8 *phy_type); -- 2.50.1 _______________________________________________ Hostap mailing list Hostap@xxxxxxxxxxxxxxxxxxx http://lists.infradead.org/mailman/listinfo/hostap