From: Chuck Lever Date: Tue, 22 Jun 2010 16:40:27 +0000 (-0400) Subject: exportfs: Add a common exit label in exportfs() X-Git-Tag: nfs-utils-1-2-3-rc4~7 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=3ca5879be32c4c11750e12230ff588195fff0738;p=nfs-utils.git exportfs: Add a common exit label in exportfs() Clean up: Reduce code duplication by introducing a goto label for freeing hp and exiting. This will make replacing "struct hostent *" with "struct addrinfo *" more straightforward in this code. Signed-off-by: Chuck Lever Signed-off-by: Steve Dickson --- diff --git a/utils/exportfs/exportfs.c b/utils/exportfs/exportfs.c index 83d00a0..50f1e34 100644 --- a/utils/exportfs/exportfs.c +++ b/utils/exportfs/exportfs.c @@ -263,14 +263,10 @@ exportfs(char *arg, char *options, int verbose) if (!exp) { if (!(eep = mkexportent(hname, path, options)) || - !(exp = export_create(eep, 0))) { - if (hp) free (hp); - return; - } - } else if (!updateexportent(&exp->m_export, options)) { - if (hp) free (hp); - return; - } + !(exp = export_create(eep, 0))) + goto out; + } else if (!updateexportent(&exp->m_export, options)) + goto out; if (verbose) printf("exporting %s:%s\n", exp->m_client->m_hostname, @@ -280,6 +276,8 @@ exportfs(char *arg, char *options, int verbose) exp->m_changed = 1; exp->m_warned = 0; validate_export(exp); + +out: if (hp) free (hp); }