]> git.ipfire.org Git - thirdparty/glibc.git/commitdiff
Deduplicate resolv/nss_dns/dns-host.c
authorOndřej Bílka <neleai@seznam.cz>
Sun, 16 Feb 2014 11:59:23 +0000 (12:59 +0100)
committerOndřej Bílka <neleai@seznam.cz>
Sun, 16 Feb 2014 11:59:23 +0000 (12:59 +0100)
In resolv/nss_dns/dns-host.c one of code path duplicated code after
that. We merge these paths.

resolv/nss_dns/dns-host.c

index 365de7095fb571b455fb79c2707537bc9d7072c9..47f998c23924eb27f7665be746cde476ab4ade11 100644 (file)
@@ -315,7 +315,13 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
   int n = __libc_res_nsearch (&_res, name, C_IN, T_UNSPEC,
                              host_buffer.buf->buf, anslen, &host_buffer.ptr,
                              &ans2p, &nans2p, &resplen2);
-  if (n < 0)
+  if (n >= 0)
+    {
+      status = gaih_getanswer (host_buffer.buf, n, (const querybuf *) ans2p,
+                              resplen2, name, pat, buffer, buflen,
+                              errnop, herrnop, ttlp);
+    }
+  else
     {
       switch (errno)
        {
@@ -342,17 +348,8 @@ _nss_dns_gethostbyname4_r (const char *name, struct gaih_addrtuple **pat,
        *errnop = EAGAIN;
       else
        __set_errno (olderr);
-
-      if (host_buffer.buf != orig_host_buffer)
-       free (host_buffer.buf);
-
-      return status;
     }
 
-  status = gaih_getanswer(host_buffer.buf, n, (const querybuf *) ans2p,
-                         resplen2, name, pat, buffer, buflen,
-                         errnop, herrnop, ttlp);
-
   /* Check whether ans2p was separately allocated.  */
   if (host_buffer.buf != orig_host_buffer)
     anslen = MAXPACKET;