if (r < 0)
return r;
if ((flags & ~SD_LOGIND_SHUTDOWN_AND_SLEEP_FLAGS_PUBLIC) != 0)
- return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Invalid flags parameter");
+ return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS,
+ "Invalid flags parameter");
if (a->handle != HANDLE_REBOOT && (flags & SD_LOGIND_REBOOT_VIA_KEXEC))
- return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS, "Reboot via kexec is only applicable with reboot operations");
+ return sd_bus_error_set(error, SD_BUS_ERROR_INVALID_ARGS,
+ "Reboot via kexec is only applicable with reboot operations");
} else {
/* Old style method: no flags parameter, but interactive bool passed as boolean in
* payload. Let's convert this argument to the new-style flags parameter for our internal
"Not enough swap space for hibernation");
if (r == 0)
return sd_bus_error_setf(error, BUS_ERROR_SLEEP_VERB_NOT_SUPPORTED,
- "Sleep verb \"%s\" not supported", sleep_operation_to_string(a->sleep_operation));
+ "Sleep verb \"%s\" not supported",
+ sleep_operation_to_string(a->sleep_operation));
if (r < 0)
return r;
}
#include "utmp-wtmp.h"
_const_ static usec_t when_wall(usec_t n, usec_t elapse) {
-
- usec_t left;
- unsigned i;
static const int wall_timers[] = {
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
25, 40, 55, 70, 100, 130, 150, 180,
if (n >= elapse)
return 0;
- left = elapse - n;
+ usec_t left = elapse - n;
- for (i = 1; i < ELEMENTSOF(wall_timers); i++)
+ for (unsigned i = 1; i < ELEMENTSOF(wall_timers); i++)
if (wall_timers[i] * USEC_PER_MINUTE >= left)
return left - wall_timers[i-1] * USEC_PER_MINUTE;
}
static int warn_wall(Manager *m, usec_t n) {
- _cleanup_free_ char *l = NULL, *username = NULL;
- usec_t left;
int r;
assert(m);
if (!m->enable_wall_messages || !m->scheduled_shutdown_action)
return 0;
- left = m->scheduled_shutdown_timeout > n;
+ usec_t left = m->scheduled_shutdown_timeout > n;
+
+ _cleanup_free_ char *l = NULL, *username = NULL;
r = asprintf(&l, "%s%sThe system will %s %s%s!",
strempty(m->wall_message),
uint64_t usec,
void *userdata) {
- Manager *m = userdata;
- usec_t n, next;
+ Manager *m = ASSERT_PTR(userdata);
int r;
- assert(m);
assert(s == m->wall_message_timeout_source);
- n = now(CLOCK_REALTIME);
+ usec_t n = now(CLOCK_REALTIME);
r = warn_wall(m, n);
if (r == 0)
return 0;
- next = when_wall(n, m->scheduled_shutdown_timeout);
+ usec_t next = when_wall(n, m->scheduled_shutdown_timeout);
if (next > 0) {
r = sd_event_source_set_time(s, n + next);
if (r < 0)
}
int manager_setup_wall_message_timer(Manager *m) {
-
- usec_t n, elapse;
int r;
assert(m);
- n = now(CLOCK_REALTIME);
- elapse = m->scheduled_shutdown_timeout;
+ usec_t n = now(CLOCK_REALTIME);
+ usec_t elapse = m->scheduled_shutdown_timeout;
/* wall message handling */