Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp4107350img; Tue, 26 Mar 2019 03:11:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqzj1/BytGcPuw5yvabu5TRFuXKRXtBR+MHgkYC7hadONWXKr2WcQ0046Om6NpRDw/R43Jfo X-Received: by 2002:aa7:83cb:: with SMTP id j11mr28738960pfn.117.1553595069676; Tue, 26 Mar 2019 03:11:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553595069; cv=none; d=google.com; s=arc-20160816; b=m4F51uP3c0vM8Y4ZijdfF4O+H6QRK5uAIlCZZ5JPjwz6dWM/XNh/xlJ2DGMODExNme BB4eCLVKSAK/jRh3Z8sdLlo+k9pVAKPham05qF+yfqcsb8qLmBpwo8y+D6qP3QPVhiZH qcg1xbMbkbSQp89JDln5N8LG68ny0v3ak+jGRZBbbwvI6eBq+iVhG7PmGa6DiV1uauRA +IdQgbf2Ec0fdQexo0bz6bRcN4UTlgOXMljmJVTYWhmbUn/uK6EiDkiCZKOtjLvmoMlx yRE4ZT6+8ZAWbPe4lcmSA5cnCwbs0+y2iRPq0hHmx7F4pGivuUDrX9qOSpk7std421uY bfvQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:organization:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=P9uFp0f7O5140eGBomXRgqcHp1DKugJDYVoVyPnDCl0=; b=qxyaK3QxVshfwZ7JXKXkHS8E5tgdTKR14bijZMm6LqEBBTDhIqp/pK0SwTSXYGC5xa p5Rh4Go4KCw9JjfR23T2x2ilvf5paqhvQH2w+ndILsI9sLyMipJOoCfaYmlDQsyGQOGI HRfE+Dt+G65KBHmPVQ+2xF6mMe1aZ9B4q2gCP57gNVKPI7fug7Hv3QVtEOdiXA6FdkpO YLk2V5Qr/KqJWvvcXUubJnWiHjoTrDClsIMCxHUcOCGYxuSq67BgqhVbqE4swcccwuT9 Q95Sm5ht0K5XitKWSFkPdLa+x+xw0FEXjaV4By6RlAFcNw007tcRcGd5bmSyhHuYld3j 9EDA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 32si16745969pls.415.2019.03.26.03.10.54; Tue, 26 Mar 2019 03:11:09 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730751AbfCZKKJ (ORCPT + 99 others); Tue, 26 Mar 2019 06:10:09 -0400 Received: from mga14.intel.com ([192.55.52.115]:12092 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726175AbfCZKKJ (ORCPT ); Tue, 26 Mar 2019 06:10:09 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from fmsmga004.fm.intel.com ([10.253.24.48]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Mar 2019 03:10:00 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.60,271,1549958400"; d="scan'208";a="155871028" Received: from smile.fi.intel.com (HELO smile) ([10.237.72.86]) by fmsmga004.fm.intel.com with ESMTP; 26 Mar 2019 03:09:57 -0700 Received: from andy by smile with local (Exim 4.92) (envelope-from ) id 1h8j1o-00018Y-1k; Tue, 26 Mar 2019 12:09:56 +0200 Date: Tue, 26 Mar 2019 12:09:56 +0200 From: Andy Shevchenko To: Yury Norov Cc: Andrew Morton , Rasmus Villemoes , Arnd Bergmann , Kees Cook , Matthew Wilcox , Tetsuo Handa , Yury Norov , linux-kernel@vger.kernel.org Subject: Re: [PATCH 1/6] bitmap_parselist: don't calculate length of the input string Message-ID: <20190326100956.GS9224@smile.fi.intel.com> References: <20190325210748.6571-1-ynorov@marvell.com> <20190325210748.6571-2-ynorov@marvell.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20190325210748.6571-2-ynorov@marvell.com> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Mar 26, 2019 at 12:07:43AM +0300, Yury Norov wrote: > bitmap_parselist() calculates length of the input string before passing > it to the __bitmap_parselist(). But the end-of-line condition is checked > for every character in __bitmap_parselist() anyway. So doing it in wrapper > is a simple waste of time. This is not best change, I think. See my further comments. > > Signed-off-by: Yury Norov > --- > lib/bitmap.c | 5 +---- > 1 file changed, 1 insertion(+), 4 deletions(-) > > diff --git a/lib/bitmap.c b/lib/bitmap.c > index 98872e9025da..ad1fb7e6ad0e 100644 > --- a/lib/bitmap.c > +++ b/lib/bitmap.c > @@ -614,10 +614,7 @@ static int __bitmap_parselist(const char *buf, unsigned int buflen, > > int bitmap_parselist(const char *bp, unsigned long *maskp, int nmaskbits) > { > - char *nl = strchrnul(bp, '\n'); > - int len = nl - bp; > - > - return __bitmap_parselist(bp, len, 0, maskp, nmaskbits); > + return __bitmap_parselist(bp, UINT_MAX, 0, maskp, nmaskbits); > } > EXPORT_SYMBOL(bitmap_parselist); > > -- > 2.17.1 > -- With Best Regards, Andy Shevchenko