1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-13 17:18:18 +03:00

Merge pull request #27773 from dtardon/timestamp-cleanup

Use *timestamp_is_set() at more places
This commit is contained in:
Yu Watanabe 2023-05-25 03:27:15 +09:00 committed by GitHub
commit 65d9bd5626
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 19 additions and 19 deletions

View File

@ -29,7 +29,7 @@ static int list_dependencies_print(
printf("%s", special_glyph(last ? SPECIAL_GLYPH_TREE_RIGHT : SPECIAL_GLYPH_TREE_BRANCH));
if (times) {
if (times->time > 0)
if (timestamp_is_set(times->time))
printf("%s%s @%s +%s%s", ansi_highlight_red(), name,
FORMAT_TIMESPAN(times->activating - boot->userspace_time, USEC_PER_MSEC),
FORMAT_TIMESPAN(times->time, USEC_PER_MSEC), ansi_normal());

View File

@ -206,14 +206,14 @@ static int produce_plot_as_svg(
if (boot->firmware_time > boot->loader_time)
m++;
if (boot->loader_time > 0) {
if (timestamp_is_set(boot->loader_time)) {
m++;
if (width < 1000.0)
width = 1000.0;
}
if (boot->initrd_time > 0)
if (timestamp_is_set(boot->initrd_time))
m++;
if (boot->kernel_done_time > 0)
if (timestamp_is_set(boot->kernel_done_time))
m++;
for (u = times; u->has_data; u++) {
@ -295,22 +295,22 @@ static int produce_plot_as_svg(
svg("<g transform=\"translate(%.3f,100)\">\n", 20.0 + (SCALE_X * boot->firmware_time));
svg_graph_box(m, -(double) boot->firmware_time, boot->finish_time);
if (boot->firmware_time > 0) {
if (timestamp_is_set(boot->firmware_time)) {
svg_bar("firmware", -(double) boot->firmware_time, -(double) boot->loader_time, y);
svg_text(true, -(double) boot->firmware_time, y, "firmware");
y++;
}
if (boot->loader_time > 0) {
if (timestamp_is_set(boot->loader_time)) {
svg_bar("loader", -(double) boot->loader_time, 0, y);
svg_text(true, -(double) boot->loader_time, y, "loader");
y++;
}
if (boot->kernel_done_time > 0) {
if (timestamp_is_set(boot->kernel_done_time)) {
svg_bar("kernel", 0, boot->kernel_done_time, y);
svg_text(true, 0, y, "kernel");
y++;
}
if (boot->initrd_time > 0) {
if (timestamp_is_set(boot->initrd_time)) {
svg_bar("initrd", boot->initrd_time, boot->userspace_time, y);
if (boot->initrd_security_start_time < boot->initrd_security_finish_time)
svg_bar("security", boot->initrd_security_start_time, boot->initrd_security_finish_time, y);
@ -330,7 +330,7 @@ static int produce_plot_as_svg(
}
svg_bar("active", boot->userspace_time, boot->finish_time, y);
if (boot->security_start_time > 0)
if (timestamp_is_set(boot->security_start_time))
svg_bar("security", boot->security_start_time, boot->security_finish_time, y);
svg_bar("generators", boot->generators_start_time, boot->generators_finish_time, y);
svg_bar("unitsload", boot->unitsload_start_time, boot->unitsload_finish_time, y);
@ -354,7 +354,7 @@ static int produce_plot_as_svg(
svg_bar("deactivating", 0, 300000, y);
svg_text(true, 400000, y, "Deactivating");
y++;
if (boot->security_start_time > 0) {
if (timestamp_is_set(boot->security_start_time)) {
svg_bar("security", 0, 300000, y);
svg_text(true, 400000, y, "Setting up security module");
y++;

View File

@ -173,24 +173,24 @@ int pretty_boot_time(sd_bus *bus, char **ret) {
if (!text)
return log_oom();
if (t->firmware_time > 0 && !strextend(&text, FORMAT_TIMESPAN(t->firmware_time - t->loader_time, USEC_PER_MSEC), " (firmware) + "))
if (timestamp_is_set(t->firmware_time) && !strextend(&text, FORMAT_TIMESPAN(t->firmware_time - t->loader_time, USEC_PER_MSEC), " (firmware) + "))
return log_oom();
if (t->loader_time > 0 && !strextend(&text, FORMAT_TIMESPAN(t->loader_time, USEC_PER_MSEC), " (loader) + "))
if (timestamp_is_set(t->loader_time) && !strextend(&text, FORMAT_TIMESPAN(t->loader_time, USEC_PER_MSEC), " (loader) + "))
return log_oom();
if (t->kernel_done_time > 0 && !strextend(&text, FORMAT_TIMESPAN(t->kernel_done_time, USEC_PER_MSEC), " (kernel) + "))
if (timestamp_is_set(t->kernel_done_time) && !strextend(&text, FORMAT_TIMESPAN(t->kernel_done_time, USEC_PER_MSEC), " (kernel) + "))
return log_oom();
if (t->initrd_time > 0 && !strextend(&text, FORMAT_TIMESPAN(t->userspace_time - t->initrd_time, USEC_PER_MSEC), " (initrd) + "))
if (timestamp_is_set(t->initrd_time) && !strextend(&text, FORMAT_TIMESPAN(t->userspace_time - t->initrd_time, USEC_PER_MSEC), " (initrd) + "))
return log_oom();
if (!strextend(&text, FORMAT_TIMESPAN(t->finish_time - t->userspace_time, USEC_PER_MSEC), " (userspace) "))
return log_oom();
if (t->kernel_done_time > 0)
if (timestamp_is_set(t->kernel_done_time))
if (!strextend(&text, "= ", FORMAT_TIMESPAN(t->firmware_time + t->finish_time, USEC_PER_MSEC), " "))
return log_oom();
if (unit_id && timestamp_is_set(activated_time)) {
usec_t base = t->userspace_time > 0 ? t->userspace_time : t->reverse_offset;
usec_t base = timestamp_is_set(t->userspace_time) ? t->userspace_time : t->reverse_offset;
if (!strextend(&text, "\n", unit_id, " reached after ", FORMAT_TIMESPAN(activated_time - base, USEC_PER_MSEC), " in userspace."))
return log_oom();

View File

@ -716,7 +716,7 @@ static void socket_dump(Unit *u, FILE *f, const char *prefix) {
prefix, strna(s->user),
prefix, strna(s->group));
if (s->keep_alive_time > 0)
if (timestamp_is_set(s->keep_alive_time))
fprintf(f,
"%sKeepAliveTimeSec: %s\n",
prefix, FORMAT_TIMESPAN(s->keep_alive_time, USEC_PER_SEC));
@ -973,7 +973,7 @@ static void socket_apply_socket_options(Socket *s, SocketPort *p, int fd) {
log_unit_warning_errno(UNIT(s), r, "SO_KEEPALIVE failed: %m");
}
if (s->keep_alive_time > 0) {
if (timestamp_is_set(s->keep_alive_time)) {
r = setsockopt_int(fd, SOL_TCP, TCP_KEEPIDLE, s->keep_alive_time / USEC_PER_SEC);
if (r < 0)
log_unit_warning_errno(UNIT(s), r, "TCP_KEEPIDLE failed: %m");

View File

@ -688,7 +688,7 @@ static int timer_serialize(Unit *u, FILE *f, FDSet *fds) {
(void) serialize_item(f, "state", timer_state_to_string(t->state));
(void) serialize_item(f, "result", timer_result_to_string(t->result));
if (t->last_trigger.realtime > 0)
if (dual_timestamp_is_set(&t->last_trigger))
(void) serialize_usec(f, "last-trigger-realtime", t->last_trigger.realtime);
if (t->last_trigger.monotonic > 0)