summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorYu Watanabe <watanabe.yu+github@gmail.com>2022-09-10 00:05:12 +0200
committerYu Watanabe <watanabe.yu+github@gmail.com>2022-09-18 10:26:22 +0200
commitbabd5b08b58a58ed0d6bf3d1efb87b87702bd182 (patch)
tree444300ffa3f8e0e3af87c28bede5d9dff9c25167
parentdissect-image: split out dissected_image_new() (diff)
downloadsystemd-babd5b08b58a58ed0d6bf3d1efb87b87702bd182.tar.xz
systemd-babd5b08b58a58ed0d6bf3d1efb87b87702bd182.zip
dissect-image: introduce DISSECTED_PARTITION_NULL
Currently, it is not necessary to set partno or architecture in dissect_image_new(), but just for safety. Preparation for later commits.
-rw-r--r--src/shared/dissect-image.c8
-rw-r--r--src/shared/dissect-image.h6
2 files changed, 10 insertions, 4 deletions
diff --git a/src/shared/dissect-image.c b/src/shared/dissect-image.c
index fcc158665d..360fc4a939 100644
--- a/src/shared/dissect-image.c
+++ b/src/shared/dissect-image.c
@@ -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
diff --git a/src/shared/dissect-image.h b/src/shared/dissect-image.h
index fe478bde49..aee8f1c315 100644
--- a/src/shared/dissect-image.h
+++ b/src/shared/dissect-image.h
@@ -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 */