]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
powerpc: boot: add strrchr function
authorRob Herring <robh@kernel.org>
Thu, 1 Mar 2018 14:57:40 +0000 (08:57 -0600)
committerRob Herring <robh@kernel.org>
Tue, 6 Mar 2018 02:58:17 +0000 (20:58 -0600)
libfdt gained a new dependency on strrchr, so copy the implementation
from lib/string.c. Most of the string functions are in assembly, but
stdio.c already has strnlen, so add strrchr there.

Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Cc: Paul Mackerras <paulus@samba.org>
Acked-by: Michael Ellerman <mpe@ellerman.id.au>
Signed-off-by: Rob Herring <robh@kernel.org>
arch/powerpc/boot/stdio.c
arch/powerpc/boot/string.h

index a701261b17818118f824221e81a7177d09f004b4..98042eff7b2628be045a3948f78daccedfb993b4 100644 (file)
@@ -21,6 +21,16 @@ size_t strnlen(const char * s, size_t count)
        return sc - s;
 }
 
+char *strrchr(const char *s, int c)
+{
+       const char *last = NULL;
+       do {
+               if (*s == (char)c)
+                       last = s;
+       } while (*s++);
+       return (char *)last;
+}
+
 #ifdef __powerpc64__
 
 # define do_div(n, base) ({                                            \
index 3fb71171da49909e10a0d2b1817bcb6090f711de..8c2ec0c05e4e064d53371163d6a374a76984a47a 100644 (file)
@@ -7,6 +7,7 @@ extern char *strcpy(char *dest, const char *src);
 extern char *strncpy(char *dest, const char *src, size_t n);
 extern char *strcat(char *dest, const char *src);
 extern char *strchr(const char *s, int c);
+extern char *strrchr(const char *s, int c);
 extern int strcmp(const char *s1, const char *s2);
 extern int strncmp(const char *s1, const char *s2, size_t n);
 extern size_t strlen(const char *s);