]> git.ipfire.org Git - thirdparty/hostap.git/commitdiff
Use a helper function to free neighbor DB entries
authorJouni Malinen <j@w1.fi>
Sun, 3 Mar 2024 18:41:30 +0000 (20:41 +0200)
committerJouni Malinen <j@w1.fi>
Sun, 3 Mar 2024 19:33:46 +0000 (21:33 +0200)
There is no need to duplicate this code in multiple locations.

Signed-off-by: Jouni Malinen <j@w1.fi>
src/ap/neighbor_db.c

index 83ff11268d48c748ee7dea572ca8d37377293ac0..f7a7d83d427deb690dbe11d6cd4b1957b5a2c786 100644 (file)
@@ -168,6 +168,14 @@ fail:
 }
 
 
+static void hostapd_neighbor_free(struct hostapd_neighbor_entry *nr)
+{
+       hostapd_neighbor_clear_entry(nr);
+       dl_list_del(&nr->list);
+       os_free(nr);
+}
+
+
 int hostapd_neighbor_remove(struct hostapd_data *hapd, const u8 *bssid,
                            const struct wpa_ssid_value *ssid)
 {
@@ -177,9 +185,7 @@ int hostapd_neighbor_remove(struct hostapd_data *hapd, const u8 *bssid,
        if (!nr)
                return -1;
 
-       hostapd_neighbor_clear_entry(nr);
-       dl_list_del(&nr->list);
-       os_free(nr);
+       hostapd_neighbor_free(nr);
 
        return 0;
 }
@@ -191,9 +197,7 @@ void hostapd_free_neighbor_db(struct hostapd_data *hapd)
 
        dl_list_for_each_safe(nr, prev, &hapd->nr_db,
                              struct hostapd_neighbor_entry, list) {
-               hostapd_neighbor_clear_entry(nr);
-               dl_list_del(&nr->list);
-               os_free(nr);
+               hostapd_neighbor_free(nr);
        }
 }
 
@@ -354,9 +358,7 @@ int hostapd_neighbor_sync_own_report(struct hostapd_data *hapd)
                return -1;
 
        /* Clear old entry due to SSID change */
-       hostapd_neighbor_clear_entry(nr);
-       dl_list_del(&nr->list);
-       os_free(nr);
+       hostapd_neighbor_free(nr);
 
        hostapd_neighbor_set_own_report(hapd);