exportfs: Add a common exit label in exportfs() From: Chuck Lever 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 --- utils/exportfs/exportfs.c | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) --- nfs-utils-1.2.1.orig/utils/exportfs/exportfs.c +++ nfs-utils-1.2.1/utils/exportfs/exportfs.c @@ -262,14 +262,10 @@ exportfs(char *arg, char *options, int v 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, @@ -279,6 +275,8 @@ exportfs(char *arg, char *options, int v exp->m_changed = 1; exp->m_warned = 0; validate_export(exp); + +out: if (hp) free (hp); }