Use char * const for the rest of the repeated GUID strings. More
authorkrw <krw@openbsd.org>
Sat, 1 Apr 2023 14:18:29 +0000 (14:18 +0000)
committerkrw <krw@openbsd.org>
Sat, 1 Apr 2023 14:18:29 +0000 (14:18 +0000)
readable, less prone to typos.

No intentional functional change.

sbin/fdisk/part.c

index 5fb1a67..8c45b96 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: part.c,v 1.147 2023/03/31 19:12:32 krw Exp $  */
+/*     $OpenBSD: part.c,v 1.148 2023/04/01 14:18:29 krw Exp $  */
 
 /*
  * Copyright (c) 1997 Tobias Weingartner
@@ -160,82 +160,104 @@ struct gpt_type {
  *         https://www.freedesktop.org/software/systemd/man/systemd-gpt-auto-generator.html
  */
 
-char * const EFI_SYSTEM_PARTITION_GUID = "c12a7328-f81f-11d2-ba4b-00a0c93ec93b";
-char * const MICROSOFT_BASIC_DATA_GUID = "ebd0a0a2-b9e5-4433-87c0-68b6b72699c7";
+char * const UNUSED_GUID               = "00000000-0000-0000-0000-000000000000";
+char * const LEGACY_MBR_GUID           = "024dee41-33e7-11d3-9d69-0008c781f39f";
+char * const LINUX_SWAP_GUID           = "0657fd6d-a4ab-43c4-84e5-0933c84b4f4f";
+char * const LINUX_FILES_GUID          = "0fc63daf-8483-4772-8e79-3d69d8477de4";
+char * const BIOS_BOOT_GUID            = "21686148-6449-6e6f-744e-656564454649";
+char * const HIFIVE_BBL_GUID           = "2e54b353-1271-4842-806f-e436d6af6985";
+char * const BEOS_I386_GUID            = "42465331-3ba3-10f1-802a-4861696b7521";
+char * const MACOS_X_BOOT_GUID         = "426f6f74-0000-11aa-aa11-00306543ecac";
+char * const MACOS_X_HFS_GUID          = "48465300-0000-11aa-aa11-00306543ecac";
+char * const NETBSD_GUID               = "49f48d5a-b10e-11dc-b99b-0019d1879648";
+char * const FREEBSD_GUID              = "516e7cb4-6ecf-11d6-8ff8-00022d09712b";
+char * const APFS_RECOVERY_GUID                = "52637672-7900-11aa-aa11-00306543ecac";
+char * const MACOS_X_GUID              = "55465300-0000-11aa-aa11-00306543ecac";
+char * const HIFIVE_FSBL_GUID          = "5b193300-fc78-40cd-8002-e86c45580b47";
+char * const APFS_ISC_GUID             = "69646961-6700-11aa-aa11-00306543ecac";
+char * const SOLARIS_GUID              = "6a85cf4d-1dd2-11b2-99a6-080020736631";
+char * const APFS_GUID                 = "7c3457ef-0000-11aa-aa11-00306543ecac";
+char * const OPENBSD_GUID              = "824cc7a0-36a8-11e3-890a-952519ad3f61";
+char * const LINUXSWAP_DR_GUID         = "af9b60a0-1431-4f62-bc68-3311714a69ad";
+char * const EFI_SYSTEM_PARTITION_GUID = "c12a7328-f81f-11d2-ba4b-00a0c93ec93b";
+char * const WIN_RECOVERY_GUID         = "de94bba4-06d1-4d40-a16a-bfd50179d6ac";
+char * const LINUX_LVM_GUID            = "e6d6d379-f507-44c2-a23c-238f2a3df928";
+char * const MICROSOFT_BASIC_DATA_GUID = "ebd0a0a2-b9e5-4433-87c0-68b6b72699c7";
+char * const CHROME_KERNEL_GUID                = "fe3a2a5d-4f32-41a7-b725-accc3285a309";
 
 const struct gpt_type          gpt_types[] = {
        { 0,
          NULL,                         /* Unused */
-         "00000000-0000-0000-0000-000000000000" },
+         UNUSED_GUID },
        { 0,
          NULL,                         /* Legacy MBR */
-         "024dee41-33e7-11d3-9d69-0008c781f39f" },
+         LEGACY_MBR_GUID },
        { 0,
          NULL,                         /* Linux swap */
-         "0657fd6d-a4ab-43c4-84e5-0933c84b4f4f" },
+         LINUX_SWAP_GUID },
        { 0,
          NULL,                         /* Linux files* */
-         "0fc63daf-8483-4772-8e79-3d69d8477de4" },
+         LINUX_FILES_GUID },
        { GTATTR_PROTECT,
          NULL,                         /* BIOS Boot */
-         "21686148-6449-6e6f-744e-656564454649" },
+         BIOS_BOOT_GUID },
        { GTATTR_PROTECT,
          NULL,                         /* HiFive BBL */
-         "2e54b353-1271-4842-806f-e436d6af6985" },
+         HIFIVE_BBL_GUID },
        { 0,
          NULL,                         /* BeOS/i386 */
-         "42465331-3ba3-10f1-802a-4861696b7521" },
+         BEOS_I386_GUID },
        { 0,
          NULL,                         /* MacOS X boot */
-         "426f6f74-0000-11aa-aa11-00306543ecac" },
+         MACOS_X_BOOT_GUID },
        { 0,
-         NULL,                         /* MacOS X HFS+ */
-         "48465300-0000-11aa-aa11-00306543ecac" },
+          NULL,                                /* MacOS X HFS+ */
+         MACOS_X_HFS_GUID },
        { 0,
          NULL,                         /* NetBSD */
-         "49f48d5a-b10e-11dc-b99b-0019d1879648" },
+         NETBSD_GUID },
        { 0,
          NULL,                         /* FreeBSD */
-         "516e7cb4-6ecf-11d6-8ff8-00022d09712b" },
+         FREEBSD_GUID },
        { GTATTR_PROTECT | GTATTR_PROTECT_EFISYS,
          NULL,                         /* APFS Recovery */
-         "52637672-7900-11aa-aa11-00306543ecac" },
+         APFS_RECOVERY_GUID },
        { 0,
          NULL,                         /* MacOS X */
-         "55465300-0000-11aa-aa11-00306543ecac" },
+         MACOS_X_GUID },
        { GTATTR_PROTECT,
          NULL,                         /* HiFive FSBL */
-         "5b193300-fc78-40cd-8002-e86c45580b47" },
+         HIFIVE_FSBL_GUID },
        { GTATTR_PROTECT | GTATTR_PROTECT_EFISYS,
          NULL,                         /* APFS ISC */
-         "69646961-6700-11aa-aa11-00306543ecac" },
+         APFS_ISC_GUID },
        { 0,
          NULL,                         /* Solaris */
-         "6a85cf4d-1dd2-11b2-99a6-080020736631" },
+         SOLARIS_GUID },
        { GTATTR_PROTECT | GTATTR_PROTECT_EFISYS,
          NULL,                         /* APFS */
-         "7c3457ef-0000-11aa-aa11-00306543ecac" },
+         APFS_GUID },
        { 0,
          NULL,                         /* OpenBSD */
-         "824cc7a0-36a8-11e3-890a-952519ad3f61" },
+         OPENBSD_GUID },
        { 0,
          NULL,                         /* LinuxSwap DR */
-         "af9b60a0-1431-4f62-bc68-3311714a69ad" },
+         LINUXSWAP_DR_GUID },
        { 0,
          NULL,                         /* EFI Sys */
          EFI_SYSTEM_PARTITION_GUID },
        { 0,
          NULL,                         /* Win Recovery*/
-         "de94bba4-06d1-4d40-a16a-bfd50179d6ac" },
+         WIN_RECOVERY_GUID },
        { 0,
          NULL,                         /* Linux VM */
-         "e6d6d379-f507-44c2-a23c-238f2a3df928" },
+         LINUX_LVM_GUID },
        { 0,
          NULL,                         /* Microsoft basic data */
          MICROSOFT_BASIC_DATA_GUID },
        { 0,
          NULL,                         /* ChromeKernel */
-         "fe3a2a5d-4f32-41a7-b725-accc3285a309" },
+         CHROME_KERNEL_GUID },
 };
 
 struct menu_item {
@@ -246,7 +268,7 @@ struct menu_item {
 };
 
 const struct menu_item menu_items[] = {
-       { 0x00, 0x00,   "Unused",       "00000000-0000-0000-0000-000000000000" },
+       { 0x00, 0x00,   "Unused",       UNUSED_GUID },
        { 0x01, 0x01,   "DOS FAT-12",   MICROSOFT_BASIC_DATA_GUID },
        { 0x02, 0x02,   "XENIX /",      NULL },
        { 0x03, 0x03,   "XENIX /usr",   NULL },
@@ -259,7 +281,7 @@ const struct menu_item menu_items[] = {
        { 0x0A, 0x0A,   "OS/2 Bootmgr", NULL },
        { 0x0B, 0x0B,   "Win95 FAT-32", MICROSOFT_BASIC_DATA_GUID },
        { 0x0C, 0x0C,   "Win95 FAT32L", MICROSOFT_BASIC_DATA_GUID },
-       { 0x0D,   -1,   "BIOS boot",    "21686148-6449-6e6f-744e-656564454649" },
+       { 0x0D,   -1,   "BIOS boot",    BIOS_BOOT_GUID },
        { 0x0E, 0x0E,   "DOS FAT-16",   MICROSOFT_BASIC_DATA_GUID },
        { 0x0F, 0x0F,   "Extended LBA", NULL },
        { 0x10, 0x10,   "OPUS",         NULL },
@@ -273,12 +295,12 @@ const struct menu_item menu_items[] = {
        { 0x1C, 0x1C,   "ThinkPad Rec", MICROSOFT_BASIC_DATA_GUID },
        { 0x20, 0x20,   "Willowsoft",   NULL },
        { 0x24, 0x24,   "NEC DOS",      NULL },
-       { 0x27, 0x27,   "Win Recovery", "de94bba4-06d1-4d40-a16a-bfd50179d6ac" },
+       { 0x27, 0x27,   "Win Recovery", WIN_RECOVERY_GUID },
        { 0x38, 0x38,   "Theos",        NULL },
        { 0x39, 0x39,   "Plan 9",       NULL },
        { 0x40, 0x40,   "VENIX 286",    NULL },
        { 0x41, 0x41,   "Lin/Minux DR", NULL },
-       { 0x42, 0x42,   "LinuxSwap DR", "af9b60a0-1431-4f62-bc68-3311714a69ad" },
+       { 0x42, 0x42,   "LinuxSwap DR", LINUXSWAP_DR_GUID },
        { 0x43, 0x43,   "Linux DR",     NULL },
        { 0x4D, 0x4D,   "QNX 4.2 Pri",  NULL },
        { 0x4E, 0x4E,   "QNX 4.2 Sec",  NULL },
@@ -301,36 +323,36 @@ const struct menu_item menu_items[] = {
        { 0x69, 0x69,   "Novell",       NULL },
        { 0x70, 0x70,   "DiskSecure",   NULL },
        { 0x75, 0x75,   "PCIX",         NULL },
-       { 0x7F,   -1,   "Chrome Kernel","fe3a2a5d-4f32-41a7-b725-accc3285a309" },
+       { 0x7F,   -1,   "Chrome Kernel",CHROME_KERNEL_GUID },
        { 0x80, 0x80,   "Minix (old)",  NULL },
        { 0x81, 0x81,   "Minix (new)",  NULL },
-       { 0x82, 0x82,   "Linux swap",   "0657fd6d-a4ab-43c4-84e5-0933c84b4f4f" },
-       { 0x83, 0x83,   "Linux files*", "0fc63daf-8483-4772-8e79-3d69d8477de4" },
+       { 0x82, 0x82,   "Linux swap",   LINUX_SWAP_GUID },
+       { 0x83, 0x83,   "Linux files*", LINUX_FILES_GUID },
        { 0x84, 0x84,   "OS/2 hidden",  NULL },
        { 0x85, 0x85,   "Linux ext.",   NULL },
        { 0x86, 0x86,   "NT FAT VS",    NULL },
        { 0x87, 0x87,   "NTFS VS",      NULL },
-       { 0x8E, 0x8E,   "Linux LVM",    "e6d6d379-f507-44c2-a23c-238f2a3df928" },
+       { 0x8E, 0x8E,   "Linux LVM",    LINUX_LVM_GUID },
        { 0x93, 0x93,   "Amoeba FS",    NULL },
        { 0x94, 0x94,   "Amoeba BBT",   NULL },
        { 0x99, 0x99,   "Mylex" ,       NULL },
        { 0x9F, 0x9F,   "BSDI",         NULL },
        { 0xA0, 0xA0,   "NotebookSave", NULL },
-       { 0xA5, 0xA5,   "FreeBSD",      "516e7cb4-6ecf-11d6-8ff8-00022d09712b" },
-       { 0xA6, 0xA6,   "OpenBSD",      "824cc7a0-36a8-11e3-890a-952519ad3f61" },
+       { 0xA5, 0xA5,   "FreeBSD",      FREEBSD_GUID },
+       { 0xA6, 0xA6,   "OpenBSD",      OPENBSD_GUID },
        { 0xA7, 0xA7,   "NeXTSTEP",     NULL },
-       { 0xA8, 0xA8,   "MacOS X",      "55465300-0000-11aa-aa11-00306543ecac" },
-       { 0xA9, 0xA9,   "NetBSD",       "49f48d5a-b10e-11dc-b99b-0019d1879648" },
-       { 0xAB, 0xAB,   "MacOS X boot", "426f6f74-0000-11aa-aa11-00306543ecac" },
-       { 0xAF, 0xAF,   "MacOS X HFS+", "48465300-0000-11aa-aa11-00306543ecac" },
-       { 0xB0,   -1,   "APFS",         "7c3457ef-0000-11aa-aa11-00306543ecac" },
-       { 0xB1,   -1,   "APFS ISC",     "69646961-6700-11aa-aa11-00306543ecac" },
-       { 0xB2,   -1,   "APFS Recovery","52637672-7900-11aa-aa11-00306543ecac" },
-       { 0xB3,   -1,   "HiFive FSBL",  "5b193300-fc78-40cd-8002-e86c45580b47" },
-       { 0xB4,   -1,   "HiFive BBL",   "2e54b353-1271-4842-806f-e436d6af6985" },
+       { 0xA8, 0xA8,   "MacOS X",      MACOS_X_GUID },
+       { 0xA9, 0xA9,   "NetBSD",       NETBSD_GUID },
+       { 0xAB, 0xAB,   "MacOS X boot", MACOS_X_BOOT_GUID },
+       { 0xAF, 0xAF,   "MacOS X HFS+", MACOS_X_HFS_GUID },
+       { 0xB0,   -1,   "APFS",         APFS_GUID },
+       { 0xB1,   -1,   "APFS ISC",     APFS_ISC_GUID },
+       { 0xB2,   -1,   "APFS Recovery",APFS_RECOVERY_GUID },
+       { 0xB3,   -1,   "HiFive FSBL",  HIFIVE_FSBL_GUID },
+       { 0xB4,   -1,   "HiFive BBL",   HIFIVE_BBL_GUID },
        { 0xB7, 0xB7,   "BSDI filesy*", NULL },
        { 0xB8, 0xB8,   "BSDI swap",    NULL },
-       { 0xBF, 0xBF,   "Solaris",      "6a85cf4d-1dd2-11b2-99a6-080020736631" },
+       { 0xBF, 0xBF,   "Solaris",      SOLARIS_GUID },
        { 0xC0, 0xC0,   "CTOS",         NULL },
        { 0xC1, 0xC1,   "DRDOSs FAT12", NULL },
        { 0xC4, 0xC4,   "DRDOSs < 32M", NULL },
@@ -341,8 +363,8 @@ const struct menu_item menu_items[] = {
        { 0xE1, 0xE1,   "SpeedStor",    NULL },
        { 0xE3, 0xE3,   "SpeedStor",    NULL },
        { 0xE4, 0xE4,   "SpeedStor",    NULL },
-       { 0xEB, 0xEB,   "BeOS/i386",    "42465331-3ba3-10f1-802a-4861696b7521" },
-       { 0xEC,   -1,   "Legacy MBR",   "024dee41-33e7-11d3-9d69-0008c781f39f" },
+       { 0xEB, 0xEB,   "BeOS/i386",    BEOS_I386_GUID },
+       { 0xEC,   -1,   "Legacy MBR",   LEGACY_MBR_GUID },
        { 0xEE, 0xEE,   "EFI GPT",      NULL },
        { 0xEF, 0xEF,   "EFI Sys",      EFI_SYSTEM_PARTITION_GUID },
        { 0xF1, 0xF1,   "SpeedStor",    NULL },