diff mbox series

[BlueZ,v3,2/7] client: Use g_clear_pointer() to clean up menus

Message ID 20241022141118.150143-3-hadess@hadess.net (mailing list archive)
State New
Headers show
Series Fix bluetoothctl --help hanging if daemon isn't running | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch fail ERROR:INITIALISED_STATIC: do not initialise statics to NULL #66: FILE: client/admin.c:194: +static GDBusClient *client = NULL; ERROR:SPACING: need consistent spacing around '*' (ctx:WxV) #66: FILE: client/admin.c:194: +static GDBusClient *client = NULL; ^ ERROR:INITIALISED_STATIC: do not initialise statics to NULL #87: FILE: client/assistant.c:393: +static GDBusClient * client = NULL; ERROR:POINTER_LOCATION: "foo * bar" should be "foo *bar" #87: FILE: client/assistant.c:393: +static GDBusClient * client = NULL; ERROR:INITIALISED_STATIC: do not initialise statics to NULL #109: FILE: client/player.c:5697: +static GDBusClient *client = NULL; /github/workspace/src/src/13845731.patch total: 5 errors, 0 warnings, 46 lines checked NOTE: For some of the reported defects, checkpatch may be able to mechanically convert to the typical style using --fix or --fix-inplace. /github/workspace/src/src/13845731.patch has style problems, please review. NOTE: Ignored message types: COMMIT_MESSAGE COMPLEX_MACRO CONST_STRUCT FILE_PATH_CHANGES MISSING_SIGN_OFF PREFER_PACKED SPDX_LICENSE_TAG SPLIT_STRING SSCANF_TO_KSTRTO NOTE: If any of the errors are false positives, please report them to the maintainer, see CHECKPATCH in MAINTAINERS.
tedd_an/GitLint success Gitlint PASS
tedd_an/IncrementalBuild success Incremental Build PASS

Commit Message

Bastien Nocera Oct. 22, 2024, 2:10 p.m. UTC
This would avoid warnings should the client be NULL.
---
 client/admin.c     | 5 ++---
 client/assistant.c | 5 ++---
 client/player.c    | 4 ++--
 3 files changed, 6 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/client/admin.c b/client/admin.c
index cd9af6f955da..9d48867bc1d7 100644
--- a/client/admin.c
+++ b/client/admin.c
@@ -191,7 +191,7 @@  static void proxy_removed(GDBusProxy *proxy, void *user_data)
 		admin_policy_status_removed(proxy);
 }
 
-static GDBusClient *client;
+static GDBusClient *client = NULL;
 
 static void disconnect_handler(DBusConnection *connection, void *user_data)
 {
@@ -215,6 +215,5 @@  void admin_add_submenu(void)
 
 void admin_remove_submenu(void)
 {
-	g_dbus_client_unref(client);
-	client = NULL;
+	g_clear_pointer(&client, g_dbus_client_unref);
 }
diff --git a/client/assistant.c b/client/assistant.c
index 16e94664a5c3..94052e26fd59 100644
--- a/client/assistant.c
+++ b/client/assistant.c
@@ -390,7 +390,7 @@  static const struct bt_shell_menu assistant_menu = {
 	{} },
 };
 
-static GDBusClient * client;
+static GDBusClient * client = NULL;
 
 void assistant_add_submenu(void)
 {
@@ -409,7 +409,6 @@  void assistant_add_submenu(void)
 
 void assistant_remove_submenu(void)
 {
-	g_dbus_client_unref(client);
-	client = NULL;
+	g_clear_pointer(&client, g_dbus_client_unref);
 }
 
diff --git a/client/player.c b/client/player.c
index 188378175486..dea5922d56db 100644
--- a/client/player.c
+++ b/client/player.c
@@ -5694,7 +5694,7 @@  static const struct bt_shell_menu transport_menu = {
 	{} },
 };
 
-static GDBusClient *client;
+static GDBusClient *client = NULL;
 
 void player_add_submenu(void)
 {
@@ -5715,6 +5715,6 @@  void player_add_submenu(void)
 
 void player_remove_submenu(void)
 {
-	g_dbus_client_unref(client);
+	g_clear_pointer(&client, g_dbus_client_unref);
 	queue_destroy(ios, transport_free);
 }