]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
dissect-image: introduce DISSECTED_PARTITION_NULL 24719/head
authorYu Watanabe <watanabe.yu+github@gmail.com>
Fri, 9 Sep 2022 22:05:12 +0000 (07:05 +0900)
committerYu Watanabe <watanabe.yu+github@gmail.com>
Sun, 18 Sep 2022 08:26:22 +0000 (17:26 +0900)
Currently, it is not necessary to set partno or architecture in
dissect_image_new(), but just for safety.
Preparation for later commits.

src/shared/dissect-image.c
src/shared/dissect-image.h

index fcc158665d4d049b80315038297d81cf9ff48a31..360fc4a93913b158bbfa14ac63c0c77d79162c1f 100644 (file)
@@ -184,6 +184,9 @@ static int dissected_image_new(const char *path, DissectedImage **ret) {
                 .image_name = TAKE_PTR(name),
         };
 
+        for (PartitionDesignator i = 0; i < _PARTITION_DESIGNATOR_MAX; i++)
+                m->partitions[i] = DISSECTED_PARTITION_NULL;
+
         *ret = TAKE_PTR(m);
         return 0;
 }
@@ -199,10 +202,7 @@ static void dissected_partition_done(DissectedPartition *p) {
         free(p->decrypted_node);
         free(p->mount_options);
 
-        *p = (DissectedPartition) {
-                .partno = -1,
-                .architecture = _ARCHITECTURE_INVALID,
-        };
+        *p = DISSECTED_PARTITION_NULL;
 }
 
 #if HAVE_BLKID
index fe478bde493b0434014f4d6b5af343500d6ab6ec..aee8f1c3153e24bfa397d937897ff377331c305e 100644 (file)
@@ -33,6 +33,12 @@ struct DissectedPartition {
         uint64_t offset;
 };
 
+#define DISSECTED_PARTITION_NULL                                        \
+        ((DissectedPartition) {                                         \
+                .partno = -1,                                           \
+                .architecture = _ARCHITECTURE_INVALID,                  \
+        })
+
 typedef enum PartitionDesignator {
         PARTITION_ROOT,
         PARTITION_ROOT_SECONDARY,  /* Secondary architecture */