Re: [PATCH 3/5] dmesg: allow loglevels specified as numbers

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 23-06-12, Sascha Hauer wrote:
> In Linux dmesg loglevels can be specified as strings or as numbers.
> Do likewise in barebox.
> 
> Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>

Reviewed-by: Marco Felsch <m.felsch@xxxxxxxxxxxxxx>

> ---
>  commands/dmesg.c | 12 +++++++++++-
>  1 file changed, 11 insertions(+), 1 deletion(-)
> 
> diff --git a/commands/dmesg.c b/commands/dmesg.c
> index 2a36710b98..00e5a159e0 100644
> --- a/commands/dmesg.c
> +++ b/commands/dmesg.c
> @@ -13,6 +13,16 @@
>  
>  static int str_to_loglevel(const char *str)
>  {
> +	int ret;
> +	unsigned long level;
> +
> +	ret = kstrtoul(str, 10, &level);
> +	if (!ret) {
> +		if (level > MSG_VDEBUG)
> +			goto unknown;
> +		return level;
> +	}
> +
>  	if (!strcmp(str, "vdebug"))
>  		return MSG_VDEBUG;
>  	if (!strcmp(str, "debug"))
> @@ -31,7 +41,7 @@ static int str_to_loglevel(const char *str)
>  		return MSG_ALERT;
>  	if (!strcmp(str, "emerg"))
>  		return MSG_EMERG;
> -
> +unknown:
>  	printf("dmesg: unknown loglevel %s\n", str);
>  
>  	return -EINVAL;
> -- 
> 2.39.2
> 
> 
> 




[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux