ACK: [PATCH] acpi: dmar: fix portability warning from cppcheck on void * cast
ivanhu
ivan.hu at canonical.com
Thu Aug 18 02:28:27 UTC 2016
On 2016年07月26日 04:36, Colin King wrote:
> 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)
>
Acked-by: Ivan Hu <ivan.hu at canonical.com>
More information about the fwts-devel
mailing list