From: krw Date: Wed, 12 Apr 2023 12:35:30 +0000 (+0000) Subject: Clarify logic in PRT_uuid_to_menudflt() by using find_gpt_menuitem(). X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=df1f7bfaeba327cc9cc99beb1892ddbccbd86b57;p=openbsd Clarify logic in PRT_uuid_to_menudflt() by using find_gpt_menuitem(). No functional change. --- 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;