summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian C. Lane <bcl@redhat.com>2022-08-04 11:39:09 -0700
committerBrian C. Lane <bcl@redhat.com>2022-08-04 11:53:32 -0700
commitaa690ee275db86d1edb2468bcf31c3d7cf81228e (patch)
treea15bdac71686255b670a2b8b7e3eb068f48bf015
parentb16be5ffc8e700df2b6b2545c4b6794cea71b8e7 (diff)
downloadparted-aa690ee275db86d1edb2468bcf31c3d7cf81228e.tar.gz
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.
-rw-r--r--include/parted/disk.in.h15
1 files 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;