ACK: [PATCH 2/5] acpi: dmar: avoid using void * pointer arithmetic

Alex Hung alex.hung at canonical.com
Tue Sep 16 02:02:31 UTC 2014


On 14-09-11 10:05 PM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> cppcheck reports:
>    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 | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/src/acpi/dmar/dmar.c b/src/acpi/dmar/dmar.c
> index d725aa5..329adc3 100644
> --- a/src/acpi/dmar/dmar.c
> +++ b/src/acpi/dmar/dmar.c
> @@ -187,13 +187,13 @@ error:
>   }
>   
>   static int acpi_parse_dev_scope(fwts_framework *fw,
> -	void *start, void *end, const uint16_t seg)
> +	uint8_t *start, uint8_t *end, const uint16_t seg)
>   {
>   	struct acpi_dev_scope *scope;
>   	int ret;
>   
>   	while (start < end) {
> -		scope = start;
> +		scope = (struct acpi_dev_scope *)start;
>   		ret = acpi_parse_one_dev_scope(fw, scope, seg);
>   		if (ret)
>   			return ret;
> @@ -221,8 +221,8 @@ static int acpi_parse_one_drhd(fwts_framework *fw,
>   		}
>   		include_all = 1;
>   	} else {
> -		return acpi_parse_dev_scope(fw, (void *)(drhd + 1),
> -			((void *)drhd) + header->length, drhd->segment);
> +		return acpi_parse_dev_scope(fw, (uint8_t *)(drhd + 1),
> +			((uint8_t *)drhd) + header->length, drhd->segment);
>   	}
>   	return FWTS_OK;
>   }
> @@ -239,8 +239,8 @@ static int acpi_parse_one_rmrr(fwts_framework *fw,
>   			"Invalid rmrr range address.");
>   		return FWTS_ERROR;
>   	}
> -	return acpi_parse_dev_scope(fw, (void *)(rmrr + 1),
> -		((void*)rmrr) + header->length, rmrr->segment);
> +	return acpi_parse_dev_scope(fw, (uint8_t *)(rmrr + 1),
> +		((uint8_t *)rmrr) + header->length, rmrr->segment);
>   }
>   
>   static int dmar_acpi_table_check(fwts_framework *fw)


Acked-by: Alex Hung <alex.hung at canonical.com>



More information about the fwts-devel mailing list