lib: make memchr_inv() compliant with Misra rule 11.8
PATCH 1/1 lib: make memchr_inv() compliant with Misra rule 11.8
Neither the sole present caller nor the two ones pending (in the AMX/ACE series on x86) require the casting away of constness.
Signed-off-by Jan Beulich <[email protected]>
xen/include/xen/string.h +1 -1
@@ -33,7 +33,7 @@ void *memcpy(void *dest, const void *srcvoid *memmove (void *dest,const void *src,size_t n);int memcmp (const void *cs,const void *ct,size_t count);void *memchr (const void *s,int c,size_t n); -void *memchr_inv (const void *s,int c,size_t n); +const void *memchr_inv (const void *s,int c,size_t n);#include <asm/string.h>
xen/lib/memchr_inv.c +2 -2
@@ -13,13 +13,13 @@* returns the address of the first occurrence of a character other than @c, * or %NULL if the whole buffer contains just @c. */ -void *memchr_inv (const void *s,int c,size_t n) +const void *memchr_inv (const void *s,int c,size_t n) {const unsigned char *p = s;while (n--)if ((unsigned char )c != *p++) -return (void *)(p -1 ); +return p -1 ;return NULL ; }
Quoted 24 lines · Jan Beulich
Neither the sole present caller nor the two ones pending (in the AMX/ACE series on x86) require the casting away of constness.
Signed-off-by Jan Beulich <[email protected]>xen/include/xen/string.h +1
-1@@ -33,7 +33,7 @@ void *memcpy(void *dest, const void *srcvoid *memmove (void *dest,const void *src,size_t n);int memcmp (const void *cs,const void *ct,size_t count);void *memchr (const void *s,int c,size_t n); -void *memchr_inv (const void *s,int c,size_t n); +const void *memchr_inv (const void *s,int c,size_t n);#include <asm/string.h> xen/lib/memchr_inv.c +1
-1@@ -13,13 +13,13 @@* returns the address of the first occurrence of a character other than @c, * or %NULL if the whole buffer contains just @c. */ -void *memchr_inv (const void *s,int c,size_t n) +const void *memchr_inv (const void *s,int c,size_t n)
xen/lib/memchr_inv.c line 25
Quoted 10 lines
xen/lib/memchr_inv.c +1
-1{const unsigned char *p = s;while (n--)if ((unsigned char )c != *p++) -return (void *)(p -1 ); +return p -1 ;return NULL ; }
Reviewed-by Dmytro Prokopchuk <[email protected]>
BR, Dmytro.