[PATCH] acpi: crsdump: fix portability warning from cppcheck

Colin King colin.king at canonical.com
Wed May 13 00:54:12 UTC 2020


From: Colin Ian King <colin.king at canonical.com>

cppcheck detected an implementation defined behaviour issue,
fix this by making 1 an unsigned integer value before shifing
it.

src/acpi/crsdump/crsdump.c:321:17: portability: Shifting signed
32-bit value by 31 bits is implementation-defined behaviour
[shiftTooManyBitsSigned]

Signed-off-by: Colin Ian King <colin.king at canonical.com>
---
 src/acpi/crsdump/crsdump.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/acpi/crsdump/crsdump.c b/src/acpi/crsdump/crsdump.c
index 5c68f802..86f8b016 100644
--- a/src/acpi/crsdump/crsdump.c
+++ b/src/acpi/crsdump/crsdump.c
@@ -318,7 +318,7 @@ static const char *crs_irq_map(const uint64_t val)
 		unsigned int i;
 
 		for (i = 0; i < 32; i++) {
-			if (val & (1 << i)) {
+			if (val & (1UL << i)) {
 				char tmp[5];
 
 				snprintf(tmp, sizeof(tmp), " %u", i);
-- 
2.25.1




More information about the fwts-devel mailing list