On 07/01/2019 10:39, Jan Beulich wrote:
> It has no users, so rather than fixing its use of types (first and
> foremost c would need to be cast to unsigned char in the comparison
> expression) drop it altogether. memchr() ought to be fine for all
> purposes.
> 
> Take the opportunity and also do some stylistic adjustments to its
> surviving sibling function memchr().
> 
> Signed-off-by: Jan Beulich <[email protected]>
> 
> --- a/xen/common/string.c
> +++ b/xen/common/string.c
> @@ -380,30 +380,6 @@ int (memcmp)(const void *cs, const void
>  }
>  #endif
>  
> -#ifndef __HAVE_ARCH_MEMSCAN
> -/**
> - * memscan - Find a character in an area of memory.
> - * @addr: The memory area
> - * @c: The byte to search for
> - * @size: The size of the area.
> - *
> - * returns the address of the first occurrence of @c, or 1 byte past
> - * the area if @c is not found
> - */
> -void * memscan(void * addr, int c, size_t size)
> -{
> -     unsigned char * p = (unsigned char *) addr;
> -
> -     while (size) {
> -             if (*p == c)
> -                     return (void *) p;
> -             p++;
> -             size--;
> -     }
> -     return (void *) p;
> -}
> -#endif
> -
>  #ifndef __HAVE_ARCH_STRSTR
>  /**
>   * strstr - Find the first substring in a %NUL terminated string
> @@ -441,14 +417,13 @@ char *(strstr)(const char *s1, const cha
>  void *(memchr)(const void *s, int c, size_t n)
>  {
>       const unsigned char *p = s;
> -     while (n-- != 0) {
> -             if ((unsigned char)c == *p++) {
> -                     return (void *)(p-1);
> -             }
> -     }
> +
> +     while (n--)
> +             if ((unsigned char)c == *p++)

White space damage.


Juergen

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xenproject.org/mailman/listinfo/xen-devel

Reply via email to