_cleanup_free_ char *value = NULL;
bool clamp;
- if (shall_restore_state() == 0)
+ if (!shall_restore_state())
return 0;
if (validate_device(device) == 0)
assert(c->rfkill_fd >= 0);
assert(event);
- if (shall_restore_state() == 0)
+ if (!shall_restore_state())
return 0;
r = determine_state_file(event, &state_file);
return log_full_errno(flags & REBOOT_LOG ? LOG_ERR : LOG_DEBUG, errno, "Failed to reboot: %m");
}
-int shall_restore_state(void) {
- bool ret;
+bool shall_restore_state(void) {
+ static int cached = -1;
+ bool b = true; /* If nothing specified or the check fails, then defaults to true. */
int r;
- r = proc_cmdline_get_bool("systemd.restore_state", /* flags = */ 0, &ret);
+ if (cached >= 0)
+ return cached;
+
+ r = proc_cmdline_get_bool("systemd.restore_state", PROC_CMDLINE_TRUE_WHEN_MISSING, &b);
if (r < 0)
- return r;
+ log_debug_errno(r, "Failed to parse systemd.restore_state= kernel command line option, ignoring: %m");
- return r > 0 ? ret : true;
+ return (cached = b);
}
static int xen_kexec_loaded(void) {
int read_reboot_parameter(char **parameter);
int reboot_with_parameter(RebootFlags flags);
-int shall_restore_state(void);
+bool shall_restore_state(void);
bool kexec_loaded(void);