loginctl,machinectl: use LESS_BY() where appropriate
And while we are at it, add a lower bound of the display output to 10 for all three cases, because it's pointless outputting someting with less space.
This commit is contained in:
committed by
Yu Watanabe
parent
5b207b3cbf
commit
3ae6e64641
@@ -436,7 +436,6 @@ static int show_unit_cgroup(
|
||||
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
_cleanup_free_ char *cgroup = NULL;
|
||||
unsigned c;
|
||||
int r;
|
||||
|
||||
assert(bus);
|
||||
@@ -450,10 +449,7 @@ static int show_unit_cgroup(
|
||||
if (isempty(cgroup))
|
||||
return 0;
|
||||
|
||||
c = columns();
|
||||
if (c > 18)
|
||||
c -= 18;
|
||||
|
||||
unsigned c = MAX(LESS_BY(columns(), 18U), 10U);
|
||||
r = unit_show_processes(bus, unit, cgroup, prefix, c, get_output_flags(), &error);
|
||||
if (r == -EBADR) {
|
||||
if (arg_transport == BUS_TRANSPORT_REMOTE)
|
||||
@@ -905,10 +901,7 @@ static int print_seat_status_info(sd_bus *bus, const char *path) {
|
||||
return table_log_print_error(r);
|
||||
|
||||
if (arg_transport == BUS_TRANSPORT_LOCAL) {
|
||||
unsigned c = columns();
|
||||
if (c > 21)
|
||||
c -= 21;
|
||||
|
||||
unsigned c = MAX(LESS_BY(columns(), 21U), 10U);
|
||||
show_sysfs(i.id, strrepa(" ", STRLEN("Sessions:")), c, get_output_flags());
|
||||
}
|
||||
|
||||
|
||||
@@ -416,7 +416,6 @@ static int show_unit_cgroup(sd_bus *bus, const char *unit, pid_t leader) {
|
||||
_cleanup_free_ char *cgroup = NULL;
|
||||
_cleanup_(sd_bus_error_free) sd_bus_error error = SD_BUS_ERROR_NULL;
|
||||
int r;
|
||||
unsigned c;
|
||||
|
||||
assert(bus);
|
||||
assert(unit);
|
||||
@@ -428,12 +427,7 @@ static int show_unit_cgroup(sd_bus *bus, const char *unit, pid_t leader) {
|
||||
if (isempty(cgroup))
|
||||
return 0;
|
||||
|
||||
c = columns();
|
||||
if (c > 18)
|
||||
c -= 18;
|
||||
else
|
||||
c = 0;
|
||||
|
||||
unsigned c = MAX(LESS_BY(columns(), 18U), 10U);
|
||||
r = unit_show_processes(bus, unit, cgroup, "\t\t ", c, get_output_flags(), &error);
|
||||
if (r == -EBADR) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user