Subject: [PATCH BlueZ 00/20] Constify all the things

Hello list,

Here is series#2 of the paper cut fixes. Here we annotate a handful of
the data as constant alongside updating all the respective APIs.

There's nothing particularly existing or controversial here, despite the
size of the series. That said, I'm not 100% sure that all code-paths
have been (runtime) tested.

As always - any input will be appreciated.

Thanks
Emil

---
Emil Velikov (20):
src: const annotate the bluetooth plugin API
monitor: const annotate util_ltv_debugger instances and API
monitor: const annotate cmd/handler tables
monitor: const annotate misc arrays
monitor: const annotate intel_version_tlv_desc::type_str and API
monitor: const annotate type_table and related API
profiles: annotate immutable data as const
attrib: annotate immutable data as const
client: annotate struct option instances as const
emulator: const annotate rfcomm_crc_table[]
gobex: const annotate RO arrays, use G_N_ELEMENTS
lib: const annotate hci_map instances and related API
lib: const annotate tupla instances and API
mesh: const annotate misc data
obexd: remove obex_mime_type_driver::set_io_watch
obexd: const obex_mime_type_driver instances and API
obexd: const obex_service_driver instances and API
obexd: const obex_transport_driver instances and API
obexd: const annotate misc immutable data
obexd: const annotate obex_plugin_desc entrypoint

attrib/gatttool.c | 8 +++---
attrib/interactive.c | 2 +-
client/mgmt.c | 42 ++++++++++++++++----------------
emulator/bthost.c | 2 +-
gobex/gobex.c | 8 +++---
lib/hci.c | 42 ++++++++++++++++----------------
lib/hci_lib.h | 4 +--
lib/sdp.c | 20 +++++++--------
mesh/agent.c | 4 +--
monitor/att.c | 54 ++++++++++++++++++++---------------------
monitor/avctp.c | 2 +-
monitor/intel.c | 28 ++++++++++-----------
monitor/l2cap.c | 2 +-
monitor/rfcomm.c | 2 +-
monitor/sdp.c | 10 ++++----
obexd/client/manager.c | 6 ++---
obexd/client/map.c | 4 +--
obexd/client/mns.c | 8 +++---
obexd/plugins/bluetooth.c | 6 ++---
obexd/plugins/filesystem.c | 8 +++---
obexd/plugins/ftp.c | 2 +-
obexd/plugins/irmc.c | 4 +--
obexd/plugins/mas.c | 18 +++++++-------
obexd/plugins/opp.c | 2 +-
obexd/plugins/pbap.c | 8 +++---
obexd/plugins/pcsuite.c | 4 +--
obexd/plugins/phonebook-ebook.c | 2 +-
obexd/plugins/syncevolution.c | 4 +--
obexd/src/genbuiltin | 4 +--
obexd/src/main.c | 2 +-
obexd/src/mimetype.c | 26 +++++++-------------
obexd/src/mimetype.h | 12 +++++----
obexd/src/obex-priv.h | 4 +--
obexd/src/obex.c | 18 +++++++-------
obexd/src/plugin.c | 8 +++---
obexd/src/plugin.h | 4 +--
obexd/src/server.c | 10 ++++----
obexd/src/server.h | 2 +-
obexd/src/service.c | 20 +++++++--------
obexd/src/service.h | 6 ++---
obexd/src/transport.c | 14 +++++------
obexd/src/transport.h | 6 ++---
profiles/audio/avctp.c | 2 +-
profiles/audio/avrcp.c | 8 +++---
profiles/audio/media.c | 6 ++---
profiles/audio/sink.c | 2 +-
profiles/audio/source.c | 2 +-
profiles/audio/transport.c | 12 ++++-----
profiles/health/hdp_util.c | 15 ++++++------
profiles/iap/main.c | 2 +-
src/genbuiltin | 4 +--
src/log.c | 2 +-
src/plugin.c | 6 ++---
src/plugin.h | 6 ++---
54 files changed, 251 insertions(+), 258 deletions(-)
---
base-commit: 770ad5614e7e8074133e6f563495ce4822f63fe4
change-id: 20240116-const-bc91df591e93

Best regards,
--
Emil Velikov <[email protected]>



Subject: [PATCH BlueZ 08/20] attrib: annotate immutable data as const

From: Emil Velikov <[email protected]>

---
attrib/gatttool.c | 8 ++++----
attrib/interactive.c | 2 +-
2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/attrib/gatttool.c b/attrib/gatttool.c
index 2d03875b0..4309d20b1 100644
--- a/attrib/gatttool.c
+++ b/attrib/gatttool.c
@@ -454,7 +454,7 @@ static gboolean parse_uuid(const char *key, const char *value,
return TRUE;
}

-static GOptionEntry primary_char_options[] = {
+static const GOptionEntry primary_char_options[] = {
{ "start", 's' , 0, G_OPTION_ARG_INT, &opt_start,
"Starting handle (optional)", "0x0001" },
{ "end", 'e' , 0, G_OPTION_ARG_INT, &opt_end,
@@ -464,7 +464,7 @@ static GOptionEntry primary_char_options[] = {
{ NULL },
};

-static GOptionEntry char_rw_options[] = {
+static const GOptionEntry char_rw_options[] = {
{ "handle", 'a' , 0, G_OPTION_ARG_INT, &opt_handle,
"Read/Write characteristic by handle (required)", "0x0001" },
{ "value", 'n' , 0, G_OPTION_ARG_STRING, &opt_value,
@@ -473,7 +473,7 @@ static GOptionEntry char_rw_options[] = {
{NULL},
};

-static GOptionEntry gatt_options[] = {
+static const GOptionEntry gatt_options[] = {
{ "primary", 0, 0, G_OPTION_ARG_NONE, &opt_primary,
"Primary Service Discovery", NULL },
{ "characteristics", 0, 0, G_OPTION_ARG_NONE, &opt_characteristics,
@@ -494,7 +494,7 @@ static GOptionEntry gatt_options[] = {
{ NULL },
};

-static GOptionEntry options[] = {
+static const GOptionEntry options[] = {
{ "adapter", 'i', 0, G_OPTION_ARG_STRING, &opt_src,
"Specify local adapter interface", "hciX" },
{ "device", 'b', 0, G_OPTION_ARG_STRING, &opt_dst,
diff --git a/attrib/interactive.c b/attrib/interactive.c
index 171b95738..c0262e87c 100644
--- a/attrib/interactive.c
+++ b/attrib/interactive.c
@@ -760,7 +760,7 @@ static void cmd_mtu(int argcp, char **argvp)
gatt_exchange_mtu(attrib, opt_mtu, exchange_mtu_cb, NULL);
}

-static struct {
+static const struct {
const char *cmd;
void (*func)(int argcp, char **argvp);
const char *params;

--
2.43.0


Subject: [PATCH BlueZ 16/20] obexd: const obex_mime_type_driver instances and API

From: Emil Velikov <[email protected]>

---
obexd/client/mns.c | 2 +-
obexd/plugins/filesystem.c | 8 ++++----
obexd/plugins/irmc.c | 2 +-
obexd/plugins/mas.c | 16 ++++++++--------
obexd/plugins/pbap.c | 6 +++---
obexd/plugins/pcsuite.c | 2 +-
obexd/plugins/syncevolution.c | 2 +-
obexd/src/mimetype.c | 14 +++++++-------
obexd/src/mimetype.h | 6 +++---
obexd/src/obex-priv.h | 2 +-
10 files changed, 30 insertions(+), 30 deletions(-)

diff --git a/obexd/client/mns.c b/obexd/client/mns.c
index e52505642..3b2ae1076 100644
--- a/obexd/client/mns.c
+++ b/obexd/client/mns.c
@@ -356,7 +356,7 @@ static struct obex_service_driver mns = {
.disconnect = mns_disconnect,
};

-static struct obex_mime_type_driver mime_event_report = {
+static const struct obex_mime_type_driver mime_event_report = {
.target = MNS_TARGET,
.target_size = TARGET_SIZE,
.mimetype = "x-bt/MAP-event-report",
diff --git a/obexd/plugins/filesystem.c b/obexd/plugins/filesystem.c
index 09bff8ad0..f52927541 100644
--- a/obexd/plugins/filesystem.c
+++ b/obexd/plugins/filesystem.c
@@ -642,7 +642,7 @@ done:
return err;
}

-static struct obex_mime_type_driver file = {
+static const struct obex_mime_type_driver file = {
.open = filesystem_open,
.close = filesystem_close,
.read = filesystem_read,
@@ -652,7 +652,7 @@ static struct obex_mime_type_driver file = {
.copy = filesystem_copy,
};

-static struct obex_mime_type_driver capability = {
+static const struct obex_mime_type_driver capability = {
.target = FTP_TARGET,
.target_size = FTP_TARGET_SIZE,
.mimetype = "x-obex/capability",
@@ -661,7 +661,7 @@ static struct obex_mime_type_driver capability = {
.read = capability_read,
};

-static struct obex_mime_type_driver folder = {
+static const struct obex_mime_type_driver folder = {
.target = FTP_TARGET,
.target_size = FTP_TARGET_SIZE,
.mimetype = "x-obex/folder-listing",
@@ -670,7 +670,7 @@ static struct obex_mime_type_driver folder = {
.read = folder_read,
};

-static struct obex_mime_type_driver pcsuite = {
+static const struct obex_mime_type_driver pcsuite = {
.target = FTP_TARGET,
.target_size = FTP_TARGET_SIZE,
.who = PCSUITE_WHO,
diff --git a/obexd/plugins/irmc.c b/obexd/plugins/irmc.c
index cd143e7a3..e85cf70a1 100644
--- a/obexd/plugins/irmc.c
+++ b/obexd/plugins/irmc.c
@@ -419,7 +419,7 @@ static ssize_t irmc_read(void *object, void *buf, size_t count)
return len;
}

-static struct obex_mime_type_driver irmc_driver = {
+static const struct obex_mime_type_driver irmc_driver = {
.target = IRMC_TARGET,
.target_size = IRMC_TARGET_SIZE,
.open = irmc_open,
diff --git a/obexd/plugins/mas.c b/obexd/plugins/mas.c
index 5d00bc563..f0eaf6d82 100644
--- a/obexd/plugins/mas.c
+++ b/obexd/plugins/mas.c
@@ -793,7 +793,7 @@ static struct obex_service_driver mas = {
.disconnect = mas_disconnect,
};

-static struct obex_mime_type_driver mime_map = {
+static const struct obex_mime_type_driver mime_map = {
.target = MAS_TARGET,
.target_size = TARGET_SIZE,
.mimetype = NULL,
@@ -803,7 +803,7 @@ static struct obex_mime_type_driver mime_map = {
.write = any_write,
};

-static struct obex_mime_type_driver mime_message = {
+static const struct obex_mime_type_driver mime_message = {
.target = MAS_TARGET,
.target_size = TARGET_SIZE,
.mimetype = "x-bt/message",
@@ -813,7 +813,7 @@ static struct obex_mime_type_driver mime_message = {
.write = any_write,
};

-static struct obex_mime_type_driver mime_folder_listing = {
+static const struct obex_mime_type_driver mime_folder_listing = {
.target = MAS_TARGET,
.target_size = TARGET_SIZE,
.mimetype = "x-obex/folder-listing",
@@ -824,7 +824,7 @@ static struct obex_mime_type_driver mime_folder_listing = {
.write = any_write,
};

-static struct obex_mime_type_driver mime_msg_listing = {
+static const struct obex_mime_type_driver mime_msg_listing = {
.target = MAS_TARGET,
.target_size = TARGET_SIZE,
.mimetype = "x-bt/MAP-msg-listing",
@@ -835,7 +835,7 @@ static struct obex_mime_type_driver mime_msg_listing = {
.write = any_write,
};

-static struct obex_mime_type_driver mime_notification_registration = {
+static const struct obex_mime_type_driver mime_notification_registration = {
.target = MAS_TARGET,
.target_size = TARGET_SIZE,
.mimetype = "x-bt/MAP-NotificationRegistration",
@@ -845,7 +845,7 @@ static struct obex_mime_type_driver mime_notification_registration = {
.write = any_write,
};

-static struct obex_mime_type_driver mime_message_status = {
+static const struct obex_mime_type_driver mime_message_status = {
.target = MAS_TARGET,
.target_size = TARGET_SIZE,
.mimetype = "x-bt/messageStatus",
@@ -855,7 +855,7 @@ static struct obex_mime_type_driver mime_message_status = {
.write = any_write,
};

-static struct obex_mime_type_driver mime_message_update = {
+static const struct obex_mime_type_driver mime_message_update = {
.target = MAS_TARGET,
.target_size = TARGET_SIZE,
.mimetype = "x-bt/MAP-messageUpdate",
@@ -865,7 +865,7 @@ static struct obex_mime_type_driver mime_message_update = {
.write = any_write,
};

-static struct obex_mime_type_driver *map_drivers[] = {
+static const struct obex_mime_type_driver *map_drivers[] = {
&mime_map,
&mime_message,
&mime_folder_listing,
diff --git a/obexd/plugins/pbap.c b/obexd/plugins/pbap.c
index ab5236316..b363c673b 100644
--- a/obexd/plugins/pbap.c
+++ b/obexd/plugins/pbap.c
@@ -929,7 +929,7 @@ static ssize_t vobject_vcard_read(void *object, void *buf, size_t count)
return string_read(obj->buffer, buf, count);
}

-static struct obex_mime_type_driver mime_pull = {
+static const struct obex_mime_type_driver mime_pull = {
.target = PBAP_TARGET,
.target_size = TARGET_SIZE,
.mimetype = "x-bt/phonebook",
@@ -939,7 +939,7 @@ static struct obex_mime_type_driver mime_pull = {
.get_next_header = vobject_pull_get_next_header,
};

-static struct obex_mime_type_driver mime_list = {
+static const struct obex_mime_type_driver mime_list = {
.target = PBAP_TARGET,
.target_size = TARGET_SIZE,
.mimetype = "x-bt/vcard-listing",
@@ -949,7 +949,7 @@ static struct obex_mime_type_driver mime_list = {
.get_next_header = vobject_list_get_next_header,
};

-static struct obex_mime_type_driver mime_vcard = {
+static const struct obex_mime_type_driver mime_vcard = {
.target = PBAP_TARGET,
.target_size = TARGET_SIZE,
.mimetype = "x-bt/vcard",
diff --git a/obexd/plugins/pcsuite.c b/obexd/plugins/pcsuite.c
index f5a9d9ae8..d4a0394af 100644
--- a/obexd/plugins/pcsuite.c
+++ b/obexd/plugins/pcsuite.c
@@ -467,7 +467,7 @@ static int backup_flush(void *object)
return 0;
}

-static struct obex_mime_type_driver backup = {
+static const struct obex_mime_type_driver backup = {
.target = FTP_TARGET,
.target_size = TARGET_SIZE,
.mimetype = "application/vnd.nokia-backup",
diff --git a/obexd/plugins/syncevolution.c b/obexd/plugins/syncevolution.c
index 88744f28a..f0387b986 100644
--- a/obexd/plugins/syncevolution.c
+++ b/obexd/plugins/syncevolution.c
@@ -427,7 +427,7 @@ static ssize_t synce_write(void *object, const void *buf, size_t count)
return -EAGAIN;
}

-static struct obex_mime_type_driver synce_driver = {
+static const struct obex_mime_type_driver synce_driver = {
.target = SYNCML_TARGET,
.target_size = SYNCML_TARGET_SIZE,
.open = synce_open,
diff --git a/obexd/src/mimetype.c b/obexd/src/mimetype.c
index cf6e15dc6..462d4ba2f 100644
--- a/obexd/src/mimetype.c
+++ b/obexd/src/mimetype.c
@@ -104,7 +104,7 @@ int obex_object_set_io_watch(void *object, obex_object_io_func func,
return 0;
}

-static struct obex_mime_type_driver *find_driver(const uint8_t *target,
+static const struct obex_mime_type_driver *find_driver(const uint8_t *target,
unsigned int target_size,
const char *mimetype, const uint8_t *who,
unsigned int who_size)
@@ -112,7 +112,7 @@ static struct obex_mime_type_driver *find_driver(const uint8_t *target,
GSList *l;

for (l = drivers; l; l = l->next) {
- struct obex_mime_type_driver *driver = l->data;
+ const struct obex_mime_type_driver *driver = l->data;

if (memncmp0(target, target_size, driver->target, driver->target_size))
continue;
@@ -134,12 +134,12 @@ static struct obex_mime_type_driver *find_driver(const uint8_t *target,
return NULL;
}

-struct obex_mime_type_driver *obex_mime_type_driver_find(const uint8_t *target,
+const struct obex_mime_type_driver *obex_mime_type_driver_find(const uint8_t *target,
unsigned int target_size,
const char *mimetype, const uint8_t *who,
unsigned int who_size)
{
- struct obex_mime_type_driver *driver;
+ const struct obex_mime_type_driver *driver;

driver = find_driver(target, target_size, mimetype, who, who_size);
if (driver == NULL) {
@@ -162,7 +162,7 @@ struct obex_mime_type_driver *obex_mime_type_driver_find(const uint8_t *target,
return driver;
}

-int obex_mime_type_driver_register(struct obex_mime_type_driver *driver)
+int obex_mime_type_driver_register(const struct obex_mime_type_driver *driver)
{
if (!driver) {
error("Invalid driver");
@@ -178,12 +178,12 @@ int obex_mime_type_driver_register(struct obex_mime_type_driver *driver)

DBG("driver %p mimetype %s registered", driver, driver->mimetype);

- drivers = g_slist_append(drivers, driver);
+ drivers = g_slist_append(drivers, (gpointer)driver);

return 0;
}

-void obex_mime_type_driver_unregister(struct obex_mime_type_driver *driver)
+void obex_mime_type_driver_unregister(const struct obex_mime_type_driver *driver)
{
if (!g_slist_find(drivers, driver)) {
error("Unable to unregister: No such driver %p", driver);
diff --git a/obexd/src/mimetype.h b/obexd/src/mimetype.h
index 55ddded08..35346bb46 100644
--- a/obexd/src/mimetype.h
+++ b/obexd/src/mimetype.h
@@ -30,9 +30,9 @@ struct obex_mime_type_driver {
int (*remove) (const char *name);
};

-int obex_mime_type_driver_register(struct obex_mime_type_driver *driver);
-void obex_mime_type_driver_unregister(struct obex_mime_type_driver *driver);
-struct obex_mime_type_driver *obex_mime_type_driver_find(const uint8_t *target,
+int obex_mime_type_driver_register(const struct obex_mime_type_driver *driver);
+void obex_mime_type_driver_unregister(const struct obex_mime_type_driver *driver);
+const struct obex_mime_type_driver *obex_mime_type_driver_find(const uint8_t *target,
unsigned int target_size,
const char *mimetype, const uint8_t *who,
unsigned int who_size);
diff --git a/obexd/src/obex-priv.h b/obexd/src/obex-priv.h
index db409e7e4..994144678 100644
--- a/obexd/src/obex-priv.h
+++ b/obexd/src/obex-priv.h
@@ -38,7 +38,7 @@ struct obex_session {
struct obex_server *server;
gboolean checked;
GObex *obex;
- struct obex_mime_type_driver *driver;
+ const struct obex_mime_type_driver *driver;
gboolean headers_sent;
};


--
2.43.0


Subject: [PATCH BlueZ 05/20] monitor: const annotate intel_version_tlv_desc::type_str and API

From: Emil Velikov <[email protected]>

---
monitor/intel.c | 26 +++++++++++++-------------
1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/monitor/intel.c b/monitor/intel.c
index 1b2414290..0de864d8a 100644
--- a/monitor/intel.c
+++ b/monitor/intel.c
@@ -171,25 +171,25 @@ struct intel_version_tlv {
};

static void print_version_tlv_u32(const struct intel_version_tlv *tlv,
- char *type_str)
+ const char *type_str)
{
print_field("%s(%u): 0x%8.8x", type_str, tlv->type, get_le32(tlv->val));
}

static void print_version_tlv_u16(const struct intel_version_tlv *tlv,
- char *type_str)
+ const char *type_str)
{
print_field("%s(%u): 0x%4.4x", type_str, tlv->type, get_le16(tlv->val));
}

static void print_version_tlv_u8(const struct intel_version_tlv *tlv,
- char *type_str)
+ const char *type_str)
{
print_field("%s(%u): 0x%2.2x", type_str, tlv->type, get_u8(tlv->val));
}

static void print_version_tlv_enabled(const struct intel_version_tlv *tlv,
- char *type_str)
+ const char *type_str)
{
print_field("%s(%u): %s(%u)", type_str, tlv->type,
tlv->val[0] ? "Enabled" : "Disabled",
@@ -197,7 +197,7 @@ static void print_version_tlv_enabled(const struct intel_version_tlv *tlv,
}

static void print_version_tlv_img_type(const struct intel_version_tlv *tlv,
- char *type_str)
+ const char *type_str)
{
const char *str;

@@ -217,34 +217,34 @@ static void print_version_tlv_img_type(const struct intel_version_tlv *tlv,
}

static void print_version_tlv_timestamp(const struct intel_version_tlv *tlv,
- char *type_str)
+ const char *type_str)
{
print_field("%s(%u): %u-%u", type_str, tlv->type,
tlv->val[1], tlv->val[0]);
}

static void print_version_tlv_min_fw(const struct intel_version_tlv *tlv,
- char *type_str)
+ const char *type_str)
{
print_field("%s(%u): %u-%u.%u", type_str, tlv->type,
tlv->val[0], tlv->val[1], 2000 + tlv->val[2]);
}

static void print_version_tlv_otp_bdaddr(const struct intel_version_tlv *tlv,
- char *type_str)
+ const char *type_str)
{
packet_print_addr(type_str, tlv->val, 0x00);
}

static void print_version_tlv_unknown(const struct intel_version_tlv *tlv,
- char *type_str)
+ const char *type_str)
{
print_field("%s(%u): ", type_str, tlv->type);
packet_hexdump(tlv->val, tlv->len);
}

static void print_version_tlv_mfg(const struct intel_version_tlv *tlv,
- char *type_str)
+ const char *type_str)
{
uint16_t mfg_id = get_le16(tlv->val);

@@ -254,8 +254,8 @@ static void print_version_tlv_mfg(const struct intel_version_tlv *tlv,

static const struct intel_version_tlv_desc {
uint8_t type;
- char *type_str;
- void (*func)(const struct intel_version_tlv *tlv, char *type_str);
+ const char *type_str;
+ void (*func)(const struct intel_version_tlv *tlv, const char *type_str);
} intel_version_tlv_table[] = {
{ 16, "CNVi TOP", print_version_tlv_u32 },
{ 17, "CNVr TOP", print_version_tlv_u32 },
@@ -365,7 +365,7 @@ static void read_version_rsp(uint16_t index, const void *data, uint8_t size)

static void read_version_cmd(uint16_t index, const void *data, uint8_t size)
{
- char *str;
+ const char *str;
uint8_t type;

/* This is the legacy read version command format and no further action

--
2.43.0


Subject: [PATCH BlueZ 14/20] mesh: const annotate misc data

From: Emil Velikov <[email protected]>

---
mesh/agent.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/mesh/agent.c b/mesh/agent.c
index 5058d0d8d..2f9697a33 100644
--- a/mesh/agent.c
+++ b/mesh/agent.c
@@ -61,7 +61,7 @@ struct oob_info {
uint16_t mask;
};

-static struct prov_action cap_table[] = {
+static const struct prov_action cap_table[] = {
{"blink", 0x0001, 0x0000, 1},
{"beep", 0x0002, 0x0000, 1},
{"vibrate", 0x0004, 0x0000, 1},
@@ -73,7 +73,7 @@ static struct prov_action cap_table[] = {
{"in-alpha", 0x0000, 0x0008, 8}
};

-static struct oob_info oob_table[] = {
+static const struct oob_info oob_table[] = {
{"other", 0x0001},
{"uri", 0x0002},
{"machine-code-2d", 0x0004},

--
2.43.0


Subject: [PATCH BlueZ 18/20] obexd: const obex_transport_driver instances and API

From: Emil Velikov <[email protected]>

---
obexd/plugins/bluetooth.c | 2 +-
obexd/src/obex.c | 4 ++--
obexd/src/server.c | 8 ++++----
obexd/src/server.h | 2 +-
obexd/src/transport.c | 14 +++++++-------
obexd/src/transport.h | 6 +++---
6 files changed, 18 insertions(+), 18 deletions(-)

diff --git a/obexd/plugins/bluetooth.c b/obexd/plugins/bluetooth.c
index bcf6e1998..51afdc9d0 100644
--- a/obexd/plugins/bluetooth.c
+++ b/obexd/plugins/bluetooth.c
@@ -416,7 +416,7 @@ static int bluetooth_getsockname(GIOChannel *io, char **name)
return 0;
}

-static struct obex_transport_driver driver = {
+static const struct obex_transport_driver driver = {
.name = "bluetooth",
.start = bluetooth_start,
.getpeername = bluetooth_getpeername,
diff --git a/obexd/src/obex.c b/obexd/src/obex.c
index 4bf5ad124..526861f40 100644
--- a/obexd/src/obex.c
+++ b/obexd/src/obex.c
@@ -1085,7 +1085,7 @@ ssize_t obex_get_non_header_data(struct obex_session *os,

int obex_getpeername(struct obex_session *os, char **name)
{
- struct obex_transport_driver *transport = os->server->transport;
+ const struct obex_transport_driver *transport = os->server->transport;

if (transport == NULL || transport->getpeername == NULL)
return -ENOTSUP;
@@ -1095,7 +1095,7 @@ int obex_getpeername(struct obex_session *os, char **name)

int obex_getsockname(struct obex_session *os, char **name)
{
- struct obex_transport_driver *transport = os->server->transport;
+ const struct obex_transport_driver *transport = os->server->transport;

if (transport == NULL || transport->getsockname == NULL)
return -ENOTSUP;
diff --git a/obexd/src/server.c b/obexd/src/server.c
index eef149272..0dca728d2 100644
--- a/obexd/src/server.c
+++ b/obexd/src/server.c
@@ -34,12 +34,12 @@

static GSList *servers = NULL;

-static void init_server(uint16_t service, GSList *transports)
+static void init_server(uint16_t service, const GSList *transports)
{
- GSList *l;
+ const GSList *l;

for (l = transports; l; l = l->next) {
- struct obex_transport_driver *transport = l->data;
+ const struct obex_transport_driver *transport = l->data;
struct obex_server *server;
int err;

@@ -66,7 +66,7 @@ static void init_server(uint16_t service, GSList *transports)
int obex_server_init(void)
{
GSList *drivers;
- GSList *transports;
+ const GSList *transports;
GSList *l;

drivers = obex_service_driver_list(0);
diff --git a/obexd/src/server.h b/obexd/src/server.h
index c31236ec0..ec063ae2e 100644
--- a/obexd/src/server.h
+++ b/obexd/src/server.h
@@ -10,7 +10,7 @@
*/

struct obex_server {
- struct obex_transport_driver *transport;
+ const struct obex_transport_driver *transport;
void *transport_data;
GSList *drivers;
};
diff --git a/obexd/src/transport.c b/obexd/src/transport.c
index 4b5895e5d..234a0e004 100644
--- a/obexd/src/transport.c
+++ b/obexd/src/transport.c
@@ -27,13 +27,13 @@

static GSList *drivers = NULL;

-static struct obex_transport_driver *obex_transport_driver_find(
+static const struct obex_transport_driver *obex_transport_driver_find(
const char *name)
{
- GSList *l;
+ const GSList *l;

for (l = drivers; l; l = l->next) {
- struct obex_transport_driver *driver = l->data;
+ const struct obex_transport_driver *driver = l->data;

if (g_strcmp0(name, driver->name) == 0)
return driver;
@@ -42,12 +42,12 @@ static struct obex_transport_driver *obex_transport_driver_find(
return NULL;
}

-GSList *obex_transport_driver_list(void)
+const GSList *obex_transport_driver_list(void)
{
return drivers;
}

-int obex_transport_driver_register(struct obex_transport_driver *driver)
+int obex_transport_driver_register(const struct obex_transport_driver *driver)
{
if (!driver) {
error("Invalid driver");
@@ -62,12 +62,12 @@ int obex_transport_driver_register(struct obex_transport_driver *driver)

DBG("driver %p transport %s registered", driver, driver->name);

- drivers = g_slist_prepend(drivers, driver);
+ drivers = g_slist_prepend(drivers, (gpointer)driver);

return 0;
}

-void obex_transport_driver_unregister(struct obex_transport_driver *driver)
+void obex_transport_driver_unregister(const struct obex_transport_driver *driver)
{
if (!g_slist_find(drivers, driver)) {
error("Unable to unregister: No such driver %p", driver);
diff --git a/obexd/src/transport.h b/obexd/src/transport.h
index 3a16b7620..fe79432cf 100644
--- a/obexd/src/transport.h
+++ b/obexd/src/transport.h
@@ -17,6 +17,6 @@ struct obex_transport_driver {
void (*stop) (void *data);
};

-int obex_transport_driver_register(struct obex_transport_driver *driver);
-void obex_transport_driver_unregister(struct obex_transport_driver *driver);
-GSList *obex_transport_driver_list(void);
+int obex_transport_driver_register(const struct obex_transport_driver *driver);
+void obex_transport_driver_unregister(const struct obex_transport_driver *driver);
+const GSList *obex_transport_driver_list(void);

--
2.43.0


2024-01-22 23:53:27

by patchwork-bot+bluetooth

[permalink] [raw]
Subject: Re: [PATCH BlueZ 00/20] Constify all the things

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <[email protected]>:

On Tue, 16 Jan 2024 14:00:25 +0000 you wrote:
> Hello list,
>
> Here is series#2 of the paper cut fixes. Here we annotate a handful of
> the data as constant alongside updating all the respective APIs.
>
> There's nothing particularly existing or controversial here, despite the
> size of the series. That said, I'm not 100% sure that all code-paths
> have been (runtime) tested.
>
> [...]

Here is the summary with links:
- [BlueZ,01/20] src: const annotate the bluetooth plugin API
(no matching commit)
- [BlueZ,02/20] monitor: const annotate util_ltv_debugger instances and API
(no matching commit)
- [BlueZ,03/20] monitor: const annotate cmd/handler tables
(no matching commit)
- [BlueZ,04/20] monitor: const annotate misc arrays
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=4630f3fba0fc
- [BlueZ,05/20] monitor: const annotate intel_version_tlv_desc::type_str and API
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=5380e63a80f2
- [BlueZ,06/20] monitor: const annotate type_table and related API
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f8e0270a7a73
- [BlueZ,07/20] profiles: annotate immutable data as const
(no matching commit)
- [BlueZ,08/20] attrib: annotate immutable data as const
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=a8543fd2b062
- [BlueZ,09/20] client: annotate struct option instances as const
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=20864af937f3
- [BlueZ,10/20] emulator: const annotate rfcomm_crc_table[]
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=4d88fd2fabd6
- [BlueZ,11/20] gobex: const annotate RO arrays, use G_N_ELEMENTS
(no matching commit)
- [BlueZ,12/20] lib: const annotate hci_map instances and related API
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=af552cd906a0
- [BlueZ,13/20] lib: const annotate tupla instances and API
(no matching commit)
- [BlueZ,14/20] mesh: const annotate misc data
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=a9393b2e9eec
- [BlueZ,15/20] obexd: remove obex_mime_type_driver::set_io_watch
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=8e88f8cecaa8
- [BlueZ,16/20] obexd: const obex_mime_type_driver instances and API
(no matching commit)
- [BlueZ,17/20] obexd: const obex_service_driver instances and API
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=ae8f9c956069
- [BlueZ,18/20] obexd: const obex_transport_driver instances and API
(no matching commit)
- [BlueZ,19/20] obexd: const annotate misc immutable data
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=ac1d2369b29a
- [BlueZ,20/20] obexd: const annotate obex_plugin_desc entrypoint
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=e0c64a2031e2

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html