diff mbox series

support_format_hostent: Add more error information for NETDB_INTERNAL

Message ID 20170904173203.A176E439942E3@oldenburg.str.redhat.com
State New
Headers show
Series support_format_hostent: Add more error information for NETDB_INTERNAL | expand

Commit Message

Florian Weimer Sept. 4, 2017, 5:32 p.m. UTC
2017-09-04  Florian Weimer  <fweimer@redhat.com>

	* support/support_format_hostent.c (support_format_hostent): Add
	more error information for NETDB_INTERNAL.

Comments

Adhemerval Zanella Netto Sept. 5, 2017, 5:54 p.m. UTC | #1
On 04/09/2017 14:32, Florian Weimer wrote:
> 2017-09-04  Florian Weimer  <fweimer@redhat.com>
> 
> 	* support/support_format_hostent.c (support_format_hostent): Add
> 	more error information for NETDB_INTERNAL.

LGTM.

> 
> diff --git a/support/support_format_hostent.c b/support/support_format_hostent.c
> index 5b5f26082e..88c85ec1f1 100644
> --- a/support/support_format_hostent.c
> +++ b/support/support_format_hostent.c
> @@ -19,6 +19,7 @@
>  #include <support/format_nss.h>
>  
>  #include <arpa/inet.h>
> +#include <errno.h>
>  #include <stdio.h>
>  #include <support/support.h>
>  #include <support/xmemstream.h>
> @@ -41,10 +42,15 @@ support_format_hostent (struct hostent *h)
>  {
>    if (h == NULL)
>      {
> -      char *value = support_format_herrno (h_errno);
> -      char *result = xasprintf ("error: %s\n", value);
> -      free (value);
> -      return result;
> +      if (h_errno == NETDB_INTERNAL)
> +        return xasprintf ("error: NETDB_INTERNAL (errno %d, %m)\n", errno);
> +      else
> +        {
> +          char *value = support_format_herrno (h_errno);
> +          char *result = xasprintf ("error: %s\n", value);
> +          free (value);
> +          return result;
> +        }
>      }
>  
>    struct xmemstream mem;
>
diff mbox series

Patch

diff --git a/support/support_format_hostent.c b/support/support_format_hostent.c
index 5b5f26082e..88c85ec1f1 100644
--- a/support/support_format_hostent.c
+++ b/support/support_format_hostent.c
@@ -19,6 +19,7 @@ 
 #include <support/format_nss.h>
 
 #include <arpa/inet.h>
+#include <errno.h>
 #include <stdio.h>
 #include <support/support.h>
 #include <support/xmemstream.h>
@@ -41,10 +42,15 @@  support_format_hostent (struct hostent *h)
 {
   if (h == NULL)
     {
-      char *value = support_format_herrno (h_errno);
-      char *result = xasprintf ("error: %s\n", value);
-      free (value);
-      return result;
+      if (h_errno == NETDB_INTERNAL)
+        return xasprintf ("error: NETDB_INTERNAL (errno %d, %m)\n", errno);
+      else
+        {
+          char *value = support_format_herrno (h_errno);
+          char *result = xasprintf ("error: %s\n", value);
+          free (value);
+          return result;
+        }
     }
 
   struct xmemstream mem;