format-table: introduce table_isempty and use it where appropriate

This commit is contained in:
Mike Yuan
2023-12-25 17:47:18 +08:00
parent c01a5c0527
commit 2413a0fab4
15 changed files with 60 additions and 44 deletions
+6
View File
@@ -144,6 +144,12 @@ static inline TableCell* TABLE_HEADER_CELL(size_t i) {
}
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);
+1 -1
View File
@@ -1530,7 +1530,7 @@ int pkcs11_list_tokens(void) {
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;
}
+1 -1
View File
@@ -5965,7 +5965,7 @@ int tpm2_list_devices(void) {
}
}
if (table_get_rows(t) <= 1) {
if (table_isempty(t)) {
log_info("No suitable TPM2 devices found.");
return 0;
}