[PATCH] acpi: dmar: fix portability warning from cppcheck on void * cast

Colin King colin.king at canonical.com
Wed Aug 17 09:21:47 UTC 2016


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

Minor fix, ensure we don't do void * pointer arithmeti as the behaviour
is undefined (even though most compilers assume it is a char * sized).
Cast to char * before doing the addition.

Fixes cppcheck portability warning:

[src/acpi/dmar/dmar.c:281]: (portability) '(void*)header' is of type 'void *'.
When using void pointers in calculations, the behaviour is undefined.

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

diff --git a/src/acpi/dmar/dmar.c b/src/acpi/dmar/dmar.c
index 899d366..6dbc1f3 100644
--- a/src/acpi/dmar/dmar.c
+++ b/src/acpi/dmar/dmar.c
@@ -278,7 +278,8 @@ static int dmar_acpi_table_check(fwts_framework *fw)
 			failed++;
 			break;
 		}
-		header = ((void *)header) + header->length;
+		header = (struct acpi_dmar_entry_header *)
+				(((char *)header) + header->length);
 	}
 
 	if (!failed)
-- 
2.8.1




More information about the fwts-devel mailing list