lkml.org 
[lkml]   [2015]   [Mar]   [18]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patch in this message
/
From
Subject[PATCH] x86,boot: standardize strcmp()
Date
Sorry for the previous messed up email.
Here's a patch.

-- >8 --

Subject: [PATCH] arm,x86: limit strcmp() rc to {-1,0,1}

Signed-off-by: Arjun Sreedharan <arjun024@gmail.com>
---
arch/arm/boot/compressed/string.c | 2 +-
arch/x86/boot/string.c | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/arm/boot/compressed/string.c b/arch/arm/boot/compressed/string.c
index 36e53ef..e48df86 100644
--- a/arch/arm/boot/compressed/string.c
+++ b/arch/arm/boot/compressed/string.c
@@ -88,7 +88,7 @@ int strcmp(const char *cs, const char *ct)
c2 = *ct++;
res = c1 - c2;
if (res)
- break;
+ return res < 0 ? -1 : 1;
} while (c1);
return res;
}
diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c
index 318b846..6eb333e 100644
--- a/arch/x86/boot/string.c
+++ b/arch/x86/boot/string.c
@@ -32,7 +32,7 @@ int strcmp(const char *str1, const char *str2)
while (*s1 || *s2) {
delta = *s1 - *s2;
if (delta)
- return delta;
+ return delta < 0 ? -1 : 1;
s1++;
s2++;
}
--


\
 
 \ /
  Last update: 2015-03-18 20:21    [W:0.209 / U:0.096 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site