summaryrefslogtreecommitdiffstats
path: root/daemon/parted.c
diff options
context:
space:
mode:
authorRichard Jones <rjones@redhat.com>2010-04-10 13:16:19 +0100
committerRichard Jones <rjones@redhat.com>2010-04-10 13:41:46 +0100
commit440ad646cdf31bdb5ad2bc92fc51fa6df3fb9c63 (patch)
tree470b728804bb62845425201a5c7767656a569d06 /daemon/parted.c
parent30752ac7ca042f533b8d0c4c6144400a8532b154 (diff)
downloadlibguestfs-440ad646cdf31bdb5ad2bc92fc51fa6df3fb9c63.tar.gz
libguestfs-440ad646cdf31bdb5ad2bc92fc51fa6df3fb9c63.tar.xz
libguestfs-440ad646cdf31bdb5ad2bc92fc51fa6df3fb9c63.zip
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.
Diffstat (limited to 'daemon/parted.c')
-rw-r--r--daemon/parted.c16
1 files changed, 9 insertions, 7 deletions
diff --git a/daemon/parted.c b/daemon/parted.c
index 99417c23..ff6cca11 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 ();