summaryrefslogtreecommitdiffstats
path: root/cat
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-11-09 18:03:49 +0100
committerRichard W.M. Jones <rjones@redhat.com>2012-11-09 19:51:09 +0000
commit2d220f5da2cd25e0fda0c98b98ecb384c1fe5c47 (patch)
treea718347b5c6141743397b90fe6cf90116a7c8738 /cat
parentb460d9f32eb527bc7aad4894a5f85c4e69366104 (diff)
downloadlibguestfs-2d220f5da2cd25e0fda0c98b98ecb384c1fe5c47.tar.gz
libguestfs-2d220f5da2cd25e0fda0c98b98ecb384c1fe5c47.tar.xz
libguestfs-2d220f5da2cd25e0fda0c98b98ecb384c1fe5c47.zip
tools: Modify existing tools to use guestfs_{push,pop}_error_handler.
This is a shorter and more convenient way to disable errors temporarily across calls.
Diffstat (limited to 'cat')
-rw-r--r--cat/virt-filesystems.c40
1 files changed, 14 insertions, 26 deletions
diff --git a/cat/virt-filesystems.c b/cat/virt-filesystems.c
index c28c4b1c..9c370186 100644
--- a/cat/virt-filesystems.c
+++ b/cat/virt-filesystems.c
@@ -36,15 +36,6 @@
#include "guestfs.h"
#include "options.h"
-#define DISABLE_GUESTFS_ERRORS_FOR(stmt) do { \
- guestfs_error_handler_cb old_error_cb; \
- void *old_error_data; \
- old_error_cb = guestfs_get_error_handler (g, &old_error_data); \
- guestfs_set_error_handler (g, NULL, NULL); \
- stmt; \
- guestfs_set_error_handler (g, old_error_cb, old_error_data); \
- } while (0)
-
/* These globals are shared with options.c. */
guestfs_h *g;
@@ -472,9 +463,9 @@ do_output_filesystems (void)
* otherwise pass them as NULL.
*/
if ((columns & COLUMN_VFS_LABEL)) {
- DISABLE_GUESTFS_ERRORS_FOR (
- vfs_label = guestfs_vfs_label (g, fses[i]);
- );
+ guestfs_push_error_handler (g, NULL, NULL);
+ vfs_label = guestfs_vfs_label (g, fses[i]);
+ guestfs_pop_error_handler (g);
if (vfs_label == NULL) {
vfs_label = strdup ("");
if (!vfs_label) {
@@ -484,9 +475,9 @@ do_output_filesystems (void)
}
}
if ((columns & COLUMN_UUID)) {
- DISABLE_GUESTFS_ERRORS_FOR (
- vfs_uuid = guestfs_vfs_uuid (g, fses[i]);
- );
+ guestfs_push_error_handler (g, NULL, NULL);
+ vfs_uuid = guestfs_vfs_uuid (g, fses[i]);
+ guestfs_pop_error_handler (g);
if (vfs_uuid == NULL) {
vfs_uuid = strdup ("");
if (!vfs_uuid) {
@@ -662,23 +653,20 @@ get_mbr_id (const char *dev, const char *parent_name)
char *parttype = NULL;
int mbr_id = -1, partnum;
- DISABLE_GUESTFS_ERRORS_FOR (
- parttype = guestfs_part_get_parttype (g, parent_name);
- );
+ guestfs_push_error_handler (g, NULL, NULL);
+
+ parttype = guestfs_part_get_parttype (g, parent_name);
if (parttype && STREQ (parttype, "msdos")) {
- DISABLE_GUESTFS_ERRORS_FOR (
- partnum = guestfs_part_to_partnum (g, dev);
- );
- if (partnum >= 0) {
- DISABLE_GUESTFS_ERRORS_FOR (
- mbr_id = guestfs_part_get_mbr_id (g, parent_name, partnum);
- );
- }
+ partnum = guestfs_part_to_partnum (g, dev);
+ if (partnum >= 0)
+ mbr_id = guestfs_part_get_mbr_id (g, parent_name, partnum);
}
free (parttype);
+ guestfs_pop_error_handler (g);
+
return mbr_id;
}