public inbox for linux-bluetooth@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ] client/gatt: Fix pointer assigned with character literal
@ 2025-03-25  8:35 Yao Zi
  2025-03-25  9:39 ` [BlueZ] " bluez.test.bot
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yao Zi @ 2025-03-25  8:35 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Christian Eggers, Yao Zi

A character literl, '\0', is assigned to the pointer. The corresponding
comment doesn't make any sense, since '\0' represents zero and this
statement does the same thing as assigning value with NULL.

Initializing value with NULL (or zero) is safe and correct here: the
only case that the initial value of the pointer is passed to
write_value() is that the if branch isn't executed, where len keeps its
initial value, zero, as well. With src_len equal to zero, write_value()
will bail out and src_val won't be dereferenced.

Let's clean up the misleading comment and change right side of the
assignment to fix compiler warnings about the wrong type,

Fixes: ee750bbaf68c ("client/gatt: proxy_property_changed: check for NULL iterator")
Signed-off-by: Yao Zi <ziyao@disroot.org>
---
 client/gatt.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/client/gatt.c b/client/gatt.c
index 4dac88590..b18186518 100644
--- a/client/gatt.c
+++ b/client/gatt.c
@@ -3207,7 +3207,7 @@ static void proxy_property_changed(GDBusProxy *proxy, const char *name,
 			chrc->path, bt_uuidstr_to_str(chrc->uuid), name);
 
 	if (!strcmp(name, "Value")) {
-		uint8_t *value = '\0';  /* don't pass NULL to write_value() */
+		uint8_t *value = NULL;
 		int len = 0;
 
 		if (iter && dbus_message_iter_get_arg_type(iter) ==
-- 
2.49.0


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

* RE: [BlueZ] client/gatt: Fix pointer assigned with character literal
  2025-03-25  8:35 [PATCH BlueZ] client/gatt: Fix pointer assigned with character literal Yao Zi
@ 2025-03-25  9:39 ` bluez.test.bot
  2025-03-25 10:28 ` [PATCH BlueZ] " Christian Eggers
  2025-03-26 15:10 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: bluez.test.bot @ 2025-03-25  9:39 UTC (permalink / raw)
  To: linux-bluetooth, ziyao

[-- Attachment #1: Type: text/plain, Size: 1260 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=947070

---Test result---

Test Summary:
CheckPatch                    PENDING   0.22 seconds
GitLint                       PENDING   0.20 seconds
BuildEll                      PASS      20.59 seconds
BluezMake                     PASS      1501.71 seconds
MakeCheck                     PASS      14.08 seconds
MakeDistcheck                 PASS      160.64 seconds
CheckValgrind                 PASS      215.44 seconds
CheckSmatch                   PASS      286.46 seconds
bluezmakeextell               PASS      98.54 seconds
IncrementalBuild              PENDING   0.71 seconds
ScanBuild                     PASS      898.19 seconds

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

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

##############################
Test: IncrementalBuild - PENDING
Desc: Incremental build with the patches in the series
Output:



---
Regards,
Linux Bluetooth


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

* Re: [PATCH BlueZ] client/gatt: Fix pointer assigned with character literal
  2025-03-25  8:35 [PATCH BlueZ] client/gatt: Fix pointer assigned with character literal Yao Zi
  2025-03-25  9:39 ` [BlueZ] " bluez.test.bot
@ 2025-03-25 10:28 ` Christian Eggers
  2025-03-26 15:10 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: Christian Eggers @ 2025-03-25 10:28 UTC (permalink / raw)
  To: linux-bluetooth, Yao Zi; +Cc: Yao Zi

On Tuesday, 25 March 2025, 09:35:47 CET, Yao Zi wrote:
> A character literl, '\0', is assigned to the pointer. The corresponding
> comment doesn't make any sense, since '\0' represents zero and this
> statement does the same thing as assigning value with NULL.
> 
> Initializing value with NULL (or zero) is safe and correct here: the
> only case that the initial value of the pointer is passed to
> write_value() is that the if branch isn't executed, where len keeps its
> initial value, zero, as well. With src_len equal to zero, write_value()
> will bail out and src_val won't be dereferenced.
> 
> Let's clean up the misleading comment and change right side of the
> assignment to fix compiler warnings about the wrong type,
> 
> Fixes: ee750bbaf68c ("client/gatt: proxy_property_changed: check for NULL iterator")
> Signed-off-by: Yao Zi <ziyao@disroot.org>

After reading my own commit message, assigning "value = '\0'" absolutely makes
no sense in this context. Actually my intention was only checking for iter != NULL.

Acked-by: Christian Eggers <ceggers@arri.de>

> ---
>  client/gatt.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/client/gatt.c b/client/gatt.c
> index 4dac88590..b18186518 100644
> --- a/client/gatt.c
> +++ b/client/gatt.c
> @@ -3207,7 +3207,7 @@ static void proxy_property_changed(GDBusProxy *proxy, const char *name,
>  			chrc->path, bt_uuidstr_to_str(chrc->uuid), name);
>  
>  	if (!strcmp(name, "Value")) {
> -		uint8_t *value = '\0';  /* don't pass NULL to write_value() */
> +		uint8_t *value = NULL;
>  		int len = 0;
>  
>  		if (iter && dbus_message_iter_get_arg_type(iter) ==
> 





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

* Re: [PATCH BlueZ] client/gatt: Fix pointer assigned with character literal
  2025-03-25  8:35 [PATCH BlueZ] client/gatt: Fix pointer assigned with character literal Yao Zi
  2025-03-25  9:39 ` [BlueZ] " bluez.test.bot
  2025-03-25 10:28 ` [PATCH BlueZ] " Christian Eggers
@ 2025-03-26 15:10 ` patchwork-bot+bluetooth
  2 siblings, 0 replies; 4+ messages in thread
From: patchwork-bot+bluetooth @ 2025-03-26 15:10 UTC (permalink / raw)
  To: Yao Zi; +Cc: linux-bluetooth, ceggers

Hello:

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

On Tue, 25 Mar 2025 08:35:47 +0000 you wrote:
> A character literl, '\0', is assigned to the pointer. The corresponding
> comment doesn't make any sense, since '\0' represents zero and this
> statement does the same thing as assigning value with NULL.
> 
> Initializing value with NULL (or zero) is safe and correct here: the
> only case that the initial value of the pointer is passed to
> write_value() is that the if branch isn't executed, where len keeps its
> initial value, zero, as well. With src_len equal to zero, write_value()
> will bail out and src_val won't be dereferenced.
> 
> [...]

Here is the summary with links:
  - [BlueZ] client/gatt: Fix pointer assigned with character literal
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=0f0039045088

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] 4+ messages in thread

end of thread, other threads:[~2025-03-26 15:10 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-03-25  8:35 [PATCH BlueZ] client/gatt: Fix pointer assigned with character literal Yao Zi
2025-03-25  9:39 ` [BlueZ] " bluez.test.bot
2025-03-25 10:28 ` [PATCH BlueZ] " Christian Eggers
2025-03-26 15:10 ` 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