* [PATCH BlueZ v2 0/3] Remove glib dep from non-glib shared library
@ 2026-04-16 14:08 Bastien Nocera
2026-04-16 14:08 ` [PATCH BlueZ v2 1/3] shared: Remove glib dependency from src/shared/ad.c Bastien Nocera
` (3 more replies)
0 siblings, 4 replies; 5+ messages in thread
From: Bastien Nocera @ 2026-04-16 14:08 UTC (permalink / raw)
To: linux-bluetooth
Changes since v1:
- remove queue_peek_head_entry() patch, we already had similar API
Bastien Nocera (3):
shared: Remove glib dependency from src/shared/ad.c
shared/queue: Fix warning when compiling ad.c
shared: Remove unneeded glib includes
plugins/neard.c | 4 ++--
src/adapter.c | 10 +++++-----
src/device.c | 29 +++++++++++++++--------------
src/device.h | 10 ++++++----
src/eir.c | 41 ++++++++++++++++++++++-------------------
src/eir.h | 11 +++++------
src/shared/csip.c | 2 --
src/shared/queue.h | 2 ++
src/shared/rap.c | 1 -
unit/test-eir.c | 29 ++++++++++++++---------------
10 files changed, 71 insertions(+), 68 deletions(-)
--
2.53.0
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH BlueZ v2 1/3] shared: Remove glib dependency from src/shared/ad.c
2026-04-16 14:08 [PATCH BlueZ v2 0/3] Remove glib dep from non-glib shared library Bastien Nocera
@ 2026-04-16 14:08 ` Bastien Nocera
2026-04-16 14:08 ` [PATCH BlueZ v2 2/3] shared/queue: Fix warning when compiling ad.c Bastien Nocera
` (2 subsequent siblings)
3 siblings, 0 replies; 5+ messages in thread
From: Bastien Nocera @ 2026-04-16 14:08 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 queue implementation to remove the glib linked-list usage.
---
plugins/neard.c | 4 ++--
src/adapter.c | 10 +++++-----
src/device.c | 29 +++++++++++++++--------------
src/device.h | 10 ++++++----
src/eir.c | 41 ++++++++++++++++++++++-------------------
src/eir.h | 11 +++++------
unit/test-eir.c | 29 ++++++++++++++---------------
7 files changed, 69 insertions(+), 65 deletions(-)
diff --git a/plugins/neard.c b/plugins/neard.c
index c84934025cd8..edfc115373ef 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;
+ struct queue *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);
+ queue_destroy(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 46b89526fcaf..8e38282b5f93 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -7162,20 +7162,20 @@ 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)
+ struct queue *msd_list)
{
GSList *cb_l, *cb_next;
- GSList *msd_l, *msd_next;
+ const struct queue_entry *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;
cb_next = g_slist_next(cb_l);
- for (msd_l = msd_list; msd_l != NULL; msd_l = msd_next) {
+ for (msd_l = queue_get_entries(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);
@@ -7214,7 +7214,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 (queue_find(eir_data->services,
m->data,
g_strcmp) != NULL)
got_match = true;
diff --git a/src/device.c b/src/device.c
index 5dbc0fde4fed..28515054cd46 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2432,16 +2432,16 @@ unref:
dev->connect = NULL;
}
-void device_add_eir_uuids(struct btd_device *dev, GSList *uuids)
+void device_add_eir_uuids(struct btd_device *dev, struct queue *uuids)
{
- GSList *l;
+ const struct queue_entry *q;
GSList *added = NULL;
if (dev->bredr_state.svc_resolved || dev->le_state.svc_resolved)
return;
- for (l = uuids; l != NULL; l = l->next) {
- const char *str = l->data;
+ for (q = queue_get_entries(uuids); q != NULL; q = q->next) {
+ const char *str = q->data;
if (g_slist_find_custom(dev->eir_uuids, str, bt_uuid_strcmp))
continue;
added = g_slist_append(added, (void *)str);
@@ -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, struct queue *queue,
bool duplicate)
{
if (duplicate)
bt_ad_clear_manufacturer_data(dev->ad);
- g_slist_foreach(list, add_manufacturer_data, dev);
+ queue_foreach(queue, 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;
+ struct queue *q;
if (bt_string_to_uuid(&uuid, sd->uuid) < 0)
return;
@@ -2487,21 +2487,22 @@ 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);
- device_add_eir_uuids(dev, l);
- g_slist_free(l);
+ q = queue_new();
+ queue_push_tail(q, sd->uuid);
+ device_add_eir_uuids(dev, q);
+ queue_destroy(q, NULL);
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, struct queue *queue,
bool duplicate)
{
if (duplicate)
bt_ad_clear_service_data(dev->ad);
- g_slist_foreach(list, add_service_data, dev);
+ queue_foreach(queue, add_service_data, dev);
}
static void add_data(void *data, void *user_data)
@@ -2518,13 +2519,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, struct queue *queue,
bool duplicate)
{
if (duplicate)
bt_ad_clear_data(dev->ad);
- g_slist_foreach(list, add_data, dev);
+ queue_foreach(queue, 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..b36f9af66dd2 100644
--- a/src/device.h
+++ b/src/device.h
@@ -9,6 +9,8 @@
*
*/
+#include "src/shared/queue.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, struct queue *uuids);
+void device_set_manufacturer_data(struct btd_device *dev, struct queue *queue,
bool duplicate);
-void device_set_service_data(struct btd_device *dev, GSList *list,
+void device_set_service_data(struct btd_device *dev, struct queue *queue,
bool duplicate);
-void device_set_data(struct btd_device *dev, GSList *list,
+void device_set_data(struct btd_device *dev, struct queue *queue,
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..89c15995a546 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -47,9 +47,18 @@ static void data_free(void *data)
g_free(ad);
}
+static struct queue *
+queue_append(struct queue *q, void *data)
+{
+ if (!q)
+ q = queue_new();
+ queue_push_tail(q, data);
+ return q;
+}
+
void eir_data_free(struct eir_data *eir)
{
- g_slist_free_full(eir->services, free);
+ queue_destroy(eir->services, g_free);
eir->services = NULL;
g_free(eir->name);
eir->name = NULL;
@@ -57,11 +66,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);
+ queue_destroy(eir->msd_list, g_free);
eir->msd_list = NULL;
- g_slist_free_full(eir->sd_list, sd_free);
+ queue_destroy(eir->sd_list, sd_free);
eir->sd_list = NULL;
- g_slist_free_full(eir->data_list, data_free);
+ queue_destroy(eir->data_list, data_free);
eir->data_list = NULL;
}
@@ -80,7 +89,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 = queue_append(eir->services, uuid_str);
}
}
@@ -99,7 +108,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 = queue_append(eir->services, uuid_str);
}
}
@@ -119,7 +128,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 = queue_append(eir->services, uuid_str);
uuid_ptr += 16;
}
}
@@ -151,7 +160,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 = queue_append(eir->msd_list, msd);
}
static void eir_parse_sd(struct eir_data *eir, uuid_t *service,
@@ -169,7 +178,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 = queue_append(eir->sd_list, sd);
}
static void eir_parse_uuid16_data(struct eir_data *eir, const uint8_t *data,
@@ -226,7 +235,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 = queue_append(eir->data_list, ad);
if (type == EIR_CSIP_RSI)
eir->rsi = true;
@@ -595,24 +604,18 @@ int eir_create_oob(const bdaddr_t *addr, const char *name, uint32_t cod,
return eir_total_len;
}
-static int match_sd_uuid(const void *data, const void *user_data)
+static bool match_sd_uuid(const void *data, const void *user_data)
{
const struct eir_sd *sd = data;
const char *uuid = user_data;
- return strcmp(sd->uuid, uuid);
+ return strcmp(sd->uuid, uuid) == 0;
}
struct eir_sd *eir_get_service_data(struct eir_data *eir, const char *uuid)
{
- GSList *l;
-
if (!eir || !uuid)
return NULL;
- l = g_slist_find_custom(eir->sd_list, uuid, match_sd_uuid);
- if (!l)
- return NULL;
-
- return l->data;
+ return queue_find(eir->sd_list, match_sd_uuid, uuid);
}
diff --git a/src/eir.h b/src/eir.h
index b9f7c3874eb3..7d7125e756ce 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/queue.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;
+ struct queue *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;
+ struct queue *msd_list;
+ struct queue *sd_list;
+ struct queue *data_list;
};
void eir_data_free(struct eir_data *eir);
diff --git a/unit/test-eir.c b/unit/test-eir.c
index 55967e957c82..62164ca993f6 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;
+ const struct queue_entry *q;
ad = bt_ad_new_with_data(test->eir_size, test->eir_data);
g_assert(ad);
@@ -607,8 +607,8 @@ static void test_ad(const struct test_data *test, struct eir_data *eir)
}
}
- for (list = eir->msd_list; list; list = list->next) {
- struct eir_msd *msd = list->data;
+ for (q = queue_get_entries(eir->msd_list); q; q = q->next) {
+ struct eir_msd *msd = q->data;
struct bt_ad_manufacturer_data adm;
adm.manufacturer_id = msd->company;
@@ -618,8 +618,8 @@ static void test_ad(const struct test_data *test, struct eir_data *eir)
g_assert(bt_ad_has_manufacturer_data(ad, &adm));
}
- for (list = eir->sd_list; list; list = list->next) {
- struct eir_sd *sd = list->data;
+ for (q = queue_get_entries(eir->sd_list); q; q = q->next) {
+ struct eir_sd *sd = q->data;
struct bt_ad_service_data ads;
bt_string_to_uuid(&ads.uuid, sd->uuid);
@@ -636,7 +636,7 @@ static void test_parsing(gconstpointer data)
{
const struct test_data *test = data;
struct eir_data eir;
- GSList *list;
+ const struct queue_entry *q;
memset(&eir, 0, sizeof(eir));
@@ -646,8 +646,8 @@ static void test_parsing(gconstpointer data)
tester_debug("Name: %s", eir.name);
tester_debug("TX power: %d", eir.tx_power);
- for (list = eir.services; list; list = list->next) {
- char *uuid_str = list->data;
+ for (q = queue_get_entries(eir.services); q; q = q->next) {
+ char *uuid_str = q->data;
tester_debug("UUID: %s", uuid_str);
}
@@ -664,11 +664,10 @@ 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++) {
- char *uuid_str = list->data;
+ for (q = queue_get_entries(eir.services); q; q = q->next, n++) {
+ char *uuid_str = q->data;
g_assert(test->uuid[n]);
g_assert_cmpstr(test->uuid[n], ==, uuid_str);
}
@@ -676,16 +675,16 @@ static void test_parsing(gconstpointer data)
g_assert(eir.services == NULL);
}
- for (list = eir.msd_list; list; list = list->next) {
- struct eir_msd *msd = list->data;
+ for (q = queue_get_entries(eir.msd_list); q; q = q->next) {
+ struct eir_msd *msd = q->data;
tester_debug("Manufacturer ID: 0x%04x", msd->company);
util_hexdump(' ', msd->data, msd->data_len, print_debug,
"Manufacturer Data:");
}
- for (list = eir.sd_list; list; list = list->next) {
- struct eir_sd *sd = list->data;
+ for (q = queue_get_entries(eir.sd_list); q; q = q->next) {
+ struct eir_sd *sd = q->data;
tester_debug("Service UUID: %s", sd->uuid);
util_hexdump(' ', sd->data, sd->data_len, print_debug,
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH BlueZ v2 2/3] shared/queue: Fix warning when compiling ad.c
2026-04-16 14:08 [PATCH BlueZ v2 0/3] Remove glib dep from non-glib shared library Bastien Nocera
2026-04-16 14:08 ` [PATCH BlueZ v2 1/3] shared: Remove glib dependency from src/shared/ad.c Bastien Nocera
@ 2026-04-16 14:08 ` Bastien Nocera
2026-04-16 14:08 ` [PATCH BlueZ v2 3/3] shared: Remove unneeded glib includes Bastien Nocera
2026-04-16 15:20 ` [PATCH BlueZ v2 0/3] Remove glib dep from non-glib shared library patchwork-bot+bluetooth
3 siblings, 0 replies; 5+ messages in thread
From: Bastien Nocera @ 2026-04-16 14:08 UTC (permalink / raw)
To: linux-bluetooth
Both ad.c and eir.h include queue.h as both use the struct declared in
this header. Quiet the warnings with a stanza that means it will be
ignored second time around.
---
src/shared/queue.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/src/shared/queue.h b/src/shared/queue.h
index 122f4eaa6c2f..f14b83ecfdac 100644
--- a/src/shared/queue.h
+++ b/src/shared/queue.h
@@ -8,6 +8,8 @@
*
*/
+#pragma once
+
#include <stdbool.h>
typedef void (*queue_destroy_func_t)(void *data);
--
2.53.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* [PATCH BlueZ v2 3/3] shared: Remove unneeded glib includes
2026-04-16 14:08 [PATCH BlueZ v2 0/3] Remove glib dep from non-glib shared library Bastien Nocera
2026-04-16 14:08 ` [PATCH BlueZ v2 1/3] shared: Remove glib dependency from src/shared/ad.c Bastien Nocera
2026-04-16 14:08 ` [PATCH BlueZ v2 2/3] shared/queue: Fix warning when compiling ad.c Bastien Nocera
@ 2026-04-16 14:08 ` Bastien Nocera
2026-04-16 15:20 ` [PATCH BlueZ v2 0/3] Remove glib dep from non-glib shared library patchwork-bot+bluetooth
3 siblings, 0 replies; 5+ messages in thread
From: Bastien Nocera @ 2026-04-16 14:08 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] 5+ messages in thread
* Re: [PATCH BlueZ v2 0/3] Remove glib dep from non-glib shared library
2026-04-16 14:08 [PATCH BlueZ v2 0/3] Remove glib dep from non-glib shared library Bastien Nocera
` (2 preceding siblings ...)
2026-04-16 14:08 ` [PATCH BlueZ v2 3/3] shared: Remove unneeded glib includes Bastien Nocera
@ 2026-04-16 15:20 ` patchwork-bot+bluetooth
3 siblings, 0 replies; 5+ messages in thread
From: patchwork-bot+bluetooth @ 2026-04-16 15:20 UTC (permalink / raw)
To: Bastien Nocera; +Cc: linux-bluetooth
Hello:
This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:
On Thu, 16 Apr 2026 16:08:39 +0200 you wrote:
> Changes since v1:
> - remove queue_peek_head_entry() patch, we already had similar API
>
> Bastien Nocera (3):
> shared: Remove glib dependency from src/shared/ad.c
> shared/queue: Fix warning when compiling ad.c
> shared: Remove unneeded glib includes
>
> [...]
Here is the summary with links:
- [BlueZ,v2,1/3] shared: Remove glib dependency from src/shared/ad.c
(no matching commit)
- [BlueZ,v2,2/3] shared/queue: Fix warning when compiling ad.c
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=6a6aaeba6aed
- [BlueZ,v2,3/3] shared: Remove unneeded glib includes
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=07a0b87e6b34
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2026-04-16 15:20 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-16 14:08 [PATCH BlueZ v2 0/3] Remove glib dep from non-glib shared library Bastien Nocera
2026-04-16 14:08 ` [PATCH BlueZ v2 1/3] shared: Remove glib dependency from src/shared/ad.c Bastien Nocera
2026-04-16 14:08 ` [PATCH BlueZ v2 2/3] shared/queue: Fix warning when compiling ad.c Bastien Nocera
2026-04-16 14:08 ` [PATCH BlueZ v2 3/3] shared: Remove unneeded glib includes Bastien Nocera
2026-04-16 15:20 ` [PATCH BlueZ v2 0/3] Remove glib dep from non-glib shared library patchwork-bot+bluetooth
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox