Skip to contentSkip to conversation

sony-laptop: fix a couple signedness bugs

PATCH In review Dan Carpenter 3 participants 5 messages Jun 7, 2012

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 sony-laptop: fix a couple signedness bugs

These need to be signed to handle negative error codes.

drivers/platform/x86/sony-laptop.c +2 -2
index 210d4ae..0a2f026 100644
@@ -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
#1 lore raw

Am 07.06.2012 10:22, schrieb Dan Carpenter:

Quoted 18 lines

These need to be signed to handle negative error codes.

drivers/platform/x86/sony-laptop.c +1 -1
index 210d4ae..0a2f026 100644
@@ -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;

drivers/platform/x86/sony-laptop.c static void sony_nc_backlight_ng_read_limits(int handle, · line 2482

Quoted 3 lines
drivers/platform/x86/sony-laptop.c +0 -0
@@ -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 ?

Quoted 5 lines
drivers/platform/x86/sony-laptop.c +1 -1
-	if (offset < 0)
+	if ((int)offset < 0)
 		return;
 
 	/* try to read the boundaries from ACPI tables, if we fail the above
#2 lore raw
Quoted 18 lines · walter harms

Am 07.06.2012 10:22, schrieb Dan Carpenter:

Quoted 15 lines

These need to be signed to handle negative error codes.

drivers/platform/x86/sony-laptop.c +1 -1
index 210d4ae..0a2f026 100644
@@ -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();
 
Quoted 8 lines

drivers/platform/x86/sony-laptop.c static void sony_nc_backlight_ng_read_limits(int handle, · line 2482

Quoted 6 lines
drivers/platform/x86/sony-laptop.c +0 -0
 	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

Quoted 9 lines
Quoted 6 lines
drivers/platform/x86/sony-laptop.c +1 -1
-	if (offset < 0)
+	if ((int)offset < 0)
 		return;
 
 	/* try to read the boundaries from ACPI tables, if we fail the above
#3 lore raw

Am 07.06.2012 11:59, schrieb Dan Carpenter:

Quoted 28 lines · walter harms
Quoted 18 lines

Am 07.06.2012 10:22, schrieb Dan Carpenter:

Quoted 15 lines

These need to be signed to handle negative error codes.

drivers/platform/x86/sony-laptop.c +1 -1
index 210d4ae..0a2f026 100644
@@ -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();
 
Quoted 8 lines

drivers/platform/x86/sony-laptop.c static void sony_nc_backlight_ng_read_limits(int handle, · line 2482

Quoted 6 lines
drivers/platform/x86/sony-laptop.c +0 -0
 	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 ?

Quoted 6 lines

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

Quoted 11 lines
Quoted 9 lines
Quoted 6 lines
drivers/platform/x86/sony-laptop.c +1 -1
-	if (offset < 0)
+	if ((int)offset < 0)
 		return;
 
 	/* try to read the boundaries from ACPI tables, if we fail the above
maintainer
#4 lore raw
Quoted 10 lines · walter harms

Am 07.06.2012 11:59, schrieb Dan Carpenter:

Quoted 7 lines · walter harms
Quoted 6 lines

Am 07.06.2012 10:22, schrieb Dan Carpenter:

Quoted 3 lines

These need to be signed to handle negative error codes.

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.

...

Quoted 9 lines
Quoted 8 lines
Quoted 1 line

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

Quoted 7 lines

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).

...

Quoted 3 lines
Quoted 3 lines
Quoted 3 lines

drivers/platform/x86/sony-laptop.c static void sony_nc_backlight_ng_read_limits(int handle, · line 2484

Quoted 3 lines
drivers/platform/x86/sony-laptop.c +1 -1
-	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

Signature · 2 lines
mattia
:wq!