From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wg0-f53.google.com (mail-wg0-f53.google.com [74.125.82.53]) by dpdk.org (Postfix) with ESMTP id DAFC87F30 for ; Wed, 5 Nov 2014 17:45:45 +0100 (CET) Received: by mail-wg0-f53.google.com with SMTP id b13so1403319wgh.12 for ; Wed, 05 Nov 2014 08:55:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:organization :user-agent:in-reply-to:references:mime-version :content-transfer-encoding:content-type; bh=llIDnDSOfz7Z1h53Ip+WpL2UM2DnT/707HY2Sqp4wWs=; b=X0GRr0urAZqPonVipbCBMP8R8F/ltgnJ+l1gLF3MZ7xuzRRz2YGDMjaVKmZqwu6HvA jkUdZTmGxTNHh7Z8Vb6kobxiqNfsdUBS2q8D8OWbcGno5ck3kwM4L7lLBIVWKRwFV6hM TpCwPyDSbYZTsWEuXRHzjyjAUODPcTYEs5ZmoSeqVS+8YVuBAoakc0IpL0nl41l7Rnqf zSJ/9+8qYSGiATR7rqck/s0gW2gN6LbNQrLpm04ZZK0eXCrj45Abry0+68uO/NSBJPdG VblZ8R263oV2+f4Uvi0Rmesj++zpKXk14Wf7iad2IfU+6UrGYlwOWPmXkiEDrmhuDKI0 NCIw== X-Gm-Message-State: ALoCoQnQSVKijcF6usORvSZgLQEu2nliuwhNFKdxgyMLF8Tko1/6g1wh7wpYmCkMA7RDZF6IP4dM X-Received: by 10.194.175.67 with SMTP id by3mr65627020wjc.32.1415206509571; Wed, 05 Nov 2014 08:55:09 -0800 (PST) Received: from xps13.localnet (108.26.90.92.rev.sfr.net. [92.90.26.108]) by mx.google.com with ESMTPSA id f9sm4689076wjw.31.2014.11.05.08.55.07 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Nov 2014 08:55:08 -0800 (PST) From: Thomas Monjalon To: "Ananyev, Konstantin" Date: Wed, 05 Nov 2014 17:52:46 +0100 Message-ID: <2670906.3ddkbcCbba@xps13> Organization: 6WIND User-Agent: KMail/4.14.2 (Linux/3.17.2-1-ARCH; KDE/4.14.2; x86_64; ; ) In-Reply-To: <2601191342CEEE43887BDE71AB977258213A2877@IRSMSX105.ger.corp.intel.com> References: <1404808110-16314-1-git-send-email-simon.kuenzer@neclab.eu> <1415137233-6364-1-git-send-email-thomas.monjalon@6wind.com> <2601191342CEEE43887BDE71AB977258213A2877@IRSMSX105.ger.corp.intel.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Cc: dev@dpdk.org Subject: Re: [dpdk-dev] [PATCH v2] eal: add option --master-lcore X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 05 Nov 2014 16:45:46 -0000 2014-11-05 11:54, Ananyev, Konstantin: > From: Thomas Monjalon > > + long master_lcore; > > + char *parsing_end; > > + struct rte_config *cfg = rte_eal_get_configuration(); > > + > > + errno = 0; > > + master_lcore = strtol(arg, &parsing_end, 0); > > + if (errno || parsing_end == arg) > > + return -1; > > Why not: "errno || parsing_end[0] != 0" > ? > Otherwise something like "1blah" would be considered as valid input. Good point. > > + if (!(master_lcore >= 0 && master_lcore < RTE_MAX_LCORE)) > > + return -1; > > If negative values are not allowed, then why not: > > unsigned long master_lcore; > ... > master_lcore = strtoul(...) > ... > if(master_clore > RTE_MAX_LCORE) > return -1; Matter of taste. Your code is less explicit. But it should be if(master_clore >= RTE_MAX_LCORE) Anyone else to vote for 1 solution or the other? > > + if (opt == OPT_MASTER_LCORE_NUM && !coremask_ok) { > > + RTE_LOG(ERR, EAL, "please specify the master lcore id" > > + "after specifying the coremask\n"); > > + eal_usage(prgname); > > + return -1; > > + } > > + > > I don't really like an idea of introducing strict order between -c and "--master-lcore.. Me too. And Aaron too :) > Can we move check for coremask_ok/ and assignment of cfg->master_lcore out of > while (getopt_long(...)) loop? > > > ret = eal_parse_common_option(opt, optarg, &internal_config); > > /* common parser is not happy */ > > if (ret < 0) { Yes we should move the check outside of the loop. First we should migrate all flags check in a common function for BSD and Linux. Simon made the v1. I made the v2. Any volunteer for the v3? -- Thomas