[PATCH 5/5] lib: fwts_multiproc: avoid using void * pointer arithmetic

Keng-Yu Lin keng-yu.lin at canonical.com
Fri Sep 12 05:25:18 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/lib/src/fwts_multiproc.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/src/lib/src/fwts_multiproc.c b/src/lib/src/fwts_multiproc.c
> index 2d17948..69084e9 100644
> --- a/src/lib/src/fwts_multiproc.c
> +++ b/src/lib/src/fwts_multiproc.c
> @@ -78,7 +78,7 @@ static int fwts_mp_get_address(uint32_t *phys_addr)
>                 if ((mem = fwts_mmap(start, size)) == FWTS_MAP_FAILED)
>                         continue;
>
> -               for (ptr = mem; ptr < (uint8_t*)(mem + size); ptr+=16) {
> +               for (ptr = mem; ptr < (uint8_t*)mem + size; ptr+=16) {
>                         if ((*ptr == '_') &&
>                             (*(ptr + 1) == 'M') &&
>                             (*(ptr + 2) == 'P') &&
> @@ -176,7 +176,7 @@ int fwts_mp_data_get(fwts_mp_data *data)
>                         tmp += sizeof(fwts_mp_compat_bus_address_space_entry);
>                         break;
>                 default:
> -                       tmp = mem + data->size; /* Force abort */
> +                       tmp = (uint8_t *)mem + data->size; /* Force abort */
>                         break;
>                 }
>         }
> --
> 2.1.0
>
>

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



More information about the fwts-devel mailing list