[09/13] Installed-header hygiene (BZ#20366): struct ifreq.

Message ID 20160830011645.25769-10-zackw@panix.com
State Superseded
Headers

Commit Message

Zack Weinberg Aug. 30, 2016, 1:16 a.m. UTC
  It's unclear to me whether this is the right change, or whether
instead net/if.h's definition of struct ifreq should be unconditional.
This has the smaller set of side effects.

net/if_ppp.h declares itself to be imported from an external source,
but that last happened in 1996 so I think it's probably a dead letter.

The Linux and Hurd versions of this file are identical, perhaps
they should be un-sysdep-ified.

	* sysdeps/mach/hurd/net/if_ppp.h
	* sysdeps/unix/sysv/linux/net/if_ppp.h:
        Only define struct ifpppstatsreq and struct ifpppcstatsreq
        if __USE_MISC is defined.
---
 sysdeps/mach/hurd/net/if_ppp.h       | 3 +++
 sysdeps/unix/sysv/linux/net/if_ppp.h | 3 +++
 2 files changed, 6 insertions(+)
  

Comments

Carlos O'Donell Sept. 21, 2016, 7:15 p.m. UTC | #1
On 08/29/2016 09:16 PM, Zack Weinberg wrote:
> It's unclear to me whether this is the right change, or whether
> instead net/if.h's definition of struct ifreq should be unconditional.
> This has the smaller set of side effects.
> 
> net/if_ppp.h declares itself to be imported from an external source,
> but that last happened in 1996 so I think it's probably a dead letter.
> 
> The Linux and Hurd versions of this file are identical, perhaps
> they should be un-sysdep-ified.
> 
> 	* sysdeps/mach/hurd/net/if_ppp.h
> 	* sysdeps/unix/sysv/linux/net/if_ppp.h:
>         Only define struct ifpppstatsreq and struct ifpppcstatsreq
>         if __USE_MISC is defined.

LGTM.

Please be aware that the Linux kernel may have definitions for some
of these structures (it doesn't for this one, I checked) which conflict.
The way we fix this is via coordinated header inclusion guards, but
the kernel is ahead of us and not coordinating on libc-alpha. If we 
change the include guards, there might be similar changes required in
linux/include/uapi/linux/libc-compat.h.
  

Patch

diff --git a/sysdeps/mach/hurd/net/if_ppp.h b/sysdeps/mach/hurd/net/if_ppp.h
index b210d7f..8ee620b 100644
--- a/sysdeps/mach/hurd/net/if_ppp.h
+++ b/sysdeps/mach/hurd/net/if_ppp.h
@@ -119,6 +119,8 @@  struct ppp_option_data {
 	int	  transmit;
 };
 
+/* 'struct ifreq' is only available from net/if.h under __USE_MISC.  */
+#ifdef __USE_MISC
 struct ifpppstatsreq {
   struct ifreq	   b;
   struct ppp_stats stats;			/* statistic information */
@@ -131,6 +133,7 @@  struct ifpppcstatsreq {
 
 #define ifr__name       b.ifr_ifrn.ifrn_name
 #define stats_ptr       b.ifr_ifru.ifru_data
+#endif
 
 /*
  * Ioctl definitions.
diff --git a/sysdeps/unix/sysv/linux/net/if_ppp.h b/sysdeps/unix/sysv/linux/net/if_ppp.h
index 9994982..31a20766 100644
--- a/sysdeps/unix/sysv/linux/net/if_ppp.h
+++ b/sysdeps/unix/sysv/linux/net/if_ppp.h
@@ -118,6 +118,8 @@  struct ppp_option_data {
 	int	 transmit;
 };
 
+/* 'struct ifreq' is only available from net/if.h under __USE_MISC.  */
+#ifdef __USE_MISC
 struct ifpppstatsreq {
   struct ifreq	   b;
   struct ppp_stats stats;			/* statistic information */
@@ -130,6 +132,7 @@  struct ifpppcstatsreq {
 
 #define ifr__name       b.ifr_ifrn.ifrn_name
 #define stats_ptr       b.ifr_ifru.ifru_data
+#endif
 
 /*
  * Ioctl definitions.