1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-08 21:17:47 +03:00

table: drop last SIZE_MAX from table_set_sort() and table_set_display()

This commit is contained in:
Yu Watanabe 2021-03-03 14:01:02 +09:00
parent 496db33004
commit ef1e0b9a46
16 changed files with 31 additions and 31 deletions

View File

@ -1528,11 +1528,11 @@ static int assess(const struct security_info *info, Table *overview_table, Analy
if (!details_table)
return log_oom();
(void) table_set_sort(details_table, (size_t) 3, (size_t) 1, (size_t) -1);
(void) table_set_sort(details_table, (size_t) 3, (size_t) 1);
(void) table_set_reverse(details_table, 3, true);
if (getenv_bool("SYSTEMD_ANALYZE_DEBUG") <= 0)
(void) table_set_display(details_table, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 6, (size_t) -1);
(void) table_set_display(details_table, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 6);
}
for (i = 0; i < ELEMENTSOF(security_assessor_table); i++) {

View File

@ -1090,7 +1090,7 @@ static int analyze_blame(int argc, char *argv[], void *userdata) {
if (r < 0)
return r;
r = table_set_sort(table, (size_t) 0, (size_t) SIZE_MAX);
r = table_set_sort(table, (size_t) 0);
if (r < 0)
return r;
@ -1622,7 +1622,7 @@ static int dump_capabilities(int argc, char *argv[], void *userdata) {
return table_log_add_error(r);
}
(void) table_set_sort(table, (size_t) 1, (size_t) -1);
(void) table_set_sort(table, (size_t) 1);
}
(void) pager_open(arg_pager_flags);

View File

@ -211,7 +211,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
if (r < 0)
return log_error_errno(r, "Failed to set empty string: %m");
r = table_set_sort(table, (size_t) COLUMN_NAME, (size_t) -1);
r = table_set_sort(table, (size_t) COLUMN_NAME);
if (r < 0)
return log_error_errno(r, "Failed to set sort column: %m");
@ -224,8 +224,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
(size_t) COLUMN_UNIT,
(size_t) COLUMN_SESSION,
(size_t) COLUMN_DESCRIPTION,
(size_t) COLUMN_MACHINE,
(size_t) -1);
(size_t) COLUMN_MACHINE);
else
r = table_set_display(table, (size_t) COLUMN_NAME,
(size_t) COLUMN_PID,
@ -234,8 +233,7 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
(size_t) COLUMN_CONNECTION,
(size_t) COLUMN_UNIT,
(size_t) COLUMN_SESSION,
(size_t) COLUMN_DESCRIPTION,
(size_t) -1);
(size_t) COLUMN_DESCRIPTION);
if (r < 0)
return log_error_errno(r, "Failed to set columns to display: %m");

View File

@ -171,7 +171,7 @@ static int list_homes(int argc, char *argv[], void *userdata) {
return bus_log_parse_error(r);
if (table_get_rows(table) > 1 || !FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF)) {
r = table_set_sort(table, (size_t) 0, (size_t) -1);
r = table_set_sort(table, (size_t) 0);
if (r < 0)
return table_log_sort_error(r);

View File

@ -131,7 +131,7 @@ static int print_inhibitors(sd_bus *bus) {
return bus_log_parse_error(r);
if (table_get_rows(table) > 1) {
r = table_set_sort(table, (size_t) 1, (size_t) 0, (size_t) 5, (size_t) 6, (size_t) -1);
r = table_set_sort(table, (size_t) 1, (size_t) 0, (size_t) 5, (size_t) 6);
if (r < 0)
return table_log_sort_error(r);

View File

@ -90,7 +90,7 @@ static int show_table(Table *table, const char *word) {
assert(word);
if (table_get_rows(table) > 1 || OUTPUT_MODE_IS_JSON(arg_output)) {
r = table_set_sort(table, (size_t) 0, (size_t) -1);
r = table_set_sort(table, (size_t) 0);
if (r < 0)
return table_log_sort_error(r);

View File

@ -239,7 +239,7 @@ static int show_table(Table *table, const char *word) {
assert(word);
if (table_get_rows(table) > 1 || OUTPUT_MODE_IS_JSON(arg_output)) {
r = table_set_sort(table, (size_t) 0, (size_t) -1);
r = table_set_sort(table, (size_t) 0);
if (r < 0)
return table_log_sort_error(r);

View File

@ -1383,7 +1383,7 @@ static int list_devices(void) {
if (arg_full)
table_set_width(table, 0);
r = table_set_sort(table, (size_t) 0, (size_t) SIZE_MAX);
r = table_set_sort(table, (size_t) 0);
if (r < 0)
return log_error_errno(r, "Failed to set sort index: %m");

View File

@ -1011,7 +1011,7 @@ static int dump_address_labels(sd_netlink *rtnl) {
if (arg_full)
table_set_width(table, 0);
r = table_set_sort(table, (size_t) 0, (size_t) SIZE_MAX);
r = table_set_sort(table, (size_t) 0);
if (r < 0)
return r;

View File

@ -1840,10 +1840,10 @@ static int context_dump_partitions(Context *context, const char *node) {
if (!DEBUG_LOGGING) {
if (arg_json_format_flags & JSON_FORMAT_OFF)
(void) table_set_display(t, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 3, (size_t) 4,
(size_t) 8, (size_t) 11, (size_t) -1);
(size_t) 8, (size_t) 11);
else
(void) table_set_display(t, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 3, (size_t) 4,
(size_t) 5, (size_t) 6, (size_t) 7, (size_t) 9, (size_t) 10, (size_t) 12, (size_t) -1);
(size_t) 5, (size_t) 6, (size_t) 7, (size_t) 9, (size_t) 10, (size_t) 12);
}
(void) table_set_align_percent(t, table_get_cell(t, 0, 4), 100);

View File

@ -834,7 +834,7 @@ static int list_images(int argc, char *argv[], void *userdata) {
return bus_log_parse_error(r);
if (table_get_rows(table) > 1) {
r = table_set_sort(table, (size_t) 0, (size_t) -1);
r = table_set_sort(table, (size_t) 0);
if (r < 0)
return table_log_sort_error(r);

View File

@ -1094,7 +1094,7 @@ int table_set_display_all(Table *t) {
return 0;
}
int table_set_display(Table *t, size_t first_column, ...) {
int table_set_display_internal(Table *t, size_t first_column, ...) {
size_t allocated, column;
va_list ap;
@ -1124,7 +1124,7 @@ int table_set_display(Table *t, size_t first_column, ...) {
return 0;
}
int table_set_sort(Table *t, size_t first_column, ...) {
int table_set_sort_internal(Table *t, size_t first_column, ...) {
size_t allocated, column;
va_list ap;

View File

@ -101,8 +101,10 @@ void table_set_width(Table *t, size_t width);
void table_set_cell_height_max(Table *t, size_t height);
int table_set_empty_string(Table *t, const char *empty);
int table_set_display_all(Table *t);
int table_set_display(Table *t, size_t first_column, ...);
int table_set_sort(Table *t, size_t first_column, ...);
int table_set_display_internal(Table *t, size_t first_column, ...);
#define table_set_display(...) table_set_display_internal(__VA_ARGS__, (size_t) SIZE_MAX)
int table_set_sort_internal(Table *t, size_t first_column, ...);
#define table_set_sort(...) table_set_sort_internal(__VA_ARGS__, (size_t) SIZE_MAX)
int table_set_reverse(Table *t, size_t column, bool b);
int table_hide_column_from_display(Table *t, size_t column);

View File

@ -228,7 +228,7 @@ static int verb_status(int argc, char **argv, void *userdata) {
ret = r;
}
(void) table_set_sort(t, (size_t) 0, (size_t) -1);
(void) table_set_sort(t, (size_t) 0);
r = table_print_with_pager(t, arg_json_format_flags, arg_pager_flags, arg_legend);
if (r < 0)
@ -842,7 +842,7 @@ static int verb_list(int argc, char **argv, void *userdata) {
return table_log_add_error(r);
}
(void) table_set_sort(t, (size_t) 0, (size_t) -1);
(void) table_set_sort(t, (size_t) 0);
return table_print_with_pager(t, arg_json_format_flags, arg_pager_flags, arg_legend);
}

View File

@ -360,7 +360,7 @@ static int output_sockets_list(struct socket_info *socket_infos, unsigned cs) {
if (!arg_show_types) {
/* Hide the second (TYPE) column */
r = table_set_display(table, (size_t) 0, (size_t) 2, (size_t) 3, (size_t) -1);
r = table_set_display(table, (size_t) 0, (size_t) 2, (size_t) 3);
if (r < 0)
return log_error_errno(r, "Failed to set columns to display: %m");
}

View File

@ -112,8 +112,8 @@ static int display_user(int argc, char *argv[], void *userdata) {
(void) table_set_align_percent(table, table_get_cell(table, 0, 2), 100);
(void) table_set_align_percent(table, table_get_cell(table, 0, 3), 100);
(void) table_set_empty_string(table, "-");
(void) table_set_sort(table, (size_t) 7, (size_t) 2, (size_t) -1);
(void) table_set_display(table, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 3, (size_t) 4, (size_t) 5, (size_t) 6, (size_t) -1);
(void) table_set_sort(table, (size_t) 7, (size_t) 2);
(void) table_set_display(table, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 3, (size_t) 4, (size_t) 5, (size_t) 6);
}
if (argc > 1) {
@ -262,8 +262,8 @@ static int display_group(int argc, char *argv[], void *userdata) {
(void) table_set_align_percent(table, table_get_cell(table, 0, 2), 100);
(void) table_set_empty_string(table, "-");
(void) table_set_sort(table, (size_t) 3, (size_t) 2, (size_t) -1);
(void) table_set_display(table, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 3, (size_t) -1);
(void) table_set_sort(table, (size_t) 3, (size_t) 2);
(void) table_set_display(table, (size_t) 0, (size_t) 1, (size_t) 2, (size_t) 3);
}
if (argc > 1) {
@ -402,7 +402,7 @@ static int display_memberships(int argc, char *argv[], void *userdata) {
if (!table)
return log_oom();
(void) table_set_sort(table, (size_t) 0, (size_t) 1, (size_t) -1);
(void) table_set_sort(table, (size_t) 0, (size_t) 1);
}
if (argc > 1) {
@ -491,7 +491,7 @@ static int display_services(int argc, char *argv[], void *userdata) {
if (!t)
return log_oom();
(void) table_set_sort(t, (size_t) 0, (size_t) -1);
(void) table_set_sort(t, (size_t) 0);
FOREACH_DIRENT(de, d, return -errno) {
_cleanup_free_ char *j = NULL, *no = NULL;