* [PATCH] HID: i2c-hid: fix format string mismatch
@ 2021-05-14 13:58 Arnd Bergmann
2021-05-14 17:40 ` Nathan Chancellor
2021-05-26 10:49 ` Jiri Kosina
0 siblings, 2 replies; 3+ messages in thread
From: Arnd Bergmann @ 2021-05-14 13:58 UTC (permalink / raw)
To: Jiri Kosina, Benjamin Tissoires, Nathan Chancellor,
Nick Desaulniers, Julian Sax
Cc: Arnd Bergmann, Hans de Goede, Douglas Anderson, Kai-Heng Feng,
Xiaofei Tan, Coiby Xu, linux-input, linux-kernel,
clang-built-linux
From: Arnd Bergmann <arnd@arndb.de>
clang doesn't like printing a 32-bit integer using %hX format string:
drivers/hid/i2c-hid/i2c-hid-core.c:994:18: error: format specifies type 'unsigned short' but the argument has type '__u32' (aka 'unsigned int') [-Werror,-Wformat]
client->name, hid->vendor, hid->product);
^~~~~~~~~~~
drivers/hid/i2c-hid/i2c-hid-core.c:994:31: error: format specifies type 'unsigned short' but the argument has type '__u32' (aka 'unsigned int') [-Werror,-Wformat]
client->name, hid->vendor, hid->product);
^~~~~~~~~~~~
Use an explicit cast to truncate it to the low 16 bits instead.
Fixes: 9ee3e06610fd ("HID: i2c-hid: override HID descriptors for certain devices")
Signed-off-by: Arnd Bergmann <arnd@arndb.de>
---
drivers/hid/i2c-hid/i2c-hid-core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
index 9993133989a5..f9d28ad17d9c 100644
--- a/drivers/hid/i2c-hid/i2c-hid-core.c
+++ b/drivers/hid/i2c-hid/i2c-hid-core.c
@@ -990,8 +990,8 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,
hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID);
hid->product = le16_to_cpu(ihid->hdesc.wProductID);
- snprintf(hid->name, sizeof(hid->name), "%s %04hX:%04hX",
- client->name, hid->vendor, hid->product);
+ snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X",
+ client->name, (u16)hid->vendor, (u16)hid->product);
strlcpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys));
ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product);
--
2.29.2
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] HID: i2c-hid: fix format string mismatch
2021-05-14 13:58 [PATCH] HID: i2c-hid: fix format string mismatch Arnd Bergmann
@ 2021-05-14 17:40 ` Nathan Chancellor
2021-05-26 10:49 ` Jiri Kosina
1 sibling, 0 replies; 3+ messages in thread
From: Nathan Chancellor @ 2021-05-14 17:40 UTC (permalink / raw)
To: Arnd Bergmann, Jiri Kosina, Benjamin Tissoires, Nick Desaulniers,
Julian Sax
Cc: Arnd Bergmann, Hans de Goede, Douglas Anderson, Kai-Heng Feng,
Xiaofei Tan, Coiby Xu, linux-input, linux-kernel,
clang-built-linux
On 5/14/2021 6:58 AM, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> clang doesn't like printing a 32-bit integer using %hX format string:
>
> drivers/hid/i2c-hid/i2c-hid-core.c:994:18: error: format specifies type 'unsigned short' but the argument has type '__u32' (aka 'unsigned int') [-Werror,-Wformat]
> client->name, hid->vendor, hid->product);
> ^~~~~~~~~~~
> drivers/hid/i2c-hid/i2c-hid-core.c:994:31: error: format specifies type 'unsigned short' but the argument has type '__u32' (aka 'unsigned int') [-Werror,-Wformat]
> client->name, hid->vendor, hid->product);
> ^~~~~~~~~~~~
>
> Use an explicit cast to truncate it to the low 16 bits instead.
>
> Fixes: 9ee3e06610fd ("HID: i2c-hid: override HID descriptors for certain devices")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Reviewed-by: Nathan Chancellor <nathan@kernel.org>
> ---
> drivers/hid/i2c-hid/i2c-hid-core.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/hid/i2c-hid/i2c-hid-core.c b/drivers/hid/i2c-hid/i2c-hid-core.c
> index 9993133989a5..f9d28ad17d9c 100644
> --- a/drivers/hid/i2c-hid/i2c-hid-core.c
> +++ b/drivers/hid/i2c-hid/i2c-hid-core.c
> @@ -990,8 +990,8 @@ int i2c_hid_core_probe(struct i2c_client *client, struct i2chid_ops *ops,
> hid->vendor = le16_to_cpu(ihid->hdesc.wVendorID);
> hid->product = le16_to_cpu(ihid->hdesc.wProductID);
>
> - snprintf(hid->name, sizeof(hid->name), "%s %04hX:%04hX",
> - client->name, hid->vendor, hid->product);
> + snprintf(hid->name, sizeof(hid->name), "%s %04X:%04X",
> + client->name, (u16)hid->vendor, (u16)hid->product);
> strlcpy(hid->phys, dev_name(&client->dev), sizeof(hid->phys));
>
> ihid->quirks = i2c_hid_lookup_quirk(hid->vendor, hid->product);
>
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] HID: i2c-hid: fix format string mismatch
2021-05-14 13:58 [PATCH] HID: i2c-hid: fix format string mismatch Arnd Bergmann
2021-05-14 17:40 ` Nathan Chancellor
@ 2021-05-26 10:49 ` Jiri Kosina
1 sibling, 0 replies; 3+ messages in thread
From: Jiri Kosina @ 2021-05-26 10:49 UTC (permalink / raw)
To: Arnd Bergmann
Cc: Benjamin Tissoires, Nathan Chancellor, Nick Desaulniers,
Julian Sax, Arnd Bergmann, Hans de Goede, Douglas Anderson,
Kai-Heng Feng, Xiaofei Tan, Coiby Xu, linux-input, linux-kernel,
clang-built-linux
On Fri, 14 May 2021, Arnd Bergmann wrote:
> From: Arnd Bergmann <arnd@arndb.de>
>
> clang doesn't like printing a 32-bit integer using %hX format string:
>
> drivers/hid/i2c-hid/i2c-hid-core.c:994:18: error: format specifies type 'unsigned short' but the argument has type '__u32' (aka 'unsigned int') [-Werror,-Wformat]
> client->name, hid->vendor, hid->product);
> ^~~~~~~~~~~
> drivers/hid/i2c-hid/i2c-hid-core.c:994:31: error: format specifies type 'unsigned short' but the argument has type '__u32' (aka 'unsigned int') [-Werror,-Wformat]
> client->name, hid->vendor, hid->product);
> ^~~~~~~~~~~~
>
> Use an explicit cast to truncate it to the low 16 bits instead.
>
> Fixes: 9ee3e06610fd ("HID: i2c-hid: override HID descriptors for certain devices")
> Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Applied, thanks Arnd.
--
Jiri Kosina
SUSE Labs
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2021-05-26 10:49 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-14 13:58 [PATCH] HID: i2c-hid: fix format string mismatch Arnd Bergmann
2021-05-14 17:40 ` Nathan Chancellor
2021-05-26 10:49 ` Jiri Kosina
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.