Merge pull request #30628 from YHNdnzj/format-table-improvement

Some improvements for format-table
This commit is contained in:
Yu Watanabe
2023-12-25 20:01:32 +09:00
committed by GitHub
17 changed files with 63 additions and 47 deletions
+1 -1
View File
@@ -2003,7 +2003,7 @@ static const char *table_data_format(Table *t, TableData *d, bool avoid_uppercas
if (d->mode == MODE_INVALID)
return table_ersatz_string(t);
return inode_type_to_string(d->mode);
return inode_type_to_string(d->mode) ?: table_ersatz_string(t);
case TABLE_DEVNUM:
if (devnum_is_zero(d->devnum))
+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;
}