]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
systemctl: use LESS_BY where appropriate
authorLennart Poettering <lennart@poettering.net>
Thu, 28 Oct 2021 14:43:27 +0000 (16:43 +0200)
committerLennart Poettering <lennart@poettering.net>
Thu, 28 Oct 2021 14:43:27 +0000 (16:43 +0200)
src/systemctl/systemctl-show.c

index c3a9ba763d6515ff27479bd0efee0984242cd2b0..ea4ac63c44b8cfcd7c2ea542415a61c871f991e9 100644 (file)
@@ -710,11 +710,7 @@ static void print_status_info(
 
                 printf("     CGroup: %s\n", i->control_group);
 
-                c = columns();
-                if (c > sizeof(prefix) - 1)
-                        c -= sizeof(prefix) - 1;
-                else
-                        c = 0;
+                c = LESS_BY(columns(), strlen(prefix));
 
                 r = unit_show_processes(bus, i->id, i->control_group, prefix, c, get_output_flags(), &error);
                 if (r == -EBADR) {
@@ -2097,11 +2093,7 @@ static int show_system_status(sd_bus *bus) {
                 static const char prefix[] = "           ";
                 unsigned c;
 
-                c = columns();
-                if (c > sizeof(prefix) - 1)
-                        c -= sizeof(prefix) - 1;
-                else
-                        c = 0;
+                c = LESS_BY(columns(), strlen(prefix));
 
                 show_cgroup(SYSTEMD_CGROUP_CONTROLLER, strempty(mi.control_group), prefix, c, get_output_flags());
         }