From: Matthew Booth Date: Wed, 23 Nov 2011 14:00:54 +0000 (+0000) Subject: NFC: Consolidate the error path in check_fstab in inspect_fs_unix.c X-Git-Tag: 1.14.4~11 X-Git-Url: http://git.annexia.org/?a=commitdiff_plain;h=b04a30131ee8de99f289eb27fe538560197d4de0;p=libguestfs.git NFC: Consolidate the error path in check_fstab in inspect_fs_unix.c (cherry picked from commit 011a248381cacd6751deb1d1be122cc9bd6aba09) --- diff --git a/src/inspect_fs_unix.c b/src/inspect_fs_unix.c index 6b1a05b..51dfa67 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