From df1f7bfaeba327cc9cc99beb1892ddbccbd86b57 Mon Sep 17 00:00:00 2001 From: krw Date: Wed, 12 Apr 2023 12:35:30 +0000 Subject: [PATCH] Clarify logic in PRT_uuid_to_menudflt() by using find_gpt_menuitem(). No functional change. --- sbin/fdisk/part.c | 20 ++++++++------------ 1 file changed, 8 insertions(+), 12 deletions(-) diff --git a/sbin/fdisk/part.c b/sbin/fdisk/part.c index 943158c256d..1efad4feac2 100644 --- a/sbin/fdisk/part.c +++ b/sbin/fdisk/part.c @@ -1,4 +1,4 @@ -/* $OpenBSD: part.c,v 1.158 2023/04/11 21:14:19 krw Exp $ */ +/* $OpenBSD: part.c,v 1.159 2023/04/12 12:35:30 krw Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -1122,21 +1122,17 @@ PRT_uuid_to_desc(const struct uuid *uuid) char * PRT_uuid_to_menudflt(const struct uuid *uuid) { + const struct menu_item *mi; char *dflt; - unsigned int i; uint32_t status; - uuid_to_string(uuid, &dflt, &status); - if (status != uuid_s_ok) - return NULL; - - for (i = 0; i < nitems(menu_items); i++) { - if (gpt_item(i) || strcasecmp(menu_items[i].mi_guid, dflt)) - continue; - free(dflt); - dflt = NULL; - if (asprintf(&dflt, "%02X", menu_items[i].mi_menuid) == -1) + mi = find_gpt_menuitem(find_gpt_type(uuid)); + if (mi == NULL) { + uuid_to_string(uuid, &dflt, &status); + if (status != uuid_s_ok) return NULL; + } else if (asprintf(&dflt, "%02X", mi->mi_menuid) == -1) { + return NULL; } return dflt; -- 2.20.1