[PATCH bluez 2/2] obexd/bluetooth: Clean up redundant code

From: Zijun Hu

Date: Wed Oct 28 2026 - 02:47:14 EST


register_profile() already frees profile->path and sets it to NULL when
it fails, so the same cleanup in name_acquired() does nothing, and the
error message always prints a NULL path. Drop the cleanup and print the
profile UUID instead.

Also drop the trailing return in void functions.

Assisted-by: Claude:claude-sonnet-5-5
---
obexd/plugins/bluetooth.c | 13 +++++--------
1 file changed, 5 insertions(+), 8 deletions(-)

diff --git a/obexd/plugins/bluetooth.c b/obexd/plugins/bluetooth.c
index b70090971119..0aeb1becdf32 100644
--- a/obexd/plugins/bluetooth.c
+++ b/obexd/plugins/bluetooth.c
@@ -88,17 +88,16 @@ done:
if (obex_server_new_connection(server, io, omtu, imtu, stream) < 0)
g_io_channel_shutdown(io, TRUE, NULL);

return;

drop:
error("%s", err->message);
g_io_channel_shutdown(io, TRUE, NULL);
- return;
}

static DBusMessage *invalid_args(DBusMessage *msg)
{
return g_dbus_create_error(msg, "org.bluez.Error.InvalidArguments",
"Invalid arguments in method call");
}

@@ -324,22 +323,19 @@ static void name_acquired(DBusConnection *conn, void *user_data)
bluez_available = TRUE;

for (l = profiles; l; l = l->next) {
struct bluetooth_profile *profile = l->data;

if (profile->path != NULL)
continue;

- if (register_profile(profile) < 0) {
- error("bluetooth: Failed to register profile %s",
- profile->path);
- g_free(profile->path);
- profile->path = NULL;
- }
+ if (register_profile(profile) < 0)
+ error("bluetooth: Failed to register profile UUID %s",
+ profile->uuid);
}
}

static void name_released(DBusConnection *conn, void *user_data)
{
GSList *l;

DBG("org.bluez disappeared");
@@ -479,14 +475,15 @@ static void bluetooth_exit_cb(gboolean at_unregister)

obex_transport_driver_unregister(&driver);
}

static int bluetooth_init(void)
{
return logind_register(bluetooth_init_cb, bluetooth_exit_cb);
}
+
static void bluetooth_exit(void)
{
- return logind_unregister(bluetooth_init_cb, bluetooth_exit_cb);
+ logind_unregister(bluetooth_init_cb, bluetooth_exit_cb);
}

OBEX_PLUGIN_DEFINE(bluetooth, bluetooth_init, bluetooth_exit)

--
2.34.1