[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[Libguestfs] [PATCH 4/9] daemon: Make the RUN_PARTED macro take an error statement.



Turns out we don't use this either.  However still a nice change.

Rich.

-- 
Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones
virt-top is 'top' for virtual machines.  Tiny program with many
powerful monitoring features, net stats, disk stats, logging, etc.
http://et.redhat.com/~rjones/virt-top
>From 440ad646cdf31bdb5ad2bc92fc51fa6df3fb9c63 Mon Sep 17 00:00:00 2001
From: Richard Jones <rjones redhat com>
Date: Sat, 10 Apr 2010 13:16:19 +0100
Subject: [PATCH 4/9] daemon: Make the RUN_PARTED macro take an error statement.

This allows us to make the RUN_PARTED macro do something else
along the error path, other than just returning -1.
---
 daemon/parted.c |   16 +++++++++-------
 1 files changed, 9 insertions(+), 7 deletions(-)

diff --git a/daemon/parted.c b/daemon/parted.c
index 99417c2..ff6cca1 100644
--- a/daemon/parted.c
+++ b/daemon/parted.c
@@ -55,7 +55,7 @@ recover_blkrrpart (const char *device, const char *err)
   return 0;
 }
 
-#define RUN_PARTED(device,...)                                          \
+#define RUN_PARTED(error,device,...)                                    \
   do {                                                                  \
     int r;                                                              \
     char *err;                                                          \
@@ -66,7 +66,7 @@ recover_blkrrpart (const char *device, const char *err)
       if (recover_blkrrpart ((device), err) == -1) {                    \
         reply_with_error ("%s: parted: %s: %s", __func__, (device), err); \
         free (err);                                                     \
-        return -1;                                                      \
+        error;                                                          \
       }                                                                 \
     }                                                                   \
                                                                         \
@@ -107,7 +107,7 @@ do_part_init (const char *device, const char *parttype)
     return -1;
   }
 
-  RUN_PARTED (device, "mklabel", parttype, NULL);
+  RUN_PARTED (return -1, device, "mklabel", parttype, NULL);
 
   udev_settle ();
 
@@ -151,7 +151,7 @@ do_part_add (const char *device, const char *prlogex,
    * name_ to prlogex, eg. "primary".  I would essentially describe
    * this as a bug in the parted mkpart command.
    */
-  RUN_PARTED (device, "mkpart", prlogex, startstr, endstr, NULL);
+  RUN_PARTED (return -1, device, "mkpart", prlogex, startstr, endstr, NULL);
 
   udev_settle ();
 
@@ -183,7 +183,8 @@ do_part_disk (const char *device, const char *parttype)
     endstr = "-1s";
   }
 
-  RUN_PARTED (device,
+  RUN_PARTED (return -1,
+              device,
               "mklabel", parttype,
               /* See comment about about the parted mkpart command. */
               "mkpart", STREQ (parttype, "gpt") ? "p1" : "primary",
@@ -201,7 +202,8 @@ do_part_set_bootable (const char *device, int partnum, int bootable)
 
   snprintf (partstr, sizeof partstr, "%d", partnum);
 
-  RUN_PARTED (device, "set", partstr, "boot", bootable ? "on" : "off", NULL);
+  RUN_PARTED (return -1,
+              device, "set", partstr, "boot", bootable ? "on" : "off", NULL);
 
   udev_settle ();
 
@@ -215,7 +217,7 @@ do_part_set_name (const char *device, int partnum, const char *name)
 
   snprintf (partstr, sizeof partstr, "%d", partnum);
 
-  RUN_PARTED (device, "name", partstr, name, NULL);
+  RUN_PARTED (return -1, device, "name", partstr, name, NULL);
 
   udev_settle ();
 
-- 
1.6.6.1


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]