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

Keng-Yu Lin keng-yu.lin at canonical.com
Fri Sep 12 05:21:54 UTC 2014


On Thu, Sep 11, 2014 at 10:05 PM, Colin King <colin.king at canonical.com> 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)
> --
> 2.1.0
>
>

Acked-by: Keng-Yu Lin <kengyu at canonical.com>



More information about the fwts-devel mailing list