diff options
author | Lennart Poettering <lennart@poettering.net> | 2019-07-12 10:25:28 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2019-07-13 11:05:07 +0200 |
commit | 701f6af6b989bae0752a98b38e1fb228a9e1831c (patch) | |
tree | a3492a22f72ca7b0c466be303d4cba206a080d23 /src/shutdown | |
parent | 60cd367649aa54e4edc2e906a87f0afba936c87f (diff) | |
download | systemd-701f6af6b989bae0752a98b38e1fb228a9e1831c.tar.gz |
shutdown: use "int" for log level type
Let's remove some unnecessary confusion around signed/unsigned types for
log levels. Let's just stick to signed, because that is what glibc
generally appears to use.
While we are at it, add explicit logging for all error causes.
Diffstat (limited to 'src/shutdown')
-rw-r--r-- | src/shutdown/shutdown.c | 13 |
1 files changed, 7 insertions, 6 deletions
diff --git a/src/shutdown/shutdown.c b/src/shutdown/shutdown.c index 9623fe9ea2..33f9de52a4 100644 --- a/src/shutdown/shutdown.c +++ b/src/shutdown/shutdown.c @@ -258,7 +258,7 @@ static void sync_with_progress(void) { static int read_current_sysctl_printk_log_level(void) { _cleanup_free_ char *sysctl_printk_vals = NULL, *sysctl_printk_curr = NULL; - unsigned current_lvl = 0; + int current_lvl; const char *p; int r; @@ -268,13 +268,14 @@ static int read_current_sysctl_printk_log_level(void) { p = sysctl_printk_vals; r = extract_first_word(&p, &sysctl_printk_curr, NULL, 0); - if (r > 0) - r = safe_atou(sysctl_printk_curr, ¤t_lvl); - else if (r == 0) - r = -EINVAL; + if (r < 0) + return log_debug_errno(r, "Failed to split out kernel printk priority: %m"); + if (r == 0) + return log_debug_errno(SYNTHETIC_ERRNO(EINVAL), "Short read while reading kernel.printk sysctl"); + r = safe_atoi(sysctl_printk_curr, ¤t_lvl); if (r < 0) - return log_debug_errno(r, "Unexpected sysctl kernel.printk content: %s", sysctl_printk_vals); + return log_debug_errno(r, "Failed to parse kernel.printk sysctl: %s", sysctl_printk_vals); return current_lvl; } |