
UADK supports registration of log to the rsyslog service. So it will read the rsyslog.conf to user's log level. Here use '%[^\n ] ' to divided the lines in file into words to analysis. But there is a problem if the first line in the file is '\n'. The fscanf will return 0 and always read the first line, which makes a infinite loop. Add a whitespace before '%[^\n ] ' to filter the unintended '\n'. Signed-off-by: Yang Shen <shenyang39@huawei.com> --- wd.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wd.c b/wd.c index ddde38d..e88c993 100644 --- a/wd.c +++ b/wd.c @@ -79,7 +79,7 @@ static void wd_parse_log_level(void) goto close_file; } - while (fscanf(in_file, "%[^\n ] ", file_contents) != EOF) { + while (fscanf(in_file, " %[^\n ] ", file_contents) != EOF) { if (!strcmp("local5.debug", file_contents)) log_debug = true; else if (!strcmp("local5.info", file_contents)) -- 2.33.0