From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=3.0 tests=MAILING_LIST_MULTI,SPF_PASS, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 581B9C43387 for ; Fri, 21 Dec 2018 22:55:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 28E2421929 for ; Fri, 21 Dec 2018 22:55:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2392197AbeLUWzS (ORCPT ); Fri, 21 Dec 2018 17:55:18 -0500 Received: from mail.kernel.org ([198.145.29.99]:46420 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725372AbeLUWzR (ORCPT ); Fri, 21 Dec 2018 17:55:17 -0500 Received: from gandalf.local.home (cpe-66-24-56-78.stny.res.rr.com [66.24.56.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 4CE7C21928; Fri, 21 Dec 2018 22:55:16 +0000 (UTC) Date: Fri, 21 Dec 2018 17:55:14 -0500 From: Steven Rostedt To: Joe Perches Cc: Andreas Schwab , Linus Torvalds , Linux List Kernel Mailing , Ingo Molnar , Andrew Morton , Namhyung Kim , Masami Hiramatsu , Tom Zanussi , Greg Kroah-Hartman Subject: Re: [for-next][PATCH 23/24] string.h: Add strncmp_prefix() helper macro Message-ID: <20181221175514.647770cf@gandalf.local.home> In-Reply-To: <84199633fd49db573c9ba71f1992936422e907d4.camel@perches.com> References: <20181221175618.968519903@goodmis.org> <20181221175659.208858193@goodmis.org> <20181221144054.20bdeb33@gandalf.local.home> <20181221153526.5e6055ca@gandalf.local.home> <077eeb8b09baebe78822819b5f15d671b738a2b2.camel@perches.com> <20181221155435.38a9a221@gandalf.local.home> <871s6ad2br.fsf@igel.home> <20181221160826.34c544e6@gandalf.local.home> <84199633fd49db573c9ba71f1992936422e907d4.camel@perches.com> X-Mailer: Claws Mail 3.16.0 (GTK+ 2.24.32; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, 21 Dec 2018 14:20:25 -0800 Joe Perches wrote: > static inline bool str_has_prefix(const char *str, const char prefix[]) > { > return !strncmp(str, prefix, strlen(prefix)); > } > > eliminates the strlen with gcc 4.8 (oldest I still have) I tested it a bit more before posting. I tested it against: gcc 4.5.1, 4.5.4, 4.6.3, 6.2.0, 7.2.0 and 8.2 And the strlen was eliminated each time. So this looks like the right approach :-) -- Steve