From 0cfa78ddf791a87a1c9bfdb41a6435de27a89ae9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 4 Apr 2018 09:05:56 +0200 Subject: [PATCH 1/5] dissect: drop unnecessary parenthesis --- src/shared/dissect-image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c index f5de54d9fe..e3213620a9 100644 --- a/src/shared/dissect-image.c +++ b/src/shared/dissect-image.c @@ -114,8 +114,8 @@ static bool device_is_mmc_special_partition(struct udev_device *d) { const char *sysname; sysname = udev_device_get_sysname(d); - return (sysname && startswith(sysname, "mmcblk") && - (endswith(sysname, "rpmb") || endswith(sysname, "boot0") || endswith(sysname, "boot1"))); + return sysname && startswith(sysname, "mmcblk") && + (endswith(sysname, "rpmb") || endswith(sysname, "boot0") || endswith(sysname, "boot1")); } static bool device_is_block(struct udev_device *d) { From e9e8cbc83a3c08f06d7cef207be468188ce35325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Wed, 4 Apr 2018 14:36:56 +0200 Subject: [PATCH 2/5] core: minor comment update --- src/core/unit.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/core/unit.c b/src/core/unit.c index 9ee50d3882..3512826707 100644 --- a/src/core/unit.c +++ b/src/core/unit.c @@ -1327,7 +1327,7 @@ int unit_load_fragment_and_dropin_optional(Unit *u) { /* Same as unit_load_fragment_and_dropin(), but whether * something can be loaded or not doesn't matter. */ - /* Load a .service file */ + /* Load a .service/.socket/.slice/… file */ r = unit_load_fragment(u); if (r < 0) return r; @@ -4728,9 +4728,8 @@ bool unit_is_pristine(Unit *u) { /* Check if the unit already exists or is already around, * in a number of different ways. Note that to cater for unit * types such as slice, we are generally fine with units that - * are marked UNIT_LOADED even though nothing was - * actually loaded, as those unit types don't require a file - * on disk to validly load. */ + * are marked UNIT_LOADED even though nothing was actually + * loaded, as those unit types don't require a file on disk. */ return !(!IN_SET(u->load_state, UNIT_NOT_FOUND, UNIT_LOADED) || u->fragment_path || From 1e9f0ccadf0bb086b10cd68c6ff534d1759d2576 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 7 Apr 2018 18:43:47 +0200 Subject: [PATCH 3/5] analyze: give a hint what is it means that boot is still active $ build/systemd-analyze time Bootup is not yet finished (org.freedesktop.systemd1.Manager.FinishTimestampMonotonic=0). Please try again later. Hint: Use 'systemctl list-jobs' to see active jobs --- src/analyze/analyze.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index 3bfeb278f8..68229a9457 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -303,7 +303,11 @@ static int acquire_boot_times(sd_bus *bus, struct boot_times **bt) { return -EIO; if (times.finish_time <= 0) { - log_error("Bootup is not yet finished. Please try again later."); + log_error("Bootup is not yet finished (org.freedesktop.systemd1.Manager.FinishTimestampMonotonic=%"PRIu64").\n" + "Please try again later.\n" + "Hint: Use 'systemctl%s list-jobs' to see active jobs", + times.finish_time, + arg_scope == UNIT_FILE_SYSTEM ? "" : " --user"); return -EINPROGRESS; } From 30dd293c8865780c8277cd15d436c798e77b048b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 7 Apr 2018 19:14:37 +0200 Subject: [PATCH 4/5] sd-event: use _cleanup_ to manage temporary references --- src/libsystemd/sd-event/sd-event.c | 24 ++++++++---------------- 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/src/libsystemd/sd-event/sd-event.c b/src/libsystemd/sd-event/sd-event.c index 7355921d30..eda32f671a 100644 --- a/src/libsystemd/sd-event/sd-event.c +++ b/src/libsystemd/sd-event/sd-event.c @@ -2403,6 +2403,7 @@ static int event_prepare(sd_event *e) { static int dispatch_exit(sd_event *e) { sd_event_source *p; + _cleanup_(sd_event_unrefp) sd_event *ref = NULL; int r; assert(e); @@ -2413,15 +2414,11 @@ static int dispatch_exit(sd_event *e) { return 0; } - sd_event_ref(e); + ref = sd_event_ref(e); e->iteration++; e->state = SD_EVENT_EXITING; - r = source_dispatch(p); - e->state = SD_EVENT_INITIAL; - sd_event_unref(e); - return r; } @@ -2661,14 +2658,12 @@ _public_ int sd_event_dispatch(sd_event *e) { p = event_next_pending(e); if (p) { - sd_event_ref(e); + _cleanup_(sd_event_unrefp) sd_event *ref = NULL; + ref = sd_event_ref(e); e->state = SD_EVENT_RUNNING; r = source_dispatch(p); e->state = SD_EVENT_INITIAL; - - sd_event_unref(e); - return r; } @@ -2735,6 +2730,7 @@ _public_ int sd_event_run(sd_event *e, uint64_t timeout) { } _public_ int sd_event_loop(sd_event *e) { + _cleanup_(sd_event_unrefp) sd_event *ref = NULL; int r; assert_return(e, -EINVAL); @@ -2742,19 +2738,15 @@ _public_ int sd_event_loop(sd_event *e) { assert_return(!event_pid_changed(e), -ECHILD); assert_return(e->state == SD_EVENT_INITIAL, -EBUSY); - sd_event_ref(e); + ref = sd_event_ref(e); while (e->state != SD_EVENT_FINISHED) { r = sd_event_run(e, (uint64_t) -1); if (r < 0) - goto finish; + return r; } - r = e->exit_code; - -finish: - sd_event_unref(e); - return r; + return e->exit_code; } _public_ int sd_event_get_fd(sd_event *e) { From 0fad9daf4b24b9063bc80d60207e6870289587bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zbigniew=20J=C4=99drzejewski-Szmek?= Date: Sat, 7 Apr 2018 19:19:49 +0200 Subject: [PATCH 5/5] time-sync-wait: trivial style fixes --- src/time-wait-sync/time-wait-sync.c | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/time-wait-sync/time-wait-sync.c b/src/time-wait-sync/time-wait-sync.c index 1cd29736aa..9b558532ce 100644 --- a/src/time-wait-sync/time-wait-sync.c +++ b/src/time-wait-sync/time-wait-sync.c @@ -47,8 +47,7 @@ static void clock_state_release(ClockState *sp) { sp->fd = safe_close(sp->fd); } -static int clock_state_update(ClockState *sp, - sd_event *event); +static int clock_state_update(ClockState *sp, sd_event *event); static int io_handler(sd_event_source * s, int fd, @@ -73,22 +72,22 @@ static int clock_state_update(ClockState *sp, clock_state_release(sp); /* The kernel supports cancelling timers whenever its realtime clock is "set" (which can happen in a variety of - * ways, generally adjustments of at least 500 ms). The way this module works is we set up a timer that will - * wake when it the clock is set, and when that happens we read the clock synchronization state from the return + * ways, generally adjustments of at least 500 ms). The way this module works is we set up a timer that will + * wake when the clock is set, and when that happens we read the clock synchronization state from the return * value of adjtimex(2), which supports the NTP time adjustment protocol. * * The kernel determines whether the clock is synchronized using driver-specific tests, based on time - * information passed by an application, generally through adjtimex(2). If the application asserts the clock + * information passed by an application, generally through adjtimex(2). If the application asserts the clock * is synchronized, but does not also do something that "sets the clock", the timer will not be cancelled and - * synchronization will not be detected. Should this behavior be observed with a time synchronization provider + * synchronization will not be detected. Should this behavior be observed with a time synchronization provider * this code might be reworked to do a periodic check as well. * * Similarly, this service will never complete if the application sets the time without also providing * information that adjtimex(2) can use to determine that the clock is synchronized. * - * Well-behaved implementations including systemd-timesyncd should not produce either situation. For timesyncd - * the initial set of the timestamp uses settimeofday(2), which sets the clock but does not mark it - * synchronized. When an NTP source is selected it sets the clock again with clock_adjtime(2) which does mark + * Well-behaved implementations including systemd-timesyncd should not produce either situation. For timesyncd + * the initial setting of the time uses settimeofday(2), which sets the clock but does not mark it + * synchronized. When an NTP source is selected it sets the clock again with clock_adjtime(2) which does mark * it synchronized. */ r = timerfd_create(CLOCK_REALTIME, TFD_NONBLOCK | TFD_CLOEXEC); if (r < 0) { @@ -119,7 +118,7 @@ static int clock_state_update(ClockState *sp, log_info("adjtime state %d status %x time %s", sp->adjtime_state, tx.status, ts); if (sp->adjtime_state == TIME_ERROR) { - /* Not synchronized. Do a one-shot wait on the descriptor and inform the caller we need to keep + /* Not synchronized. Do a one-shot wait on the descriptor and inform the caller we need to keep * running. */ r = sd_event_add_io(event, &sp->event_source, sp->fd, EPOLLIN, io_handler, sp); @@ -140,8 +139,7 @@ static int clock_state_update(ClockState *sp, return r; } -int main(int argc, - char * argv[]) { +int main(int argc, char * argv[]) { int r; _cleanup_(sd_event_unrefp) sd_event *event; ClockState state = { @@ -177,7 +175,7 @@ int main(int argc, r = clock_state_update(&state, event); if (r > 0) { r = sd_event_loop(event); - if (0 > r) + if (r < 0) log_error_errno(r, "Failed in event loop: %m"); else if (state.adjtime_state == TIME_ERROR) { log_error("Event loop terminated without synchronizing");