platform/x86: fujitsu-laptop: Revert UNSUPPORTED_CMD back to an int
Subsystems (2)
PATCH 1/1 platform/x86: fujitsu-laptop: Revert UNSUPPORTED_CMD back to an int
UNSUPPORTED_CMD was previously 0x80000000 (int), but commit 819cddae7cfa ("platform/x86: fujitsu-laptop: Clean up constants") changed it into an unsigned long due to BIT() being used to define it. As call_fext_func() returns an int, 0x80000000 would get type promoted when compared to an unsigned long, which on a 64-bit system would cause it to become 0xffffffff80000000 due to sign extension. This causes one logical condition in fujitsu-laptop to always be true and another one to always be false on 64-bit systems. Fix this by reverting UNSUPPORTED_CMD back to an int.
This patch fixes the following smatch warnings:
drivers/platform/x86/fujitsu-laptop.c:763 acpi_fujitsu_laptop_leds_register() warn: always true condition '(call_fext_func(device, ((1 << (12)) | (1 << (0))), 2, (1 << (16)), 0) != (1 << (31))) => (s32min-s32max != 2147483648)' drivers/platform/x86/fujitsu-laptop.c:816 acpi_fujitsu_laptop_add() warn: impossible condition '(priv->flags_supported == (1 << (31))) => (0-2147483647,18446744071562067968-u64max == 2147483648)'
---
This fixes a bug introduced by a commit queued for 4.17, so it needs to be applied on top of for-next.
drivers/platform/x86/fujitsu-laptop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/platform/x86/fujitsu-laptop.c +1 -1
@@ -85,7 +85,7 @@#define FUNC_BACKLIGHT (BIT(12) | BIT(2))/* FUNC interface - responses */ -#define UNSUPPORTED_CMD BIT(31) +#define UNSUPPORTED_CMD 0x80000000/* FUNC interface - status flags */ #define FLAG_RFKILL BIT(5)
Signature · 1 line
2.16.2
Quoted 30 lines · Micha?? K??pie??
UNSUPPORTED_CMDwas previously0x80000000(int), but commit819cddae7cfa("platform/x86: fujitsu-laptop: Clean up constants") changed it into an unsigned long due toBIT()being used to define it. Ascall_fext_func()returns an int,0x80000000would get type promoted when compared to an unsigned long, which on a 64-bit system would cause it to become0xffffffff80000000due to sign extension. This causes one logical condition in fujitsu-laptop to always be true and another one to always be false on 64-bit systems. Fix this by revertingUNSUPPORTED_CMDback to an int.This patch fixes the following smatch warnings:
drivers/platform/x86/fujitsu-laptop.c:763acpi_fujitsu_laptop_leds_register()warn: always true condition '(call_fext_func(device, ((1 << (12)) | (1 << (0))), 2, (1 << (16)), 0)!= (1 << (31))) => (s32min-s32max != 2147483648)'drivers/platform/x86/fujitsu-laptop.c:816acpi_fujitsu_laptop_add()warn: impossible condition '(priv->flags_supported== (1 << (31))) => (0-2147483647,18446744071562067968-u64max == 2147483648)'Fixes 819cddae7cfa ("platform/x86: fujitsu-laptop: Clean up constants")Reported-by Dan Carpenter <[email protected]>Signed-off-by Micha?? K??pie?? <[email protected]>---
This fixes a bug introduced by a commit queued for 4.17, so it needs to be applied on top of for-next.drivers/platform/x86/fujitsu-laptop.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/platform/x86/fujitsu-laptop.c +0
-0
drivers/platform/x86/fujitsu-laptop.c line 91
Quoted 8 lines
drivers/platform/x86/fujitsu-laptop.c +1
-1@@ -85,7 +85,7 @@#define FUNC_BACKLIGHT (BIT(12) | BIT(2))/* FUNC interface - responses */ -#define UNSUPPORTED_CMD BIT(31) +#define UNSUPPORTED_CMD 0x80000000/* FUNC interface - status flags */ #define FLAG_RFKILL BIT(5)
This looks like a sensible, succinct solution to the regression.
Regards
jonathan
Darren Hart
AppliedQuoted 11 lines · Jonathan Woithe
Quoted 10 lines · Micha?? K??pie??
UNSUPPORTED_CMDwas previously0x80000000(int), but commit819cddae7cfa("platform/x86: fujitsu-laptop: Clean up constants") changed it into an unsigned long due toBIT()being used to define it. Ascall_fext_func()returns an int,0x80000000would get type promoted when compared to an unsigned long, which on a 64-bit system would cause it to become0xffffffff80000000due to sign extension. This causes one logical condition in fujitsu-laptop to always be true and another one to always be false on 64-bit systems. Fix this by revertingUNSUPPORTED_CMDback to an int.
Quoted 8 lines
Quoted 8 lines
This patch fixes the following smatch warnings:
drivers/platform/x86/fujitsu-laptop.c:763acpi_fujitsu_laptop_leds_register()warn: always true condition '(call_fext_func(device, ((1 << (12)) | (1 << (0))), 2, (1 << (16)), 0)!= (1 << (31))) => (s32min-s32max != 2147483648)'drivers/platform/x86/fujitsu-laptop.c:816acpi_fujitsu_laptop_add()warn: impossible condition '(priv->flags_supported== (1 << (31))) => (0-2147483647,18446744071562067968-u64max == 2147483648)'Fixes 819cddae7cfa ("platform/x86: fujitsu-laptop: Clean up constants")Reported-by Dan Carpenter <[email protected]>Signed-off-by Micha?? K??pie?? <[email protected]>
Queued up, thank you.
Signature · 2 lines
Darren Hart VMware Open Source Technology Center