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.
This commit is contained in:
Yu Watanabe
2022-09-18 17:26:22 +09:00
parent 00e295055b
commit babd5b08b5
2 changed files with 10 additions and 4 deletions
+4 -4
View 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
+6
View 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 */