summaryrefslogtreecommitdiff
path: root/src/pstore
diff options
context:
space:
mode:
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-06-02 17:53:14 +0200
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>2020-06-03 15:31:28 +0200
commitbacafb09908fe032d4da10409852b5a746743035 (patch)
tree75cc7b9ae427731a31c87dcbaf571a6108726de4 /src/pstore
parenteb10767565c60e1feafa8793029aea6c076747f7 (diff)
downloadsystemd-bacafb09908fe032d4da10409852b5a746743035.tar.gz
pstore: use typesafe_qsort
Also move "allocated" above "n", since, conceptually, it is modified earlier (and that is the definition order we normally use).
Diffstat (limited to 'src/pstore')
-rw-r--r--src/pstore/pstore.c9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/pstore/pstore.c b/src/pstore/pstore.c
index 5c812b5d5b..0a6ad21908 100644
--- a/src/pstore/pstore.c
+++ b/src/pstore/pstore.c
@@ -98,8 +98,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) {
@@ -109,8 +109,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);
}
@@ -346,7 +345,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) {
@@ -391,7 +390,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);