aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/process.c')
-rw-r--r--src/process.c36
1 files changed, 17 insertions, 19 deletions
diff --git a/src/process.c b/src/process.c
index 9f3bb0e5803..08da53b4a40 100644
--- a/src/process.c
+++ b/src/process.c
@@ -3581,33 +3581,31 @@ format; see the description of ADDRESS in `make-network-process'. */)
3581 if (s < 0) 3581 if (s < 0)
3582 return Qnil; 3582 return Qnil;
3583 3583
3584 again: 3584 do
3585
3586 buf = xpalloc (buf, &buf_size, sizeof *ifreq, INT_MAX, 1);
3587 ifconf.ifc_buf = buf;
3588 ifconf.ifc_len = buf_size;
3589 if (ioctl (s, SIOCGIFCONF, &ifconf))
3590 { 3585 {
3591 close (s); 3586 buf = xpalloc (buf, &buf_size, 1, INT_MAX, 1);
3592 xfree (buf); 3587 ifconf.ifc_buf = buf;
3593 return Qnil; 3588 ifconf.ifc_len = buf_size;
3589 if (ioctl (s, SIOCGIFCONF, &ifconf))
3590 {
3591 close (s);
3592 xfree (buf);
3593 return Qnil;
3594 }
3594 } 3595 }
3595 3596 while (ifconf.ifc_len == buf_size);
3596 if (ifconf.ifc_len == buf_size)
3597 goto again;
3598 3597
3599 close (s); 3598 close (s);
3600 3599
3601 res = Qnil; 3600 res = Qnil;
3602 for (ifreq = ifconf.ifc_req; 3601 ifreq = ifconf.ifc_req;
3603 (char *) ifreq < (char *) (ifconf.ifc_req) + ifconf.ifc_len; 3602 while ((char *) ifreq < (char *) ifconf.ifc_req + ifconf.ifc_len)
3604 )
3605 { 3603 {
3606 struct ifreq *ifq = ifreq; 3604 struct ifreq *ifq = ifreq;
3607#ifdef HAVE_STRUCT_IFREQ_IFR_ADDR_SA_LEN 3605#ifdef HAVE_STRUCT_IFREQ_IFR_ADDR_SA_LEN
3608#define SIZEOF_IFREQ(sif) \ 3606#define SIZEOF_IFREQ(sif) \
3609 ((sif)->ifr_addr.sa_len < sizeof(struct sockaddr) ? \ 3607 ((sif)->ifr_addr.sa_len < sizeof (struct sockaddr) \
3610 sizeof((*sif)) : sizeof ((sif)->ifr_name) + sif->ifr_addr.sa_len) 3608 ? sizeof (*(sif)) : sizeof ((sif)->ifr_name) + (sif)->ifr_addr.sa_len)
3611 3609
3612 int len = SIZEOF_IFREQ (ifq); 3610 int len = SIZEOF_IFREQ (ifq);
3613#else 3611#else
@@ -3615,7 +3613,7 @@ format; see the description of ADDRESS in `make-network-process'. */)
3615#endif 3613#endif
3616 char namebuf[sizeof (ifq->ifr_name) + 1]; 3614 char namebuf[sizeof (ifq->ifr_name) + 1];
3617 i += len; 3615 i += len;
3618 ifreq = (struct ifreq*) ((char*) ifreq + len); 3616 ifreq = (struct ifreq *) ((char *) ifreq + len);
3619 3617
3620 if (ifq->ifr_addr.sa_family != AF_INET) 3618 if (ifq->ifr_addr.sa_family != AF_INET)
3621 continue; 3619 continue;