HID: i2c-hid: fix format string mismatch
PATCH 1/1 HID: i2c-hid: fix format string mismatch
From: Arnd Bergmann <[email protected]>
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.
--- drivers/hid/i2c-hid/i2c-hid-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/hid/i2c-hid/i2c-hid-core.c +2 -2
@@ -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);
Signature · 1 line
2.29.2
Quoted 11 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
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); ^~~~~~~~~~~~
Quoted 4 lines
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 <[email protected]>
Quoted 20 lines
--- drivers/hid/i2c-hid/i2c-hid-core.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)drivers/hid/i2c-hid/i2c-hid-core.c +2
-2@@ -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);
Quoted 11 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
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); ^~~~~~~~~~~~
Quoted 4 lines
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 <[email protected]>
Applied, thanks Arnd.
Signature · 2 lines
Jiri Kosina SUSE Labs