diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-10-15 23:00:54 +0200 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2017-10-18 17:14:05 +0200 |
commit | c47f86e660176a1149f3afc5e2eb12ea3bcbb6d9 (patch) | |
tree | d397e72bf3f2ae9b0bc0f7ae9b60c1946f81c655 /src/basic | |
parent | 545a30a9a921018a2b59cd92f78a6b287defc8cf (diff) | |
download | systemd-c47f86e660176a1149f3afc5e2eb12ea3bcbb6d9.tar.gz |
util-lib: simplify kexec_loaded()
Diffstat (limited to 'src/basic')
-rw-r--r-- | src/basic/util.c | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/src/basic/util.c b/src/basic/util.c index 687de40993..37fbfbf97f 100644 --- a/src/basic/util.c +++ b/src/basic/util.c @@ -177,15 +177,12 @@ int block_get_whole_disk(dev_t d, dev_t *ret) { } bool kexec_loaded(void) { - bool loaded = false; - char *s; - - if (read_one_line_file("/sys/kernel/kexec_loaded", &s) >= 0) { - if (s[0] == '1') - loaded = true; - free(s); - } - return loaded; + _cleanup_free_ char *s = NULL; + + if (read_one_line_file("/sys/kernel/kexec_loaded", &s) < 0) + return false; + + return s[0] == '1'; } int prot_from_flags(int flags) { |