* [PATCH 1/1] log: check argument of 'log level' command
@ 2020-05-31 13:44 Heinrich Schuchardt
2020-05-31 16:14 ` Simon Glass
2020-06-13 3:11 ` sjg at google.com
0 siblings, 2 replies; 3+ messages in thread
From: Heinrich Schuchardt @ 2020-05-31 13:44 UTC (permalink / raw)
To: u-boot
Check that the argument provided to the 'log level' command is in the range
between zero and CONFIG_LOG_MAX_LEVEL.
Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
cmd/log.c | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/cmd/log.c b/cmd/log.c
index 664f7bd7ac..78352b2cb9 100644
--- a/cmd/log.c
+++ b/cmd/log.c
@@ -14,10 +14,18 @@ static char log_fmt_chars[LOGF_COUNT] = "clFLfm";
static int do_log_level(struct cmd_tbl *cmdtp, int flag, int argc,
char *const argv[])
{
- if (argc > 1)
- gd->default_log_level = simple_strtol(argv[1], NULL, 10);
- else
+ if (argc > 1) {
+ long log_level = simple_strtol(argv[1], NULL, 10);
+
+ if (log_level < 0 || log_level > _LOG_MAX_LEVEL) {
+ printf("Only log levels <= %d are supported\n",
+ _LOG_MAX_LEVEL);
+ return CMD_RET_FAILURE;
+ }
+ gd->default_log_level = log_level;
+ } else {
printf("Default log level: %d\n", gd->default_log_level);
+ }
return 0;
}
--
2.20.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 1/1] log: check argument of 'log level' command
2020-05-31 13:44 [PATCH 1/1] log: check argument of 'log level' command Heinrich Schuchardt
@ 2020-05-31 16:14 ` Simon Glass
2020-06-13 3:11 ` sjg at google.com
1 sibling, 0 replies; 3+ messages in thread
From: Simon Glass @ 2020-05-31 16:14 UTC (permalink / raw)
To: u-boot
On Sun, 31 May 2020 at 07:44, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> Check that the argument provided to the 'log level' command is in the range
> between zero and CONFIG_LOG_MAX_LEVEL.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> cmd/log.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
Then we should have a little test for the log command, perhaps
run_command() and then check that the default log level is set (or
not, on error).
^ permalink raw reply [flat|nested] 3+ messages in thread
* [PATCH 1/1] log: check argument of 'log level' command
2020-05-31 13:44 [PATCH 1/1] log: check argument of 'log level' command Heinrich Schuchardt
2020-05-31 16:14 ` Simon Glass
@ 2020-06-13 3:11 ` sjg at google.com
1 sibling, 0 replies; 3+ messages in thread
From: sjg at google.com @ 2020-06-13 3:11 UTC (permalink / raw)
To: u-boot
On Sun, 31 May 2020 at 07:44, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> Check that the argument provided to the 'log level' command is in the range
> between zero and CONFIG_LOG_MAX_LEVEL.
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
> cmd/log.c | 14 +++++++++++---
> 1 file changed, 11 insertions(+), 3 deletions(-)
Reviewed-by: Simon Glass <sjg@chromium.org>
Then we should have a little test for the log command, perhaps
run_command() and then check that the default log level is set (or
not, on error).
Applied to u-boot-dm, thanks!
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2020-06-13 3:11 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-05-31 13:44 [PATCH 1/1] log: check argument of 'log level' command Heinrich Schuchardt
2020-05-31 16:14 ` Simon Glass
2020-06-13 3:11 ` sjg at google.com
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.