diff mbox

[RFC,01/12] ARM: Add strstr to the decompressor

Message ID 20120715024608.227203804@gmail.com (mailing list archive)
State New, archived
Headers show

Commit Message

Domenico Andreoli July 15, 2012, 2:44 a.m. UTC
From: Domenico Andreoli <domenico.andreoli@linux.com>

This is a classic that doesn't need presentations, it comes directly
from lib/string.c so the credits are not mine at all.

We use it to extract the console device name from the kernel command line.

Signed-off-by: Domenico Andreoli <domenico.andreoli@linux.com>

---
 arch/arm/boot/compressed/string.c |   17 +++++++++++++++++
 1 file changed, 17 insertions(+)
diff mbox

Patch

Index: b/arch/arm/boot/compressed/string.c
===================================================================
--- a/arch/arm/boot/compressed/string.c
+++ b/arch/arm/boot/compressed/string.c
@@ -93,6 +93,23 @@  int strcmp(const char *cs, const char *c
 	return res;
 }
 
+char *strstr(const char *s1, const char *s2)
+{
+	size_t l1, l2;
+
+	l2 = strlen(s2);
+	if (!l2)
+		return (char *)s1;
+	l1 = strlen(s1);
+	while (l1 >= l2) {
+		l1--;
+		if (!memcmp(s1, s2, l2))
+			return (char *)s1;
+		s1++;
+	}
+	return NULL;
+}
+
 void *memchr(const void *s, int c, size_t count)
 {
 	const unsigned char *p = s;