From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga17.intel.com (mga17.intel.com [192.55.52.151]) by dpdk.org (Postfix) with ESMTP id 57E3A1B6F7; Mon, 17 Dec 2018 10:35:48 +0100 (CET) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga107.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 17 Dec 2018 01:35:47 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.56,364,1539673200"; d="scan'208";a="130570102" Received: from aburakov-mobl1.ger.corp.intel.com (HELO [10.251.86.46]) ([10.251.86.46]) by fmsmga001.fm.intel.com with ESMTP; 17 Dec 2018 01:35:46 -0800 To: Gaetan Rivet , dev@dpdk.org Cc: stable@dpdk.org References: <20181217092559.21801-1-gaetan.rivet@6wind.com> From: "Burakov, Anatoly" Message-ID: Date: Mon, 17 Dec 2018 09:35:45 +0000 User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.3.3 MIME-Version: 1.0 In-Reply-To: <20181217092559.21801-1-gaetan.rivet@6wind.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] eal/option: fix option register duplicate detection X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 17 Dec 2018 09:35:49 -0000 On 17-Dec-18 9:25 AM, Gaetan Rivet wrote: > Missing brackets around the if means that the loop will end at its first > iteration. > > Cc: stable@dpdk.org > > Fixes: 2395332798d0 ("eal: add option register infrastructure") > Signed-off-by: Gaetan Rivet > --- > lib/librte_eal/common/rte_option.c | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/lib/librte_eal/common/rte_option.c b/lib/librte_eal/common/rte_option.c > index 02d59a869..eefb8b923 100644 > --- a/lib/librte_eal/common/rte_option.c > +++ b/lib/librte_eal/common/rte_option.c > @@ -35,10 +35,11 @@ void __rte_experimental > rte_option_register(struct rte_option *opt) > { > TAILQ_FOREACH(option, &rte_option_list, next) { > - if (strcmp(opt->opt_str, option->opt_str) == 0) > + if (strcmp(opt->opt_str, option->opt_str) == 0) { > RTE_LOG(INFO, EAL, "Option %s has already been registered.", > opt->opt_str); > return; > + } > } > > TAILQ_INSERT_HEAD(&rte_option_list, opt, next); > This is why i don't like the "no brackets on single-statement if clause" rule in our coding style guide - it makes mistakes like these easier to do. This wouldn't have happened if we mandated to have brackets always, for everything. Reviewed-by: Anatoly Burakov -- Thanks, Anatoly