Skip to content

Commit baa4880

Browse files
committed
analyze: remove implicit conversions of numbers to booleans
1 parent 80efdac commit baa4880

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/analyze/analyze.c

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ static int acquire_boot_times(sd_bus *bus, struct boot_times **bt) {
297297
}
298298

299299
if (arg_scope == UNIT_FILE_SYSTEM) {
300-
if (times.initrd_time)
300+
if (times.initrd_time > 0)
301301
times.kernel_done_time = times.initrd_time;
302302
else
303303
times.kernel_done_time = times.userspace_time;
@@ -539,11 +539,11 @@ static int pretty_boot_time(sd_bus *bus, char **_buf) {
539539
size = sizeof(buf);
540540

541541
size = strpcpyf(&ptr, size, "Startup finished in ");
542-
if (t->firmware_time)
542+
if (t->firmware_time > 0)
543543
size = strpcpyf(&ptr, size, "%s (firmware) + ", format_timespan(ts, sizeof(ts), t->firmware_time - t->loader_time, USEC_PER_MSEC));
544-
if (t->loader_time)
544+
if (t->loader_time > 0)
545545
size = strpcpyf(&ptr, size, "%s (loader) + ", format_timespan(ts, sizeof(ts), t->loader_time, USEC_PER_MSEC));
546-
if (t->kernel_time)
546+
if (t->kernel_time > 0)
547547
size = strpcpyf(&ptr, size, "%s (kernel) + ", format_timespan(ts, sizeof(ts), t->kernel_done_time, USEC_PER_MSEC));
548548
if (t->initrd_time > 0)
549549
size = strpcpyf(&ptr, size, "%s (initrd) + ", format_timespan(ts, sizeof(ts), t->userspace_time - t->initrd_time, USEC_PER_MSEC));
@@ -552,7 +552,7 @@ static int pretty_boot_time(sd_bus *bus, char **_buf) {
552552
if (t->kernel_time > 0)
553553
strpcpyf(&ptr, size, "= %s", format_timespan(ts, sizeof(ts), t->firmware_time + t->finish_time, USEC_PER_MSEC));
554554

555-
if (unit_id && (activated_time > 0 && activated_time != USEC_INFINITY))
555+
if (unit_id && activated_time > 0 && activated_time != USEC_INFINITY)
556556
size = strpcpyf(&ptr, size, "\n%s reached after %s in userspace", unit_id, format_timespan(ts, sizeof(ts), activated_time - t->userspace_time, USEC_PER_MSEC));
557557
else if (unit_id && activated_time == 0)
558558
size = strpcpyf(&ptr, size, "\n%s was never reached", unit_id);
@@ -631,14 +631,14 @@ static int analyze_plot(int argc, char *argv[], void *userdata) {
631631

632632
if (boot->firmware_time > boot->loader_time)
633633
m++;
634-
if (boot->loader_time) {
634+
if (boot->loader_time > 0) {
635635
m++;
636636
if (width < 1000.0)
637637
width = 1000.0;
638638
}
639-
if (boot->initrd_time)
639+
if (boot->initrd_time > 0)
640640
m++;
641-
if (boot->kernel_time)
641+
if (boot->kernel_time > 0)
642642
m++;
643643

644644
for (u = times; u < times + n; u++) {
@@ -727,22 +727,22 @@ static int analyze_plot(int argc, char *argv[], void *userdata) {
727727
svg("<g transform=\"translate(%.3f,100)\">\n", 20.0 + (SCALE_X * boot->firmware_time));
728728
svg_graph_box(m, -(double) boot->firmware_time, boot->finish_time);
729729

730-
if (boot->firmware_time) {
730+
if (boot->firmware_time > 0) {
731731
svg_bar("firmware", -(double) boot->firmware_time, -(double) boot->loader_time, y);
732732
svg_text(true, -(double) boot->firmware_time, y, "firmware");
733733
y++;
734734
}
735-
if (boot->loader_time) {
735+
if (boot->loader_time > 0) {
736736
svg_bar("loader", -(double) boot->loader_time, 0, y);
737737
svg_text(true, -(double) boot->loader_time, y, "loader");
738738
y++;
739739
}
740-
if (boot->kernel_time) {
740+
if (boot->kernel_time > 0) {
741741
svg_bar("kernel", 0, boot->kernel_done_time, y);
742742
svg_text(true, 0, y, "kernel");
743743
y++;
744744
}
745-
if (boot->initrd_time) {
745+
if (boot->initrd_time > 0) {
746746
svg_bar("initrd", boot->initrd_time, boot->userspace_time, y);
747747
svg_text(true, boot->initrd_time, y, "initrd");
748748
y++;
@@ -820,7 +820,7 @@ static int list_dependencies_print(const char *name, unsigned int level, unsigne
820820
printf("%s", special_glyph(last ? TREE_RIGHT : TREE_BRANCH));
821821

822822
if (times) {
823-
if (times->time)
823+
if (times->time > 0)
824824
printf("%s%s @%s +%s%s", ansi_highlight_red(), name,
825825
format_timespan(ts, sizeof(ts), times->activating - boot->userspace_time, USEC_PER_MSEC),
826826
format_timespan(ts2, sizeof(ts2), times->time, USEC_PER_MSEC), ansi_normal());
@@ -940,7 +940,7 @@ static int list_dependencies_one(sd_bus *bus, const char *name, unsigned int lev
940940
if (r < 0)
941941
return r;
942942

943-
if (!to_print)
943+
if (to_print == 0)
944944
break;
945945
}
946946
return 0;

0 commit comments

Comments
 (0)