util-lib: simplify kexec_loaded()

This commit is contained in:
Zbigniew Jędrzejewski-Szmek 2017-10-15 23:00:54 +02:00
parent 545a30a9a9
commit c47f86e660

View file

@ -177,15 +177,12 @@ int block_get_whole_disk(dev_t d, dev_t *ret) {
}
bool kexec_loaded(void) {
bool loaded = false;
char *s;
_cleanup_free_ char *s = NULL;
if (read_one_line_file("/sys/kernel/kexec_loaded", &s) >= 0) {
if (s[0] == '1')
loaded = true;
free(s);
}
return loaded;
if (read_one_line_file("/sys/kernel/kexec_loaded", &s) < 0)
return false;
return s[0] == '1';
}
int prot_from_flags(int flags) {