On Wed, Mar 10, 2021 at 12:31:10AM +0100, Thomas Monjalon wrote:
> The parsing check for invalid log level was not trying to catch
> irrelevant numeric values.
> A log level 0 or too high is now a failure in options parsing
> so it can be caught early.
> 
> Signed-off-by: Thomas Monjalon <tho...@monjalon.net>

One thing I'd note here is that our log range of 1 to 8 is a little
strange, and that it would be nice if we could accept 9 as a valid log
level too on the cmdline. Ideally 0 would also be acceptable, for all
logging off, but it's more likely that people want to up the log level than
reduce it, and 9 is a more expected max value than 8.

> ---
>  lib/librte_eal/common/eal_common_options.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/lib/librte_eal/common/eal_common_options.c 
> b/lib/librte_eal/common/eal_common_options.c
> index febc99612a..5b9ce286ff 100644
> --- a/lib/librte_eal/common/eal_common_options.c
> +++ b/lib/librte_eal/common/eal_common_options.c
> @@ -1289,7 +1289,7 @@ eal_parse_log_level(const char *arg)
>       }
>  
>       priority = eal_parse_log_priority(level);
> -     if (priority < 0) {
> +     if (priority <= 0 || priority > (int) RTE_LOG_MAX) {
>               fprintf(stderr, "invalid log priority: %s\n", level);
>               goto fail;
>       }

Reply via email to