diff mbox series

[01/14] network: add network_bss_list_prune

Message ID 20240807181427.170515-1-prestwoj@gmail.com (mailing list archive)
State New
Headers show
Series [01/14] network: add network_bss_list_prune | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
prestwoj/iwd-alpine-ci-fetch success Fetch PR
prestwoj/iwd-ci-fetch success Fetch PR
prestwoj/iwd-alpine-ci-setupell success Prep - Setup ELL
prestwoj/iwd-ci-gitlint success GitLint
prestwoj/iwd-ci-setupell success Prep - Setup ELL
prestwoj/iwd-ci-makedistcheck fail Make Distcheck Make FAIL: ../../src/network.c: In function ‘network_register_bss’: ../../src/network.c:1167:24: warning: implicit declaration of function ‘l_dbus_object_set_data’; did you mean ‘l_dbus_object_get_data’? [-Wimplicit-function-declaration] 1167 | return l_dbus_object_set_data(dbus_get_bus(), | ^~~~~~~~~~~~~~~~~~~~~~ | l_dbus_object_get_data ../../client/bss.c:32:10: fatal error: client/bss.h: No such file or directory 32 | #include "client/bss.h" | ^~~~~~~~~~~~~~ compilation terminated. make[2]: *** [Makefile:2584: client/bss.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [Makefile:1744: all] Error 2 make: *** [Makefile:3368: distcheck] Error 1
prestwoj/iwd-alpine-ci-makedistcheck fail Make Distcheck Make FAIL: ../../src/network.c: In function 'network_register_bss': ../../src/network.c:1167:24: warning: implicit declaration of function 'l_dbus_object_set_data'; did you mean 'l_dbus_object_get_data'? [-Wimplicit-function-declaration] 1167 | return l_dbus_object_set_data(dbus_get_bus(), | ^~~~~~~~~~~~~~~~~~~~~~ | l_dbus_object_get_data ../../client/bss.c:32:10: fatal error: client/bss.h: No such file or directory 32 | #include "client/bss.h" | ^~~~~~~~~~~~~~ compilation terminated. make[2]: *** [Makefile:2585: client/bss.o] Error 1 make[2]: *** Waiting for unfinished jobs.... make[1]: *** [Makefile:1745: all] Error 2 make: *** [Makefile:3369: distcheck] Error 1
prestwoj/iwd-ci-build success Build - Configure
prestwoj/iwd-alpine-ci-build success Build - Configure
prestwoj/iwd-ci-makecheckvalgrind fail Make FAIL: src/network.c: In function ‘network_register_bss’: src/network.c:1167:24: error: implicit declaration of function ‘l_dbus_object_set_data’; did you mean ‘l_dbus_object_get_data’? [-Werror=implicit-function-declaration] 1167 | return l_dbus_object_set_data(dbus_get_bus(), | ^~~~~~~~~~~~~~~~~~~~~~ | l_dbus_object_get_data cc1: all warnings being treated as errors make[1]: *** [Makefile:2584: src/network.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1744: all] Error 2
prestwoj/iwd-ci-clang fail Clang IWD - make FAIL: src/network.c:1167:10: error: implicit declaration of function 'l_dbus_object_set_data' is invalid in C99 [-Werror,-Wimplicit-function-declaration] return l_dbus_object_set_data(dbus_get_bus(), ^ src/network.c:1167:10: note: did you mean 'l_dbus_object_get_data'? ./ell/dbus.h:228:7: note: 'l_dbus_object_get_data' declared here void *l_dbus_object_get_data(struct l_dbus *dbus, const char *object, ^ 1 error generated. make[1]: *** [Makefile:2584: src/network.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1744: all] Error 2
prestwoj/iwd-ci-testrunner pending testrunner SKIP
prestwoj/iwd-ci-makecheck pending makecheck SKIP
prestwoj/iwd-alpine-ci-makecheckvalgrind fail Make FAIL: src/network.c: In function 'network_register_bss': src/network.c:1167:24: error: implicit declaration of function 'l_dbus_object_set_data'; did you mean 'l_dbus_object_get_data'? [-Werror=implicit-function-declaration] 1167 | return l_dbus_object_set_data(dbus_get_bus(), | ^~~~~~~~~~~~~~~~~~~~~~ | l_dbus_object_get_data cc1: all warnings being treated as errors make[1]: *** [Makefile:2585: src/network.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1745: all] Error 2
prestwoj/iwd-alpine-ci-makecheck pending makecheck SKIP
prestwoj/iwd-ci-incremental_build fail Make FAIL (patch 4): src/network.c: In function ‘network_register_bss’: src/network.c:1167:24: error: implicit declaration of function ‘l_dbus_object_set_data’; did you mean ‘l_dbus_object_get_data’? [-Werror=implicit-function-declaration] 1167 | return l_dbus_object_set_data(dbus_get_bus(), | ^~~~~~~~~~~~~~~~~~~~~~ | l_dbus_object_get_data cc1: all warnings being treated as errors make[1]: *** [Makefile:2578: src/network.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1741: all] Error 2
prestwoj/iwd-alpine-ci-incremental_build fail Make FAIL (patch 4): src/network.c: In function 'network_register_bss': src/network.c:1167:24: error: implicit declaration of function 'l_dbus_object_set_data'; did you mean 'l_dbus_object_get_data'? [-Werror=implicit-function-declaration] 1167 | return l_dbus_object_set_data(dbus_get_bus(), | ^~~~~~~~~~~~~~~~~~~~~~ | l_dbus_object_get_data cc1: all warnings being treated as errors make[1]: *** [Makefile:2579: src/network.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:1742: all] Error 2

Commit Message

James Prestwood Aug. 7, 2024, 6:14 p.m. UTC
This adds a new API meant to replace network_bss_list_clear. Instead
of clearing the entirely network->bss_list on each scan we can
instead just prune out entries that didn't show up in the scan.
The network_bss_add API was also updated to prepare for
network_bss_list_prune by removing existing entries, as now even
"new" entries may exist in the list still and need to be removed.
---
 src/network.c | 43 ++++++++++++++++++++++++++++++++++++-------
 src/network.h |  2 ++
 2 files changed, 38 insertions(+), 7 deletions(-)
diff mbox series

Patch

diff --git a/src/network.c b/src/network.c
index 09099fac..6d7e5ec4 100644
--- a/src/network.c
+++ b/src/network.c
@@ -1129,8 +1129,17 @@  bool network_update_known_frequencies(struct network *network)
 	return true;
 }
 
+static bool match_addr(const void *a, const void *b)
+{
+	const struct scan_bss *bss = a;
+
+	return memcmp(bss->addr, b, 6) == 0;
+}
+
 bool network_bss_add(struct network *network, struct scan_bss *bss)
 {
+	l_queue_remove_if(network->bss_list, match_addr, bss->addr);
+
 	if (!l_queue_insert(network->bss_list, bss, scan_bss_rank_compare,
 									NULL))
 		return false;
@@ -1150,13 +1159,6 @@  bool network_bss_add(struct network *network, struct scan_bss *bss)
 	return true;
 }
 
-static bool match_addr(const void *a, const void *b)
-{
-	const struct scan_bss *bss = a;
-
-	return memcmp(bss->addr, b, 6) == 0;
-}
-
 /*
  * Replaces an old scan_bss (if exists) in the bss list with a new bss object.
  * Note this BSS is *not* freed and must be by the caller. scan_bss objects are
@@ -1188,6 +1190,33 @@  void network_bss_list_clear(struct network *network)
 	network->bss_list = l_queue_new();
 }
 
+struct network_prune_data {
+	struct network *network;
+	struct l_queue *new_list;
+};
+
+static bool scan_bss_prune_missing(void *a, void *user_data)
+{
+	struct scan_bss *bss = a;
+	struct network_prune_data *data = user_data;
+
+	if (!l_queue_find(data->new_list, match_addr, bss->addr))
+		return true;
+
+	return false;
+}
+
+void network_bss_list_prune(struct network *network, struct l_queue *new_list)
+{
+	struct network_prune_data data;
+
+	data.network = network;
+	data.new_list = new_list;
+
+	l_queue_foreach_remove(network->bss_list,
+				scan_bss_prune_missing, &data);
+}
+
 struct scan_bss *network_bss_list_pop(struct network *network)
 {
 	return l_queue_pop_head(network->bss_list);
diff --git a/src/network.h b/src/network.h
index 17dfcca8..be81c150 100644
--- a/src/network.h
+++ b/src/network.h
@@ -71,6 +71,8 @@  bool network_bss_add(struct network *network, struct scan_bss *bss);
 bool network_bss_update(struct network *network, struct scan_bss *bss);
 bool network_bss_list_isempty(struct network *network);
 void network_bss_list_clear(struct network *network);
+void network_bss_list_prune(struct network *network, struct l_queue *new_list);
+
 struct scan_bss *network_bss_list_pop(struct network *network);
 struct scan_bss *network_bss_find_by_addr(struct network *network,
 							const uint8_t *addr);