part: Add accessors for struct disk_partition uuid

This field is only present when a CONFIG is set. To avoid annoying #ifdefs
in the source code, add accessors. Update all code to use it.

Note that the accessor is optional. It can be omitted if it is known that
the option is enabled.

Signed-off-by: Simon Glass <sjg@chromium.org>
This commit is contained in:
Simon Glass
2023-08-24 13:55:31 -06:00
committed by Tom Rini
parent ade2316da3
commit c5f1d005f5
6 changed files with 58 additions and 39 deletions

View File

@@ -211,12 +211,10 @@ static struct disk_part *allocate_disk_part(struct disk_partition *info,
PART_TYPE_LEN);
newpart->gpt_part_info.type[PART_TYPE_LEN - 1] = '\0';
newpart->gpt_part_info.bootable = info->bootable;
#ifdef CONFIG_PARTITION_UUIDS
strncpy(newpart->gpt_part_info.uuid, (const char *)info->uuid,
UUID_STR_LEN);
/* UUID_STR_LEN is correct, as uuid[]'s length is UUID_STR_LEN+1 chars */
newpart->gpt_part_info.uuid[UUID_STR_LEN] = '\0';
#endif
if (IS_ENABLED(CONFIG_PARTITION_UUIDS)) {
strlcpy(newpart->gpt_part_info.uuid, disk_partition_uuid(info),
UUID_STR_LEN + 1);
}
newpart->partnum = partnum;
return newpart;