[dpdk-dev] [PATCH v3 20/20] eal: set log level from command line

Neil Horman nhorman at tuxdriver.com
Wed Sep 17 16:45:31 CEST 2014


On Wed, Sep 17, 2014 at 03:46:52PM +0200, David Marchand wrote:
> Add a --log-level option to set the default eal log level.
> 
> Signed-off-by: David Marchand <david.marchand at 6wind.com>
> Acked-by: Bruce Richardson <bruce.richardson at intel.com>
> ---
>  #else
> @@ -652,6 +679,18 @@ eal_parse_args(int argc, char **argv)
>  					eal_usage(prgname);
>  					return -1;
>  				}
> +			} else if (!strcmp(lgopts[option_index].name,
> +					 OPT_LOG_LEVEL)) {
> +				uint32_t log;
> +
> +				if (eal_parse_log_level(optarg, &log) < 0) {
> +					RTE_LOG(ERR, EAL,
> +						"invalid parameters for --"
> +						OPT_LOG_LEVEL "\n");
> +					eal_usage(prgname);
> +					return -1;
> +				}
> +				internal_config.log_level = log;


This is a nit, but since you're working in this code anyway, would you mind
fixing the long options parsing please?  Instead of having a single case
statement that just does a never ending if..else..if series of strcmps that
could possibly cause a stack overflow, you can set the val value in the lgopts
array to a unique value for each option and just have a set of case statements.
It would look a lot more readable and exeucte more safely.

Thanks
Neil



More information about the dev mailing list