All of lore.kernel.org
 help / color / mirror / Atom feed
* [patch] sony-laptop: fix a couple signedness bugs
@ 2012-06-07  8:22 ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2012-06-07  8:22 UTC (permalink / raw)
  To: Mattia Dongili; +Cc: Matthew Garrett, platform-driver-x86, kernel-janitors

These need to be signed to handle negative error codes.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 210d4ae..0a2f026 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -2113,7 +2113,7 @@ static ssize_t sony_nc_thermal_mode_show(struct device *dev,
 		struct device_attribute *attr, char *buffer)
 {
 	ssize_t count = 0;
-	unsigned int mode = sony_nc_thermal_mode_get();
+	int mode = sony_nc_thermal_mode_get();
 
 	if (mode < 0)
 		return mode;
@@ -2480,7 +2480,7 @@ static void sony_nc_backlight_ng_read_limits(int handle,
 	props->maxlvl = 0xff;
 
 	offset = sony_find_snc_handle(handle);
-	if (offset < 0)
+	if ((int)offset < 0)
 		return;
 
 	/* try to read the boundaries from ACPI tables, if we fail the above

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

* [patch] sony-laptop: fix a couple signedness bugs
@ 2012-06-07  8:22 ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2012-06-07  8:22 UTC (permalink / raw)
  To: Mattia Dongili; +Cc: Matthew Garrett, platform-driver-x86, kernel-janitors

These need to be signed to handle negative error codes.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
index 210d4ae..0a2f026 100644
--- a/drivers/platform/x86/sony-laptop.c
+++ b/drivers/platform/x86/sony-laptop.c
@@ -2113,7 +2113,7 @@ static ssize_t sony_nc_thermal_mode_show(struct device *dev,
 		struct device_attribute *attr, char *buffer)
 {
 	ssize_t count = 0;
-	unsigned int mode = sony_nc_thermal_mode_get();
+	int mode = sony_nc_thermal_mode_get();
 
 	if (mode < 0)
 		return mode;
@@ -2480,7 +2480,7 @@ static void sony_nc_backlight_ng_read_limits(int handle,
 	props->maxlvl = 0xff;
 
 	offset = sony_find_snc_handle(handle);
-	if (offset < 0)
+	if ((int)offset < 0)
 		return;
 
 	/* try to read the boundaries from ACPI tables, if we fail the above

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

* Re: [patch] sony-laptop: fix a couple signedness bugs
  2012-06-07  8:22 ` Dan Carpenter
@ 2012-06-07  9:47   ` walter harms
  -1 siblings, 0 replies; 10+ messages in thread
From: walter harms @ 2012-06-07  9:47 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Mattia Dongili, Matthew Garrett, platform-driver-x86,
	kernel-janitors



Am 07.06.2012 10:22, schrieb Dan Carpenter:
> These need to be signed to handle negative error codes.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
> index 210d4ae..0a2f026 100644
> --- a/drivers/platform/x86/sony-laptop.c
> +++ b/drivers/platform/x86/sony-laptop.c
> @@ -2113,7 +2113,7 @@ static ssize_t sony_nc_thermal_mode_show(struct device *dev,
>  		struct device_attribute *attr, char *buffer)
>  {
>  	ssize_t count = 0;
> -	unsigned int mode = sony_nc_thermal_mode_get();
> +	int mode = sony_nc_thermal_mode_get();
>  
>  	if (mode < 0)
>  		return mode;
> @@ -2480,7 +2480,7 @@ static void sony_nc_backlight_ng_read_limits(int handle,
>  	props->maxlvl = 0xff;
>  
>  	offset = sony_find_snc_handle(handle);

sony_find_snc_handle() should return an int, did something change ?

> -	if (offset < 0)
> +	if ((int)offset < 0)
>  		return;
>  
>  	/* try to read the boundaries from ACPI tables, if we fail the above





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

* Re: [patch] sony-laptop: fix a couple signedness bugs
@ 2012-06-07  9:47   ` walter harms
  0 siblings, 0 replies; 10+ messages in thread
From: walter harms @ 2012-06-07  9:47 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Mattia Dongili, Matthew Garrett, platform-driver-x86,
	kernel-janitors



Am 07.06.2012 10:22, schrieb Dan Carpenter:
> These need to be signed to handle negative error codes.
> 
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
> index 210d4ae..0a2f026 100644
> --- a/drivers/platform/x86/sony-laptop.c
> +++ b/drivers/platform/x86/sony-laptop.c
> @@ -2113,7 +2113,7 @@ static ssize_t sony_nc_thermal_mode_show(struct device *dev,
>  		struct device_attribute *attr, char *buffer)
>  {
>  	ssize_t count = 0;
> -	unsigned int mode = sony_nc_thermal_mode_get();
> +	int mode = sony_nc_thermal_mode_get();
>  
>  	if (mode < 0)
>  		return mode;
> @@ -2480,7 +2480,7 @@ static void sony_nc_backlight_ng_read_limits(int handle,
>  	props->maxlvl = 0xff;
>  
>  	offset = sony_find_snc_handle(handle);

sony_find_snc_handle() should return an int, did something change ?

> -	if (offset < 0)
> +	if ((int)offset < 0)
>  		return;
>  
>  	/* try to read the boundaries from ACPI tables, if we fail the above

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

* Re: [patch] sony-laptop: fix a couple signedness bugs
  2012-06-07  9:47   ` walter harms
@ 2012-06-07  9:59     ` Dan Carpenter
  -1 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2012-06-07  9:59 UTC (permalink / raw)
  To: walter harms
  Cc: Mattia Dongili, Matthew Garrett, platform-driver-x86,
	kernel-janitors

On Thu, Jun 07, 2012 at 11:47:30AM +0200, walter harms wrote:
> 
> 
> Am 07.06.2012 10:22, schrieb Dan Carpenter:
> > These need to be signed to handle negative error codes.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
> > index 210d4ae..0a2f026 100644
> > --- a/drivers/platform/x86/sony-laptop.c
> > +++ b/drivers/platform/x86/sony-laptop.c
> > @@ -2113,7 +2113,7 @@ static ssize_t sony_nc_thermal_mode_show(struct device *dev,
> >  		struct device_attribute *attr, char *buffer)
> >  {
> >  	ssize_t count = 0;
> > -	unsigned int mode = sony_nc_thermal_mode_get();
> > +	int mode = sony_nc_thermal_mode_get();
> >  
> >  	if (mode < 0)
> >  		return mode;
> > @@ -2480,7 +2480,7 @@ static void sony_nc_backlight_ng_read_limits(int handle,
> >  	props->maxlvl = 0xff;
> >  
> >  	offset = sony_find_snc_handle(handle);
> 
> sony_find_snc_handle() should return an int, did something change ?

offset is a u64.  It has to be 64 bit.  I thought about changing it
to s64, but decided to just cast it here instead.

regards,
dan carpenter

> 
> > -	if (offset < 0)
> > +	if ((int)offset < 0)
> >  		return;
> >  
> >  	/* try to read the boundaries from ACPI tables, if we fail the above
> 
> 
> 

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

* Re: [patch] sony-laptop: fix a couple signedness bugs
@ 2012-06-07  9:59     ` Dan Carpenter
  0 siblings, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2012-06-07  9:59 UTC (permalink / raw)
  To: walter harms
  Cc: Mattia Dongili, Matthew Garrett, platform-driver-x86,
	kernel-janitors

On Thu, Jun 07, 2012 at 11:47:30AM +0200, walter harms wrote:
> 
> 
> Am 07.06.2012 10:22, schrieb Dan Carpenter:
> > These need to be signed to handle negative error codes.
> > 
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> > 
> > diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
> > index 210d4ae..0a2f026 100644
> > --- a/drivers/platform/x86/sony-laptop.c
> > +++ b/drivers/platform/x86/sony-laptop.c
> > @@ -2113,7 +2113,7 @@ static ssize_t sony_nc_thermal_mode_show(struct device *dev,
> >  		struct device_attribute *attr, char *buffer)
> >  {
> >  	ssize_t count = 0;
> > -	unsigned int mode = sony_nc_thermal_mode_get();
> > +	int mode = sony_nc_thermal_mode_get();
> >  
> >  	if (mode < 0)
> >  		return mode;
> > @@ -2480,7 +2480,7 @@ static void sony_nc_backlight_ng_read_limits(int handle,
> >  	props->maxlvl = 0xff;
> >  
> >  	offset = sony_find_snc_handle(handle);
> 
> sony_find_snc_handle() should return an int, did something change ?

offset is a u64.  It has to be 64 bit.  I thought about changing it
to s64, but decided to just cast it here instead.

regards,
dan carpenter

> 
> > -	if (offset < 0)
> > +	if ((int)offset < 0)
> >  		return;
> >  
> >  	/* try to read the boundaries from ACPI tables, if we fail the above
> 
> 
> 

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

* Re: [patch] sony-laptop: fix a couple signedness bugs
  2012-06-07  9:59     ` Dan Carpenter
@ 2012-06-07 10:17       ` walter harms
  -1 siblings, 0 replies; 10+ messages in thread
From: walter harms @ 2012-06-07 10:17 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Mattia Dongili, Matthew Garrett, platform-driver-x86,
	kernel-janitors



Am 07.06.2012 11:59, schrieb Dan Carpenter:
> On Thu, Jun 07, 2012 at 11:47:30AM +0200, walter harms wrote:
>>
>>
>> Am 07.06.2012 10:22, schrieb Dan Carpenter:
>>> These need to be signed to handle negative error codes.
>>>
>>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>>>
>>> diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
>>> index 210d4ae..0a2f026 100644
>>> --- a/drivers/platform/x86/sony-laptop.c
>>> +++ b/drivers/platform/x86/sony-laptop.c
>>> @@ -2113,7 +2113,7 @@ static ssize_t sony_nc_thermal_mode_show(struct device *dev,
>>>  		struct device_attribute *attr, char *buffer)
>>>  {
>>>  	ssize_t count = 0;
>>> -	unsigned int mode = sony_nc_thermal_mode_get();
>>> +	int mode = sony_nc_thermal_mode_get();
>>>  
>>>  	if (mode < 0)
>>>  		return mode;
>>> @@ -2480,7 +2480,7 @@ static void sony_nc_backlight_ng_read_limits(int handle,
>>>  	props->maxlvl = 0xff;
>>>  
>>>  	offset = sony_find_snc_handle(handle);
>>
>> sony_find_snc_handle() should return an int, did something change ?
> 
> offset is a u64.  It has to be 64 bit.  I thought about changing it
> to s64, but decided to just cast it here instead.
> 
> regards,
> dan carpenter
> 

If it this function
 http://lxr.free-electrons.com/source/drivers/platform/x86/sony-laptop.c?a=powerpc#L817
it just returns an index expected to be <0x10.
also offset was an int
 http://lxr.free-electrons.com/source/drivers/platform/x86/sony-laptop.c?a=powerpc#L1563

it make we wonder why somebody made the change ...

never mind

re,
 wh


>>
>>> -	if (offset < 0)
>>> +	if ((int)offset < 0)
>>>  		return;
>>>  
>>>  	/* try to read the boundaries from ACPI tables, if we fail the above
>>
>>
>>
> 
> 

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

* Re: [patch] sony-laptop: fix a couple signedness bugs
@ 2012-06-07 10:17       ` walter harms
  0 siblings, 0 replies; 10+ messages in thread
From: walter harms @ 2012-06-07 10:17 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: Mattia Dongili, Matthew Garrett, platform-driver-x86,
	kernel-janitors



Am 07.06.2012 11:59, schrieb Dan Carpenter:
> On Thu, Jun 07, 2012 at 11:47:30AM +0200, walter harms wrote:
>>
>>
>> Am 07.06.2012 10:22, schrieb Dan Carpenter:
>>> These need to be signed to handle negative error codes.
>>>
>>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>>>
>>> diff --git a/drivers/platform/x86/sony-laptop.c b/drivers/platform/x86/sony-laptop.c
>>> index 210d4ae..0a2f026 100644
>>> --- a/drivers/platform/x86/sony-laptop.c
>>> +++ b/drivers/platform/x86/sony-laptop.c
>>> @@ -2113,7 +2113,7 @@ static ssize_t sony_nc_thermal_mode_show(struct device *dev,
>>>  		struct device_attribute *attr, char *buffer)
>>>  {
>>>  	ssize_t count = 0;
>>> -	unsigned int mode = sony_nc_thermal_mode_get();
>>> +	int mode = sony_nc_thermal_mode_get();
>>>  
>>>  	if (mode < 0)
>>>  		return mode;
>>> @@ -2480,7 +2480,7 @@ static void sony_nc_backlight_ng_read_limits(int handle,
>>>  	props->maxlvl = 0xff;
>>>  
>>>  	offset = sony_find_snc_handle(handle);
>>
>> sony_find_snc_handle() should return an int, did something change ?
> 
> offset is a u64.  It has to be 64 bit.  I thought about changing it
> to s64, but decided to just cast it here instead.
> 
> regards,
> dan carpenter
> 

If it this function
 http://lxr.free-electrons.com/source/drivers/platform/x86/sony-laptop.c?a=powerpc#L817
it just returns an index expected to be <0x10.
also offset was an int
 http://lxr.free-electrons.com/source/drivers/platform/x86/sony-laptop.c?a=powerpc#L1563

it make we wonder why somebody made the change ...

never mind

re,
 wh


>>
>>> -	if (offset < 0)
>>> +	if ((int)offset < 0)
>>>  		return;
>>>  
>>>  	/* try to read the boundaries from ACPI tables, if we fail the above
>>
>>
>>
> 
> 

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

* Re: [patch] sony-laptop: fix a couple signedness bugs
  2012-06-07 10:17       ` walter harms
@ 2012-06-07 21:42         ` Mattia Dongili
  -1 siblings, 0 replies; 10+ messages in thread
From: Mattia Dongili @ 2012-06-07 21:42 UTC (permalink / raw)
  To: walter harms
  Cc: Dan Carpenter, Matthew Garrett, platform-driver-x86,
	kernel-janitors

On Thu, Jun 07, 2012 at 12:17:37PM +0200, walter harms wrote:
> 
> 
> Am 07.06.2012 11:59, schrieb Dan Carpenter:
> > On Thu, Jun 07, 2012 at 11:47:30AM +0200, walter harms wrote:
> >>
> >>
> >> Am 07.06.2012 10:22, schrieb Dan Carpenter:
> >>> These need to be signed to handle negative error codes.
> >>>
> >>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks Dan, I'll take this and the other patch you sent earlier and
submit to Matthew together with other patches I have pending here.
See below for a quick comment.

...
> >> sony_find_snc_handle() should return an int, did something change ?
> > 
> > offset is a u64.  It has to be 64 bit.  I thought about changing it
> > to s64, but decided to just cast it here instead.
> > 
> > regards,
> > dan carpenter
> > 
> 
> If it this function
>  http://lxr.free-electrons.com/source/drivers/platform/x86/sony-laptop.c?a=powerpc#L817
> it just returns an index expected to be <0x10.
> also offset was an int
>  http://lxr.free-electrons.com/source/drivers/platform/x86/sony-laptop.c?a=powerpc#L1563
> 
> it make we wonder why somebody made the change ...

it was changed to call into sony_nc_buffer_call which is a new function
(ebcef1b0e41f2ff972e5c5487a30e8f4ee2b6f13).

...
> >>> -	if (offset < 0)
> >>> +	if ((int)offset < 0)
> >>>  		return;

This check is actually redundant in a way as
sony_nc_backlight_ng_read_limits is only called with a valid handle.
Might as well remove the if statement altogether. sony_nc_rfkill_setup
has similar code without the check for a valid offset.

Thanks
-- 
mattia
:wq!

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

* Re: [patch] sony-laptop: fix a couple signedness bugs
@ 2012-06-07 21:42         ` Mattia Dongili
  0 siblings, 0 replies; 10+ messages in thread
From: Mattia Dongili @ 2012-06-07 21:42 UTC (permalink / raw)
  To: walter harms
  Cc: Dan Carpenter, Matthew Garrett, platform-driver-x86,
	kernel-janitors

On Thu, Jun 07, 2012 at 12:17:37PM +0200, walter harms wrote:
> 
> 
> Am 07.06.2012 11:59, schrieb Dan Carpenter:
> > On Thu, Jun 07, 2012 at 11:47:30AM +0200, walter harms wrote:
> >>
> >>
> >> Am 07.06.2012 10:22, schrieb Dan Carpenter:
> >>> These need to be signed to handle negative error codes.
> >>>
> >>> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Thanks Dan, I'll take this and the other patch you sent earlier and
submit to Matthew together with other patches I have pending here.
See below for a quick comment.

...
> >> sony_find_snc_handle() should return an int, did something change ?
> > 
> > offset is a u64.  It has to be 64 bit.  I thought about changing it
> > to s64, but decided to just cast it here instead.
> > 
> > regards,
> > dan carpenter
> > 
> 
> If it this function
>  http://lxr.free-electrons.com/source/drivers/platform/x86/sony-laptop.c?a=powerpc#L817
> it just returns an index expected to be <0x10.
> also offset was an int
>  http://lxr.free-electrons.com/source/drivers/platform/x86/sony-laptop.c?a=powerpc#L1563
> 
> it make we wonder why somebody made the change ...

it was changed to call into sony_nc_buffer_call which is a new function
(ebcef1b0e41f2ff972e5c5487a30e8f4ee2b6f13).

...
> >>> -	if (offset < 0)
> >>> +	if ((int)offset < 0)
> >>>  		return;

This check is actually redundant in a way as
sony_nc_backlight_ng_read_limits is only called with a valid handle.
Might as well remove the if statement altogether. sony_nc_rfkill_setup
has similar code without the check for a valid offset.

Thanks
-- 
mattia
:wq!

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

end of thread, other threads:[~2012-06-07 21:42 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-07  8:22 [patch] sony-laptop: fix a couple signedness bugs Dan Carpenter
2012-06-07  8:22 ` Dan Carpenter
2012-06-07  9:47 ` walter harms
2012-06-07  9:47   ` walter harms
2012-06-07  9:59   ` Dan Carpenter
2012-06-07  9:59     ` Dan Carpenter
2012-06-07 10:17     ` walter harms
2012-06-07 10:17       ` walter harms
2012-06-07 21:42       ` Mattia Dongili
2012-06-07 21:42         ` Mattia Dongili

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.