From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pd0-f176.google.com (mail-pd0-f176.google.com [209.85.192.176]) by dpdk.org (Postfix) with ESMTP id 7709F6789 for ; Tue, 15 Apr 2014 05:00:23 +0200 (CEST) Received: by mail-pd0-f176.google.com with SMTP id r10so8880585pdi.35 for ; Mon, 14 Apr 2014 20:00:23 -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=zJ0yELwU4pmspeGE06WkzVjhX5ZyDjzkGzg9LjApwIv/CBeYJu1+yb+i+uNIJxxsDO 5bg6oZaVY3mGsX+oHOmt4VcUYvMVZULWsSZZ6pT8ZaTl+iTBjgHIy+9ApoHeFbamVUjU uxLq78Zya8rvvrt20Kl7rN/3fGNt1PHZmeS8n2C4TYieUfH35Yp4HX4g2/H7/xJBe2md 1HBt9u2Hvyhus2ZzsgmFhRClEU/pdvfEZ/vMUBKWuHc1u8I7j/yWmNH8wYMxi57E30pP PMwZ5669/u4f30SU35iTq6B3xdz/I4F9i8ukIyG9mlYB0Hnnx3Ebl8pCzV70cQfbA0QN S07g== X-Received: by 10.66.164.70 with SMTP id yo6mr25385421pab.85.1397530823151; Mon, 14 Apr 2014 20:00:23 -0700 (PDT) Received: from [10.200.0.70] ([124.207.145.166]) by mx.google.com with ESMTPSA id vf7sm36932151pbc.5.2014.04.14.20.00.19 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Mon, 14 Apr 2014 20:00:22 -0700 (PDT) Message-ID: <534CA0B9.3080602@gmail.com> Date: Tue, 15 Apr 2014 11:00:09 +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:00:23 -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