From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755931AbbCRShS (ORCPT ); Wed, 18 Mar 2015 14:37:18 -0400 Received: from mail-pd0-f169.google.com ([209.85.192.169]:36240 "EHLO mail-pd0-f169.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754372AbbCRShR (ORCPT ); Wed, 18 Mar 2015 14:37:17 -0400 From: Arjun Sreedharan To: Bernd Petrovitsch Cc: Ingo Molnar , "H. Peter Anvin" , Thomas Gleixner , Ingo Molnar , x86@kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] x86,boot: standardize strcmp() Date: Thu, 19 Mar 2015 00:07:01 +0530 Message-Id: <1426703821-2099-1-git-send-email-arjun024@gmail.com> X-Mailer: git-send-email 1.7.11.7 In-Reply-To: <1426642573.20946.2.camel@thorin> References: <1426642573.20946.2.camel@thorin> Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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 --- 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++; } --