diff mbox series

[Bluez,v3,1/3] device: Add "Bonded" flag to dbus property

Message ID 20220504140940.Bluez.v3.1.I6ab300fa4999c9310f4cb6fc09b1290edb6b2c2b@changeid (mailing list archive)
State Superseded
Headers show
Series Adding bonded flag to D-Bus property | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/checkpatch success Checkpatch PASS
tedd_an/gitlint success Gitlint PASS
tedd_an/setupell success Setup ELL PASS
tedd_an/buildprep success Build Prep PASS
tedd_an/build success Build Configuration PASS
tedd_an/makecheck fail Make Check FAIL: src/device.c: In function ‘device_set_bonded’: src/device.c:6141:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 6141 | struct bearer_state *state = get_state(device, bdaddr_type); | ^~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:10248: src/bluetoothd-device.o] Error 1 make: *** [Makefile:11283: check] Error 2
tedd_an/makecheckvalgrind fail Make FAIL: tools/mgmt-tester.c: In function ‘main’: tools/mgmt-tester.c:12364:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without 12364 | int main(int argc, char *argv[]) | ^~~~ src/device.c: In function ‘device_set_bonded’: src/device.c:6141:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 6141 | struct bearer_state *state = get_state(device, bdaddr_type); | ^~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:10248: src/bluetoothd-device.o] Error 1 make: *** [Makefile:4310: all] Error 2
tedd_an/makedistcheck success Make Distcheck PASS
tedd_an/build_extell success Build External ELL PASS
tedd_an/build_extell_make fail Build Make with External ELL FAIL: tools/mgmt-tester.c: In function ‘main’: tools/mgmt-tester.c:12364:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without 12364 | int main(int argc, char *argv[]) | ^~~~ unit/test-avdtp.c: In function ‘main’: unit/test-avdtp.c:766:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without 766 | int main(int argc, char *argv[]) | ^~~~ unit/test-avrcp.c: In function ‘main’: unit/test-avrcp.c:989:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without 989 | int main(int argc, char *argv[]) | ^~~~ src/device.c: In function ‘device_set_bonded’: src/device.c:6141:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 6141 | struct bearer_state *state = get_state(device, bdaddr_type); | ^~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:10248: src/bluetoothd-device.o] Error 1 make: *** [Makefile:4310: all] Error 2
tedd_an/incremental_build fail Make FAIL: tools/mgmt-tester.c: In function ‘main’: tools/mgmt-tester.c:12364:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without 12364 | int main(int argc, char *argv[]) | ^~~~ unit/test-avdtp.c: In function ‘main’: unit/test-avdtp.c:766:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without 766 | int main(int argc, char *argv[]) | ^~~~ unit/test-avrcp.c: In function ‘main’: unit/test-avrcp.c:989:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without 989 | int main(int argc, char *argv[]) | ^~~~ src/device.c: In function ‘device_set_bonded’: src/device.c:6141:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement] 6141 | struct bearer_state *state = get_state(device, bdaddr_type); | ^~~~~~ cc1: all warnings being treated as errors make[1]: *** [Makefile:10248: src/bluetoothd-device.o] Error 1 make: *** [Makefile:4310: all] Error 2

Commit Message

Zhengping Jiang May 4, 2022, 9:09 p.m. UTC
Add "Bonded" to dbus device property table. When setting the "Bonded
flag, check the status of the Bonded property first. If the Bonded
property is changed, send property changed signal.

Reviewed-by: Sonny Sasaka <sonnysasaka@chromium.org>
Reviewed-by: Yun-Hao Chung <howardchung@chromium.org>

Signed-off-by: Zhengping Jiang <jiangzp@google.com>
---

(no changes since v2)

Changes in v2:
- Move one variable declaration to the top following C90 standard

Changes in v1:
- Add "Bonded" to D-Bus interface
- Send property changed signal if the bonded flag is changed

 src/device.c | 38 +++++++++++++++++++++++++++++++++-----
 1 file changed, 33 insertions(+), 5 deletions(-)

Comments

bluez.test.bot@gmail.com May 4, 2022, 10:40 p.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=638455

---Test result---

Test Summary:
CheckPatch                    PASS      4.37 seconds
GitLint                       PASS      2.85 seconds
Prep - Setup ELL              PASS      43.69 seconds
Build - Prep                  PASS      0.69 seconds
Build - Configure             PASS      8.79 seconds
Build - Make                  FAIL      1282.94 seconds
Make Check                    FAIL      5.14 seconds
Make Check w/Valgrind         FAIL      308.39 seconds
Make Distcheck                PASS      235.79 seconds
Build w/ext ELL - Configure   PASS      8.96 seconds
Build w/ext ELL - Make        FAIL      1253.26 seconds
Incremental Build with patchesFAIL      1279.49 seconds

Details
##############################
Test: Build - Make - FAIL
Desc: Build the BlueZ source tree
Output:
tools/mgmt-tester.c: In function ‘main’:
tools/mgmt-tester.c:12364:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
12364 | int main(int argc, char *argv[])
      |     ^~~~
unit/test-avdtp.c: In function ‘main’:
unit/test-avdtp.c:766:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
  766 | int main(int argc, char *argv[])
      |     ^~~~
unit/test-avrcp.c: In function ‘main’:
unit/test-avrcp.c:989:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
  989 | int main(int argc, char *argv[])
      |     ^~~~
src/device.c: In function ‘device_set_bonded’:
src/device.c:6141:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
 6141 |  struct bearer_state *state = get_state(device, bdaddr_type);
      |  ^~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:10248: src/bluetoothd-device.o] Error 1
make: *** [Makefile:4310: all] Error 2


##############################
Test: Make Check - FAIL
Desc: Run 'make check'
Output:
src/device.c: In function ‘device_set_bonded’:
src/device.c:6141:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
 6141 |  struct bearer_state *state = get_state(device, bdaddr_type);
      |  ^~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:10248: src/bluetoothd-device.o] Error 1
make: *** [Makefile:11283: check] Error 2


##############################
Test: Make Check w/Valgrind - FAIL
Desc: Run 'make check' with Valgrind
Output:
tools/mgmt-tester.c: In function ‘main’:
tools/mgmt-tester.c:12364:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
12364 | int main(int argc, char *argv[])
      |     ^~~~
src/device.c: In function ‘device_set_bonded’:
src/device.c:6141:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
 6141 |  struct bearer_state *state = get_state(device, bdaddr_type);
      |  ^~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:10248: src/bluetoothd-device.o] Error 1
make: *** [Makefile:4310: all] Error 2


##############################
Test: Build w/ext ELL - Make - FAIL
Desc: Build BlueZ source with '--enable-external-ell' configuration
Output:
tools/mgmt-tester.c: In function ‘main’:
tools/mgmt-tester.c:12364:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
12364 | int main(int argc, char *argv[])
      |     ^~~~
unit/test-avdtp.c: In function ‘main’:
unit/test-avdtp.c:766:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
  766 | int main(int argc, char *argv[])
      |     ^~~~
unit/test-avrcp.c: In function ‘main’:
unit/test-avrcp.c:989:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
  989 | int main(int argc, char *argv[])
      |     ^~~~
src/device.c: In function ‘device_set_bonded’:
src/device.c:6141:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
 6141 |  struct bearer_state *state = get_state(device, bdaddr_type);
      |  ^~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:10248: src/bluetoothd-device.o] Error 1
make: *** [Makefile:4310: all] Error 2


##############################
Test: Incremental Build with patches - FAIL
Desc: Incremental build per patch in the series
Output:
tools/mgmt-tester.c: In function ‘main’:
tools/mgmt-tester.c:12364:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
12364 | int main(int argc, char *argv[])
      |     ^~~~
unit/test-avdtp.c: In function ‘main’:
unit/test-avdtp.c:766:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
  766 | int main(int argc, char *argv[])
      |     ^~~~
unit/test-avrcp.c: In function ‘main’:
unit/test-avrcp.c:989:5: note: variable tracking size limit exceeded with ‘-fvar-tracking-assignments’, retrying without
  989 | int main(int argc, char *argv[])
      |     ^~~~
src/device.c: In function ‘device_set_bonded’:
src/device.c:6141:2: error: ISO C90 forbids mixed declarations and code [-Werror=declaration-after-statement]
 6141 |  struct bearer_state *state = get_state(device, bdaddr_type);
      |  ^~~~~~
cc1: all warnings being treated as errors
make[1]: *** [Makefile:10248: src/bluetoothd-device.o] Error 1
make: *** [Makefile:4310: all] Error 2




---
Regards,
Linux Bluetooth
diff mbox series

Patch

diff --git a/src/device.c b/src/device.c
index a62564b14f49..72804713b25b 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1143,6 +1143,22 @@  static gboolean dev_property_get_paired(const GDBusPropertyTable *property,
 	return TRUE;
 }
 
+static gboolean dev_property_get_bonded(const GDBusPropertyTable *property,
+					DBusMessageIter *iter, void *data)
+{
+	struct btd_device *dev = data;
+	dbus_bool_t val;
+
+	if (dev->bredr_state.bonded || dev->le_state.bonded)
+		val = TRUE;
+	else
+		val = FALSE;
+
+	dbus_message_iter_append_basic(iter, DBUS_TYPE_BOOLEAN, &val);
+
+	return TRUE;
+}
+
 static gboolean dev_property_get_legacy(const GDBusPropertyTable *property,
 					DBusMessageIter *iter, void *data)
 {
@@ -4033,6 +4049,7 @@  static const GDBusPropertyTable device_properties[] = {
 	{ "Icon", "s", dev_property_get_icon, NULL,
 					dev_property_exists_icon },
 	{ "Paired", "b", dev_property_get_paired },
+	{ "Bonded", "b", dev_property_get_bonded },
 	{ "Trusted", "b", dev_property_get_trusted, dev_property_set_trusted },
 	{ "Blocked", "b", dev_property_get_blocked, dev_property_set_blocked },
 	{ "LegacyPairing", "b", dev_property_get_legacy },
@@ -7065,14 +7082,25 @@  void device_set_bonded(struct btd_device *device, uint8_t bdaddr_type)
 	if (!device)
 		return;
 
-	DBG("");
+	struct bearer_state *state = get_state(device, bdaddr_type);
 
-	if (bdaddr_type == BDADDR_BREDR)
-		device->bredr_state.bonded = true;
-	else
-		device->le_state.bonded = true;
+	if (state->bonded)
+		return;
+
+	DBG("setting bonded for device to true");
+
+	state->bonded = true;
 
 	btd_device_set_temporary(device, false);
+
+	/* If the other bearer state was already true we don't need to
+	 * send any property signals.
+	 */
+	if (device->bredr_state.bonded == device->le_state.bonded)
+		return;
+
+	g_dbus_emit_property_changed(dbus_conn, device->path,
+						DEVICE_INTERFACE, "Bonded");
 }
 
 void device_set_legacy(struct btd_device *device, bool legacy)