This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[PATCH] Deduplicate resolv/nss_dns/dns-host.c


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);
 


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]