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@suse.com>
--- a/xen/include/xen/string.h
+++ b/xen/include/xen/string.h
@@ -33,7 +33,7 @@ void *memcpy(void *dest, const void *src
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>
--- 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;
}
On 11/3/26 13:24, Jan Beulich wrote:
> 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@suse.com>
>
> --- a/xen/include/xen/string.h
> +++ b/xen/include/xen/string.h
> @@ -33,7 +33,7 @@ void *memcpy(void *dest, const void *src
> 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>
>
> --- 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;
> }
Reviewed-by: Dmytro Prokopchuk <dmytro_prokopchuk1@epam.com>
BR, Dmytro.
© 2016 - 2026 Red Hat, Inc.