Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp640165ybl; Fri, 9 Aug 2019 11:19:04 -0700 (PDT) X-Google-Smtp-Source: APXvYqzoWyQ8uvWrn2UVmbvFmnKADgDxjHJeN2Jdq12eZkZDztiw94pePkHBfrmfOqwYSuEor3PH X-Received: by 2002:a17:90a:ac11:: with SMTP id o17mr10782833pjq.134.1565374744579; Fri, 09 Aug 2019 11:19:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565374744; cv=none; d=google.com; s=arc-20160816; b=0BaLu85wkZY06hRhmphoCXnQ6/Vnfxt5SR3GtpejFNtWMdVb7N6Ar+1V6gjroT0T02 d3ArTWUZE7vSVQAPZnicm9wOMDyetvaffV+q/LYowAfJrbeAmIkh5uaejQhC2PyvEEjn RbLR5HSpF6ZgrT35s7T+dVC5oGmYYJZ1rjQkWlckgZquD1fAdp5MjploaOK7m1ywjDZj URtBWOnNytlYeoEngMViIzAICxyjBQG5Q7Bma7/wzcMLVqMBWQFotwa/ZdjyJ2ZR25Zj s4PgueTeUkoGeLdx1tMgfizlxmK6Y5hswwBhx0e6Vf/C6bIUVSf2YfQehZx4uMZSj6k6 Sbjg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=SVm+IxX6yGNetZ1noaOGvk3cck8u8/5E12taR+hrzuY=; b=nOvcYtf2mXC/E32mk1tcoGwX8zUj5+ZFeofBBPmE9PCGGESOCXUqVcdpQA9UVU9+Kl nPZMHuU/8AHR77oj6Fbpsit4q61tq8O6tnaIJU8b15+U0dk86yRzJE34hpNxu87jsK4u 8YUJ/9weGyXqDF0Qu/XC3/+m6mX/h9lnbsFJug75Wqt8/CRDljab39IsL5smEXAjGTOo P6owDcWJxcMVHgaCmBebCEPckopw/emcnfE3BxQldPQrc02l0MlOzmB3kYsy7Unmi9KI kHACyGSuFgCd/KKvQkFx1jwRN613jvRu2wfw0TXFWEbzJO3UeLeQZ2NON0VGl05dQ2mV gWbQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eVFI3JOH; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k13si54935428pgj.525.2019.08.09.11.18.49; Fri, 09 Aug 2019 11:19:04 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=eVFI3JOH; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2437113AbfHIREs (ORCPT + 99 others); Fri, 9 Aug 2019 13:04:48 -0400 Received: from mail-ed1-f66.google.com ([209.85.208.66]:34072 "EHLO mail-ed1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2437086AbfHIREs (ORCPT ); Fri, 9 Aug 2019 13:04:48 -0400 Received: by mail-ed1-f66.google.com with SMTP id s49so60860079edb.1 for ; Fri, 09 Aug 2019 10:04:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=SVm+IxX6yGNetZ1noaOGvk3cck8u8/5E12taR+hrzuY=; b=eVFI3JOH5DluCznSfwkv+tvmdDi7A08we5AJVmkQ5ei6VmnaURk3d65Wft9KmpteKx TcORgXt18VKv1O0PIZmsknj/A16wO3RINuCPiqUeKYBGi2ynlI5/wsiySsjMfnwtj4KI HfwO/tIsTVZwDvjVfpHj97G0WB76mlWM/DGFM9jjak2x0l0TPjDyHXnS6n9UB0E1kHvk Cn+OUDO7/XsyxQ0ChaoVGrkpjF3aAMuQ48RbRW86R5W2qpcZIhvno5FOKuor7XK2l8n+ CdHtml7t3Xw+dOTWEF8tSMovQmD+0wsA/nwjqLecI1dKB0/M1UTMFEP4ih2g/jXpSm7g 0+HA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=SVm+IxX6yGNetZ1noaOGvk3cck8u8/5E12taR+hrzuY=; b=C/xKWmscVq8a8GsDs9TjKZg1u35ZeMS1bJ+sYFK0xgUudRug18uRjabZsFH96i4buZ ZUBQ7hRQo/fi7cDXUGAIi4egnAnmWtEXltl2I2dQxM7fX5Qunv49T1I/mGGqV3FujVYU QKFUCQOCjiWDhT4NczLvRPJJ+D19odEzJNMpTcMrSz6H0Lj30+DKe77G5kAyBtvMuAAo PCMnXl9VV7JAq/foUiccel1wr11kB94U1KIbMigQPAfX8R+yIdlY7eSKEDGEiCIg17E7 gZA3flC04zZd0//xGNWqHWfGXmoeBJ1eMRVZWt8/+23CcWvNd8FFEvEbWeO2KQUkzXOM ZLCA== X-Gm-Message-State: APjAAAUrwFtbXHksy5xJ5J7z9kmwRX2+UYuOFlUnOhiv6KFQjpTSJXRX ciEK5w5ILCx1qp4DZaym3OUmxomt393PRC2yqKo= X-Received: by 2002:aa7:ca54:: with SMTP id j20mr23149212edt.50.1565370286475; Fri, 09 Aug 2019 10:04:46 -0700 (PDT) MIME-Version: 1.0 References: <20190809071051.17387-1-hslester96@gmail.com> In-Reply-To: From: Chuhong Yuan Date: Sat, 10 Aug 2019 01:04:35 +0800 Message-ID: Subject: Re: [PATCH v4 6/8] sched: Replace strncmp with str_has_prefix To: Valentin Schneider Cc: Ingo Molnar , Peter Zijlstra , LKML Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Aug 9, 2019 at 7:31 PM Valentin Schneider wrote: > > On 09/08/2019 08:10, Chuhong Yuan wrote: > > strncmp(str, const, len) is error-prone because len > > is easy to have typo. > > The example is the hard-coded len has counting error > > or sizeof(const) forgets - 1. > > So we prefer using newly introduced str_has_prefix() > > to substitute such strncmp to make code better. > > > > Signed-off-by: Chuhong Yuan > > I tried to have a look at the series as a whole but it's not properly > threaded (or at least doesn't appear as such on lore), which makes it > unnecessarily annoying to review. > > Please make sure to use git-send-email, which should properly thread all > patches (IOW make them in-reply-to the cover letter). > I have used git-send-email to send the series with a cover letter. The cover letter is here: https://lkml.org/lkml/2019/8/9/108 Indeed I find the series are not in the same thread, I am not sure what is wrong with them. > > Other than that, I stared at it and it seems fine. It's not that helpful > here since I doubt any of these prefixes will change in the near feature, > but hey, why not. > > Reviewed-by: Valentin Schneider > > > --- > > Changes in v4: > > - Eliminate assignments in if conditions. > > > > kernel/sched/debug.c | 6 ++++-- > > kernel/sched/isolation.c | 11 +++++++---- > > 2 files changed, 11 insertions(+), 6 deletions(-) > > > > diff --git a/kernel/sched/debug.c b/kernel/sched/debug.c > > index f7e4579e746c..a03900523e5d 100644 > > --- a/kernel/sched/debug.c > > +++ b/kernel/sched/debug.c > > @@ -102,10 +102,12 @@ static int sched_feat_set(char *cmp) > > { > > int i; > > int neg = 0; > > + size_t len; > > > > - if (strncmp(cmp, "NO_", 3) == 0) { > > + len = str_has_prefix(cmp, "NO_"); > > + if (len) { > > neg = 1; > > - cmp += 3; > > + cmp += len; > > } > > > > i = match_string(sched_feat_names, __SCHED_FEAT_NR, cmp); > > diff --git a/kernel/sched/isolation.c b/kernel/sched/isolation.c > > index ccb28085b114..ea2ead4b1906 100644 > > --- a/kernel/sched/isolation.c > > +++ b/kernel/sched/isolation.c > > @@ -141,16 +141,19 @@ __setup("nohz_full=", housekeeping_nohz_full_setup); > > static int __init housekeeping_isolcpus_setup(char *str) > > { > > unsigned int flags = 0; > > + size_t len; > > > > while (isalpha(*str)) { > > - if (!strncmp(str, "nohz,", 5)) { > > - str += 5; > > + len = str_has_prefix(str, "nohz,"); > > + if (len) { > > + str += len; > > flags |= HK_FLAG_TICK; > > continue; > > } > > > > - if (!strncmp(str, "domain,", 7)) { > > - str += 7; > > + len = str_has_prefix(str, "domain,"); > > + if (len) { > > + str += len; > > flags |= HK_FLAG_DOMAIN; > > continue; > > } > >