From mboxrd@z Thu Jan  1 00:00:00 1970
Return-Path: <thomas.monjalon@6wind.com>
Received: from mail-wg0-f46.google.com (mail-wg0-f46.google.com [74.125.82.46])
 by dpdk.org (Postfix) with ESMTP id 46CA7AFD9
 for <dev@dpdk.org>; Mon,  5 May 2014 17:50:13 +0200 (CEST)
Received: by mail-wg0-f46.google.com with SMTP id n12so5790093wgh.29
 for <dev@dpdk.org>; Mon, 05 May 2014 08:50:18 -0700 (PDT)
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=8BDGnVNpZaHOM5/bg+JUV8isRfQFgvZnzLUwaPBc0Ek=;
 b=c5a4eIfuE8s7RMZ7XPXRnsWYMSrswvjQNQFYgiBpx4PxdIE6rcRylDSOJPvjF5iGjv
 /nuJehnHt81/EwejL+6+DotYcd50abpfAbmX9uZjaDu7+bf2DpHSXlC4xh5el2TcvNc5
 2MPcTAvt78lLR5oUwAk58czoKd5gLtAM/hT3kdyHzDezk/SSEQz1wQe8+vJB4KopULLg
 LLQo5377Ybd7zXzHJWXYxv3zsccMYEjkwVALlLmgxdpRoM3uGkeFCuCgTRvr2BPPGSCF
 43vSwB76yRqHR6jthEVf7CYIyQxRpnnXDotojWq1r1PoZb7jpH6xMNJw5ymPOej1RTAj
 qorQ==
X-Gm-Message-State: ALoCoQmXtZqWZw8NWfMCDjAi0TAAxNkOvDcKNrUx+7Y1YxQyaMPF7DrB1b7s5i3msdwvVElPa9vU
X-Received: by 10.180.14.199 with SMTP id r7mr16687250wic.0.1399305018470;
 Mon, 05 May 2014 08:50:18 -0700 (PDT)
Received: from xps13.localnet (6wind.net2.nerim.net. [213.41.180.237])
 by mx.google.com with ESMTPSA id ej2sm8935174wjd.21.2014.05.05.08.50.16
 for <multiple recipients>
 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128);
 Mon, 05 May 2014 08:50:17 -0700 (PDT)
From: Thomas Monjalon <thomas.monjalon@6wind.com>
To: Wang Sheng-Hui <shhuiw@gmail.com>
Date: Mon, 05 May 2014 17:50:15 +0200
Message-ID: <2073730.rjlHe4Kf7A@xps13>
Organization: 6WIND
User-Agent: KMail/4.13 (Linux/3.14.2-1-ARCH; KDE/4.13.0; x86_64; ; )
In-Reply-To: <534CA193.2000604@gmail.com>
References: <534CA193.2000604@gmail.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] 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 <dev.dpdk.org>
List-Unsubscribe: <http://dpdk.org/ml/options/dev>,
 <mailto:dev-request@dpdk.org?subject=unsubscribe>
List-Archive: <http://dpdk.org/ml/archives/dev/>
List-Post: <mailto:dev@dpdk.org>
List-Help: <mailto:dev-request@dpdk.org?subject=help>
List-Subscribe: <http://dpdk.org/ml/listinfo/dev>,
 <mailto:dev-request@dpdk.org?subject=subscribe>
X-List-Received-Date: Mon, 05 May 2014 15:50:13 -0000

2014-04-15 11:03, Wang Sheng-Hui:
> 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 <shhuiw@gmail.com>
[...]
> @@ -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;

I wonder if there are some use cases where default values could be used for 
first tests.
If we can set some default values for coremask and memory channels, then we 
can accept having no argument.
Maybe that an option -h would be needed.

> @@ -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 &&

You should move eal_parse_args() just after rte_eal_log_early_init() in order 
to have logs available.

Could you send a v2 patch with this kind of change for BSD also.

Thank you
-- 
Thomas