public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/3] shared: Add single-link list implementation
@ 2026-04-02 15:44 Bastien Nocera
  2026-04-02 15:44 ` [PATCH BlueZ 2/3] shared: Remove glib dependency from src/shared/ad.c Bastien Nocera
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: Bastien Nocera @ 2026-04-02 15:44 UTC (permalink / raw)
  To: linux-bluetooth

This will allow some parts of the project to stop relying on glib
headers without linking to glib, or glib dependencies being introduced
in shared sources that need to be able not to link with glib.

ell doesn't include any linked-list API either, so it's glib or
home-made.
---
 Makefile.am       |  5 +++
 src/shared/list.c | 90 +++++++++++++++++++++++++++++++++++++++++++++++
 src/shared/list.h | 26 ++++++++++++++
 unit/test-list.c  | 68 +++++++++++++++++++++++++++++++++++
 4 files changed, 189 insertions(+)
 create mode 100644 src/shared/list.c
 create mode 100644 src/shared/list.h
 create mode 100644 unit/test-list.c

diff --git a/Makefile.am b/Makefile.am
index d9de71d587d8..2d28f93d611e 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -214,6 +214,7 @@ endif
 shared_sources = src/shared/io.h src/shared/timeout.h \
 			src/shared/queue.h src/shared/queue.c \
 			src/shared/util.h src/shared/util.c \
+			src/shared/list.h src/shared/list.c \
 			src/shared/mgmt.h src/shared/mgmt.c \
 			src/shared/crypto.h src/shared/crypto.c \
 			src/shared/ecc.h src/shared/ecc.c \
@@ -700,6 +701,10 @@ unit_tests += unit/test-util
 unit_test_util_LDADD = src/libshared-glib.la \
 				lib/libbluetooth-internal.la $(GLIB_LIBS)
 
+unit_tests += unit/test-list
+unit_test_list_LDADD = src/libshared-glib.la \
+				lib/libbluetooth-internal.la $(GLIB_LIBS)
+
 unit_tests += unit/test-gatt
 
 unit_test_gatt_SOURCES = unit/test-gatt.c
diff --git a/src/shared/list.c b/src/shared/list.c
new file mode 100644
index 000000000000..1eb617a9e40f
--- /dev/null
+++ b/src/shared/list.c
@@ -0,0 +1,90 @@
+// SPDX-License-Identifier: LGPL-2.1-or-later
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2026 Bastien Nocera <hadess@hadess.net>
+ *
+ *
+ */
+
+#ifdef HAVE_CONFIG_H
+#include <config.h>
+#endif
+
+#include "src/shared/list.h"
+
+#include <stddef.h>
+#include <stdlib.h>
+
+static slist_t*
+slist_last(slist_t *list)
+{
+	slist_t *last;
+
+	if (list == NULL)
+		return NULL;
+	last = list;
+	while (last->next != NULL)
+		last = last->next;
+	return last;
+}
+
+slist_t* slist_append(slist_t *list, void *data)
+{
+	slist_t *new_item;
+
+	new_item = malloc(sizeof(slist_t));
+	new_item->data = data;
+	new_item->next = NULL;
+
+	if (list != NULL) {
+		slist_t *last;
+		last = slist_last(list);
+		last->next = new_item;
+		return list;
+	}
+	return new_item;
+}
+
+void slist_clear(slist_t *list, free_func func)
+{
+	slist_t *l;
+
+	l = list;
+	while (l != NULL) {
+		slist_t *next = l->next;
+		if (func != NULL)
+			(func)(l->data);
+		free(l);
+		l = next;
+	}
+}
+
+void slist_free(slist_t *list)
+{
+	slist_clear(list, NULL);
+}
+
+slist_t* slist_find(slist_t *list, const void *data, compare_func func)
+{
+	slist_t *l;
+
+	if (func == NULL)
+		return NULL;
+	for (l = list; l != NULL; l = l->next) {
+		if ((func)(data, l->data) == 0)
+			return l;
+	}
+	return NULL;
+}
+
+void slist_foreach(slist_t *list, foreach_func func, void *user_data)
+{
+	slist_t *l;
+
+	if (func == NULL)
+		return;
+	for (l = list; l != NULL; l = l->next)
+		(func)(l->data, user_data);
+}
diff --git a/src/shared/list.h b/src/shared/list.h
new file mode 100644
index 000000000000..3a01d0425315
--- /dev/null
+++ b/src/shared/list.h
@@ -0,0 +1,26 @@
+/* SPDX-License-Identifier: LGPL-2.1-or-later */
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2026  Bastien Nocera <hadess@hadess.net>
+ *
+ *
+ */
+
+#pragma once
+
+typedef struct slist {
+	void *next;
+	void *data;
+} slist_t;
+
+typedef void (*free_func) (void *data);
+typedef int (*compare_func) (const void *a, const void *b);
+typedef void (*foreach_func) (void *data, void *user_data);
+
+slist_t* slist_append(slist_t *list, void *data);
+void slist_clear(slist_t *list, free_func func);
+void slist_free(slist_t *list);
+slist_t* slist_find(slist_t *list, const void *data, compare_func func);
+void slist_foreach(slist_t *list, foreach_func func, void *user_data);
diff --git a/unit/test-list.c b/unit/test-list.c
new file mode 100644
index 000000000000..5dc41ebf3ebd
--- /dev/null
+++ b/unit/test-list.c
@@ -0,0 +1,68 @@
+// SPDX-License-Identifier: GPL-2.0-or-later
+/*
+ *
+ *  BlueZ - Bluetooth protocol stack for Linux
+ *
+ *  Copyright (C) 2026  Bastien Nocera <hadess@hadess.net>
+ *
+ *
+ */
+
+#include <assert.h>
+
+#include "src/shared/list.h"
+#include "src/shared/util.h"
+#include "src/shared/tester.h"
+
+#define ONE 1
+#define TWO 2
+#define THREE 3
+#define ADDITION (ONE + TWO + THREE)
+
+static void add_up(void *data, void *user_data)
+{
+	int *total = (int *) user_data;
+	*total += PTR_TO_UINT(data);
+}
+
+static int int_equal(const void *a, const void *b)
+{
+	if (PTR_TO_UINT(a) == PTR_TO_UINT(b))
+		return 0;
+	return 1;
+}
+
+static void test_list_common(const void *data)
+{
+	slist_t *l;
+	slist_t *head;
+	slist_t *two;
+	int total;
+
+	l = slist_append(NULL, UINT_TO_PTR(ONE));
+	head = l;
+	l = slist_append(l, UINT_TO_PTR(TWO));
+	l = slist_append(l, UINT_TO_PTR(THREE));
+
+	assert(l == head);
+	total = 0;
+	slist_foreach(l, add_up, &total);
+	assert(total == ADDITION);
+
+	two = slist_find(l, UINT_TO_PTR(TWO), int_equal);
+	assert(two == l->next);
+
+	slist_clear(l, NULL);
+
+	tester_test_passed();
+}
+
+int main(int argc, char *argv[])
+{
+	tester_init(&argc, &argv);
+
+	tester_add("/list/common", NULL, NULL,
+			test_list_common, NULL);
+
+	return tester_run();
+}
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH BlueZ 2/3] shared: Remove glib dependency from src/shared/ad.c
  2026-04-02 15:44 [PATCH BlueZ 1/3] shared: Add single-link list implementation Bastien Nocera
@ 2026-04-02 15:44 ` Bastien Nocera
  2026-04-02 16:23   ` Luiz Augusto von Dentz
  2026-04-02 15:44 ` [PATCH BlueZ 3/3] shared: Remove unneeded glib includes Bastien Nocera
  2026-04-02 16:33 ` [BlueZ,1/3] shared: Add single-link list implementation bluez.test.bot
  2 siblings, 1 reply; 6+ messages in thread
From: Bastien Nocera @ 2026-04-02 15:44 UTC (permalink / raw)
  To: linux-bluetooth

src/shared/ad.c includes src/eir.h, which uses glib, which means that
the non-glib shared library can't be used without linking to glib.

Use our own linked list implementation to remove the glib use.
---
 plugins/neard.c |  4 ++--
 src/adapter.c   |  9 +++++----
 src/device.c    | 22 +++++++++++-----------
 src/device.h    | 10 ++++++----
 src/eir.c       | 24 ++++++++++++------------
 src/eir.h       | 11 +++++------
 unit/test-eir.c |  5 ++---
 7 files changed, 43 insertions(+), 42 deletions(-)

diff --git a/plugins/neard.c b/plugins/neard.c
index c84934025cd8..b2860403d50d 100644
--- a/plugins/neard.c
+++ b/plugins/neard.c
@@ -58,7 +58,7 @@ struct oob_params {
 	bdaddr_t address;
 	uint32_t class;
 	char *name;
-	GSList *services;
+	slist_t *services;
 	uint8_t *hash;
 	uint8_t *randomizer;
 	uint8_t *pin;
@@ -68,7 +68,7 @@ struct oob_params {
 
 static void free_oob_params(struct oob_params *params)
 {
-	g_slist_free_full(params->services, free);
+	slist_clear(params->services, free);
 	g_free(params->name);
 	g_free(params->hash);
 	g_free(params->randomizer);
diff --git a/src/adapter.c b/src/adapter.c
index 04568dae6e98..8eb0caa34223 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -43,6 +43,7 @@
 #include "textfile.h"
 
 #include "src/shared/util.h"
+#include "src/shared/list.h"
 #include "src/shared/queue.h"
 #include "src/shared/att.h"
 #include "src/shared/gatt-db.h"
@@ -7171,10 +7172,10 @@ static void confirm_name(struct btd_adapter *adapter, const bdaddr_t *bdaddr,
 
 static void adapter_msd_notify(struct btd_adapter *adapter,
 							struct btd_device *dev,
-							GSList *msd_list)
+							slist_t *msd_list)
 {
 	GSList *cb_l, *cb_next;
-	GSList *msd_l, *msd_next;
+	slist_t *msd_l, *msd_next;
 
 	for (cb_l = adapter->msd_callbacks; cb_l != NULL; cb_l = cb_next) {
 		btd_msd_cb_t cb = cb_l->data;
@@ -7184,7 +7185,7 @@ static void adapter_msd_notify(struct btd_adapter *adapter,
 		for (msd_l = msd_list; msd_l != NULL; msd_l = msd_next) {
 			const struct eir_msd *msd = msd_l->data;
 
-			msd_next = g_slist_next(msd_l);
+			msd_next = msd_l->next;
 
 			cb(adapter, dev, msd->company, msd->data,
 								msd->data_len);
@@ -7223,7 +7224,7 @@ static bool is_filter_match(GSList *discovery_filter, struct eir_data *eir_data,
 				/* m->data contains string representation of
 				 * uuid.
 				 */
-				if (g_slist_find_custom(eir_data->services,
+				if (slist_find(eir_data->services,
 							m->data,
 							g_strcmp) != NULL)
 					got_match = true;
diff --git a/src/device.c b/src/device.c
index 0e8ca28d3809..2a3b23ef3013 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2432,9 +2432,9 @@ unref:
 	dev->connect = NULL;
 }
 
-void device_add_eir_uuids(struct btd_device *dev, GSList *uuids)
+void device_add_eir_uuids(struct btd_device *dev, slist_t *uuids)
 {
-	GSList *l;
+	slist_t *l;
 	GSList *added = NULL;
 
 	if (dev->bredr_state.svc_resolved || dev->le_state.svc_resolved)
@@ -2465,13 +2465,13 @@ static void add_manufacturer_data(void *data, void *user_data)
 					DEVICE_INTERFACE, "ManufacturerData");
 }
 
-void device_set_manufacturer_data(struct btd_device *dev, GSList *list,
+void device_set_manufacturer_data(struct btd_device *dev, slist_t *list,
 								bool duplicate)
 {
 	if (duplicate)
 		bt_ad_clear_manufacturer_data(dev->ad);
 
-	g_slist_foreach(list, add_manufacturer_data, dev);
+	slist_foreach(list, add_manufacturer_data, dev);
 }
 
 static void add_service_data(void *data, void *user_data)
@@ -2479,7 +2479,7 @@ static void add_service_data(void *data, void *user_data)
 	struct eir_sd *sd = data;
 	struct btd_device *dev = user_data;
 	bt_uuid_t uuid;
-	GSList *l;
+	slist_t *l;
 
 	if (bt_string_to_uuid(&uuid, sd->uuid) < 0)
 		return;
@@ -2487,21 +2487,21 @@ static void add_service_data(void *data, void *user_data)
 	if (!bt_ad_add_service_data(dev->ad, &uuid, sd->data, sd->data_len))
 		return;
 
-	l = g_slist_append(NULL, sd->uuid);
+	l = slist_append(NULL, sd->uuid);
 	device_add_eir_uuids(dev, l);
-	g_slist_free(l);
+	slist_free(l);
 
 	g_dbus_emit_property_changed(dbus_conn, dev->path,
 					DEVICE_INTERFACE, "ServiceData");
 }
 
-void device_set_service_data(struct btd_device *dev, GSList *list,
+void device_set_service_data(struct btd_device *dev, slist_t *list,
 							bool duplicate)
 {
 	if (duplicate)
 		bt_ad_clear_service_data(dev->ad);
 
-	g_slist_foreach(list, add_service_data, dev);
+	slist_foreach(list, add_service_data, dev);
 }
 
 static void add_data(void *data, void *user_data)
@@ -2518,13 +2518,13 @@ static void add_data(void *data, void *user_data)
 						"AdvertisingData");
 }
 
-void device_set_data(struct btd_device *dev, GSList *list,
+void device_set_data(struct btd_device *dev, slist_t *list,
 							bool duplicate)
 {
 	if (duplicate)
 		bt_ad_clear_data(dev->ad);
 
-	g_slist_foreach(list, add_data, dev);
+	slist_foreach(list, add_data, dev);
 }
 
 static struct btd_service *find_connectable_service(struct btd_device *dev,
diff --git a/src/device.h b/src/device.h
index c7b8b2a16eb9..5ee1f2300223 100644
--- a/src/device.h
+++ b/src/device.h
@@ -9,6 +9,8 @@
  *
  */
 
+#include "src/shared/list.h"
+
 #define DEVICE_INTERFACE	"org.bluez.Device1"
 
 struct btd_device;
@@ -78,12 +80,12 @@ void btd_device_gatt_set_service_changed(struct btd_device *device,
 						uint16_t start, uint16_t end);
 bool device_attach_att(struct btd_device *dev, GIOChannel *io);
 void btd_device_add_uuid(struct btd_device *device, const char *uuid);
-void device_add_eir_uuids(struct btd_device *dev, GSList *uuids);
-void device_set_manufacturer_data(struct btd_device *dev, GSList *list,
+void device_add_eir_uuids(struct btd_device *dev, slist_t *uuids);
+void device_set_manufacturer_data(struct btd_device *dev, slist_t *list,
 							bool duplicate);
-void device_set_service_data(struct btd_device *dev, GSList *list,
+void device_set_service_data(struct btd_device *dev, slist_t *list,
 							bool duplicate);
-void device_set_data(struct btd_device *dev, GSList *list,
+void device_set_data(struct btd_device *dev, slist_t *list,
 							bool duplicate);
 void device_probe_profile(gpointer a, gpointer b);
 void device_remove_profile(gpointer a, gpointer b);
diff --git a/src/eir.c b/src/eir.c
index 68ed74fe6493..8efca6978b39 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -49,7 +49,7 @@ static void data_free(void *data)
 
 void eir_data_free(struct eir_data *eir)
 {
-	g_slist_free_full(eir->services, free);
+	slist_clear(eir->services, free);
 	eir->services = NULL;
 	g_free(eir->name);
 	eir->name = NULL;
@@ -57,11 +57,11 @@ void eir_data_free(struct eir_data *eir)
 	eir->hash = NULL;
 	free(eir->randomizer);
 	eir->randomizer = NULL;
-	g_slist_free_full(eir->msd_list, g_free);
+	slist_clear(eir->msd_list, g_free);
 	eir->msd_list = NULL;
-	g_slist_free_full(eir->sd_list, sd_free);
+	slist_clear(eir->sd_list, sd_free);
 	eir->sd_list = NULL;
-	g_slist_free_full(eir->data_list, data_free);
+	slist_clear(eir->data_list, data_free);
 	eir->data_list = NULL;
 }
 
@@ -80,7 +80,7 @@ static void eir_parse_uuid16(struct eir_data *eir, const void *data,
 		uuid_str = bt_uuid2string(&service);
 		if (!uuid_str)
 			continue;
-		eir->services = g_slist_append(eir->services, uuid_str);
+		eir->services = slist_append(eir->services, uuid_str);
 	}
 }
 
@@ -99,7 +99,7 @@ static void eir_parse_uuid32(struct eir_data *eir, const void *data,
 		uuid_str = bt_uuid2string(&service);
 		if (!uuid_str)
 			continue;
-		eir->services = g_slist_append(eir->services, uuid_str);
+		eir->services = slist_append(eir->services, uuid_str);
 	}
 }
 
@@ -119,7 +119,7 @@ static void eir_parse_uuid128(struct eir_data *eir, const uint8_t *data,
 		uuid_str = bt_uuid2string(&service);
 		if (!uuid_str)
 			continue;
-		eir->services = g_slist_append(eir->services, uuid_str);
+		eir->services = slist_append(eir->services, uuid_str);
 		uuid_ptr += 16;
 	}
 }
@@ -151,7 +151,7 @@ static void eir_parse_msd(struct eir_data *eir, const uint8_t *data,
 	msd->data_len = len - 2;
 	memcpy(&msd->data, data + 2, msd->data_len);
 
-	eir->msd_list = g_slist_append(eir->msd_list, msd);
+	eir->msd_list = slist_append(eir->msd_list, msd);
 }
 
 static void eir_parse_sd(struct eir_data *eir, uuid_t *service,
@@ -169,7 +169,7 @@ static void eir_parse_sd(struct eir_data *eir, uuid_t *service,
 	sd->data_len = len;
 	memcpy(&sd->data, data, sd->data_len);
 
-	eir->sd_list = g_slist_append(eir->sd_list, sd);
+	eir->sd_list = slist_append(eir->sd_list, sd);
 }
 
 static void eir_parse_uuid16_data(struct eir_data *eir, const uint8_t *data,
@@ -226,7 +226,7 @@ static void eir_parse_data(struct eir_data *eir, uint8_t type,
 	ad->data = g_malloc(len);
 	memcpy(ad->data, data, len);
 
-	eir->data_list = g_slist_append(eir->data_list, ad);
+	eir->data_list = slist_append(eir->data_list, ad);
 
 	if (type == EIR_CSIP_RSI)
 		eir->rsi = true;
@@ -605,12 +605,12 @@ static int match_sd_uuid(const void *data, const void *user_data)
 
 struct eir_sd *eir_get_service_data(struct eir_data *eir, const char *uuid)
 {
-	GSList *l;
+	slist_t *l;
 
 	if (!eir || !uuid)
 		return NULL;
 
-	l = g_slist_find_custom(eir->sd_list, uuid, match_sd_uuid);
+	l = slist_find(eir->sd_list, uuid, match_sd_uuid);
 	if (!l)
 		return NULL;
 
diff --git a/src/eir.h b/src/eir.h
index b9f7c3874eb3..7adaef7fb0e4 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -9,10 +9,9 @@
  *
  */
 
-#include <glib.h>
-
 #include "bluetooth/sdp.h"
 #include "bluetooth/uuid.h"
+#include "src/shared/list.h"
 
 #define EIR_FLAGS                   0x01  /* flags */
 #define EIR_UUID16_SOME             0x02  /* 16-bit UUID, more available */
@@ -73,7 +72,7 @@ struct eir_ad {
 };
 
 struct eir_data {
-	GSList *services;
+	slist_t *services;
 	unsigned int flags;
 	char *name;
 	uint32_t class;
@@ -88,9 +87,9 @@ struct eir_data {
 	uint16_t did_product;
 	uint16_t did_version;
 	uint16_t did_source;
-	GSList *msd_list;
-	GSList *sd_list;
-	GSList *data_list;
+	slist_t *msd_list;
+	slist_t *sd_list;
+	slist_t *data_list;
 };
 
 void eir_data_free(struct eir_data *eir);
diff --git a/unit/test-eir.c b/unit/test-eir.c
index 55967e957c82..5024d43723a8 100644
--- a/unit/test-eir.c
+++ b/unit/test-eir.c
@@ -587,7 +587,7 @@ static void print_debug(const char *str, void *user_data)
 static void test_ad(const struct test_data *test, struct eir_data *eir)
 {
 	struct bt_ad *ad;
-	GSList *list;
+	slist_t *list;
 
 	ad = bt_ad_new_with_data(test->eir_size, test->eir_data);
 	g_assert(ad);
@@ -636,7 +636,7 @@ static void test_parsing(gconstpointer data)
 {
 	const struct test_data *test = data;
 	struct eir_data eir;
-	GSList *list;
+	slist_t *list;
 
 	memset(&eir, 0, sizeof(eir));
 
@@ -664,7 +664,6 @@ static void test_parsing(gconstpointer data)
 	g_assert(eir.tx_power == test->tx_power);
 
 	if (test->uuid) {
-		GSList *list;
 		int n = 0;
 
 		for (list = eir.services; list; list = list->next, n++) {
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH BlueZ 3/3] shared: Remove unneeded glib includes
  2026-04-02 15:44 [PATCH BlueZ 1/3] shared: Add single-link list implementation Bastien Nocera
  2026-04-02 15:44 ` [PATCH BlueZ 2/3] shared: Remove glib dependency from src/shared/ad.c Bastien Nocera
@ 2026-04-02 15:44 ` Bastien Nocera
  2026-04-02 16:33 ` [BlueZ,1/3] shared: Add single-link list implementation bluez.test.bot
  2 siblings, 0 replies; 6+ messages in thread
From: Bastien Nocera @ 2026-04-02 15:44 UTC (permalink / raw)
  To: linux-bluetooth

glib was included, but no glib functions or data types were being used,
so remove those includes.
---
 src/shared/csip.c | 2 --
 src/shared/rap.c  | 1 -
 2 files changed, 3 deletions(-)

diff --git a/src/shared/csip.c b/src/shared/csip.c
index c5b77001a1aa..06b1606d9123 100644
--- a/src/shared/csip.c
+++ b/src/shared/csip.c
@@ -15,8 +15,6 @@
 #include <unistd.h>
 #include <errno.h>
 
-#include <glib.h>
-
 #include "bluetooth/bluetooth.h"
 #include "bluetooth/uuid.h"
 
diff --git a/src/shared/rap.c b/src/shared/rap.c
index 39ef3f2783c4..ccf3e6f33793 100644
--- a/src/shared/rap.c
+++ b/src/shared/rap.c
@@ -12,7 +12,6 @@
 #include <stdbool.h>
 #include <unistd.h>
 #include <errno.h>
-#include <glib.h>
 
 #include "bluetooth/bluetooth.h"
 #include "bluetooth/uuid.h"
-- 
2.53.0


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH BlueZ 2/3] shared: Remove glib dependency from src/shared/ad.c
  2026-04-02 15:44 ` [PATCH BlueZ 2/3] shared: Remove glib dependency from src/shared/ad.c Bastien Nocera
@ 2026-04-02 16:23   ` Luiz Augusto von Dentz
  2026-04-03  8:40     ` Bastien Nocera
  0 siblings, 1 reply; 6+ messages in thread
From: Luiz Augusto von Dentz @ 2026-04-02 16:23 UTC (permalink / raw)
  To: Bastien Nocera; +Cc: linux-bluetooth

Hi Bastien,

On Thu, Apr 2, 2026 at 11:48 AM Bastien Nocera <hadess@hadess.net> wrote:
>
> src/shared/ad.c includes src/eir.h, which uses glib, which means that
> the non-glib shared library can't be used without linking to glib.
>
> Use our own linked list implementation to remove the glib use.
> ---
>  plugins/neard.c |  4 ++--
>  src/adapter.c   |  9 +++++----
>  src/device.c    | 22 +++++++++++-----------
>  src/device.h    | 10 ++++++----
>  src/eir.c       | 24 ++++++++++++------------
>  src/eir.h       | 11 +++++------
>  unit/test-eir.c |  5 ++---
>  7 files changed, 43 insertions(+), 42 deletions(-)
>
> diff --git a/plugins/neard.c b/plugins/neard.c
> index c84934025cd8..b2860403d50d 100644
> --- a/plugins/neard.c
> +++ b/plugins/neard.c
> @@ -58,7 +58,7 @@ struct oob_params {
>         bdaddr_t address;
>         uint32_t class;
>         char *name;
> -       GSList *services;
> +       slist_t *services;

No need to come up with another list implementation, just use struct queue.

>         uint8_t *hash;
>         uint8_t *randomizer;
>         uint8_t *pin;
> @@ -68,7 +68,7 @@ struct oob_params {
>
>  static void free_oob_params(struct oob_params *params)
>  {
> -       g_slist_free_full(params->services, free);
> +       slist_clear(params->services, free);
>         g_free(params->name);
>         g_free(params->hash);
>         g_free(params->randomizer);
> diff --git a/src/adapter.c b/src/adapter.c
> index 04568dae6e98..8eb0caa34223 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -43,6 +43,7 @@
>  #include "textfile.h"
>
>  #include "src/shared/util.h"
> +#include "src/shared/list.h"
>  #include "src/shared/queue.h"
>  #include "src/shared/att.h"
>  #include "src/shared/gatt-db.h"
> @@ -7171,10 +7172,10 @@ static void confirm_name(struct btd_adapter *adapter, const bdaddr_t *bdaddr,
>
>  static void adapter_msd_notify(struct btd_adapter *adapter,
>                                                         struct btd_device *dev,
> -                                                       GSList *msd_list)
> +                                                       slist_t *msd_list)
>  {
>         GSList *cb_l, *cb_next;
> -       GSList *msd_l, *msd_next;
> +       slist_t *msd_l, *msd_next;
>
>         for (cb_l = adapter->msd_callbacks; cb_l != NULL; cb_l = cb_next) {
>                 btd_msd_cb_t cb = cb_l->data;
> @@ -7184,7 +7185,7 @@ static void adapter_msd_notify(struct btd_adapter *adapter,
>                 for (msd_l = msd_list; msd_l != NULL; msd_l = msd_next) {
>                         const struct eir_msd *msd = msd_l->data;
>
> -                       msd_next = g_slist_next(msd_l);
> +                       msd_next = msd_l->next;
>
>                         cb(adapter, dev, msd->company, msd->data,
>                                                                 msd->data_len);
> @@ -7223,7 +7224,7 @@ static bool is_filter_match(GSList *discovery_filter, struct eir_data *eir_data,
>                                 /* m->data contains string representation of
>                                  * uuid.
>                                  */
> -                               if (g_slist_find_custom(eir_data->services,
> +                               if (slist_find(eir_data->services,
>                                                         m->data,
>                                                         g_strcmp) != NULL)
>                                         got_match = true;
> diff --git a/src/device.c b/src/device.c
> index 0e8ca28d3809..2a3b23ef3013 100644
> --- a/src/device.c
> +++ b/src/device.c
> @@ -2432,9 +2432,9 @@ unref:
>         dev->connect = NULL;
>  }
>
> -void device_add_eir_uuids(struct btd_device *dev, GSList *uuids)
> +void device_add_eir_uuids(struct btd_device *dev, slist_t *uuids)
>  {
> -       GSList *l;
> +       slist_t *l;
>         GSList *added = NULL;
>
>         if (dev->bredr_state.svc_resolved || dev->le_state.svc_resolved)
> @@ -2465,13 +2465,13 @@ static void add_manufacturer_data(void *data, void *user_data)
>                                         DEVICE_INTERFACE, "ManufacturerData");
>  }
>
> -void device_set_manufacturer_data(struct btd_device *dev, GSList *list,
> +void device_set_manufacturer_data(struct btd_device *dev, slist_t *list,
>                                                                 bool duplicate)
>  {
>         if (duplicate)
>                 bt_ad_clear_manufacturer_data(dev->ad);
>
> -       g_slist_foreach(list, add_manufacturer_data, dev);
> +       slist_foreach(list, add_manufacturer_data, dev);
>  }
>
>  static void add_service_data(void *data, void *user_data)
> @@ -2479,7 +2479,7 @@ static void add_service_data(void *data, void *user_data)
>         struct eir_sd *sd = data;
>         struct btd_device *dev = user_data;
>         bt_uuid_t uuid;
> -       GSList *l;
> +       slist_t *l;
>
>         if (bt_string_to_uuid(&uuid, sd->uuid) < 0)
>                 return;
> @@ -2487,21 +2487,21 @@ static void add_service_data(void *data, void *user_data)
>         if (!bt_ad_add_service_data(dev->ad, &uuid, sd->data, sd->data_len))
>                 return;
>
> -       l = g_slist_append(NULL, sd->uuid);
> +       l = slist_append(NULL, sd->uuid);
>         device_add_eir_uuids(dev, l);
> -       g_slist_free(l);
> +       slist_free(l);
>
>         g_dbus_emit_property_changed(dbus_conn, dev->path,
>                                         DEVICE_INTERFACE, "ServiceData");
>  }
>
> -void device_set_service_data(struct btd_device *dev, GSList *list,
> +void device_set_service_data(struct btd_device *dev, slist_t *list,
>                                                         bool duplicate)
>  {
>         if (duplicate)
>                 bt_ad_clear_service_data(dev->ad);
>
> -       g_slist_foreach(list, add_service_data, dev);
> +       slist_foreach(list, add_service_data, dev);
>  }
>
>  static void add_data(void *data, void *user_data)
> @@ -2518,13 +2518,13 @@ static void add_data(void *data, void *user_data)
>                                                 "AdvertisingData");
>  }
>
> -void device_set_data(struct btd_device *dev, GSList *list,
> +void device_set_data(struct btd_device *dev, slist_t *list,
>                                                         bool duplicate)
>  {
>         if (duplicate)
>                 bt_ad_clear_data(dev->ad);
>
> -       g_slist_foreach(list, add_data, dev);
> +       slist_foreach(list, add_data, dev);
>  }
>
>  static struct btd_service *find_connectable_service(struct btd_device *dev,
> diff --git a/src/device.h b/src/device.h
> index c7b8b2a16eb9..5ee1f2300223 100644
> --- a/src/device.h
> +++ b/src/device.h
> @@ -9,6 +9,8 @@
>   *
>   */
>
> +#include "src/shared/list.h"
> +
>  #define DEVICE_INTERFACE       "org.bluez.Device1"
>
>  struct btd_device;
> @@ -78,12 +80,12 @@ void btd_device_gatt_set_service_changed(struct btd_device *device,
>                                                 uint16_t start, uint16_t end);
>  bool device_attach_att(struct btd_device *dev, GIOChannel *io);
>  void btd_device_add_uuid(struct btd_device *device, const char *uuid);
> -void device_add_eir_uuids(struct btd_device *dev, GSList *uuids);
> -void device_set_manufacturer_data(struct btd_device *dev, GSList *list,
> +void device_add_eir_uuids(struct btd_device *dev, slist_t *uuids);
> +void device_set_manufacturer_data(struct btd_device *dev, slist_t *list,
>                                                         bool duplicate);
> -void device_set_service_data(struct btd_device *dev, GSList *list,
> +void device_set_service_data(struct btd_device *dev, slist_t *list,
>                                                         bool duplicate);
> -void device_set_data(struct btd_device *dev, GSList *list,
> +void device_set_data(struct btd_device *dev, slist_t *list,
>                                                         bool duplicate);
>  void device_probe_profile(gpointer a, gpointer b);
>  void device_remove_profile(gpointer a, gpointer b);
> diff --git a/src/eir.c b/src/eir.c
> index 68ed74fe6493..8efca6978b39 100644
> --- a/src/eir.c
> +++ b/src/eir.c
> @@ -49,7 +49,7 @@ static void data_free(void *data)
>
>  void eir_data_free(struct eir_data *eir)
>  {
> -       g_slist_free_full(eir->services, free);
> +       slist_clear(eir->services, free);
>         eir->services = NULL;
>         g_free(eir->name);
>         eir->name = NULL;
> @@ -57,11 +57,11 @@ void eir_data_free(struct eir_data *eir)
>         eir->hash = NULL;
>         free(eir->randomizer);
>         eir->randomizer = NULL;
> -       g_slist_free_full(eir->msd_list, g_free);
> +       slist_clear(eir->msd_list, g_free);
>         eir->msd_list = NULL;
> -       g_slist_free_full(eir->sd_list, sd_free);
> +       slist_clear(eir->sd_list, sd_free);
>         eir->sd_list = NULL;
> -       g_slist_free_full(eir->data_list, data_free);
> +       slist_clear(eir->data_list, data_free);
>         eir->data_list = NULL;
>  }
>
> @@ -80,7 +80,7 @@ static void eir_parse_uuid16(struct eir_data *eir, const void *data,
>                 uuid_str = bt_uuid2string(&service);
>                 if (!uuid_str)
>                         continue;
> -               eir->services = g_slist_append(eir->services, uuid_str);
> +               eir->services = slist_append(eir->services, uuid_str);
>         }
>  }
>
> @@ -99,7 +99,7 @@ static void eir_parse_uuid32(struct eir_data *eir, const void *data,
>                 uuid_str = bt_uuid2string(&service);
>                 if (!uuid_str)
>                         continue;
> -               eir->services = g_slist_append(eir->services, uuid_str);
> +               eir->services = slist_append(eir->services, uuid_str);
>         }
>  }
>
> @@ -119,7 +119,7 @@ static void eir_parse_uuid128(struct eir_data *eir, const uint8_t *data,
>                 uuid_str = bt_uuid2string(&service);
>                 if (!uuid_str)
>                         continue;
> -               eir->services = g_slist_append(eir->services, uuid_str);
> +               eir->services = slist_append(eir->services, uuid_str);
>                 uuid_ptr += 16;
>         }
>  }
> @@ -151,7 +151,7 @@ static void eir_parse_msd(struct eir_data *eir, const uint8_t *data,
>         msd->data_len = len - 2;
>         memcpy(&msd->data, data + 2, msd->data_len);
>
> -       eir->msd_list = g_slist_append(eir->msd_list, msd);
> +       eir->msd_list = slist_append(eir->msd_list, msd);
>  }
>
>  static void eir_parse_sd(struct eir_data *eir, uuid_t *service,
> @@ -169,7 +169,7 @@ static void eir_parse_sd(struct eir_data *eir, uuid_t *service,
>         sd->data_len = len;
>         memcpy(&sd->data, data, sd->data_len);
>
> -       eir->sd_list = g_slist_append(eir->sd_list, sd);
> +       eir->sd_list = slist_append(eir->sd_list, sd);
>  }
>
>  static void eir_parse_uuid16_data(struct eir_data *eir, const uint8_t *data,
> @@ -226,7 +226,7 @@ static void eir_parse_data(struct eir_data *eir, uint8_t type,
>         ad->data = g_malloc(len);
>         memcpy(ad->data, data, len);
>
> -       eir->data_list = g_slist_append(eir->data_list, ad);
> +       eir->data_list = slist_append(eir->data_list, ad);
>
>         if (type == EIR_CSIP_RSI)
>                 eir->rsi = true;
> @@ -605,12 +605,12 @@ static int match_sd_uuid(const void *data, const void *user_data)
>
>  struct eir_sd *eir_get_service_data(struct eir_data *eir, const char *uuid)
>  {
> -       GSList *l;
> +       slist_t *l;
>
>         if (!eir || !uuid)
>                 return NULL;
>
> -       l = g_slist_find_custom(eir->sd_list, uuid, match_sd_uuid);
> +       l = slist_find(eir->sd_list, uuid, match_sd_uuid);
>         if (!l)
>                 return NULL;
>
> diff --git a/src/eir.h b/src/eir.h
> index b9f7c3874eb3..7adaef7fb0e4 100644
> --- a/src/eir.h
> +++ b/src/eir.h
> @@ -9,10 +9,9 @@
>   *
>   */
>
> -#include <glib.h>
> -
>  #include "bluetooth/sdp.h"
>  #include "bluetooth/uuid.h"
> +#include "src/shared/list.h"
>
>  #define EIR_FLAGS                   0x01  /* flags */
>  #define EIR_UUID16_SOME             0x02  /* 16-bit UUID, more available */
> @@ -73,7 +72,7 @@ struct eir_ad {
>  };
>
>  struct eir_data {
> -       GSList *services;
> +       slist_t *services;
>         unsigned int flags;
>         char *name;
>         uint32_t class;
> @@ -88,9 +87,9 @@ struct eir_data {
>         uint16_t did_product;
>         uint16_t did_version;
>         uint16_t did_source;
> -       GSList *msd_list;
> -       GSList *sd_list;
> -       GSList *data_list;
> +       slist_t *msd_list;
> +       slist_t *sd_list;
> +       slist_t *data_list;
>  };
>
>  void eir_data_free(struct eir_data *eir);
> diff --git a/unit/test-eir.c b/unit/test-eir.c
> index 55967e957c82..5024d43723a8 100644
> --- a/unit/test-eir.c
> +++ b/unit/test-eir.c
> @@ -587,7 +587,7 @@ static void print_debug(const char *str, void *user_data)
>  static void test_ad(const struct test_data *test, struct eir_data *eir)
>  {
>         struct bt_ad *ad;
> -       GSList *list;
> +       slist_t *list;
>
>         ad = bt_ad_new_with_data(test->eir_size, test->eir_data);
>         g_assert(ad);
> @@ -636,7 +636,7 @@ static void test_parsing(gconstpointer data)
>  {
>         const struct test_data *test = data;
>         struct eir_data eir;
> -       GSList *list;
> +       slist_t *list;
>
>         memset(&eir, 0, sizeof(eir));
>
> @@ -664,7 +664,6 @@ static void test_parsing(gconstpointer data)
>         g_assert(eir.tx_power == test->tx_power);
>
>         if (test->uuid) {
> -               GSList *list;
>                 int n = 0;
>
>                 for (list = eir.services; list; list = list->next, n++) {
> --
> 2.53.0
>
>


-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 6+ messages in thread

* RE: [BlueZ,1/3] shared: Add single-link list implementation
  2026-04-02 15:44 [PATCH BlueZ 1/3] shared: Add single-link list implementation Bastien Nocera
  2026-04-02 15:44 ` [PATCH BlueZ 2/3] shared: Remove glib dependency from src/shared/ad.c Bastien Nocera
  2026-04-02 15:44 ` [PATCH BlueZ 3/3] shared: Remove unneeded glib includes Bastien Nocera
@ 2026-04-02 16:33 ` bluez.test.bot
  2 siblings, 0 replies; 6+ messages in thread
From: bluez.test.bot @ 2026-04-02 16:33 UTC (permalink / raw)
  To: linux-bluetooth, hadess

[-- Attachment #1: Type: text/plain, Size: 524 bytes --]

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----

error: patch failed: Makefile.am:700
error: Makefile.am: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch

Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH BlueZ 2/3] shared: Remove glib dependency from src/shared/ad.c
  2026-04-02 16:23   ` Luiz Augusto von Dentz
@ 2026-04-03  8:40     ` Bastien Nocera
  0 siblings, 0 replies; 6+ messages in thread
From: Bastien Nocera @ 2026-04-03  8:40 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

On Thu, 2026-04-02 at 12:23 -0400, Luiz Augusto von Dentz wrote:
> Hi Bastien,
> 
> On Thu, Apr 2, 2026 at 11:48 AM Bastien Nocera <hadess@hadess.net>
> wrote:
> > 
> > src/shared/ad.c includes src/eir.h, which uses glib, which means
> > that
> > the non-glib shared library can't be used without linking to glib.
> > 
> > Use our own linked list implementation to remove the glib use.
> > ---
> >  plugins/neard.c |  4 ++--
> >  src/adapter.c   |  9 +++++----
> >  src/device.c    | 22 +++++++++++-----------
> >  src/device.h    | 10 ++++++----
> >  src/eir.c       | 24 ++++++++++++------------
> >  src/eir.h       | 11 +++++------
> >  unit/test-eir.c |  5 ++---
> >  7 files changed, 43 insertions(+), 42 deletions(-)
> > 
> > diff --git a/plugins/neard.c b/plugins/neard.c
> > index c84934025cd8..b2860403d50d 100644
> > --- a/plugins/neard.c
> > +++ b/plugins/neard.c
> > @@ -58,7 +58,7 @@ struct oob_params {
> >         bdaddr_t address;
> >         uint32_t class;
> >         char *name;
> > -       GSList *services;
> > +       slist_t *services;
> 
> No need to come up with another list implementation, just use struct
> queue.

It's not a linked list if you can't access the links...

I'm adding "document our own data types" to the documentation TODO.

> 
> >         uint8_t *hash;
> >         uint8_t *randomizer;
> >         uint8_t *pin;
> > @@ -68,7 +68,7 @@ struct oob_params {
> > 
> >  static void free_oob_params(struct oob_params *params)
> >  {
> > -       g_slist_free_full(params->services, free);
> > +       slist_clear(params->services, free);
> >         g_free(params->name);
> >         g_free(params->hash);
> >         g_free(params->randomizer);
> > diff --git a/src/adapter.c b/src/adapter.c
> > index 04568dae6e98..8eb0caa34223 100644
> > --- a/src/adapter.c
> > +++ b/src/adapter.c
> > @@ -43,6 +43,7 @@
> >  #include "textfile.h"
> > 
> >  #include "src/shared/util.h"
> > +#include "src/shared/list.h"
> >  #include "src/shared/queue.h"
> >  #include "src/shared/att.h"
> >  #include "src/shared/gatt-db.h"
> > @@ -7171,10 +7172,10 @@ static void confirm_name(struct btd_adapter
> > *adapter, const bdaddr_t *bdaddr,
> > 
> >  static void adapter_msd_notify(struct btd_adapter *adapter,
> >                                                         struct
> > btd_device *dev,
> > -                                                       GSList
> > *msd_list)
> > +                                                       slist_t
> > *msd_list)
> >  {
> >         GSList *cb_l, *cb_next;
> > -       GSList *msd_l, *msd_next;
> > +       slist_t *msd_l, *msd_next;
> > 
> >         for (cb_l = adapter->msd_callbacks; cb_l != NULL; cb_l =
> > cb_next) {
> >                 btd_msd_cb_t cb = cb_l->data;
> > @@ -7184,7 +7185,7 @@ static void adapter_msd_notify(struct
> > btd_adapter *adapter,
> >                 for (msd_l = msd_list; msd_l != NULL; msd_l =
> > msd_next) {
> >                         const struct eir_msd *msd = msd_l->data;
> > 
> > -                       msd_next = g_slist_next(msd_l);
> > +                       msd_next = msd_l->next;
> > 
> >                         cb(adapter, dev, msd->company, msd->data,
> >                                                                
> > msd->data_len);
> > @@ -7223,7 +7224,7 @@ static bool is_filter_match(GSList
> > *discovery_filter, struct eir_data *eir_data,
> >                                 /* m->data contains string
> > representation of
> >                                  * uuid.
> >                                  */
> > -                               if (g_slist_find_custom(eir_data-
> > >services,
> > +                               if (slist_find(eir_data->services,
> >                                                         m->data,
> >                                                         g_strcmp)
> > != NULL)
> >                                         got_match = true;
> > diff --git a/src/device.c b/src/device.c
> > index 0e8ca28d3809..2a3b23ef3013 100644
> > --- a/src/device.c
> > +++ b/src/device.c
> > @@ -2432,9 +2432,9 @@ unref:
> >         dev->connect = NULL;
> >  }
> > 
> > -void device_add_eir_uuids(struct btd_device *dev, GSList *uuids)
> > +void device_add_eir_uuids(struct btd_device *dev, slist_t *uuids)
> >  {
> > -       GSList *l;
> > +       slist_t *l;
> >         GSList *added = NULL;
> > 
> >         if (dev->bredr_state.svc_resolved || dev-
> > >le_state.svc_resolved)
> > @@ -2465,13 +2465,13 @@ static void add_manufacturer_data(void
> > *data, void *user_data)
> >                                         DEVICE_INTERFACE,
> > "ManufacturerData");
> >  }
> > 
> > -void device_set_manufacturer_data(struct btd_device *dev, GSList
> > *list,
> > +void device_set_manufacturer_data(struct btd_device *dev, slist_t
> > *list,
> >                                                                
> > bool duplicate)
> >  {
> >         if (duplicate)
> >                 bt_ad_clear_manufacturer_data(dev->ad);
> > 
> > -       g_slist_foreach(list, add_manufacturer_data, dev);
> > +       slist_foreach(list, add_manufacturer_data, dev);
> >  }
> > 
> >  static void add_service_data(void *data, void *user_data)
> > @@ -2479,7 +2479,7 @@ static void add_service_data(void *data, void
> > *user_data)
> >         struct eir_sd *sd = data;
> >         struct btd_device *dev = user_data;
> >         bt_uuid_t uuid;
> > -       GSList *l;
> > +       slist_t *l;
> > 
> >         if (bt_string_to_uuid(&uuid, sd->uuid) < 0)
> >                 return;
> > @@ -2487,21 +2487,21 @@ static void add_service_data(void *data,
> > void *user_data)
> >         if (!bt_ad_add_service_data(dev->ad, &uuid, sd->data, sd-
> > >data_len))
> >                 return;
> > 
> > -       l = g_slist_append(NULL, sd->uuid);
> > +       l = slist_append(NULL, sd->uuid);
> >         device_add_eir_uuids(dev, l);
> > -       g_slist_free(l);
> > +       slist_free(l);
> > 
> >         g_dbus_emit_property_changed(dbus_conn, dev->path,
> >                                         DEVICE_INTERFACE,
> > "ServiceData");
> >  }
> > 
> > -void device_set_service_data(struct btd_device *dev, GSList *list,
> > +void device_set_service_data(struct btd_device *dev, slist_t
> > *list,
> >                                                         bool
> > duplicate)
> >  {
> >         if (duplicate)
> >                 bt_ad_clear_service_data(dev->ad);
> > 
> > -       g_slist_foreach(list, add_service_data, dev);
> > +       slist_foreach(list, add_service_data, dev);
> >  }
> > 
> >  static void add_data(void *data, void *user_data)
> > @@ -2518,13 +2518,13 @@ static void add_data(void *data, void
> > *user_data)
> >                                                 "AdvertisingData");
> >  }
> > 
> > -void device_set_data(struct btd_device *dev, GSList *list,
> > +void device_set_data(struct btd_device *dev, slist_t *list,
> >                                                         bool
> > duplicate)
> >  {
> >         if (duplicate)
> >                 bt_ad_clear_data(dev->ad);
> > 
> > -       g_slist_foreach(list, add_data, dev);
> > +       slist_foreach(list, add_data, dev);
> >  }
> > 
> >  static struct btd_service *find_connectable_service(struct
> > btd_device *dev,
> > diff --git a/src/device.h b/src/device.h
> > index c7b8b2a16eb9..5ee1f2300223 100644
> > --- a/src/device.h
> > +++ b/src/device.h
> > @@ -9,6 +9,8 @@
> >   *
> >   */
> > 
> > +#include "src/shared/list.h"
> > +
> >  #define DEVICE_INTERFACE       "org.bluez.Device1"
> > 
> >  struct btd_device;
> > @@ -78,12 +80,12 @@ void btd_device_gatt_set_service_changed(struct
> > btd_device *device,
> >                                                 uint16_t start,
> > uint16_t end);
> >  bool device_attach_att(struct btd_device *dev, GIOChannel *io);
> >  void btd_device_add_uuid(struct btd_device *device, const char
> > *uuid);
> > -void device_add_eir_uuids(struct btd_device *dev, GSList *uuids);
> > -void device_set_manufacturer_data(struct btd_device *dev, GSList
> > *list,
> > +void device_add_eir_uuids(struct btd_device *dev, slist_t *uuids);
> > +void device_set_manufacturer_data(struct btd_device *dev, slist_t
> > *list,
> >                                                         bool
> > duplicate);
> > -void device_set_service_data(struct btd_device *dev, GSList *list,
> > +void device_set_service_data(struct btd_device *dev, slist_t
> > *list,
> >                                                         bool
> > duplicate);
> > -void device_set_data(struct btd_device *dev, GSList *list,
> > +void device_set_data(struct btd_device *dev, slist_t *list,
> >                                                         bool
> > duplicate);
> >  void device_probe_profile(gpointer a, gpointer b);
> >  void device_remove_profile(gpointer a, gpointer b);
> > diff --git a/src/eir.c b/src/eir.c
> > index 68ed74fe6493..8efca6978b39 100644
> > --- a/src/eir.c
> > +++ b/src/eir.c
> > @@ -49,7 +49,7 @@ static void data_free(void *data)
> > 
> >  void eir_data_free(struct eir_data *eir)
> >  {
> > -       g_slist_free_full(eir->services, free);
> > +       slist_clear(eir->services, free);
> >         eir->services = NULL;
> >         g_free(eir->name);
> >         eir->name = NULL;
> > @@ -57,11 +57,11 @@ void eir_data_free(struct eir_data *eir)
> >         eir->hash = NULL;
> >         free(eir->randomizer);
> >         eir->randomizer = NULL;
> > -       g_slist_free_full(eir->msd_list, g_free);
> > +       slist_clear(eir->msd_list, g_free);
> >         eir->msd_list = NULL;
> > -       g_slist_free_full(eir->sd_list, sd_free);
> > +       slist_clear(eir->sd_list, sd_free);
> >         eir->sd_list = NULL;
> > -       g_slist_free_full(eir->data_list, data_free);
> > +       slist_clear(eir->data_list, data_free);
> >         eir->data_list = NULL;
> >  }
> > 
> > @@ -80,7 +80,7 @@ static void eir_parse_uuid16(struct eir_data
> > *eir, const void *data,
> >                 uuid_str = bt_uuid2string(&service);
> >                 if (!uuid_str)
> >                         continue;
> > -               eir->services = g_slist_append(eir->services,
> > uuid_str);
> > +               eir->services = slist_append(eir->services,
> > uuid_str);
> >         }
> >  }
> > 
> > @@ -99,7 +99,7 @@ static void eir_parse_uuid32(struct eir_data
> > *eir, const void *data,
> >                 uuid_str = bt_uuid2string(&service);
> >                 if (!uuid_str)
> >                         continue;
> > -               eir->services = g_slist_append(eir->services,
> > uuid_str);
> > +               eir->services = slist_append(eir->services,
> > uuid_str);
> >         }
> >  }
> > 
> > @@ -119,7 +119,7 @@ static void eir_parse_uuid128(struct eir_data
> > *eir, const uint8_t *data,
> >                 uuid_str = bt_uuid2string(&service);
> >                 if (!uuid_str)
> >                         continue;
> > -               eir->services = g_slist_append(eir->services,
> > uuid_str);
> > +               eir->services = slist_append(eir->services,
> > uuid_str);
> >                 uuid_ptr += 16;
> >         }
> >  }
> > @@ -151,7 +151,7 @@ static void eir_parse_msd(struct eir_data *eir,
> > const uint8_t *data,
> >         msd->data_len = len - 2;
> >         memcpy(&msd->data, data + 2, msd->data_len);
> > 
> > -       eir->msd_list = g_slist_append(eir->msd_list, msd);
> > +       eir->msd_list = slist_append(eir->msd_list, msd);
> >  }
> > 
> >  static void eir_parse_sd(struct eir_data *eir, uuid_t *service,
> > @@ -169,7 +169,7 @@ static void eir_parse_sd(struct eir_data *eir,
> > uuid_t *service,
> >         sd->data_len = len;
> >         memcpy(&sd->data, data, sd->data_len);
> > 
> > -       eir->sd_list = g_slist_append(eir->sd_list, sd);
> > +       eir->sd_list = slist_append(eir->sd_list, sd);
> >  }
> > 
> >  static void eir_parse_uuid16_data(struct eir_data *eir, const
> > uint8_t *data,
> > @@ -226,7 +226,7 @@ static void eir_parse_data(struct eir_data
> > *eir, uint8_t type,
> >         ad->data = g_malloc(len);
> >         memcpy(ad->data, data, len);
> > 
> > -       eir->data_list = g_slist_append(eir->data_list, ad);
> > +       eir->data_list = slist_append(eir->data_list, ad);
> > 
> >         if (type == EIR_CSIP_RSI)
> >                 eir->rsi = true;
> > @@ -605,12 +605,12 @@ static int match_sd_uuid(const void *data,
> > const void *user_data)
> > 
> >  struct eir_sd *eir_get_service_data(struct eir_data *eir, const
> > char *uuid)
> >  {
> > -       GSList *l;
> > +       slist_t *l;
> > 
> >         if (!eir || !uuid)
> >                 return NULL;
> > 
> > -       l = g_slist_find_custom(eir->sd_list, uuid, match_sd_uuid);
> > +       l = slist_find(eir->sd_list, uuid, match_sd_uuid);
> >         if (!l)
> >                 return NULL;
> > 
> > diff --git a/src/eir.h b/src/eir.h
> > index b9f7c3874eb3..7adaef7fb0e4 100644
> > --- a/src/eir.h
> > +++ b/src/eir.h
> > @@ -9,10 +9,9 @@
> >   *
> >   */
> > 
> > -#include <glib.h>
> > -
> >  #include "bluetooth/sdp.h"
> >  #include "bluetooth/uuid.h"
> > +#include "src/shared/list.h"
> > 
> >  #define EIR_FLAGS                   0x01  /* flags */
> >  #define EIR_UUID16_SOME             0x02  /* 16-bit UUID, more
> > available */
> > @@ -73,7 +72,7 @@ struct eir_ad {
> >  };
> > 
> >  struct eir_data {
> > -       GSList *services;
> > +       slist_t *services;
> >         unsigned int flags;
> >         char *name;
> >         uint32_t class;
> > @@ -88,9 +87,9 @@ struct eir_data {
> >         uint16_t did_product;
> >         uint16_t did_version;
> >         uint16_t did_source;
> > -       GSList *msd_list;
> > -       GSList *sd_list;
> > -       GSList *data_list;
> > +       slist_t *msd_list;
> > +       slist_t *sd_list;
> > +       slist_t *data_list;
> >  };
> > 
> >  void eir_data_free(struct eir_data *eir);
> > diff --git a/unit/test-eir.c b/unit/test-eir.c
> > index 55967e957c82..5024d43723a8 100644
> > --- a/unit/test-eir.c
> > +++ b/unit/test-eir.c
> > @@ -587,7 +587,7 @@ static void print_debug(const char *str, void
> > *user_data)
> >  static void test_ad(const struct test_data *test, struct eir_data
> > *eir)
> >  {
> >         struct bt_ad *ad;
> > -       GSList *list;
> > +       slist_t *list;
> > 
> >         ad = bt_ad_new_with_data(test->eir_size, test->eir_data);
> >         g_assert(ad);
> > @@ -636,7 +636,7 @@ static void test_parsing(gconstpointer data)
> >  {
> >         const struct test_data *test = data;
> >         struct eir_data eir;
> > -       GSList *list;
> > +       slist_t *list;
> > 
> >         memset(&eir, 0, sizeof(eir));
> > 
> > @@ -664,7 +664,6 @@ static void test_parsing(gconstpointer data)
> >         g_assert(eir.tx_power == test->tx_power);
> > 
> >         if (test->uuid) {
> > -               GSList *list;
> >                 int n = 0;
> > 
> >                 for (list = eir.services; list; list = list->next,
> > n++) {
> > --
> > 2.53.0
> > 
> > 
> 

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2026-04-03  8:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-02 15:44 [PATCH BlueZ 1/3] shared: Add single-link list implementation Bastien Nocera
2026-04-02 15:44 ` [PATCH BlueZ 2/3] shared: Remove glib dependency from src/shared/ad.c Bastien Nocera
2026-04-02 16:23   ` Luiz Augusto von Dentz
2026-04-03  8:40     ` Bastien Nocera
2026-04-02 15:44 ` [PATCH BlueZ 3/3] shared: Remove unneeded glib includes Bastien Nocera
2026-04-02 16:33 ` [BlueZ,1/3] shared: Add single-link list implementation bluez.test.bot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox