ACK: [PATCH] lib: fwts_safe_mem: don't perform void * pointer arithmetic, fix 32 bit end
Alex Hung
alex.hung at canonical.com
Wed Jan 24 03:39:34 UTC 2018
On 2018-01-23 04:05 AM, Colin King wrote:
> From: Colin Ian King <colin.king at canonical.com>
>
> Don't perform void * pointer arithmetic, it is non-portable. Fix the 32 bit
> fwts_safe_memread32 end pointer; it is the start + number of 32 bit words
> rather than start + n bytes. Also fix up comment to the fwts_safe_memread32
> function name.
>
> Signed-off-by: Colin Ian King <colin.king at canonical.com>
> ---
> src/lib/src/fwts_safe_mem.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/src/lib/src/fwts_safe_mem.c b/src/lib/src/fwts_safe_mem.c
> index 7436977f..199b27f6 100644
> --- a/src/lib/src/fwts_safe_mem.c
> +++ b/src/lib/src/fwts_safe_mem.c
> @@ -69,7 +69,7 @@ int OPTIMIZE0 fwts_safe_memcpy(void *dst, const void *src, const size_t n)
> int OPTIMIZE0 fwts_safe_memread(const void *src, const size_t n)
> {
> static uint8_t buffer[256];
> - const uint8_t *ptr, *end = src + n;
> + const uint8_t *ptr, *end = (const uint8_t *)src + n;
> uint8_t *bufptr;
> const uint8_t *bufend = buffer + sizeof(buffer);
>
> @@ -94,7 +94,7 @@ int OPTIMIZE0 fwts_safe_memread(const void *src, const size_t n)
> }
>
> /*
> - * fwts_safe_memread()
> + * fwts_safe_memread32()
> * check we can safely read a region of memory. This catches
> * SIGSEGV/SIGBUS errors and returns FWTS_ERROR if it is not
> * readable or FWTS_OK if it's OK.
> @@ -104,7 +104,7 @@ int OPTIMIZE0 fwts_safe_memread(const void *src, const size_t n)
> int OPTIMIZE0 fwts_safe_memread32(const void *src, const size_t n)
> {
> static uint32_t buffer[256];
> - const uint32_t *ptr, *end = src + n;
> + const uint32_t *ptr, *end = (uint32_t *)src + n;
> uint32_t *bufptr;
> const uint32_t *bufend = buffer + (sizeof(buffer) / sizeof(*buffer));
>
>
Acked-by: Alex Hung <alex.hung at canonical.com>
More information about the fwts-devel
mailing list