From patchwork Tue Jun 21 13:37:17 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Wilco Dijkstra X-Patchwork-Id: 13284 Received: (qmail 30057 invoked by alias); 21 Jun 2016 13:37:34 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk 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 30040 invoked by uid 89); 21 Jun 2016 13:37:33 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS autolearn=ham version=3.3.2 spammy=6025, Hx-languages-length:1733, bucket X-HELO: eu-smtp-delivery-143.mimecast.com From: Wilco Dijkstra To: Mike Frysinger CC: 'GNU C Library' , nd Subject: Re: [PATCH] Use strlen when searching for a nul char Date: Tue, 21 Jun 2016 13:37:17 +0000 Message-ID: References: <20160419175706.GI5369@vapier.lan> , <20160419222134.GQ5369@vapier.lan>, , , In-Reply-To: x-ms-office365-filtering-correlation-id: c7f53633-2c5b-4648-0015-08d399d9296e x-microsoft-exchange-diagnostics: 1; AM3PR08MB0085; 20:CwKhNZND1at0LUCHwqFhtsNS4CzLUpEvOrP3zsGnS/KkLQTtu5U/LE3tj4SzTWt6C2ZOjSnEsFjhzFkEScQQbkPuTSfN4r/4x0gvjlQHL7BXJOiqOFyH5B83hgT1nUGuxfyO8NKerW1OeHJb66Uoxxh0lGWKDQLBS3N6Gh3Heo4= x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:;SRVR:AM3PR08MB0085; nodisclaimer: True x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:; x-exchange-antispam-report-cfa-test: BCL:0; PCL:0; RULEID:(601004)(2401047)(5005006)(8121501046)(3002001)(10201501046)(6055026); SRVR:AM3PR08MB0085; BCL:0; PCL:0; RULEID:; SRVR:AM3PR08MB0085; x-forefront-prvs: 098076C36C x-forefront-antispam-report: SFV:NSPM; SFS:(10009020)(6009001)(7916002)(199003)(189002)(24454002)(2900100001)(110136002)(4326007)(87936001)(33656002)(2950100001)(97736004)(8936002)(7736002)(5003600100003)(7846002)(106116001)(68736007)(105586002)(106356001)(74316001)(2906002)(50986999)(5002640100001)(81156014)(93886004)(81166006)(76176999)(54356999)(6116002)(3280700002)(8676002)(11100500001)(92566002)(5250100002)(102836003)(86362001)(586003)(101416001)(189998001)(3846002)(3660700001)(76576001)(3900700001)(66066001)(9686002)(575784001)(7696003)(51383001); DIR:OUT; SFP:1101; SCL:1; SRVR:AM3PR08MB0085; H:AM3PR08MB0088.eurprd08.prod.outlook.com; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM MIME-Version: 1.0 X-OriginatorOrg: arm.com X-MS-Exchange-CrossTenant-originalarrivaltime: 21 Jun 2016 13:37:17.0218 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: f34e5979-57d9-4aaa-ad4d-b122a662184d X-MS-Exchange-Transport-CrossTenantHeadersStamped: AM3PR08MB0085 X-MC-Unique: 2bulkwvsOT6qufuOb3lnpQ-1 ping diff --git a/string/bits/string2.h b/string/bits/string2.h index 80987602f34ded483854bcea86dabd5b81e42a18..62edc93b0f04249a504078caeee8fca192e91df8 100644 --- a/string/bits/string2.h +++ b/string/bits/string2.h @@ -60,13 +60,25 @@  #ifndef _HAVE_STRING_ARCH_strchr  extern void *__rawmemchr (const void *__s, int __c); -#  define strchr(s, c) \ +# define strchr(s, c) \    (__extension__ (__builtin_constant_p (c) && !__builtin_constant_p (s)              \                   && (c) == '\0'                                              \                   ? (char *) __rawmemchr (s, c)                               \                   : __builtin_strchr (s, c)))  #endif +#ifndef _HAVE_STRING_ARCH_rawmemchr +extern void *__rawmemchr (const void *__s, int __c); +# define __rawmemchr(s, c) \ +    (__extension__ ({ char *__s = (char *)(s);         \ +      __builtin_constant_p (c) && (c) == '\0'          \ +      ? (void *)(__s + strlen (__s))                   \ +      : __rawmemchr (__s, (c));})) +# ifdef __USE_GNU +#  define rawmemchr(s,c) __rawmemchr ((s), (c)) +# endif +#endif +  /* Copy SRC to DEST, returning pointer to final NUL byte.  */  #ifdef __USE_GNU