From patchwork Mon Mar 31 15:04:17 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Will Newton X-Patchwork-Id: 27423 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-ob0-f198.google.com (mail-ob0-f198.google.com [209.85.214.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id 33B24202E0 for ; Mon, 31 Mar 2014 15:04:39 +0000 (UTC) Received: by mail-ob0-f198.google.com with SMTP id wn1sf29066455obc.1 for ; Mon, 31 Mar 2014 08:04:38 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:delivered-to:mailing-list :precedence:list-id:list-unsubscribe:list-subscribe:list-archive :list-post:list-help:sender:delivered-to:from:to:subject:date :message-id:x-original-sender:x-original-authentication-results; bh=VcQS+b55CRyShR/A+IdZVcg0D+Ox0QHhv/NhJexDDRM=; b=OeZcUT4RRB5rL1FmhEskaHI+LkzeATEq43tr2l722NAiX/dXxZVuDQrNWD/n0gsNeu 96b9TAY+2ZB2irdIf94cG16PITrXJM3cLXpJ/P0X7tQ/dnIWiSe/VTD1LsXd9vg1h5Sw 2PSkHBD5AfZlVlHWgEAoyf4cjbn0D8Er5qHIWXODpbxC4etTY8HrsoU8aM26nUNWvZAh AdiScFFImSiFLG5GKHSOUkSBcUInUBYGbRkm9iTxLmWhNy4h6HIO5DcM++rjlpK6ev3Y 3GtVJ7KGzFf2tPNBjhqu01Sb6IVo24cFdom3n6F8/i0nbHVX2vWTbZOl3Av0JdctJXgk sZ0A== X-Gm-Message-State: ALoCoQlTIK/ClwObjx+LKuO4bgZmqwG7ZVRtXaw+GQNKtR5Skh3EYZTlUsNG78hXpEvy5k7gXS8G X-Received: by 10.42.250.196 with SMTP id mp4mr8966641icb.29.1396278278665; Mon, 31 Mar 2014 08:04:38 -0700 (PDT) MIME-Version: 1.0 X-BeenThere: patchwork-forward@linaro.org Received: by 10.140.96.132 with SMTP id k4ls95364qge.42.gmail; Mon, 31 Mar 2014 08:04:38 -0700 (PDT) X-Received: by 10.52.104.7 with SMTP id ga7mr1123857vdb.29.1396278278504; Mon, 31 Mar 2014 08:04:38 -0700 (PDT) Received: from mail-vc0-x230.google.com (mail-vc0-x230.google.com [2607:f8b0:400c:c03::230]) by mx.google.com with ESMTPS id sj4si3012420vdc.48.2014.03.31.08.04.38 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 31 Mar 2014 08:04:38 -0700 (PDT) Received-SPF: neutral (google.com: 2607:f8b0:400c:c03::230 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) client-ip=2607:f8b0:400c:c03::230; Received: by mail-vc0-f176.google.com with SMTP id lc6so8477096vcb.35 for ; Mon, 31 Mar 2014 08:04:38 -0700 (PDT) X-Received: by 10.220.159.4 with SMTP id h4mr24070322vcx.1.1396278278407; Mon, 31 Mar 2014 08:04:38 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.220.12.8 with SMTP id v8csp149673vcv; Mon, 31 Mar 2014 08:04:38 -0700 (PDT) X-Received: by 10.68.164.229 with SMTP id yt5mr25785019pbb.28.1396278277489; Mon, 31 Mar 2014 08:04:37 -0700 (PDT) Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id nm5si4213178pbc.251.2014.03.31.08.04.36 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 31 Mar 2014 08:04:37 -0700 (PDT) Received-SPF: pass (google.com: domain of libc-alpha-return-48748-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Received: (qmail 25093 invoked by alias); 31 Mar 2014 15:04:28 -0000 Mailing-List: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org Precedence: list List-Id: List-Unsubscribe: , List-Subscribe: List-Archive: List-Post: , List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 25075 invoked by uid 89); 31 Mar 2014 15:04:27 -0000 X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_LOW, SPF_PASS autolearn=ham version=3.3.2 X-HELO: mail-we0-f173.google.com X-Received: by 10.194.19.161 with SMTP id g1mr15063185wje.20.1396278262671; Mon, 31 Mar 2014 08:04:22 -0700 (PDT) From: Will Newton To: libc-alpha@sourceware.org Subject: [PATCH] string: Cosmetic cleanup of string functions Date: Mon, 31 Mar 2014 16:04:17 +0100 Message-Id: <1396278257-24507-1-git-send-email-will.newton@linaro.org> X-Original-Sender: will.newton@linaro.org X-Original-Authentication-Results: mx.google.com; spf=neutral (google.com: 2607:f8b0:400c:c03::230 is neither permitted nor denied by best guess record for domain of patch+caf_=patchwork-forward=linaro.org@linaro.org) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org; dkim=pass header.i=@sourceware.org X-Google-Group-Id: 836684582541 Clean up string functions that do not have a version in gnulib on the assumption that glibc is the canonical upstream copy of this code. basename has a copy in gnulib but it is largely written to handle Windows paths so merging it is not really viable. The changes mostly consist of switching to ANSI function prototypes and removing unused includes. As many of these functions do not get built in a typical build due to architecture optimized versions being used instead I built these by hand to verify there were no build warnings and the code was identical. 2014-03-31 Will Newton * string/basename.c [HAVE_CONFIG_H]: Remove #ifdef and and contents. [!_LIBC] Remove #ifndef and contents. (basename): Use ANSI prototype. [_LIBC] Remove #idef. * string/memccpy.c (__memccpy): Use ANSI prototype. * string/memfrob.c (memfrob): Likewise. * string/strcoll.c (STRCOLL): Likewise. * string/strlen.c (strlen): Likewise. * string/strtok.c (STRTOK): Likewise. * string/strcat.c: Remove unused #include of memcopy.h. (strcat): Use ANSI prototype. * string/strchr.c: Remove unused #include of memcopy.h. (strchr): Use ANSI prototype. * string/strcmp.c: Remove unused #include of memcopy.h. (strcmp): Use ANSI prototype. * string/strcpy.c: Remove unused #include of memcopy.h. (strcpy): Use ANSI prototype. --- string/basename.c | 16 +--------------- string/memccpy.c | 6 +----- string/memfrob.c | 4 +--- string/strcat.c | 5 +---- string/strchr.c | 5 +---- string/strcmp.c | 5 +---- string/strcoll.c | 4 +--- string/strcpy.c | 5 +---- string/strlen.c | 3 +-- string/strtok.c | 4 +--- 10 files changed, 10 insertions(+), 47 deletions(-) diff --git a/string/basename.c b/string/basename.c index 29b84ee..98bf96c 100644 --- a/string/basename.c +++ b/string/basename.c @@ -16,26 +16,12 @@ License along with the GNU C Library; if not, see . */ -#ifdef HAVE_CONFIG_H -# include -#endif - #include -#ifndef _LIBC -/* We cannot generally use the name `basename' since XPG defines an unusable - variant of the function but we cannot use it. */ -# define basename gnu_basename -#endif - - char * -basename (filename) - const char *filename; +basename (const char *filename) { char *p = strrchr (filename, '/'); return p ? p + 1 : (char *) filename; } -#ifdef _LIBC libc_hidden_def (basename) -#endif diff --git a/string/memccpy.c b/string/memccpy.c index 793f68e..70ee2ae 100644 --- a/string/memccpy.c +++ b/string/memccpy.c @@ -24,11 +24,7 @@ Return the position in DEST one byte past where C was copied, or NULL if C was not found in the first N bytes of SRC. */ void * -__memccpy (dest, src, c, n) - void *dest; - const void *src; - int c; - size_t n; +__memccpy (void *dest, const void *src, int c, size_t n) { const char *s = src; char *d = dest; diff --git a/string/memfrob.c b/string/memfrob.c index 4841309..68339f7 100644 --- a/string/memfrob.c +++ b/string/memfrob.c @@ -18,9 +18,7 @@ #include void * -memfrob (s, n) - void *s; - size_t n; +memfrob (void *s, size_t n) { char *p = (char *) s; diff --git a/string/strcat.c b/string/strcat.c index bb7c0a9..2cbe8b3 100644 --- a/string/strcat.c +++ b/string/strcat.c @@ -16,15 +16,12 @@ . */ #include -#include #undef strcat /* Append SRC on the end of DEST. */ char * -strcat (dest, src) - char *dest; - const char *src; +strcat (char *dest, const char *src) { char *s1 = dest; const char *s2 = src; diff --git a/string/strchr.c b/string/strchr.c index da69ed2..6bea03e 100644 --- a/string/strchr.c +++ b/string/strchr.c @@ -21,16 +21,13 @@ . */ #include -#include #include #undef strchr /* Find the first occurrence of C in S. */ char * -strchr (s, c_in) - const char *s; - int c_in; +strchr (const char *s, int c_in) { const unsigned char *char_ptr; const unsigned long int *longword_ptr; diff --git a/string/strcmp.c b/string/strcmp.c index 212f20c..85b0170 100644 --- a/string/strcmp.c +++ b/string/strcmp.c @@ -16,7 +16,6 @@ . */ #include -#include #undef strcmp @@ -24,9 +23,7 @@ greater than zero if S1 is lexicographically less than, equal to or greater than S2. */ int -strcmp (p1, p2) - const char *p1; - const char *p2; +strcmp (const char *p1, const char *p2) { const unsigned char *s1 = (const unsigned char *) p1; const unsigned char *s2 = (const unsigned char *) p2; diff --git a/string/strcoll.c b/string/strcoll.c index 779ba13..367ab2e 100644 --- a/string/strcoll.c +++ b/string/strcoll.c @@ -29,9 +29,7 @@ int -STRCOLL (s1, s2) - const STRING_TYPE *s1; - const STRING_TYPE *s2; +STRCOLL (const STRING_TYPE *s1, const STRING_TYPE *s2) { return STRCOLL_L (s1, s2, _NL_CURRENT_LOCALE); } diff --git a/string/strcpy.c b/string/strcpy.c index f136916..caa234a 100644 --- a/string/strcpy.c +++ b/string/strcpy.c @@ -17,15 +17,12 @@ #include #include -#include #undef strcpy /* Copy SRC to DEST. */ char * -strcpy (dest, src) - char *dest; - const char *src; +strcpy (char *dest, const char *src) { char c; char *s = (char *) src; diff --git a/string/strlen.c b/string/strlen.c index 342c4a2..19d2b2b 100644 --- a/string/strlen.c +++ b/string/strlen.c @@ -26,8 +26,7 @@ /* Return the length of the null-terminated string STR. Scan for the null terminator quickly by testing four bytes at a time. */ size_t -strlen (str) - const char *str; +strlen (const char *str) { const char *char_ptr; const unsigned long int *longword_ptr; diff --git a/string/strtok.c b/string/strtok.c index 2253440..924313e 100644 --- a/string/strtok.c +++ b/string/strtok.c @@ -36,9 +36,7 @@ static char *olds; // s = "abc\0=-def\0" */ char * -STRTOK (s, delim) - char *s; - const char *delim; +STRTOK (char *s, const char *delim) { char *token;