diff options
author | Simon Glass | 2023-08-24 13:55:31 -0600 |
---|---|---|
committer | Tom Rini | 2023-08-25 17:55:18 -0400 |
commit | c5f1d005f51783a5b34d6164ab66289eb1f4a45b (patch) | |
tree | ce2387e3ccb134d02bfd2c458546c420ca886c53 /cmd/gpt.c | |
parent | ade2316da3cd76abe7649d34abb84f1370fb942d (diff) |
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>
Diffstat (limited to 'cmd/gpt.c')
-rw-r--r-- | cmd/gpt.c | 10 |
1 files changed, 4 insertions, 6 deletions
diff --git a/cmd/gpt.c b/cmd/gpt.c index 007a68eaa72..8969efba8c8 100644 --- a/cmd/gpt.c +++ b/cmd/gpt.c @@ -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; |