i2c-hid: explicitly cast parametrs to follow specifiers
PATCH 1/1 i2c-hid: explicitly cast parametrs to follow specifiers
The vendor and product parameters are defined as __u32, but used as short int. Let's do an explicit casting for them.
--- drivers/hid/i2c-hid/i2c-hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/hid/i2c-hid/i2c-hid.c +1 -1
@@ -1009,7 +1009,7 @@ static int i2c_hid_probe(struct i2c_client *client, hid->product =le16_to_cpu (ihid->hdesc.wProductID);snprintf (hid->name,sizeof (hid->name),"%s %04hX:%04hX" , - client->name, hid->vendor, hid->product); + client->name, (short int )hid->vendor, (short int )hid->product); ret =hid_add_device (hid);if (ret) {
Signature · 1 line
1.8.3.1
Quoted 2 lines · Andy Shevchenko
The vendor and product parameters are defined as
__u32, but used as short int. Let's do an explicit casting for them.
Jiri, Benjamin, any comment on this?
Quoted 19 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/hid/i2c-hid/i2c-hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hid/i2c-hid/i2c-hid.c +1
-1@@ -1009,7 +1009,7 @@ static int i2c_hid_probe(struct i2c_client *client, hid->product =le16_to_cpu (ihid->hdesc.wProductID);snprintf (hid->name,sizeof (hid->name),"%s %04hX:%04hX" , - client->name, hid->vendor, hid->product); + client->name, (short int )hid->vendor, (short int )hid->product); ret =hid_add_device (hid);if (ret) {
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy
Quoted 2 lines · Andy Shevchenko
The vendor and product parameters are defined as
__u32, but used as short int. Let's do an explicit casting for them.
Is this fixing any compiler warning you have seen?
Quoted 22 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/hid/i2c-hid/i2c-hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hid/i2c-hid/i2c-hid.c +1
-1@@ -1009,7 +1009,7 @@ static int i2c_hid_probe(struct i2c_client *client, hid->product =le16_to_cpu (ihid->hdesc.wProductID);snprintf (hid->name,sizeof (hid->name),"%s %04hX:%04hX" , - client->name, hid->vendor, hid->product); + client->name, (short int )hid->vendor, (short int )hid->product); ret =hid_add_device (hid);if (ret) {Signature · 1 line
1.8.3.1
Signature · 2 lines
Jiri Kosina SUSE Labs
Quoted 6 lines · Jiri Kosina
Quoted 2 lines · Andy Shevchenko
The vendor and product parameters are defined as
__u32, but used as short int. Let's do an explicit casting for them.Is this fixing any compiler warning you have seen?
It was found by static analyzer.
Quoted 14 lines
Quoted 14 lines
Signed-off-by Andy Shevchenko <[email protected]>--- drivers/hid/i2c-hid/i2c-hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/hid/i2c-hid/i2c-hid.c +0
-0@@ -1009,7 +1009,7 @@ static int i2c_hid_probe(struct i2c_client *client, hid->product =le16_to_cpu (ihid->hdesc.wProductID);
Quoted 3 lines
drivers/hid/i2c-hid/i2c-hid.c static int i2c_hid_probe(struct i2c_client *client, · line 1012
Quoted 3 lines
drivers/hid/i2c-hid/i2c-hid.c +1
-1snprintf (hid->name,sizeof (hid->name),"%s %04hX:%04hX" , - client->name, hid->vendor, hid->product); + client->name, (short int )hid->vendor, (short int )hid->product);
...and it's probably better to use (unsigned short int) if this patch is going anywhere.
Quoted 7 lines
Quoted 6 lines
drivers/hid/i2c-hid/i2c-hid.c +0
-0ret =hid_add_device (hid);if (ret) {Signature · 1 line
1.8.3.1
Signature · 2 lines
Andy Shevchenko <[email protected]> Intel Finland Oy