diff options
author | Matthew Booth <mbooth@redhat.com> | 2011-11-23 14:00:54 +0000 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2011-11-24 12:50:26 +0000 |
commit | 011a248381cacd6751deb1d1be122cc9bd6aba09 (patch) | |
tree | 2807b5017c5f738f1121256d224cafdb1081661e /src | |
parent | 454a08380d9de78448927ab77480f833342d214c (diff) | |
download | libguestfs-011a248381cacd6751deb1d1be122cc9bd6aba09.tar.gz libguestfs-011a248381cacd6751deb1d1be122cc9bd6aba09.tar.xz libguestfs-011a248381cacd6751deb1d1be122cc9bd6aba09.zip |
NFC: Consolidate the error path in check_fstab in inspect_fs_unix.c
Diffstat (limited to 'src')
-rw-r--r-- | src/inspect_fs_unix.c | 23 |
1 files changed, 9 insertions, 14 deletions
diff --git a/src/inspect_fs_unix.c b/src/inspect_fs_unix.c index 6b1a05ba..51dfa673 100644 --- a/src/inspect_fs_unix.c +++ b/src/inspect_fs_unix.c @@ -685,13 +685,11 @@ static int check_fstab (guestfs_h *g, struct inspect_fs *fs) { char **lines = guestfs_aug_ls (g, "/files/etc/fstab"); - if (lines == NULL) - return -1; + if (lines == NULL) goto error; if (lines[0] == NULL) { error (g, _("could not parse /etc/fstab or empty file")); - guestfs___free_string_list (lines); - return -1; + goto error; } size_t i; @@ -703,32 +701,29 @@ check_fstab (guestfs_h *g, struct inspect_fs *fs) if (match (g, lines[i], re_aug_seq)) { snprintf (augpath, sizeof augpath, "%s/spec", lines[i]); char *spec = guestfs_aug_get (g, augpath); - if (spec == NULL) { - guestfs___free_string_list (lines); - return -1; - } + if (spec == NULL) goto error; snprintf (augpath, sizeof augpath, "%s/file", lines[i]); char *mp = guestfs_aug_get (g, augpath); if (mp == NULL) { - guestfs___free_string_list (lines); free (spec); - return -1; + goto error; } int r = add_fstab_entry (g, fs, spec, mp); free (spec); free (mp); - if (r == -1) { - guestfs___free_string_list (lines); - return -1; - } + if (r == -1) goto error; } } guestfs___free_string_list (lines); return 0; + +error: + if (lines) guestfs___free_string_list (lines); + return -1; } /* Add a filesystem and possibly a mountpoint entry for |