[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] lib: make memchr_inv() compliant with Misra rule 11.8



commit 9e4bca2fae2a849bd25fefd7c0c645fb5821e056
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Thu Nov 5 09:47:43 2026 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Thu Nov 5 09:47:43 2026 +0100

    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 <jbeulich@xxxxxxxx>
    Reviewed-by: Dmytro Prokopchuk <dmytro_prokopchuk1@xxxxxxxx>
---
 xen/include/xen/string.h | 2 +-
 xen/lib/memchr_inv.c     | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/xen/include/xen/string.h b/xen/include/xen/string.h
index 0ad65303da..6e077f0a03 100644
--- a/xen/include/xen/string.h
+++ b/xen/include/xen/string.h
@@ -33,7 +33,7 @@ void *memcpy(void *dest, const void *src, size_t n);
 void *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>
 
diff --git a/xen/lib/memchr_inv.c b/xen/lib/memchr_inv.c
index 1bf6cb6ee0..e082e09a54 100644
--- a/xen/lib/memchr_inv.c
+++ b/xen/lib/memchr_inv.c
@@ -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;
 }
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.