diff options
author | Yu Watanabe <watanabe.yu+github@gmail.com> | 2020-06-04 04:30:14 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-06-04 04:30:14 +0200 |
commit | 161bc1b62777b3f32ce645a8e128007a654a2300 (patch) | |
tree | 40bfcc5e811a6fb5113191d287f1ee7c687312f6 /src/pstore | |
parent | Merge pull request #15171 from ssahani/tc-qfq (diff) | |
parent | basic/sort-util: adorn qsort_safe with a prefix underscore (diff) | |
download | systemd-161bc1b62777b3f32ce645a8e128007a654a2300.tar.xz systemd-161bc1b62777b3f32ce645a8e128007a654a2300.zip |
Merge pull request #16057 from keszybz/resolvectl-sorted-no-nta
Drop NTA lists from resolvectl status and sort output by link number
Diffstat (limited to 'src/pstore')
-rw-r--r-- | src/pstore/pstore.c | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/pstore/pstore.c b/src/pstore/pstore.c index 59d0b5b74e..9b888a2baa 100644 --- a/src/pstore/pstore.c +++ b/src/pstore/pstore.c @@ -101,8 +101,8 @@ typedef struct PStoreEntry { typedef struct PStoreList { PStoreEntry *entries; + size_t n_allocated; size_t n_entries; - size_t n_entries_allocated; } PStoreList; static void pstore_entries_reset(PStoreList *list) { @@ -112,8 +112,7 @@ static void pstore_entries_reset(PStoreList *list) { list->n_entries = 0; } -static int compare_pstore_entries(const void *_a, const void *_b) { - PStoreEntry *a = (PStoreEntry *)_a, *b = (PStoreEntry *)_b; +static int compare_pstore_entries(const PStoreEntry *a, const PStoreEntry *b) { return strcmp(a->dirent.d_name, b->dirent.d_name); } @@ -349,7 +348,7 @@ static int list_files(PStoreList *list, const char *sourcepath) { continue; } - if (!GREEDY_REALLOC(list->entries, list->n_entries_allocated, list->n_entries + 1)) + if (!GREEDY_REALLOC(list->entries, list->n_allocated, list->n_entries + 1)) return log_oom(); list->entries[list->n_entries++] = (PStoreEntry) { @@ -394,7 +393,7 @@ static int run(int argc, char *argv[]) { /* Handle each pstore file */ /* Sort files lexigraphically ascending, generally needed by all */ - qsort_safe(list.entries, list.n_entries, sizeof(PStoreEntry), compare_pstore_entries); + typesafe_qsort(list.entries, list.n_entries, compare_pstore_entries); /* Process known file types */ process_dmesg_files(&list); |