partutil: Explicitly use PART_TYPE_UNKNOWN
authorMartin Pitt <martin.pitt@ubuntu.com>
Thu, 21 Oct 2010 07:33:00 +0000 (09:33 +0200)
committerMartin Pitt <martin.pitt@ubuntu.com>
Thu, 21 Oct 2010 07:33:00 +0000 (09:33 +0200)
Previously we were comparing PartitionScheme values against the undefined enum
value -1, which causes a warning with gcc 4.5. Define -1 explicitly as
"PART_TYPE_UNKNOWN" and only use that in the code, which is cleaner.

Thanks to Marti Raudsepp for pointing this out!

src/helpers/partutil.c
src/helpers/partutil.h

index 63d3422..ecec84c 100644 (file)
@@ -1410,7 +1410,7 @@ part_add_change_partition (char *device_file,
       DEBUG ("In part_add_partition: device_file=%s, start=%lld, size=%lld, type=%s", device_file, start, size, type);
     }
 
-  scheme = -1;
+  scheme = PART_TYPE_UNKNOWN;
   if (is_change)
     {
       PartitionTable *p;
@@ -1456,7 +1456,7 @@ part_add_change_partition (char *device_file,
   /* now that we know the partitoning scheme, sanity check type and flags */
   switch (scheme)
     {
-    case -1:
+    case PART_TYPE_UNKNOWN:
       /* unknown partition table format; error out if any type, label or flags are given */
       if ((flags != NULL && flags[0] != NULL))
         {
index cbd8c9b..ffa4a22 100644 (file)
@@ -32,6 +32,7 @@
 /* Partition schemes understood by this library */
 typedef enum
   {
+    PART_TYPE_UNKNOWN = -1,
     PART_TYPE_MSDOS = 0,
     PART_TYPE_MSDOS_EXTENDED = 1,
     PART_TYPE_APPLE = 2,