linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] i2c-hid: explicitly cast parametrs to follow specifiers
@ 2013-06-25 12:24 Andy Shevchenko
  2013-08-06 11:43 ` Andy Shevchenko
  2013-09-04 11:17 ` Jiri Kosina
  0 siblings, 2 replies; 4+ messages in thread
From: Andy Shevchenko @ 2013-06-25 12:24 UTC (permalink / raw)
  To: Jiri Kosina, linux-input; +Cc: Andy Shevchenko

The vendor and product parameters are defined as __u32, but used as short int.
Let's do an explicit casting for them.

Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
---
 drivers/hid/i2c-hid/i2c-hid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
index 879b0ed..d595f2a 100644
--- a/drivers/hid/i2c-hid/i2c-hid.c
+++ b/drivers/hid/i2c-hid/i2c-hid.c
@@ -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) {
-- 
1.8.3.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c-hid: explicitly cast parametrs to follow specifiers
  2013-06-25 12:24 [PATCH] i2c-hid: explicitly cast parametrs to follow specifiers Andy Shevchenko
@ 2013-08-06 11:43 ` Andy Shevchenko
  2013-09-04 11:17 ` Jiri Kosina
  1 sibling, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2013-08-06 11:43 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: linux-input, Benjamin Tissoires

On Tue, 2013-06-25 at 15:24 +0300, Andy Shevchenko wrote: 
> 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?

> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/hid/i2c-hid/i2c-hid.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
> index 879b0ed..d595f2a 100644
> --- a/drivers/hid/i2c-hid/i2c-hid.c
> +++ b/drivers/hid/i2c-hid/i2c-hid.c
> @@ -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) {

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c-hid: explicitly cast parametrs to follow specifiers
  2013-06-25 12:24 [PATCH] i2c-hid: explicitly cast parametrs to follow specifiers Andy Shevchenko
  2013-08-06 11:43 ` Andy Shevchenko
@ 2013-09-04 11:17 ` Jiri Kosina
  2013-09-04 11:51   ` Andy Shevchenko
  1 sibling, 1 reply; 4+ messages in thread
From: Jiri Kosina @ 2013-09-04 11:17 UTC (permalink / raw)
  To: Andy Shevchenko; +Cc: linux-input

On Tue, 25 Jun 2013, Andy Shevchenko wrote:

> 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?

> 
> Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> ---
>  drivers/hid/i2c-hid/i2c-hid.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
> index 879b0ed..d595f2a 100644
> --- a/drivers/hid/i2c-hid/i2c-hid.c
> +++ b/drivers/hid/i2c-hid/i2c-hid.c
> @@ -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) {
> -- 
> 1.8.3.1
> 

-- 
Jiri Kosina
SUSE Labs

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] i2c-hid: explicitly cast parametrs to follow specifiers
  2013-09-04 11:17 ` Jiri Kosina
@ 2013-09-04 11:51   ` Andy Shevchenko
  0 siblings, 0 replies; 4+ messages in thread
From: Andy Shevchenko @ 2013-09-04 11:51 UTC (permalink / raw)
  To: Jiri Kosina; +Cc: linux-input

On Wed, 2013-09-04 at 13:17 +0200, Jiri Kosina wrote: 
> On Tue, 25 Jun 2013, Andy Shevchenko wrote:
> 
> > 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.

> 
> > 
> > Signed-off-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
> > ---
> >  drivers/hid/i2c-hid/i2c-hid.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> > 
> > diff --git a/drivers/hid/i2c-hid/i2c-hid.c b/drivers/hid/i2c-hid/i2c-hid.c
> > index 879b0ed..d595f2a 100644
> > --- a/drivers/hid/i2c-hid/i2c-hid.c
> > +++ b/drivers/hid/i2c-hid/i2c-hid.c
> > @@ -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);

...and it's probably better to use (unsigned short int) if this patch is
going anywhere.

> >  
> >  	ret = hid_add_device(hid);
> >  	if (ret) {
> > -- 
> > 1.8.3.1
> > 
> 

-- 
Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Intel Finland Oy

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2013-09-04 11:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-06-25 12:24 [PATCH] i2c-hid: explicitly cast parametrs to follow specifiers Andy Shevchenko
2013-08-06 11:43 ` Andy Shevchenko
2013-09-04 11:17 ` Jiri Kosina
2013-09-04 11:51   ` Andy Shevchenko

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).