Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp1319305yba; Tue, 2 Apr 2019 06:48:23 -0700 (PDT) X-Google-Smtp-Source: APXvYqyA4ZX/OtTcF1qrhnzcwOPOC1HyGb6bAJcHI0eqXaeC7Jz5RAAlV4jOK4M/L9izbl0/LOQU X-Received: by 2002:aa7:938b:: with SMTP id t11mr61379840pfe.67.1554212903414; Tue, 02 Apr 2019 06:48:23 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554212903; cv=none; d=google.com; s=arc-20160816; b=sjJhnbQtdkpn4uz+zrj7eDPzDNKT4rXybJViTF3b2klaIxX1EV6Qncpjd1CM8gK1Va IlFVfS3e1ATGSq2co7y4/3aPq/ofO2dNVJYdhBNDAQwxp0q+q5CulAAspAdQu1JEnJNh 2AwbibDjlxr8t+NYBRZ+i+7bs0dvhhlODz7lAhzRlQHf4yRVXGLdsoHsE0HVahPby4O1 aAPD7e0uam9ugHsAZNKXA6oy3M4AL0Y4hAl1DJSe9sCps5oM9gQhpT0TfD+7rhpeYz6o BfWgqmliSNg9eWIGQCWR2LJY+BOf/zPSOuBPOGfsfwQ+xyp5iL/t1XBBagg8n4x08K7o +ZxA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:subject:message-id:date:cc:to :from:mime-version:content-transfer-encoding:content-disposition; bh=Knxa1DlM+x88K5poQYXblHuPp+M/8+hvRTwVlHZfuos=; b=R9qE0L7L9kPjfrol6e9gn43jetXasdL9k0GwJjKCq03J8ZV2yOEh1SUWOwcGq8MlES IIRbZZLKG2vBUWo0pBt1aBkj30zwTlXlnXaV2vxL+1UhgTfr+ca5dIMjSE+9C69pYHfy fuK4DzVYz+Fg6pkJqNhJOJOosLQOxAoV6Jn9Hdo+b7C7uiH0jH1Eu3rG33a41X+OSDz1 F/6cXu/ntNcacFOF8tu3EgPFc/gFSXmGXtZG8soNKElHZ9dTks5/pKMRxKBS41r/Lmvz aIPMpF6U/H1OiScOVJPltFciE8ZCKQCXjMkXdZs3h1HmUWetUf0z6gkneUMNP3kj96X4 AHcA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 16si10966323pfh.244.2019.04.02.06.48.08; Tue, 02 Apr 2019 06:48:23 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1732128AbfDBNpq (ORCPT + 99 others); Tue, 2 Apr 2019 09:45:46 -0400 Received: from shadbolt.e.decadent.org.uk ([88.96.1.126]:43250 "EHLO shadbolt.e.decadent.org.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731446AbfDBNkG (ORCPT ); Tue, 2 Apr 2019 09:40:06 -0400 Received: from [167.98.27.226] (helo=deadeye) by shadbolt.decadent.org.uk with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.89) (envelope-from ) id 1hBJdu-0002mm-WC; Tue, 02 Apr 2019 14:39:59 +0100 Received: from ben by deadeye with local (Exim 4.92) (envelope-from ) id 1hBJdu-0004rm-53; Tue, 02 Apr 2019 14:39:58 +0100 Content-Type: text/plain; charset="UTF-8" Content-Disposition: inline Content-Transfer-Encoding: 8bit MIME-Version: 1.0 From: Ben Hutchings To: linux-kernel@vger.kernel.org, stable@vger.kernel.org CC: akpm@linux-foundation.org, Denis Kirjanov , "Linus Torvalds" , "Andi Kleen" , "Dan Carpenter" , "Rasmus Villemoes" , "H. Peter Anvin" , "Grant Likely" Date: Tue, 02 Apr 2019 14:38:27 +0100 Message-ID: X-Mailer: LinuxStableQueue (scripts by bwh) X-Patchwork-Hint: ignore Subject: [PATCH 3.16 17/99] lib/string.c: remove duplicated function In-Reply-To: X-SA-Exim-Connect-IP: 167.98.27.226 X-SA-Exim-Mail-From: ben@decadent.org.uk X-SA-Exim-Scanned: No (on shadbolt.decadent.org.uk); SAEximRunCond expanded to false Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 3.16.65-rc1 review patch. If anyone has any objections, please let me know. ------------------ From: Rasmus Villemoes commit cd514e727b18ff4d189b8e268db13729a4175091 upstream. lib/string.c contains two functions, strnicmp and strncasecmp, which do roughly the same thing, namely compare two strings case-insensitively up to a given bound. They have slightly different implementations, but the only important difference is that strncasecmp doesn't handle len==0 appropriately; it effectively becomes strcasecmp in that case. strnicmp correctly says that two strings are always equal in their first 0 characters. strncasecmp is the POSIX name for this functionality. So rename the non-broken function to the standard name. To minimize the impact on the rest of the kernel (and since both are exported to modules), make strnicmp a wrapper for strncasecmp. Signed-off-by: Rasmus Villemoes Cc: Grant Likely Cc: Andi Kleen Cc: Dan Carpenter Cc: "H. Peter Anvin" Signed-off-by: Andrew Morton Signed-off-by: Linus Torvalds Signed-off-by: Ben Hutchings --- lib/string.c | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) --- a/lib/string.c +++ b/lib/string.c @@ -31,14 +31,14 @@ #include #include -#ifndef __HAVE_ARCH_STRNICMP +#ifndef __HAVE_ARCH_STRNCASECMP /** - * strnicmp - Case insensitive, length-limited string comparison + * strncasecmp - Case insensitive, length-limited string comparison * @s1: One string * @s2: The other string * @len: the maximum number of characters to compare */ -int strnicmp(const char *s1, const char *s2, size_t len) +int strncasecmp(const char *s1, const char *s2, size_t len) { /* Yes, Virginia, it had better be unsigned */ unsigned char c1, c2; @@ -60,6 +60,13 @@ int strnicmp(const char *s1, const char } while (--len); return (int)c1 - (int)c2; } +EXPORT_SYMBOL(strncasecmp); +#endif +#ifndef __HAVE_ARCH_STRNICMP +int strnicmp(const char *s1, const char *s2, size_t len) +{ + return strncasecmp(s1, s2, len); +} EXPORT_SYMBOL(strnicmp); #endif @@ -77,20 +84,6 @@ int strcasecmp(const char *s1, const cha EXPORT_SYMBOL(strcasecmp); #endif -#ifndef __HAVE_ARCH_STRNCASECMP -int strncasecmp(const char *s1, const char *s2, size_t n) -{ - int c1, c2; - - do { - c1 = tolower(*s1++); - c2 = tolower(*s2++); - } while ((--n > 0) && c1 == c2 && c1 != 0); - return c1 - c2; -} -EXPORT_SYMBOL(strncasecmp); -#endif - #ifndef __HAVE_ARCH_STRCPY /** * strcpy - Copy a %NUL terminated string