diff options
| author | Richard W.M. Jones <rjones@redhat.com> | 2012-11-09 18:03:49 +0100 |
|---|---|---|
| committer | Richard W.M. Jones <rjones@redhat.com> | 2012-11-09 19:51:09 +0000 |
| commit | 2d220f5da2cd25e0fda0c98b98ecb384c1fe5c47 (patch) | |
| tree | a718347b5c6141743397b90fe6cf90116a7c8738 /format | |
| parent | b460d9f32eb527bc7aad4894a5f85c4e69366104 (diff) | |
| download | libguestfs-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 'format')
| -rw-r--r-- | format/format.c | 14 |
1 files changed, 4 insertions, 10 deletions
diff --git a/format/format.c b/format/format.c index 05b84347..32b4bdb5 100644 --- a/format/format.c +++ b/format/format.c @@ -430,11 +430,8 @@ do_rescan (char **devices) { size_t i; size_t errors = 0; - 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); + guestfs_push_error_handler (g, NULL, NULL); for (i = 0; devices[i] != NULL; ++i) { if (guestfs_blockdev_rereadpt (g, devices[i]) == -1) @@ -444,7 +441,7 @@ do_rescan (char **devices) if (guestfs_vgscan (g) == -1) errors++; - guestfs_set_error_handler (g, old_error_cb, old_error_data); + guestfs_pop_error_handler (g); return errors ? 1 : 0; } @@ -455,15 +452,12 @@ feature_available (guestfs_h *g, const char *feature) /* If there's an error we should ignore it, so to do that we have to * temporarily replace the error handler with a null one. */ - 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); + guestfs_push_error_handler (g, NULL, NULL); const char *groups[] = { feature, NULL }; int r = guestfs_available (g, (char * const *) groups); - guestfs_set_error_handler (g, old_error_cb, old_error_data); + guestfs_pop_error_handler (g); return r == 0 ? 1 : 0; } |
