[parted-devel] [PATCH] libparted: Convert first and last macros to ints

Brian C. Lane bcl at redhat.com
Thu Oct 8 20:49:50 UTC 2015


Currently the PED_PARTITION_FIRST_FLAG and _LAST_FLAG are defined as
enum symbols. This means that they cannot be evaluated by #if in the
preprocessor (they evaluate to false).

Redefine them as their integer values so that library users, such as
pyparted, can evaluate them at compile time and optionally include
support for newer flags by checking #if PED_PARTITION_LAST_FLAG > 15
---
 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 b06e69d..64d8c23 100644
--- a/include/parted/disk.in.h
+++ b/include/parted/disk.in.h
@@ -39,8 +39,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
@@ -78,15 +78,15 @@ enum _PedPartitionFlag {
         PED_PARTITION_ESP=18,
         PED_PARTITION_NONFS=19
 };
-#define PED_PARTITION_FIRST_FLAG        PED_PARTITION_BOOT
-#define PED_PARTITION_LAST_FLAG         PED_PARTITION_NONFS
+#define PED_PARTITION_FIRST_FLAG        1
+#define PED_PARTITION_LAST_FLAG         19
 
 enum _PedDiskTypeFeature {
         PED_DISK_TYPE_EXTENDED=1,       /**< supports extended partitions */
         PED_DISK_TYPE_PARTITION_NAME=2  /**< supports partition names */
 };
-#define PED_DISK_TYPE_FIRST_FEATURE    PED_DISK_TYPE_EXTENDED
-#define PED_DISK_TYPE_LAST_FEATURE     PED_DISK_TYPE_PARTITION_NAME
+#define PED_DISK_TYPE_FIRST_FEATURE    1
+#define PED_DISK_TYPE_LAST_FEATURE     2
 
 struct _PedDisk;
 struct _PedPartition;
-- 
2.4.3




More information about the parted-devel mailing list