]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
catalog: use structured initialization more
authorLennart Poettering <lennart@poettering.net>
Wed, 6 Mar 2019 10:41:59 +0000 (11:41 +0100)
committerLennart Poettering <lennart@poettering.net>
Thu, 7 Mar 2019 14:10:06 +0000 (15:10 +0100)
src/journal/catalog.c

index efe86bdef44d809ad160ed194183bdda30c90363..af9e9191b1f66226a25636152754d6d7cdec6ae8 100644 (file)
@@ -33,7 +33,7 @@ const char * const catalog_file_dirs[] = {
         NULL
 };
 
-#define CATALOG_SIGNATURE (uint8_t[]) { 'R', 'H', 'H', 'H', 'K', 'S', 'L', 'P' }
+#define CATALOG_SIGNATURE { 'R', 'H', 'H', 'H', 'K', 'S', 'L', 'P' }
 
 typedef struct CatalogHeader {
         uint8_t signature[8];  /* "RHHHKSLP" */
@@ -392,11 +392,12 @@ static int64_t write_catalog(
                 return log_error_errno(r, "Failed to open database for writing: %s: %m",
                                        database);
 
-        zero(header);
-        memcpy(header.signature, CATALOG_SIGNATURE, sizeof(header.signature));
-        header.header_size = htole64(ALIGN_TO(sizeof(CatalogHeader), 8));
-        header.catalog_item_size = htole64(sizeof(CatalogItem));
-        header.n_items = htole64(n);
+        header = (CatalogHeader) {
+                .signature = CATALOG_SIGNATURE,
+                .header_size = htole64(ALIGN_TO(sizeof(CatalogHeader), 8)),
+                .catalog_item_size = htole64(sizeof(CatalogItem)),
+                .n_items = htole64(n),
+        };
 
         r = -EIO;
 
@@ -537,7 +538,7 @@ static int open_mmap(const char *database, int *_fd, struct stat *_st, void **_p
         }
 
         h = p;
-        if (memcmp(h->signature, CATALOG_SIGNATURE, sizeof(h->signature)) != 0 ||
+        if (memcmp(h->signature, (const uint8_t[]) CATALOG_SIGNATURE, sizeof(h->signature)) != 0 ||
             le64toh(h->header_size) < sizeof(CatalogHeader) ||
             le64toh(h->catalog_item_size) < sizeof(CatalogItem) ||
             h->incompatible_flags != 0 ||