aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorPaul Eggert2017-11-26 20:13:16 -0800
committerPaul Eggert2017-11-26 20:14:31 -0800
commit3a1d9821f4404d07c21f0d501e8c9daa98ce16ec (patch)
tree8300a6ac65cde1dd3e76ec7a19b83f3c96331b68 /src/process.c
parent6ec5d497b6623e612ca6936ac848234725d4fc61 (diff)
downloademacs-3a1d9821f4404d07c21f0d501e8c9daa98ce16ec.tar.gz
emacs-3a1d9821f4404d07c21f0d501e8c9daa98ce16ec.zip
Pacify --enable-gcc-warnings on Ubuntu 17.10 x86-64
* src/process.c (Fmake_network_process): Avoid duplicate test of NILP (host), which apparently confuses GCC into thinking that portstringlen might be used uninitialized.
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c60
1 files changed, 31 insertions, 29 deletions
diff --git a/src/process.c b/src/process.c
index a4f016fc25b..3a8bcfb3fcf 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3835,7 +3835,6 @@ usage: (make-network-process &rest ARGS) */)
3835 Lisp_Object contact; 3835 Lisp_Object contact;
3836 struct Lisp_Process *p; 3836 struct Lisp_Process *p;
3837 const char *portstring UNINIT; 3837 const char *portstring UNINIT;
3838 ptrdiff_t portstringlen ATTRIBUTE_UNUSED;
3839 char portbuf[INT_BUFSIZE_BOUND (EMACS_INT)]; 3838 char portbuf[INT_BUFSIZE_BOUND (EMACS_INT)];
3840#ifdef HAVE_LOCAL_SOCKETS 3839#ifdef HAVE_LOCAL_SOCKETS
3841 struct sockaddr_un address_un; 3840 struct sockaddr_un address_un;
@@ -3982,6 +3981,8 @@ usage: (make-network-process &rest ARGS) */)
3982 3981
3983 if (!NILP (host)) 3982 if (!NILP (host))
3984 { 3983 {
3984 ptrdiff_t portstringlen ATTRIBUTE_UNUSED;
3985
3985 /* SERVICE can either be a string or int. 3986 /* SERVICE can either be a string or int.
3986 Convert to a C string for later use by getaddrinfo. */ 3987 Convert to a C string for later use by getaddrinfo. */
3987 if (EQ (service, Qt)) 3988 if (EQ (service, Qt))
@@ -4000,37 +4001,38 @@ usage: (make-network-process &rest ARGS) */)
4000 portstring = SSDATA (service); 4001 portstring = SSDATA (service);
4001 portstringlen = SBYTES (service); 4002 portstringlen = SBYTES (service);
4002 } 4003 }
4003 }
4004 4004
4005#ifdef HAVE_GETADDRINFO_A 4005#ifdef HAVE_GETADDRINFO_A
4006 if (!NILP (host) && !NILP (Fplist_get (contact, QCnowait))) 4006 if (!NILP (Fplist_get (contact, QCnowait)))
4007 { 4007 {
4008 ptrdiff_t hostlen = SBYTES (host); 4008 ptrdiff_t hostlen = SBYTES (host);
4009 struct req 4009 struct req
4010 { 4010 {
4011 struct gaicb gaicb; 4011 struct gaicb gaicb;
4012 struct addrinfo hints; 4012 struct addrinfo hints;
4013 char str[FLEXIBLE_ARRAY_MEMBER]; 4013 char str[FLEXIBLE_ARRAY_MEMBER];
4014 } *req = xmalloc (FLEXSIZEOF (struct req, str, 4014 } *req = xmalloc (FLEXSIZEOF (struct req, str,
4015 hostlen + 1 + portstringlen + 1)); 4015 hostlen + 1 + portstringlen + 1));
4016 dns_request = &req->gaicb; 4016 dns_request = &req->gaicb;
4017 dns_request->ar_name = req->str; 4017 dns_request->ar_name = req->str;
4018 dns_request->ar_service = req->str + hostlen + 1; 4018 dns_request->ar_service = req->str + hostlen + 1;
4019 dns_request->ar_request = &req->hints; 4019 dns_request->ar_request = &req->hints;
4020 dns_request->ar_result = NULL; 4020 dns_request->ar_result = NULL;
4021 memset (&req->hints, 0, sizeof req->hints); 4021 memset (&req->hints, 0, sizeof req->hints);
4022 req->hints.ai_family = family; 4022 req->hints.ai_family = family;
4023 req->hints.ai_socktype = socktype; 4023 req->hints.ai_socktype = socktype;
4024 strcpy (req->str, SSDATA (host)); 4024 strcpy (req->str, SSDATA (host));
4025 strcpy (req->str + hostlen + 1, portstring); 4025 strcpy (req->str + hostlen + 1, portstring);
4026 4026
4027 int ret = getaddrinfo_a (GAI_NOWAIT, &dns_request, 1, NULL); 4027 int ret = getaddrinfo_a (GAI_NOWAIT, &dns_request, 1, NULL);
4028 if (ret) 4028 if (ret)
4029 error ("%s/%s getaddrinfo_a error %d", SSDATA (host), portstring, ret); 4029 error ("%s/%s getaddrinfo_a error %d",
4030 4030 SSDATA (host), portstring, ret);
4031 goto open_socket; 4031
4032 } 4032 goto open_socket;
4033 }
4033#endif /* HAVE_GETADDRINFO_A */ 4034#endif /* HAVE_GETADDRINFO_A */
4035 }
4034 4036
4035 /* If we have a host, use getaddrinfo to resolve both host and service. 4037 /* If we have a host, use getaddrinfo to resolve both host and service.
4036 Otherwise, use getservbyname to lookup the service. */ 4038 Otherwise, use getservbyname to lookup the service. */