- prioq_size(s) != 0
+ !prioq_isempty(s)
)
+@@
+expression s;
+@@
+(
+- table_get_rows(s) <= 1
++ table_isempty(s)
+|
+- table_get_rows(s) > 1
++ !table_isempty(s)
+)
if (r < 0)
return r;
- if (FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF) && table_get_rows(table) <= 1)
+ if (FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF) && table_isempty(table))
log_info("No file descriptors in fdstore of '%s'.", unit);
else {
r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, /* show_header= */true);
assert(table);
assert(word);
- if (table_get_rows(table) > 1) {
+ if (!table_isempty(table)) {
table_set_header(table, arg_legend);
if (!FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF))
}
if (arg_legend) {
- if (table_get_rows(table) > 1)
- printf("\n%zu %s listed.\n", table_get_rows(table) - 1, word);
- else
+ if (table_isempty(table))
printf("No %s.\n", word);
+ else
+ printf("\n%zu %s listed.\n", table_get_rows(table) - 1, word);
}
return 0;
return log_error_errno(SYNTHETIC_ERRNO(ENXIO), "No credentials passed. (i.e. $CREDENTIALS_DIRECTORY not set.)");
}
- if ((arg_json_format_flags & JSON_FORMAT_OFF) && table_get_rows(t) <= 1) {
+ if (FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF) && table_isempty(t)) {
log_info("No credentials");
return 0;
}
return table_log_add_error(r);
}
- if (table_get_rows(t) <= 1) {
+ if (table_isempty(t)) {
log_info("No slots found.");
return 0;
}
if (r < 0)
return bus_log_parse_error(r);
- if (table_get_rows(table) > 1 || !FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF)) {
+ if (!table_isempty(table) || !FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF)) {
r = table_set_sort(table, (size_t) 0);
if (r < 0)
return table_log_sort_error(r);
return r;
}
- if (arg_legend && (arg_json_format_flags & JSON_FORMAT_OFF)) {
- if (table_get_rows(table) > 1)
- printf("\n%zu home areas listed.\n", table_get_rows(table) - 1);
- else
+ if (arg_legend && !FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF)) {
+ if (table_isempty(table))
printf("No home areas.\n");
+ else
+ printf("\n%zu home areas listed.\n", table_get_rows(table) - 1);
}
return 0;
if (r < 0)
return bus_log_parse_error(r);
- if (table_get_rows(table) > 1) {
+ if (!table_isempty(table)) {
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);
}
if (arg_legend) {
- if (table_get_rows(table) > 1)
- printf("\n%zu inhibitors listed.\n", table_get_rows(table) - 1);
- else
+ if (table_isempty(table))
printf("No inhibitors.\n");
+ else
+ printf("\n%zu inhibitors listed.\n", table_get_rows(table) - 1);
}
return 0;
assert(table);
assert(word);
- if (table_get_rows(table) > 1 || OUTPUT_MODE_IS_JSON(arg_output)) {
+ if (!table_isempty(table) || OUTPUT_MODE_IS_JSON(arg_output)) {
r = table_set_sort(table, (size_t) 0);
if (r < 0)
return table_log_sort_error(r);
}
if (arg_legend) {
- if (table_get_rows(table) > 1)
- printf("\n%zu %s listed.\n", table_get_rows(table) - 1, word);
- else
+ if (table_isempty(table))
printf("No %s.\n", word);
+ else
+ printf("\n%zu %s listed.\n", table_get_rows(table) - 1, word);
}
return 0;
assert(table);
assert(word);
- if (table_get_rows(table) > 1 || OUTPUT_MODE_IS_JSON(arg_output)) {
+ if (!table_isempty(table) || OUTPUT_MODE_IS_JSON(arg_output)) {
r = table_set_sort(table, (size_t) 0);
if (r < 0)
return table_log_sort_error(r);
}
if (arg_legend) {
- if (table_get_rows(table) > 1)
- printf("\n%zu %s listed.\n", table_get_rows(table) - 1, word);
- else
+ if (table_isempty(table))
printf("No %s.\n", word);
+ else
+ printf("\n%zu %s listed.\n", table_get_rows(table) - 1, word);
}
return 0;
}
}
- if (table_get_rows(table) > 1 || !FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF)) {
+ if (!table_isempty(table) || !FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF)) {
r = table_print_with_pager(table, arg_json_format_flags, arg_pager_flags, /* show_header= */ true);
if (r < 0)
return log_error_errno(r, "Failed to output table: %m");
}
if (FLAGS_SET(arg_json_format_flags, JSON_FORMAT_OFF)) {
- if (table_get_rows(table) > 1)
- printf("\n%zu components listed.\n", table_get_rows(table) - 1);
- else
+ if (table_isempty(table))
printf("No components defined.\n");
+ else
+ printf("\n%zu components listed.\n", table_get_rows(table) - 1);
}
return 0;
if (r < 0)
return bus_log_parse_error(r);
- if (table_get_rows(table) > 1) {
+ if (!table_isempty(table)) {
r = table_set_sort(table, (size_t) 0);
if (r < 0)
return table_log_sort_error(r);
}
if (arg_legend) {
- if (table_get_rows(table) > 1)
- printf("\n%zu images listed.\n", table_get_rows(table) - 1);
- else
+ if (table_isempty(table))
printf("No images.\n");
+ else
+ printf("\n%zu images listed.\n", table_get_rows(table) - 1);
}
return 0;
}
size_t table_get_rows(Table *t);
+static inline bool table_isempty(Table *t) {
+ if (!t)
+ return true;
+
+ return table_get_rows(t) <= 1;
+}
size_t table_get_columns(Table *t);
size_t table_get_current_column(Table *t);
if (r < 0 && r != -EAGAIN)
return r;
- if (table_get_rows(t) <= 1) {
+ if (table_isempty(t)) {
log_info("No suitable PKCS#11 tokens found.");
return 0;
}
}
}
- if (table_get_rows(t) <= 1) {
+ if (table_isempty(t)) {
log_info("No suitable TPM2 devices found.");
return 0;
}
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);
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);
}
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);
}
}
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;