From 810394481b73f932f9fabbc75aee14cc6cba12d2 Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 14 Nov 2020 09:19:01 +0900 Subject: [PATCH 1/3] systemctl: always show underline even if unit has no job ID --- src/systemctl/systemctl-list-units.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systemctl/systemctl-list-units.c b/src/systemctl/systemctl-list-units.c index 0801912396..ddef5def0c 100644 --- a/src/systemctl/systemctl-list-units.c +++ b/src/systemctl/systemctl-list-units.c @@ -156,7 +156,7 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) { TABLE_STRING, u->sub_state, TABLE_SET_BOTH_COLORS, on_active, TABLE_STRING, u->job_id ? u->job_type: "", - TABLE_SET_BOTH_COLORS, u->job_id ? on_underline : "", + TABLE_SET_BOTH_COLORS, on_underline, TABLE_STRING, u->description, TABLE_SET_BOTH_COLORS, on_underline); if (r < 0) From ca7b9e1e0a84c007d848381527d043d9447b826b Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 14 Nov 2020 09:05:29 +0900 Subject: [PATCH 2/3] systemctl: use unsigned for job_count As, the number of units `c` is unsigned. --- src/systemctl/systemctl-list-units.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/systemctl/systemctl-list-units.c b/src/systemctl/systemctl-list-units.c index ddef5def0c..e6a530ed5b 100644 --- a/src/systemctl/systemctl-list-units.c +++ b/src/systemctl/systemctl-list-units.c @@ -90,6 +90,7 @@ static int get_unit_list_recursive( static int output_units_list(const UnitInfo *unit_infos, unsigned c) { _cleanup_(table_unrefp) Table *table = NULL; + unsigned job_count = 0; int r; table = table_new("", "unit", "load", "active", "sub", "job", "description"); @@ -108,7 +109,6 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) { (void) table_set_empty_string(table, "-"); - int job_count = 0; for (const UnitInfo *u = unit_infos; unit_infos && u < unit_infos + c; u++) { _cleanup_free_ char *j = NULL; const char *on_underline = "", *on_loaded = "", *on_active = ""; From 5ba97fc0a967e0c07f00bce605f5bdd8484d716c Mon Sep 17 00:00:00 2001 From: Yu Watanabe Date: Sat, 14 Nov 2020 09:06:35 +0900 Subject: [PATCH 3/3] systemctl: fix minor coding style issue --- src/systemctl/systemctl-list-units.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/systemctl/systemctl-list-units.c b/src/systemctl/systemctl-list-units.c index e6a530ed5b..b747cb5a55 100644 --- a/src/systemctl/systemctl-list-units.c +++ b/src/systemctl/systemctl-list-units.c @@ -186,7 +186,8 @@ static int output_units_list(const UnitInfo *unit_infos, unsigned c) { "LOAD = Reflects whether the unit definition was properly loaded.\n" "ACTIVE = The high-level unit activation state, i.e. generalization of SUB.\n" "SUB = The low-level unit activation state, values depend on unit type."); - puts(job_count ? "JOB = Pending job for the unit.\n" : ""); + if (job_count > 0) + puts("JOB = Pending job for the unit.\n"); on = ansi_highlight(); off = ansi_normal(); } else {