Re: [PATCH BlueZ] client/gatt: Fix pointer assigned with character literal

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxxx>

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@xxxxxxx>

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








[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux