提交 77007f95 编写于 作者: H Heinrich Schuchardt 提交者: Simon Glass

log: check argument of 'log level' command

Check that the argument provided to the 'log level' command is in the range
between zero and CONFIG_LOG_MAX_LEVEL.
Signed-off-by: NHeinrich Schuchardt <xypron.glpk@gmx.de>
Reviewed-by: NSimon Glass <sjg@chromium.org>
上级 7b6c34cb
......@@ -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;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册