From cc64ab77d51dfce989067c72925f2225ae647a47 Mon Sep 17 00:00:00 2001 From: "Brian C. Lane" Date: Thu, 4 Aug 2022 11:54:17 -0700 Subject: [PATCH] - Update enum patch description for upstream --- ..._LAST_-macro-values-in-disk.h-direct.patch | 73 ------------------- ...in.h-Remove-use-of-enums-with-define.patch | 59 +++++++++++++++ parted.spec | 12 ++- 3 files changed, 64 insertions(+), 80 deletions(-) delete mode 100644 0001-Set-_FIRST_-and-_LAST_-macro-values-in-disk.h-direct.patch create mode 100644 0006-disk.in.h-Remove-use-of-enums-with-define.patch diff --git a/0001-Set-_FIRST_-and-_LAST_-macro-values-in-disk.h-direct.patch b/0001-Set-_FIRST_-and-_LAST_-macro-values-in-disk.h-direct.patch deleted file mode 100644 index b206c95..0000000 --- a/0001-Set-_FIRST_-and-_LAST_-macro-values-in-disk.h-direct.patch +++ /dev/null @@ -1,73 +0,0 @@ -From 6ce543f4999f21b363865bf845543326ba91406b Mon Sep 17 00:00:00 2001 -From: Adam Williamson -Date: Mon, 20 Jun 2022 12:07:14 -0700 -Subject: [PATCH] Set _FIRST_ and _LAST_ macro values in disk.h directly - -I may be missing something, but it seems impossible to use these -_FIRST_ and _LAST_ macros in practice as they are currently set. -You cannot use them at preprocessor time, because they will -always evaluate to 0 at that time, because the preprocessor does -not handle enums: - -https://stackoverflow.com/questions/34677148 - -and you cannot really use them at build time, because if you do -something like this: - - if (PED_PARTITION_LAST_FLAG > 17) { - PyModule_AddIntConstant(m, "PARTITION_ESP", PED_PARTITION_ESP); - } - -the compiler still throws an undeclared identifier error if you -actually try and build the code against an older parted. - -Unless anyone can suggest a way to use these properly as-is, -this is the best idea I can come up with: we just have to define -the _FIRST_ and _LAST_ values directly, and remember to keep -them in line when adding new entries to the enums. - -Signed-off-by: Adam Williamson ---- - include/parted/disk.in.h | 12 ++++++------ - 1 file changed, 6 insertions(+), 6 deletions(-) - -diff --git a/include/parted/disk.in.h b/include/parted/disk.in.h -index 672c4ee..fedcee9 100644 ---- a/include/parted/disk.in.h -+++ b/include/parted/disk.in.h -@@ -47,8 +47,8 @@ enum _PedDiskFlag { - /* This flag controls whether the boot flag of a GPT PMBR is set */ - PED_DISK_GPT_PMBR_BOOT=2, - }; --#define PED_DISK_FIRST_FLAG PED_DISK_CYLINDER_ALIGNMENT --#define PED_DISK_LAST_FLAG PED_DISK_GPT_PMBR_BOOT -+#define PED_DISK_FIRST_FLAG 1 -+#define PED_DISK_LAST_FLAG 2 - - /** - * Partition types -@@ -88,8 +88,8 @@ enum _PedPartitionFlag { - PED_PARTITION_BLS_BOOT=20, - PED_PARTITION_LINUX_HOME=21, - }; --#define PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT --#define PED_PARTITION_LAST_FLAG PED_PARTITION_LINUX_HOME -+#define PED_PARTITION_FIRST_FLAG 1 -+#define PED_PARTITION_LAST_FLAG 21 - - enum _PedDiskTypeFeature { - PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */ -@@ -97,8 +97,8 @@ enum _PedDiskTypeFeature { - PED_DISK_TYPE_PARTITION_TYPE_ID=4, /**< supports partition type-ids */ - PED_DISK_TYPE_PARTITION_TYPE_UUID=8, /**< supports partition type-uuids */ - }; --#define PED_DISK_TYPE_FIRST_FEATURE PED_DISK_TYPE_EXTENDED --#define PED_DISK_TYPE_LAST_FEATURE PED_DISK_TYPE_PARTITION_TYPE_UUID -+#define PED_DISK_TYPE_FIRST_FEATURE 1 -+#define PED_DISK_TYPE_LAST_FEATURE 8 - - struct _PedDisk; - struct _PedPartition; --- -2.36.1 - diff --git a/0006-disk.in.h-Remove-use-of-enums-with-define.patch b/0006-disk.in.h-Remove-use-of-enums-with-define.patch new file mode 100644 index 0000000..335be09 --- /dev/null +++ b/0006-disk.in.h-Remove-use-of-enums-with-define.patch @@ -0,0 +1,59 @@ +From aa690ee275db86d1edb2468bcf31c3d7cf81228e Mon Sep 17 00:00:00 2001 +From: "Brian C. Lane" +Date: Thu, 4 Aug 2022 11:39:09 -0700 +Subject: [PATCH] disk.in.h: Remove use of enums with #define + +The preprocessor doesn't evaluate the enum, so it ends up being 0, which +causes problems for library users like pyparted which try to use the _LAST +value to conditionally include support for newer flags. + +Instead just define the int that is the first and last entry in each enum. + +Thanks to adamw and dcantrell for help arriving at a solution. +--- + include/parted/disk.in.h | 15 +++++++++------ + 1 file changed, 9 insertions(+), 6 deletions(-) + +diff --git a/include/parted/disk.in.h b/include/parted/disk.in.h +index 672c4ee..715637d 100644 +--- a/include/parted/disk.in.h ++++ b/include/parted/disk.in.h +@@ -47,8 +47,9 @@ enum _PedDiskFlag { + /* This flag controls whether the boot flag of a GPT PMBR is set */ + PED_DISK_GPT_PMBR_BOOT=2, + }; +-#define PED_DISK_FIRST_FLAG PED_DISK_CYLINDER_ALIGNMENT +-#define PED_DISK_LAST_FLAG PED_DISK_GPT_PMBR_BOOT ++// NOTE: DO NOT define using enums ++#define PED_DISK_FIRST_FLAG 1 // PED_DISK_CYLINDER_ALIGNMENT ++#define PED_DISK_LAST_FLAG 2 // PED_DISK_GPT_PMBR_BOOT + + /** + * Partition types +@@ -88,8 +89,9 @@ enum _PedPartitionFlag { + PED_PARTITION_BLS_BOOT=20, + PED_PARTITION_LINUX_HOME=21, + }; +-#define PED_PARTITION_FIRST_FLAG PED_PARTITION_BOOT +-#define PED_PARTITION_LAST_FLAG PED_PARTITION_LINUX_HOME ++// NOTE: DO NOT define using enums ++#define PED_PARTITION_FIRST_FLAG 1 // PED_PARTITION_BOOT ++#define PED_PARTITION_LAST_FLAG 21 // PED_PARTITION_LINUX_HOME + + enum _PedDiskTypeFeature { + PED_DISK_TYPE_EXTENDED=1, /**< supports extended partitions */ +@@ -97,8 +99,9 @@ enum _PedDiskTypeFeature { + PED_DISK_TYPE_PARTITION_TYPE_ID=4, /**< supports partition type-ids */ + PED_DISK_TYPE_PARTITION_TYPE_UUID=8, /**< supports partition type-uuids */ + }; +-#define PED_DISK_TYPE_FIRST_FEATURE PED_DISK_TYPE_EXTENDED +-#define PED_DISK_TYPE_LAST_FEATURE PED_DISK_TYPE_PARTITION_TYPE_UUID ++// NOTE: DO NOT define using enums ++#define PED_DISK_TYPE_FIRST_FEATURE 1 // PED_DISK_TYPE_EXTENDED ++#define PED_DISK_TYPE_LAST_FEATURE 8 // PED_DISK_TYPE_PARTITION_TYPE_UUID + + struct _PedDisk; + struct _PedPartition; +-- +2.37.1 + diff --git a/parted.spec b/parted.spec index de7ec52..7b49a68 100644 --- a/parted.spec +++ b/parted.spec @@ -1,7 +1,7 @@ Summary: The GNU disk partition manipulation program Name: parted Version: 3.5 -Release: 4%{?dist} +Release: 5%{?dist} License: GPLv3+ URL: http://www.gnu.org/software/parted @@ -16,12 +16,7 @@ Patch0002: 0002-parted-add-type-command.patch Patch0003: 0003-libparted-add-swap-flag-for-DASD-label.patch Patch0004: 0004-parted-Reset-the-filesystem-type-when-changing-the-i.patch Patch0005: 0005-tests-t3200-type-change-now-passes.patch - -# Set _FIRST_ and _LAST_ macro values directly (not from an enum -# value) so they work at preprocessor time: -# https://github.com/dcantrell/pyparted/issues/91 -Patch1001: 0001-Set-_FIRST_-and-_LAST_-macro-values-in-disk.h-direct.patch - +Patch0006: 0006-disk.in.h-Remove-use-of-enums-with-define.patch BuildRequires: gcc BuildRequires: e2fsprogs-devel @@ -125,6 +120,9 @@ make check %changelog +* Thu Aug 04 2022 Brian C. Lane - 3.5-5 +- Update enum patch description for upstream + * Fri Jul 22 2022 Fedora Release Engineering - 3.5-4 - Rebuilt for https://fedoraproject.org/wiki/Fedora_37_Mass_Rebuild