[network-manager-pptp/nm-1-2] service: streamline the call to inet_ntop



commit 65613ae4edbf033efad8a4abbedb7b0a96e5746b
Author: Lubomir Rintel <lkundrak v3 sk>
Date:   Wed Apr 27 19:26:44 2016 +0200

    service: streamline the call to inet_ntop
    
    (cherry picked from commit 58d2e74457403ccd68b46875686a886cb3b91950)

 src/nm-pptp-service.c |   16 +++-------------
 1 files changed, 3 insertions(+), 13 deletions(-)
---
diff --git a/src/nm-pptp-service.c b/src/nm-pptp-service.c
index 4ba1ee2..40fe2bd 100644
--- a/src/nm-pptp-service.c
+++ b/src/nm-pptp-service.c
@@ -748,7 +748,7 @@ lookup_gateway (NMPptpPlugin *self,
        struct addrinfo hints;
        struct addrinfo *result = NULL, *rp;
        int err;
-       char buf[INET_ADDRSTRLEN + 1];
+       char buf[INET_ADDRSTRLEN];
 
        g_return_val_if_fail (src != NULL, FALSE);
 
@@ -818,19 +818,9 @@ lookup_gateway (NMPptpPlugin *self,
                return FALSE;
        }
 
-       memset (buf, 0, sizeof (buf));
-       errno = 0;
-       if (inet_ntop (AF_INET, &naddr, buf, sizeof (buf) - 1) == NULL) {
-               g_set_error (error,
-                            NM_VPN_PLUGIN_ERROR,
-                            NM_VPN_PLUGIN_ERROR_LAUNCH_FAILED,
-                            _("no usable addresses returned for PPTP VPN gateway '%s' (%d)"),
-                            src, errno);
-               return FALSE;
-       }
-
        priv->naddr = naddr.s_addr;
-       priv->saddr = g_strdup (buf);
+       priv->saddr = g_strdup (inet_ntop (AF_INET, &naddr, buf, sizeof (buf)));
+
        return TRUE;
 }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]