linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ] battery: Check interface before getting property
@ 2023-05-28  7:44 Arkadiusz Bokowy
  2023-05-28  9:35 ` [BlueZ] " bluez.test.bot
  2023-06-07 19:50 ` [PATCH BlueZ] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Arkadiusz Bokowy @ 2023-05-28  7:44 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Arkadiusz Bokowy

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(-)

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);
-- 
2.30.2


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* RE: [BlueZ] battery: Check interface before getting property
  2023-05-28  7:44 [PATCH BlueZ] battery: Check interface before getting property Arkadiusz Bokowy
@ 2023-05-28  9:35 ` bluez.test.bot
  2023-06-07 19:50 ` [PATCH BlueZ] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2023-05-28  9:35 UTC (permalink / raw)
  To: linux-bluetooth, arkadiusz.bokowy

[-- Attachment #1: Type: text/plain, Size: 1925 bytes --]

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


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH BlueZ] battery: Check interface before getting property
  2023-05-28  7:44 [PATCH BlueZ] battery: Check interface before getting property Arkadiusz Bokowy
  2023-05-28  9:35 ` [BlueZ] " bluez.test.bot
@ 2023-06-07 19:50 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2023-06-07 19:50 UTC (permalink / raw)
  To: Arkadiusz Bokowy; +Cc: linux-bluetooth

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!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-06-07 19:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-28  7:44 [PATCH BlueZ] battery: Check interface before getting property Arkadiusz Bokowy
2023-05-28  9:35 ` [BlueZ] " bluez.test.bot
2023-06-07 19:50 ` [PATCH BlueZ] " patchwork-bot+bluetooth

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).