aboutsummaryrefslogtreecommitdiff
path: root/sysdeps
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/generic/ifreq.h7
-rw-r--r--sysdeps/gnu/ifaddrs.c10
-rw-r--r--sysdeps/mach/hurd/ifreq.h7
-rw-r--r--sysdeps/unix/grantpt.c3
-rw-r--r--sysdeps/unix/sysv/linux/ifreq.h6
5 files changed, 29 insertions, 4 deletions
diff --git a/sysdeps/generic/ifreq.h b/sysdeps/generic/ifreq.h
index f750065..0d975be 100644
--- a/sysdeps/generic/ifreq.h
+++ b/sysdeps/generic/ifreq.h
@@ -73,6 +73,13 @@ __ifreq (struct ifreq **ifreqs, int *num_ifs, int sockfd)
}
+static inline struct ifreq *
+__if_nextreq (struct ifreq *ifr)
+{
+ return ifr + 1;
+}
+
+
static inline void
__if_freereq (struct ifreq *ifreqs, int num_ifs)
{
diff --git a/sysdeps/gnu/ifaddrs.c b/sysdeps/gnu/ifaddrs.c
index e0a5b42..0c1ae5b 100644
--- a/sysdeps/gnu/ifaddrs.c
+++ b/sysdeps/gnu/ifaddrs.c
@@ -40,7 +40,7 @@ getifaddrs (struct ifaddrs **ifap)
Some different mechanism entirely must be used for IPv6. */
int fd = __socket (AF_INET, SOCK_DGRAM, 0);
struct ifreq *ifreqs;
- int nifs, i;
+ int nifs;
if (fd < 0)
return -1;
@@ -64,6 +64,8 @@ getifaddrs (struct ifaddrs **ifap)
struct sockaddr addr, netmask, broadaddr;
char name[IF_NAMESIZE];
} *storage;
+ struct ifreq *ifr;
+ int i;
storage = malloc (nifs * sizeof storage[0]);
if (storage == NULL)
@@ -74,10 +76,9 @@ getifaddrs (struct ifaddrs **ifap)
}
i = 0;
+ ifr = ifreqs;
do
{
- struct ifreq *const ifr = &ifreqs[i];
-
/* Fill in all pointers to the storage we've already allocated. */
storage[i].ia.ifa_next = &storage[i + 1].ia;
storage[i].ia.ifa_addr = &storage[i].addr;
@@ -97,6 +98,7 @@ getifaddrs (struct ifaddrs **ifap)
storage[i].ia.ifa_flags = ifr->ifr_flags;
ifr->ifr_addr = storage[i].addr;
+
if (__ioctl (fd, SIOCGIFNETMASK, ifr) < 0)
break;
storage[i].netmask = ifr->ifr_netmask;
@@ -121,6 +123,7 @@ getifaddrs (struct ifaddrs **ifap)
storage[i].ia.ifa_data = NULL; /* Nothing here for now. */
+ ifr = __if_nextreq (ifr);
} while (++i < nifs);
if (i < nifs) /* Broke out early on error. */
{
@@ -129,6 +132,7 @@ getifaddrs (struct ifaddrs **ifap)
__if_freereq (ifreqs, nifs);
return -1;
}
+
storage[i - 1].ia.ifa_next = NULL;
*ifap = &storage[0].ia;
diff --git a/sysdeps/mach/hurd/ifreq.h b/sysdeps/mach/hurd/ifreq.h
index f2143d8..77f0b9c 100644
--- a/sysdeps/mach/hurd/ifreq.h
+++ b/sysdeps/mach/hurd/ifreq.h
@@ -66,6 +66,13 @@ __ifreq (struct ifreq **ifreqs, int *num_ifs, int sockfd)
}
+static inline struct ifreq *
+__if_nextreq (struct ifreq *ifr)
+{
+ return ifr + 1;
+}
+
+
static inline void
__if_freereq (struct ifreq *ifreqs, int num_ifs)
{
diff --git a/sysdeps/unix/grantpt.c b/sysdeps/unix/grantpt.c
index 5f27ce9..98d601c 100644
--- a/sysdeps/unix/grantpt.c
+++ b/sysdeps/unix/grantpt.c
@@ -55,7 +55,8 @@ pts_name (int fd, char **pts, size_t buf_len)
/* ptsname_r returns with ENOTTY to indicate
a descriptor not referring to a pty master.
For this condition, grantpt must return EINVAL. */
- errno = EINVAL;
+ rv = EINVAL;
+ errno = rv; /* Not necessarily set by __ptsname_r. */
break;
}
diff --git a/sysdeps/unix/sysv/linux/ifreq.h b/sysdeps/unix/sysv/linux/ifreq.h
index 9d42664..f498e5c 100644
--- a/sysdeps/unix/sysv/linux/ifreq.h
+++ b/sysdeps/unix/sysv/linux/ifreq.h
@@ -105,6 +105,12 @@ __ifreq (struct ifreq **ifreqs, int *num_ifs, int sockfd)
*ifreqs = realloc (ifc.ifc_buf, nifs * sizeof (struct ifreq));
}
+static inline struct ifreq *
+__if_nextreq (struct ifreq *ifr)
+{
+ return ifr + 1;
+}
+
static inline void
__if_freereq (struct ifreq *ifreqs, int num_ifs)
{