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

[Xen-changelog] [xen master] string: remove memscan()



commit c07186ca6665a59d8461140218cb8b53df4133fc
Author:     Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Wed Mar 13 11:25:04 2019 +0100
Commit:     Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Wed Mar 13 11:25:04 2019 +0100

    string: remove memscan()
    
    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 <jbeulich@xxxxxxxx>
    Acked-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx>
---
 xen/common/string.c      | 35 +++++------------------------------
 xen/include/xen/string.h |  4 ----
 2 files changed, 5 insertions(+), 34 deletions(-)

diff --git a/xen/common/string.c b/xen/common/string.c
index b8639dd30d..dafeaa827d 100644
--- a/xen/common/string.c
+++ b/xen/common/string.c
@@ -380,30 +380,6 @@ int (memcmp)(const void *cs, const void *ct, size_t count)
 }
 #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 char *s2)
 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++)
+                       return (void *)(p - 1);
+
        return NULL;
 }
-
 #endif
 
 /*
diff --git a/xen/include/xen/string.h b/xen/include/xen/string.h
index 853db2f6b4..711cb60a7d 100644
--- a/xen/include/xen/string.h
+++ b/xen/include/xen/string.h
@@ -96,10 +96,6 @@ void *memmove(void *, const void *, size_t);
 #define memmove(d, s, n) __builtin_memmove(d, s, n)
 #endif
 
-#ifndef __HAVE_ARCH_MEMSCAN
-void *memscan(void *, int, size_t);
-#endif
-
 #ifndef __HAVE_ARCH_MEMCMP
 int memcmp(const void *, const void *, size_t);
 #define memcmp(s1, s2, n) __builtin_memcmp(s1, s2, n)
--
generated by git-patchbot for /home/xen/git/xen.git#master

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/xen-changelog

 


Rackspace

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