Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

powerpc: boot: add strrchr function

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>

+11
+10
arch/powerpc/boot/stdio.c
··· 21 21 return sc - s; 22 22 } 23 23 24 + char *strrchr(const char *s, int c) 25 + { 26 + const char *last = NULL; 27 + do { 28 + if (*s == (char)c) 29 + last = s; 30 + } while (*s++); 31 + return (char *)last; 32 + } 33 + 24 34 #ifdef __powerpc64__ 25 35 26 36 # define do_div(n, base) ({ \
+1
arch/powerpc/boot/string.h
··· 7 7 extern char *strncpy(char *dest, const char *src, size_t n); 8 8 extern char *strcat(char *dest, const char *src); 9 9 extern char *strchr(const char *s, int c); 10 + extern char *strrchr(const char *s, int c); 10 11 extern int strcmp(const char *s1, const char *s2); 11 12 extern int strncmp(const char *s1, const char *s2, size_t n); 12 13 extern size_t strlen(const char *s);