From: Yao Zi <ziyao@disroot.org>
To: linux-bluetooth@vger.kernel.org
Cc: Christian Eggers <ceggers@arri.de>, Yao Zi <ziyao@disroot.org>
Subject: [PATCH BlueZ] client/gatt: Fix pointer assigned with character literal
Date: Tue, 25 Mar 2025 08:35:47 +0000 [thread overview]
Message-ID: <20250325083546.31597-2-ziyao@disroot.org> (raw)
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
next reply other threads:[~2025-03-25 8:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-03-25 8:35 Yao Zi [this message]
2025-03-25 9:39 ` [BlueZ] client/gatt: Fix pointer assigned with character literal bluez.test.bot
2025-03-25 10:28 ` [PATCH BlueZ] " Christian Eggers
2025-03-26 15:10 ` patchwork-bot+bluetooth
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250325083546.31597-2-ziyao@disroot.org \
--to=ziyao@disroot.org \
--cc=ceggers@arri.de \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox