From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pb0-f48.google.com (mail-pb0-f48.google.com [209.85.160.48]) by dpdk.org (Postfix) with ESMTP id 3F9216789 for ; Tue, 15 Apr 2014 05:03:55 +0200 (CEST) Received: by mail-pb0-f48.google.com with SMTP id md12so8903492pbc.7 for ; Mon, 14 Apr 2014 20:03:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:subject :content-type:content-transfer-encoding; bh=zmdO7H0wczzobsmoif1dHyUwTuGX07m8QVXkgqtVRN4=; b=OFBXeQsUSXe6I4+S6qVCare2q+MZ3o5BHMzoZ+WXVR7tuggIGBY8DPu/ygDOJgYAfn hI7tETn1Dq25mfAtvt8YNYxis6buvkEbaCkowkjM7/cWN/Lj/W/4bAnNZFbImyqcobRc zb/w0tDVWEtcSXntppn4C6Usubdu9j8XnlTZ5qJlnsOD3M4gXkwGFEe0BDEC4t6zhVaz X4WBZ3c+m8eQzDVILeIqI5HhKQkC+8rhaJXWb+t/cnQwOdre15h3Urc2b2QHAXRWQ/NA L52nR+L1WLXW7iQo0WVZxGQtkkuAOi9LDhGRYd2PL4t+qDOTE26aDMEelhQxOGTryLet aStQ== X-Received: by 10.67.30.168 with SMTP id kf8mr48125771pad.84.1397531035123; Mon, 14 Apr 2014 20:03:55 -0700 (PDT) Received: from [10.200.0.70] ([124.207.145.166]) by mx.google.com with ESMTPSA id au16sm88483876pac.27.2014.04.14.20.03.51 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 14 Apr 2014 20:03:54 -0700 (PDT) Message-ID: <534CA193.2000604@gmail.com> Date: Tue, 15 Apr 2014 11:03:47 +0800 From: Wang Sheng-Hui User-Agent: Mozilla/5.0 (X11; Linux i686; rv:24.0) Gecko/20100101 Thunderbird/24.2.0 MIME-Version: 1.0 To: dev@dpdk.org Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: [dpdk-dev] [PATCH] eal: parse args before any kinds of init 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: Tue, 15 Apr 2014 03:03:55 -0000 Parse args first, to resolve any invalid args and give out the usage string. E.g './helloworld --invalid', the '--invalid' will be checked before any init. After the options are checked, take any init actions. Signed-off-by: Wang Sheng-Hui --- lib/librte_eal/linuxapp/eal/eal.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal.c b/lib/librte_eal/linuxapp/eal/eal.c index 3ded563..9d20718 100644 --- a/lib/librte_eal/linuxapp/eal/eal.c +++ b/lib/librte_eal/linuxapp/eal/eal.c @@ -637,6 +637,11 @@ eal_parse_args(int argc, char **argv) }; struct shared_driver *solib; + /* check the no args case */ + if (argc == 1) { + eal_usage(prgname); + return (-1); + } argvopt = argv; internal_config.memory = 0; @@ -964,16 +969,16 @@ rte_eal_init(int argc, char **argv) thread_id = pthread_self(); + fctret = eal_parse_args(argc, argv); + if (fctret < 0) + exit(1); + if (rte_eal_log_early_init() < 0) rte_panic("Cannot init early logs\n"); if (rte_eal_cpu_init() < 0) rte_panic("Cannot detect lcores\n"); - fctret = eal_parse_args(argc, argv); - if (fctret < 0) - exit(1); - if (internal_config.no_hugetlbfs == 0 && internal_config.process_type != RTE_PROC_SECONDARY && internal_config.xen_dom0_support == 0 && -- 1.8.3.2