diff mbox series

[BlueZ,v3] tools/obexctl: Add support for system/session bus

Message ID 20241115064304.503655-1-quic_dgangire@quicinc.com (mailing list archive)
State Superseded
Headers show
Series [BlueZ,v3] tools/obexctl: Add support for system/session bus | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake fail BluezMake FAIL: tools/obexctl.c: In function ‘check_obexd_service’: tools/obexctl.c:2160:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 2160 | bool has_owner = dbus_bus_name_has_owner(conn, OBEXD_SERVICE, &err); | ^~~~ tools/obexctl.c: In function ‘main’: tools/obexctl.c:2179:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 2179 | bool session_bus_active = false; | ^~~~ tools/obexctl.c:2205:2: error: ‘client’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 2205 | g_dbus_client_unref(client); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:7875: tools/obexctl.o] Error 1 make[1]: *** Waiting for unfinished jobs.... tools/mgmt-tester.c: In function ‘main’: tools/mgmt-tester.c:12725:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without 12725 | int main(int argc, char *argv[]) | ^~~~ make: *** [Makefile:4693: all] Error 2
tedd_an/MakeCheck fail BlueZ Make Check FAIL:
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind fail Check Valgrind FAIL: tools/obexctl.c: In function ‘check_obexd_service’: tools/obexctl.c:2160:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 2160 | bool has_owner = dbus_bus_name_has_owner(conn, OBEXD_SERVICE, &err); | ^~~~ tools/obexctl.c: In function ‘main’: tools/obexctl.c:2179:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 2179 | bool session_bus_active = false; | ^~~~ tools/obexctl.c:2205:2: error: ‘client’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 2205 | g_dbus_client_unref(client); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:7875: tools/obexctl.o] Error 1 make[1]: *** Waiting for unfinished jobs.... tools/mgmt-tester.c: In function ‘main’: tools/mgmt-tester.c:12725:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without 12725 | int main(int argc, char *argv[]) | ^~~~ make: *** [Makefile:12358: check] Error 2
tedd_an/CheckSmatch fail CheckSparse: FAIL: src/shared/crypto.c:271:21: warning: Variable length array is used. src/shared/crypto.c:272:23: warning: Variable length array is used. src/shared/gatt-helpers.c:768:31: warning: Variable length array is used. src/shared/gatt-helpers.c:830:31: warning: Variable length array is used. src/shared/gatt-helpers.c:1323:31: warning: Variable length array is used. src/shared/gatt-helpers.c:1354:23: warning: Variable length array is used. src/shared/gatt-server.c:278:25: warning: Variable length array is used. src/shared/gatt-server.c:618:25: warning: Variable length array is used. src/shared/gatt-server.c:716:25: warning: Variable length array is used. src/shared/bap.c:296:25: warning: array of flexible structures src/shared/bap.c: note: in included file: ./src/shared/ascs.h:88:25: warning: array of flexible structures src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h): /usr/include/readline/rltypedefs.h:35:23: warning: non-ANSI function declaration of function 'Function' /usr/include/readline/rltypedefs.h:36:25: warning: non-ANSI function declaration of function 'VFunction' /usr/include/readline/rltypedefs.h:37:27: warning: non-ANSI function declaration of function 'CPFunction' /usr/include/readline/rltypedefs.h:38:29: warning: non-ANSI function declaration of function 'CPPFunction' src/shared/crypto.c:271:21: warning: Variable length array is used. src/shared/crypto.c:272:23: warning: Variable length array is used. src/shared/gatt-helpers.c:768:31: warning: Variable length array is used. src/shared/gatt-helpers.c:830:31: warning: Variable length array is used. src/shared/gatt-helpers.c:1323:31: warning: Variable length array is used. src/shared/gatt-helpers.c:1354:23: warning: Variable length array is used. src/shared/gatt-server.c:278:25: warning: Variable length array is used. src/shared/gatt-server.c:618:25: warning: Variable length array is used. src/shared/gatt-server.c:716:25: warning: Variable length array is used. src/shared/bap.c:296:25: warning: array of flexible structures src/shared/bap.c: note: in included file: ./src/shared/ascs.h:88:25: warning: array of flexible structures src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h): /usr/include/readline/rltypedefs.h:35:23: warning: non-ANSI function declaration of function 'Function' /usr/include/readline/rltypedefs.h:36:25: warning: non-ANSI function declaration of function 'VFunction' /usr/include/readline/rltypedefs.h:37:27: warning: non-ANSI function declaration of function 'CPFunction' /usr/include/readline/rltypedefs.h:38:29: warning: non-ANSI function declaration of function 'CPPFunction' tools/mesh-cfgtest.c:1453:17: warning: unknown escape sequence: '\%' tools/sco-tester.c: note: in included file: ./lib/bluetooth.h:219:15: warning: array of flexible structures ./lib/bluetooth.h:224:31: warning: array of flexible structures tools/bneptest.c:634:39: warning: unknown escape sequence: '\%' tools/seq2bseq.c:57:26: warning: Variable length array is used. tools/obex-client-tool.c: note: in included file (through /usr/include/readline/readline.h): /usr/include/readline/rltypedefs.h:35:23: warning: non-ANSI function declaration of function 'Function' /usr/include/readline/rltypedefs.h:36:25: warning: non-ANSI function declaration of function 'VFunction' /usr/include/readline/rltypedefs.h:37:27: warning: non-ANSI function declaration of function 'CPFunction' /usr/include/readline/rltypedefs.h:38:29: warning: non-ANSI function declaration of function 'CPPFunction' tools/obexctl.c:2160:9: warning: mixing declarations and code tools/obexctl.c:2179:9: warning: mixing declarations and code tools/obexctl.c: In function ‘check_obexd_service’: tools/obexctl.c:2160:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 2160 | bool has_owner = dbus_bus_name_has_owner(conn, OBEXD_SERVICE, &err); | ^~~~ tools/obexctl.c: In function ‘main’: tools/obexctl.c:2179:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 2179 | bool session_bus_active = false; | ^~~~ tools/obexctl.c:2205:2: error: ‘client’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 2205 | g_dbus_client_unref(client); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:7875: tools/obexctl.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:4693: all] Error 2
tedd_an/bluezmakeextell fail Make External ELL FAIL: tools/obexctl.c: In function ‘check_obexd_service’: tools/obexctl.c:2160:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 2160 | bool has_owner = dbus_bus_name_has_owner(conn, OBEXD_SERVICE, &err); | ^~~~ tools/obexctl.c: In function ‘main’: tools/obexctl.c:2179:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 2179 | bool session_bus_active = false; | ^~~~ tools/obexctl.c:2205:2: error: ‘client’ may be used uninitialized in this function [-Werror=maybe-uninitialized] 2205 | g_dbus_client_unref(client); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:7875: tools/obexctl.o] Error 1 make[1]: *** Waiting for unfinished jobs.... make: *** [Makefile:4693: all] Error 2
tedd_an/ScanBuild success Scan Build PASS

Commit Message

Damodar Reddy GangiReddy Nov. 15, 2024, 6:43 a.m. UTC
From: Damodar Reddy GangiReddy <quic_dgangire@quicinc.com>

Currently obexctl only uses session bus.
As obexd has been enabled support for both session and system bus.
Configuring obexctl to use session/system bus during the runtime
if the name is available over session or system bus.

---
 tools/obexctl.c | 45 ++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 40 insertions(+), 5 deletions(-)

Comments

bluez.test.bot@gmail.com Nov. 15, 2024, 7:12 a.m. UTC | #1
This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=909857

---Test result---

Test Summary:
CheckPatch                    PENDING   0.20 seconds
GitLint                       PENDING   0.20 seconds
BuildEll                      PASS      20.44 seconds
BluezMake                     FAIL      49.01 seconds
MakeCheck                     FAIL      164.40 seconds
MakeDistcheck                 PASS      159.04 seconds
CheckValgrind                 FAIL      41.81 seconds
CheckSmatch                   FAIL      93.81 seconds
bluezmakeextell               FAIL      24.51 seconds
IncrementalBuild              PENDING   0.27 seconds
ScanBuild                     PASS      842.87 seconds

Details
##############################
Test: CheckPatch - PENDING
Desc: Run checkpatch.pl script
Output:

##############################
Test: GitLint - PENDING
Desc: Run gitlint
Output:

##############################
Test: BluezMake - FAIL
Desc: Build BlueZ
Output:

tools/obexctl.c: In function ‘check_obexd_service’:
tools/obexctl.c:2160:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
 2160 |  bool has_owner = dbus_bus_name_has_owner(conn, OBEXD_SERVICE, &err);
      |  ^~~~
tools/obexctl.c: In function ‘main’:
tools/obexctl.c:2179:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
 2179 |  bool session_bus_active = false;
      |  ^~~~
tools/obexctl.c:2205:2: error: ‘client’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 2205 |  g_dbus_client_unref(client);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:7875: tools/obexctl.o] Error 1
make[1]: *** Waiting for unfinished jobs....
tools/mgmt-tester.c: In function ‘main’:
tools/mgmt-tester.c:12725:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
12725 | int main(int argc, char *argv[])
      |     ^~~~
make: *** [Makefile:4693: all] Error 2
##############################
Test: MakeCheck - FAIL
Desc: Run Bluez Make Check
Output:

tools/obexctl.c: In function ‘check_obexd_service’:
tools/obexctl.c:2160:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
 2160 |  bool has_owner = dbus_bus_name_has_owner(conn, OBEXD_SERVICE, &err);
      |  ^~~~
tools/obexctl.c: In function ‘main’:
tools/obexctl.c:2179:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
 2179 |  bool session_bus_active = false;
      |  ^~~~
tools/obexctl.c:2205:2: error: ‘client’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 2205 |  g_dbus_client_unref(client);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:7875: tools/obexctl.o] Error 1
make: *** [Makefile:12358: check] Error 2
##############################
Test: CheckValgrind - FAIL
Desc: Run Bluez Make Check with Valgrind
Output:

tools/obexctl.c: In function ‘check_obexd_service’:
tools/obexctl.c:2160:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
 2160 |  bool has_owner = dbus_bus_name_has_owner(conn, OBEXD_SERVICE, &err);
      |  ^~~~
tools/obexctl.c: In function ‘main’:
tools/obexctl.c:2179:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
 2179 |  bool session_bus_active = false;
      |  ^~~~
tools/obexctl.c:2205:2: error: ‘client’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 2205 |  g_dbus_client_unref(client);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:7875: tools/obexctl.o] Error 1
make[1]: *** Waiting for unfinished jobs....
tools/mgmt-tester.c: In function ‘main’:
tools/mgmt-tester.c:12725:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
12725 | int main(int argc, char *argv[])
      |     ^~~~
make: *** [Makefile:12358: check] Error 2
##############################
Test: CheckSmatch - FAIL
Desc: Run smatch tool with source
Output:

src/shared/crypto.c:271:21: warning: Variable length array is used.
src/shared/crypto.c:272:23: warning: Variable length array is used.
src/shared/gatt-helpers.c:768:31: warning: Variable length array is used.
src/shared/gatt-helpers.c:830:31: warning: Variable length array is used.
src/shared/gatt-helpers.c:1323:31: warning: Variable length array is used.
src/shared/gatt-helpers.c:1354:23: warning: Variable length array is used.
src/shared/gatt-server.c:278:25: warning: Variable length array is used.
src/shared/gatt-server.c:618:25: warning: Variable length array is used.
src/shared/gatt-server.c:716:25: warning: Variable length array is used.
src/shared/bap.c:296:25: warning: array of flexible structures
src/shared/bap.c: note: in included file:
./src/shared/ascs.h:88:25: warning: array of flexible structures
src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):
/usr/include/readline/rltypedefs.h:35:23: warning: non-ANSI function declaration of function 'Function'
/usr/include/readline/rltypedefs.h:36:25: warning: non-ANSI function declaration of function 'VFunction'
/usr/include/readline/rltypedefs.h:37:27: warning: non-ANSI function declaration of function 'CPFunction'
/usr/include/readline/rltypedefs.h:38:29: warning: non-ANSI function declaration of function 'CPPFunction'
src/shared/crypto.c:271:21: warning: Variable length array is used.
src/shared/crypto.c:272:23: warning: Variable length array is used.
src/shared/gatt-helpers.c:768:31: warning: Variable length array is used.
src/shared/gatt-helpers.c:830:31: warning: Variable length array is used.
src/shared/gatt-helpers.c:1323:31: warning: Variable length array is used.
src/shared/gatt-helpers.c:1354:23: warning: Variable length array is used.
src/shared/gatt-server.c:278:25: warning: Variable length array is used.
src/shared/gatt-server.c:618:25: warning: Variable length array is used.
src/shared/gatt-server.c:716:25: warning: Variable length array is used.
src/shared/bap.c:296:25: warning: array of flexible structures
src/shared/bap.c: note: in included file:
./src/shared/ascs.h:88:25: warning: array of flexible structures
src/shared/shell.c: note: in included file (through /usr/include/readline/readline.h):
/usr/include/readline/rltypedefs.h:35:23: warning: non-ANSI function declaration of function 'Function'
/usr/include/readline/rltypedefs.h:36:25: warning: non-ANSI function declaration of function 'VFunction'
/usr/include/readline/rltypedefs.h:37:27: warning: non-ANSI function declaration of function 'CPFunction'
/usr/include/readline/rltypedefs.h:38:29: warning: non-ANSI function declaration of function 'CPPFunction'
tools/mesh-cfgtest.c:1453:17: warning: unknown escape sequence: '\%'
tools/sco-tester.c: note: in included file:
./lib/bluetooth.h:219:15: warning: array of flexible structures
./lib/bluetooth.h:224:31: warning: array of flexible structures
tools/bneptest.c:634:39: warning: unknown escape sequence: '\%'
tools/seq2bseq.c:57:26: warning: Variable length array is used.
tools/obex-client-tool.c: note: in included file (through /usr/include/readline/readline.h):
/usr/include/readline/rltypedefs.h:35:23: warning: non-ANSI function declaration of function 'Function'
/usr/include/readline/rltypedefs.h:36:25: warning: non-ANSI function declaration of function 'VFunction'
/usr/include/readline/rltypedefs.h:37:27: warning: non-ANSI function declaration of function 'CPFunction'
/usr/include/readline/rltypedefs.h:38:29: warning: non-ANSI function declaration of function 'CPPFunction'
tools/obexctl.c:2160:9: warning: mixing declarations and code
tools/obexctl.c:2179:9: warning: mixing declarations and code
tools/obexctl.c: In function ‘check_obexd_service’:
tools/obexctl.c:2160:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
 2160 |  bool has_owner = dbus_bus_name_has_owner(conn, OBEXD_SERVICE, &err);
      |  ^~~~
tools/obexctl.c: In function ‘main’:
tools/obexctl.c:2179:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
 2179 |  bool session_bus_active = false;
      |  ^~~~
tools/obexctl.c:2205:2: error: ‘client’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 2205 |  g_dbus_client_unref(client);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:7875: tools/obexctl.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:4693: all] Error 2
##############################
Test: bluezmakeextell - FAIL
Desc: Build Bluez with External ELL
Output:

tools/obexctl.c: In function ‘check_obexd_service’:
tools/obexctl.c:2160:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
 2160 |  bool has_owner = dbus_bus_name_has_owner(conn, OBEXD_SERVICE, &err);
      |  ^~~~
tools/obexctl.c: In function ‘main’:
tools/obexctl.c:2179:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
 2179 |  bool session_bus_active = false;
      |  ^~~~
tools/obexctl.c:2205:2: error: ‘client’ may be used uninitialized in this function [-Werror=maybe-uninitialized]
 2205 |  g_dbus_client_unref(client);
      |  ^~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:7875: tools/obexctl.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make: *** [Makefile:4693: all] Error 2
##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/tools/obexctl.c b/tools/obexctl.c
index a398b095b..95350358c 100644
--- a/tools/obexctl.c
+++ b/tools/obexctl.c
@@ -43,8 +43,10 @@ 
 #define OBEX_PBAP_INTERFACE "org.bluez.obex.PhonebookAccess1"
 #define OBEX_MAP_INTERFACE "org.bluez.obex.MessageAccess1"
 #define OBEX_MSG_INTERFACE "org.bluez.obex.Message1"
+#define OBEXD_SERVICE  "org.bluez.obex"
 
-static DBusConnection *dbus_conn;
+static DBusConnection *dbus_session_conn;
+static DBusConnection *dbus_system_conn;
 static GDBusProxy *default_session;
 static GList *sessions = NULL;
 static GList *opps = NULL;
@@ -2149,6 +2151,22 @@  static void property_changed(GDBusProxy *proxy, const char *name,
 		session_property_changed(proxy, name, iter);
 }
 
+static bool check_obexd_service(DBusConnection *conn)
+{
+	DBusError err;
+
+	dbus_error_init(&err);
+
+	bool has_owner = dbus_bus_name_has_owner(conn, OBEXD_SERVICE, &err);
+
+	if (dbus_error_is_set(&err)) {
+		fprintf(stderr, "D-Bus Error: %s\n", err.message);
+		dbus_error_free(&err);
+	}
+
+	return has_owner;
+}
+
 int main(int argc, char *argv[])
 {
 	GDBusClient *client;
@@ -2158,10 +2176,23 @@  int main(int argc, char *argv[])
 	bt_shell_set_menu(&main_menu);
 	bt_shell_set_prompt(PROMPT, NULL);
 
-	dbus_conn = g_dbus_setup_bus(DBUS_BUS_SESSION, NULL, NULL);
+	bool session_bus_active = false;
+	bool system_bus_active = false;
+
+	dbus_session_conn = g_dbus_setup_bus(DBUS_BUS_SESSION, NULL, NULL);
+	if (dbus_session_conn)
+		session_bus_active = check_obexd_service(dbus_session_conn);
 
-	client = g_dbus_client_new(dbus_conn, "org.bluez.obex",
-							"/org/bluez/obex");
+	dbus_system_conn = g_dbus_setup_bus(DBUS_BUS_SYSTEM, NULL, NULL);
+	if (dbus_system_conn)
+		system_bus_active = check_obexd_service(dbus_system_conn);
+
+	if (session_bus_active)
+		client = g_dbus_client_new(dbus_session_conn, OBEXD_SERVICE,
+								"/org/bluez/obex");
+	else if (system_bus_active)
+		client = g_dbus_client_new(dbus_system_conn, OBEXD_SERVICE,
+								"/org/bluez/obex");
 
 	g_dbus_client_set_connect_watch(client, connect_handler, NULL);
 	g_dbus_client_set_disconnect_watch(client, disconnect_handler, NULL);
@@ -2173,7 +2204,11 @@  int main(int argc, char *argv[])
 
 	g_dbus_client_unref(client);
 
-	dbus_connection_unref(dbus_conn);
+	if (dbus_session_conn)
+		dbus_connection_unref(dbus_session_conn);
+
+	if (dbus_system_conn)
+		dbus_connection_unref(dbus_system_conn);
 
 	return status;
 }