From b7fd7d03cac92fcd580b7009b810ee6395098591 Mon Sep 17 00:00:00 2001 From: "Peter H. Froehlich" Date: Sun, 25 Apr 2021 16:36:58 +0200 Subject: Just formatting. --- part_ids.c | 67 ++++++++++++++++++++++++++++++++++++-------------------------- 1 file changed, 39 insertions(+), 28 deletions(-) diff --git a/part_ids.c b/part_ids.c index 84f4189..fc7ba9c 100644 --- a/part_ids.c +++ b/part_ids.c @@ -7,34 +7,37 @@ #include #include -#define GUID_TABLE \ - X(LINUX_SWAP, "0657FD6D-A4AB-43C4-84E5-0933C84B4F4F") \ - X(LINUX_FS, "0FC63DAF-8483-4772-8E79-3D69D8477DE4") \ - X(EFI_SYSTEM, "C12A7328-F81F-11D2-BA4B-00A0C93EC93B") \ - X(MS_BASIC_DATA, "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7") \ +#define GUID_TABLE \ + X(LINUX_SWAP, "0657FD6D-A4AB-43C4-84E5-0933C84B4F4F") \ + X(LINUX_FS, "0FC63DAF-8483-4772-8E79-3D69D8477DE4") \ + X(EFI_SYSTEM, "C12A7328-F81F-11D2-BA4B-00A0C93EC93B") \ + X(MS_BASIC_DATA, "EBD0A0A2-B9E5-4433-87C0-68B6B72699C7") \ X(BIOS_BOOT, "21686148-6449-6E6F-744E-656564454649") -#define ALIAS_TABLE \ - X("fat12", 0x01, MS_BASIC_DATA) \ - X("fat16", 0x04, MS_BASIC_DATA) \ - X("fat16b", 0x06, MS_BASIC_DATA) \ - X("ntfs", 0x07, MS_BASIC_DATA) \ - X("fat32", 0x0b, MS_BASIC_DATA) \ - X("fat32x", 0x0c, MS_BASIC_DATA) \ - X("fat16x", 0x0e, MS_BASIC_DATA) \ - X("fat16+", 0x28, MS_BASIC_DATA) \ - X("fat32+", 0x29, MS_BASIC_DATA) \ - X("swap", 0x82, LINUX_SWAP) \ - X("linux", 0x83, LINUX_FS) \ - X("system", 0x100, EFI_SYSTEM) \ +#define ALIAS_TABLE \ + X("fat12", 0x01, MS_BASIC_DATA) \ + X("fat16", 0x04, MS_BASIC_DATA) \ + X("fat16b", 0x06, MS_BASIC_DATA) \ + X("ntfs", 0x07, MS_BASIC_DATA) \ + X("fat32", 0x0b, MS_BASIC_DATA) \ + X("fat32x", 0x0c, MS_BASIC_DATA) \ + X("fat16x", 0x0e, MS_BASIC_DATA) \ + X("fat16+", 0x28, MS_BASIC_DATA) \ + X("fat32+", 0x29, MS_BASIC_DATA) \ + X("swap", 0x82, LINUX_SWAP) \ + X("linux", 0x83, LINUX_FS) \ + X("system", 0x100, EFI_SYSTEM) \ X("bios", 0x101, BIOS_BOOT) -/* First we generate compact indices for each GUID using an enum. */ +/* + * First we generate compact indices for each GUID using an enum. (It's true, + * clang-format is not improving things below.) + */ enum GUID_INDEX { -#define X(index, guid) GUID_ ## index, +#define X(index, guid) GUID_##index, GUID_TABLE #undef X - NUM_GUIDS, + NUM_GUIDS }; /* @@ -43,7 +46,7 @@ enum GUID_INDEX { * a GUID, so don't try to `printf` them directly! */ static const char guids[NUM_GUIDS][GUID_STRLEN] = { -#define X(index, guid) [GUID_ ## index] = guid, +#define X(index, guid) [GUID_##index] = guid, GUID_TABLE #undef X }; @@ -53,8 +56,11 @@ static const char guids[NUM_GUIDS][GUID_STRLEN] = { * sorted, but unless we have thousands of names, a linear search should be * all we need. A `key` of `NULL` marks the end. */ -static const struct {char *key; int value;} name_to_guid[] = { -#define X(name, id, index) {name, GUID_ ## index}, +static const struct { + char *key; + int value; +} name_to_guid[] = { +#define X(name, id, index) {name, GUID_##index}, ALIAS_TABLE #undef X {NULL, -1}, @@ -63,8 +69,11 @@ static const struct {char *key; int value;} name_to_guid[] = { /* * The same for the "short" MBR-style ids. A `key` of `-1` marks the end. */ -static const struct {int key; int value;} mbr_to_guid[] = { -#define X(name, id, index) {id, GUID_ ## index}, +static const struct { + int key; + int value; +} mbr_to_guid[] = { +#define X(name, id, index) {id, GUID_##index}, ALIAS_TABLE #undef X {-1, -1}, @@ -108,7 +117,8 @@ find_by_name(const char *str, GUID *guid) { for (int i = 0; name_to_guid[i].key != NULL; i++) { if (!strcmp(str, name_to_guid[i].key)) { - return string_to_guid(guid, guids[name_to_guid[i].value]); + return string_to_guid( + guid, guids[name_to_guid[i].value]); } } return -1; @@ -119,7 +129,8 @@ find_by_id(const int id, GUID *guid) { for (int i = 0; mbr_to_guid[i].key != -1; i++) { if (mbr_to_guid[i].key == id) { - return string_to_guid(guid, guids[mbr_to_guid[i].value]); + return string_to_guid( + guid, guids[mbr_to_guid[i].value]); } } return -1; -- cgit 1.4.1-2-gfad0