From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753008AbbCWMXs (ORCPT ); Mon, 23 Mar 2015 08:23:48 -0400 Received: from terminus.zytor.com ([198.137.202.10]:41324 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752480AbbCWMXq (ORCPT ); Mon, 23 Mar 2015 08:23:46 -0400 Date: Mon, 23 Mar 2015 05:23:32 -0700 From: tip-bot for Arjun Sreedharan Message-ID: Cc: hpa@zytor.com, arjun024@gmail.com, mingo@kernel.org, linux-kernel@vger.kernel.org, bp@suse.de, tglx@linutronix.de Reply-To: mingo@kernel.org, hpa@zytor.com, arjun024@gmail.com, bp@suse.de, tglx@linutronix.de, linux-kernel@vger.kernel.org In-Reply-To: <1426520267-1803-1-git-send-email-arjun024@gmail.com> References: <1426520267-1803-1-git-send-email-arjun024@gmail.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/boot] x86/boot: Standardize strcmp() Git-Commit-ID: 1c1d046be692493d00a4831d4fbc266745008e09 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 1c1d046be692493d00a4831d4fbc266745008e09 Gitweb: http://git.kernel.org/tip/1c1d046be692493d00a4831d4fbc266745008e09 Author: Arjun Sreedharan AuthorDate: Mon, 16 Mar 2015 21:07:47 +0530 Committer: Ingo Molnar CommitDate: Mon, 23 Mar 2015 10:24:12 +0100 x86/boot: Standardize strcmp() strcmp() is always expected to return 0 when arguments are equal, negative when its first argument @str1 is less than its second argument @str2 and a positive value otherwise. Previously strcmp("a", "b") returned 1. Now it gives -1, as it is supposed to. Until now this bug never triggered, because all uses for strcmp() in the boot code tested for nonzero: triton:~/tip> git grep strcmp arch/x86/boot/ arch/x86/boot/boot.h:int strcmp(const char *str1, const char *str2); arch/x86/boot/edd.c: if (!strcmp(eddarg, "skipmbr") || !strcmp(eddarg, "skip")) { arch/x86/boot/edd.c: else if (!strcmp(eddarg, "off")) arch/x86/boot/edd.c: else if (!strcmp(eddarg, "on")) should in the future strcmp() be used in a comparative way in the boot code, it might have led to (not so subtle) bugs. Signed-off-by: Arjun Sreedharan Signed-off-by: Borislav Petkov Cc: H. Peter Anvin Cc: Thomas Gleixner Link: http://lkml.kernel.org/r/1426520267-1803-1-git-send-email-arjun024@gmail.com Signed-off-by: Ingo Molnar --- arch/x86/boot/string.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/boot/string.c b/arch/x86/boot/string.c index 493f3fd..318b846 100644 --- a/arch/x86/boot/string.c +++ b/arch/x86/boot/string.c @@ -30,7 +30,7 @@ int strcmp(const char *str1, const char *str2) int delta = 0; while (*s1 || *s2) { - delta = *s2 - *s1; + delta = *s1 - *s2; if (delta) return delta; s1++;