aboutsummaryrefslogtreecommitdiffstats
path: root/src/process.c
diff options
context:
space:
mode:
authorPaul Eggert2011-08-18 10:01:52 -0700
committerPaul Eggert2011-08-18 10:01:52 -0700
commit76667214e7bdc7f6196de2bb6d7e14ef879a2694 (patch)
tree58ca2d3448d502ff4ac2e46aefc8b90582c4d1ab /src/process.c
parent2fab8395070ff77b836cb8ca9b84c261c4387a9a (diff)
parent92b714445aac9be4227684f9c90cd61c3a0f02d5 (diff)
downloademacs-76667214e7bdc7f6196de2bb6d7e14ef879a2694.tar.gz
emacs-76667214e7bdc7f6196de2bb6d7e14ef879a2694.zip
Merge from trunk.
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;