This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
[PATCH] Deduplicate resolv/nss_dns/dns-host.c
- From: OndÅej BÃlka <neleai at seznam dot cz>
- To: libc-alpha at sourceware dot org
- Date: Thu, 13 Feb 2014 13:38:12 +0100
- Subject: [PATCH] Deduplicate resolv/nss_dns/dns-host.c
- Authentication-results: sourceware.org; auth=none
Hi, when reviewing Andreas patch I noticed duplicated code. One way to
improve that is jump to exit logic. A second possibility would be put
gaih_getanswer into a else block. What do you prefer?
* resolv/nss_dns/dns-host.c (_nss_dns_gethostbyname4_r): Remove
duplicate code.
diff --git a/resolv/nss_dns/dns-host.c b/resolv/nss_dns/dns-host.c
index 541c25a..4bf331e 100644
--- a/resolv/nss_dns/dns-host.c
+++ b/resolv/nss_dns/dns-host.c
@@ -342,16 +342,14 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
else
__set_errno (olderr);
- if (host_buffer.buf != orig_host_buffer)
- free (host_buffer.buf);
-
- return status;
+ goto free_and_return;
}
status = gaih_getanswer(host_buffer.buf, n, (const querybuf *) ans2p,
resplen2, name, pat, buffer, buflen,
errnop, herrnop, ttlp);
+ free_and_return:
if (host_buffer.buf != orig_host_buffer)
free (host_buffer.buf);