Skip to contentSkip to conversation

ARM: boot: add strrchr function

PATCH New Rob Herring 1 participant 1 message Mar 1, 2018 Arm (32-bit)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 ARM: boot: add strrchr function

libfdt gained a new dependency on strrchr, so copy the implementation from lib/string.c.

Cc Russell King <[email protected]>
Cc linux-arm-kernel at lists.infradead.org

---
Please ack. This is a dependency for dtc/libfdt sync with upstream.

 arch/arm/boot/compressed/string.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
arch/arm/boot/compressed/string.c +10 -0
index 13c90abc68d6..ade5079bebbf 100644
@@ -121,6 +121,16 @@ char *strchr(const char *s, int c)
 	return (char *)s;
 }
 
+char *strrchr(const char *s, int c)
+{
+	const char *last = NULL;
+	do {
+		if (*s == (char)c)
+			last = s;
+	} while (*s++);
+	return (char *)last;
+}
+
 #undef memset
 
 void *memset(void *s, int c, size_t count)
Signature · 1 line
2.14.1