diff options
author | Mike Yuan <me@yhndnzj.com> | 2023-12-25 10:34:57 +0100 |
---|---|---|
committer | Mike Yuan <me@yhndnzj.com> | 2023-12-25 10:47:18 +0100 |
commit | 2413a0fab4fdad7eef3ce1d4b57664be5795b002 (patch) | |
tree | e7a21c95fa93122312f4243b211e668ca11a2cdf /src/userdb | |
parent | siphash24: introduce siphash24_compress_typesafe() macro (diff) | |
download | systemd-2413a0fab4fdad7eef3ce1d4b57664be5795b002.tar.xz systemd-2413a0fab4fdad7eef3ce1d4b57664be5795b002.zip |
format-table: introduce table_isempty and use it where appropriate
Diffstat (limited to 'src/userdb')
-rw-r--r-- | src/userdb/userdbctl.c | 20 |
1 files changed, 10 insertions, 10 deletions
diff --git a/src/userdb/userdbctl.c b/src/userdb/userdbctl.c index a7db3fb0d5..9ab5d42c4b 100644 --- a/src/userdb/userdbctl.c +++ b/src/userdb/userdbctl.c @@ -440,7 +440,7 @@ static int display_user(int argc, char *argv[], void *userdata) { if (uid_map_lines < 0) return uid_map_lines; - if (table_get_rows(table) > 1) { + if (!table_isempty(table)) { r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend); if (r < 0) return table_log_print_error(r); @@ -743,7 +743,7 @@ static int display_group(int argc, char *argv[], void *userdata) { if (gid_map_lines < 0) return gid_map_lines; - if (table_get_rows(table) > 1) { + if (!table_isempty(table)) { r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend); if (r < 0) return table_log_print_error(r); @@ -891,17 +891,17 @@ static int display_memberships(int argc, char *argv[], void *userdata) { } if (table) { - if (table_get_rows(table) > 1) { + if (!table_isempty(table)) { r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, arg_legend); if (r < 0) return table_log_print_error(r); } if (arg_legend) { - if (table_get_rows(table) > 1) - printf("\n%zu memberships listed.\n", table_get_rows(table) - 1); - else + if (table_isempty(table)) printf("No memberships.\n"); + else + printf("\n%zu memberships listed.\n", table_get_rows(table) - 1); } } @@ -956,17 +956,17 @@ static int display_services(int argc, char *argv[], void *userdata) { return table_log_add_error(r); } - if (table_get_rows(t) > 1) { + if (!table_isempty(t)) { r = table_print_with_pager(t, arg_json_format_flags, arg_pager_flags, arg_legend); if (r < 0) return table_log_print_error(r); } if (arg_legend && arg_output != OUTPUT_JSON) { - if (table_get_rows(t) > 1) - printf("\n%zu services listed.\n", table_get_rows(t) - 1); - else + if (table_isempty(t)) printf("No services.\n"); + else + printf("\n%zu services listed.\n", table_get_rows(t) - 1); } return 0; |