diff options
author | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-02-08 22:20:19 +0100 |
---|---|---|
committer | Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl> | 2018-02-09 12:27:34 +0100 |
commit | 230cc99a0f84bc0a5d9d974f665a81060b264a70 (patch) | |
tree | 4135d2137dd409a73ca8eafb83ad55b907ef8b07 | |
parent | baa4880bac202f53937739d0a1af6fc9900b29cd (diff) | |
download | systemd-230cc99a0f84bc0a5d9d974f665a81060b264a70.tar.gz |
analyze: slight simplification
-rw-r--r-- | src/analyze/analyze.c | 25 |
1 files changed, 13 insertions, 12 deletions
diff --git a/src/analyze/analyze.c b/src/analyze/analyze.c index 8ba237987d..2d65fdbdb8 100644 --- a/src/analyze/analyze.c +++ b/src/analyze/analyze.c @@ -441,8 +441,7 @@ static int acquire_time_data(sd_bus *bus, struct unit_times **out) { return c; fail: - if (unit_times) - free_unit_times(unit_times, (unsigned) c); + free_unit_times(unit_times, (unsigned) c); return r; } @@ -866,6 +865,11 @@ static int list_dependencies_compare(const void *_a, const void *_b) { return usb - usa; } +static bool times_in_range(const struct unit_times *times, const struct boot_times *boot) { + return times && + times->activated > 0 && times->activated <= boot->finish_time; +} + static int list_dependencies_one(sd_bus *bus, const char *name, unsigned int level, char ***units, unsigned int branches) { _cleanup_strv_free_ char **deps = NULL; @@ -891,11 +895,9 @@ static int list_dependencies_one(sd_bus *bus, const char *name, unsigned int lev STRV_FOREACH(c, deps) { times = hashmap_get(unit_times_hashmap, *c); - if (times - && times->activated - && times->activated <= boot->finish_time - && (times->activated >= service_longest - || service_longest == 0)) { + if (times_in_range(times, boot) && + (times->activated >= service_longest + || service_longest == 0)) { service_longest = times->activated; break; } @@ -906,7 +908,8 @@ static int list_dependencies_one(sd_bus *bus, const char *name, unsigned int lev STRV_FOREACH(c, deps) { times = hashmap_get(unit_times_hashmap, *c); - if (times && times->activated && times->activated <= boot->finish_time && (service_longest - times->activated) <= arg_fuzz) + if (times_in_range(times, boot) && + service_longest - times->activated <= arg_fuzz) to_print++; } @@ -915,10 +918,8 @@ static int list_dependencies_one(sd_bus *bus, const char *name, unsigned int lev STRV_FOREACH(c, deps) { times = hashmap_get(unit_times_hashmap, *c); - if (!times - || !times->activated - || times->activated > boot->finish_time - || service_longest - times->activated > arg_fuzz) + if (!times_in_range(times, boot) || + service_longest - times->activated > arg_fuzz) continue; to_print--; |