mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Marco Felsch <m.felsch@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: Barebox List <barebox@lists.infradead.org>
Subject: Re: [PATCH 3/5] dmesg: allow loglevels specified as numbers
Date: Tue, 13 Jun 2023 08:41:04 +0200	[thread overview]
Message-ID: <20230613064104.tcenib27cinuoxni@pengutronix.de> (raw)
In-Reply-To: <20230612123232.3071957-4-s.hauer@pengutronix.de>

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@pengutronix.de>

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

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



  reply	other threads:[~2023-06-13  6:42 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-12 12:32 [PATCH 0/5] implement dmesg -n Sascha Hauer
2023-06-12 12:32 ` [PATCH 1/5] dmesg: factor out str_to_loglevel() Sascha Hauer
2023-06-13  6:41   ` Marco Felsch
2023-06-12 12:32 ` [PATCH 2/5] dmesg: error out on unknown loglevels Sascha Hauer
2023-06-13  6:34   ` Marco Felsch
2023-06-13  6:49     ` Sascha Hauer
2023-06-13  6:57       ` Marco Felsch
2023-06-12 12:32 ` [PATCH 3/5] dmesg: allow loglevels specified as numbers Sascha Hauer
2023-06-13  6:41   ` Marco Felsch [this message]
2023-06-12 12:32 ` [PATCH 4/5] dmesg: implement dmesg -n Sascha Hauer
2023-06-13  6:45   ` Marco Felsch
2023-06-13  6:54     ` Sascha Hauer
2023-06-12 12:32 ` [PATCH 5/5] dmesg: udpate help Sascha Hauer
2023-06-13  6:40   ` Marco Felsch

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20230613064104.tcenib27cinuoxni@pengutronix.de \
    --to=m.felsch@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox