diff mbox series

[BlueZ] battery: Check interface before getting property

Message ID 20230528074445.694554-1-arkadiusz.bokowy@gmail.com (mailing list archive)
State Accepted
Commit 8f32fa24cc9d044263bef468ef940d4353456f31
Headers show
Series [BlueZ] battery: Check interface before getting property | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch warning WARNING:TYPO_SPELLING: 'manger' may be misspelled - perhaps 'manager'? #84: This change will allow client to implement only one object manger for ^^^^^^ /github/workspace/src/src/13257782.patch total: 0 errors, 1 warnings, 39 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/13257782.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/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/IncrementalBuild success Incremental Build PASS
tedd_an/ScanBuild success Scan Build PASS

Commit Message

Arkadiusz Bokowy May 28, 2023, 7:44 a.m. UTC
Client can export other interfaces than the BatteryProvide1 on the
registered object manager. So, before getting battery provider specific
property, validate that we are operating on the right interface.

This change will allow client to implement only one object manger for
media applications, players and battery providers without triggering
error message.
---
 src/battery.c | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)

Comments

bluez.test.bot@gmail.com May 28, 2023, 9:35 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=751640

---Test result---

Test Summary:
CheckPatch                    FAIL      0.74 seconds
GitLint                       PASS      0.32 seconds
BuildEll                      PASS      33.90 seconds
BluezMake                     PASS      1196.98 seconds
MakeCheck                     PASS      13.52 seconds
MakeDistcheck                 PASS      195.72 seconds
CheckValgrind                 PASS      319.77 seconds
CheckSmatch                   PASS      439.07 seconds
bluezmakeextell               PASS      131.39 seconds
IncrementalBuild              PASS      1032.03 seconds
ScanBuild                     PASS      1401.45 seconds

Details
##############################
Test: CheckPatch - FAIL
Desc: Run checkpatch.pl script
Output:
[BlueZ] battery: Check interface before getting property
WARNING:TYPO_SPELLING: 'manger' may be misspelled - perhaps 'manager'?
#84: 
This change will allow client to implement only one object manger for
                                                           ^^^^^^

/github/workspace/src/src/13257782.patch total: 0 errors, 1 warnings, 39 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/13257782.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.




---
Regards,
Linux Bluetooth
patchwork-bot+bluetooth@kernel.org June 7, 2023, 7:50 p.m. UTC | #2
Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Sun, 28 May 2023 09:44:45 +0200 you wrote:
> Client can export other interfaces than the BatteryProvide1 on the
> registered object manager. So, before getting battery provider specific
> property, validate that we are operating on the right interface.
> 
> This change will allow client to implement only one object manger for
> media applications, players and battery providers without triggering
> error message.
> 
> [...]

Here is the summary with links:
  - [BlueZ] battery: Check interface before getting property
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=8f32fa24cc9d

You are awesome, thank you!
diff mbox series

Patch

diff --git a/src/battery.c b/src/battery.c
index 88a53e80e..5c52581f3 100644
--- a/src/battery.c
+++ b/src/battery.c
@@ -288,6 +288,10 @@  static void provided_battery_added_cb(GDBusProxy *proxy, void *user_data)
 	uint8_t percentage;
 	DBusMessageIter iter;
 
+	if (strcmp(g_dbus_proxy_get_interface(proxy),
+		   BATTERY_PROVIDER_INTERFACE) != 0)
+		return;
+
 	if (g_dbus_proxy_get_property(proxy, "Device", &iter) == FALSE) {
 		warn("Battery object %s does not specify device path", path);
 		return;
@@ -295,10 +299,6 @@  static void provided_battery_added_cb(GDBusProxy *proxy, void *user_data)
 
 	dbus_message_iter_get_basic(&iter, &export_path);
 
-	if (strcmp(g_dbus_proxy_get_interface(proxy),
-		   BATTERY_PROVIDER_INTERFACE) != 0)
-		return;
-
 	device = btd_adapter_find_device_by_path(provider->manager->adapter,
 						 export_path);
 	if (!device || device_is_temporary(device)) {
@@ -341,15 +341,15 @@  static void provided_battery_removed_cb(GDBusProxy *proxy, void *user_data)
 	const char *export_path;
 	DBusMessageIter iter;
 
+	if (strcmp(g_dbus_proxy_get_interface(proxy),
+		   BATTERY_PROVIDER_INTERFACE) != 0)
+		return;
+
 	if (g_dbus_proxy_get_property(proxy, "Device", &iter) == FALSE)
 		return;
 
 	dbus_message_iter_get_basic(&iter, &export_path);
 
-	if (strcmp(g_dbus_proxy_get_interface(proxy),
-		   BATTERY_PROVIDER_INTERFACE) != 0)
-		return;
-
 	DBG("provided battery removed %s", g_dbus_proxy_get_path(proxy));
 
 	battery = find_battery_by_path(export_path);