diff mbox series

[v2] libmnl src: Use double quotes in #includes for non-system headers

Message ID 20180605062004.21685-1-duncan_roe@optusnet.com.au
State Not Applicable
Delegated to: Pablo Neira
Headers show
Series [v2] libmnl src: Use double quotes in #includes for non-system headers | expand

Commit Message

Duncan Roe June 5, 2018, 6:20 a.m. UTC
libmnl carries a private copy of a number of system headers. These were mostly
still being included with angle brackets as though they were system headers.
Tested configurations of gcc would pick up the private copy in these cases but
it has been reported that others do not.

By using double quotes, developers are reminded that the code is using a
private header which may differ from the system one, in fact
./include/linux/netlink.h differs considerably from /usr/include/linux/netlink.h
at kernel-headers-4.4.14 and even more so at kernel-headers-4.16.12.

This patch is not applied to sources in ./examples/, because it is expected
that these may be compiled out-of-tree, where angle brackets are appropriate.

Signed-off-by: Duncan Roe <duncan_roe@optusnet.com.au>
---
 include/libmnl/libmnl.h | 2 +-
 include/linux/netlink.h | 2 +-
 src/attr.c              | 2 +-
 src/callback.c          | 2 +-
 src/nlmsg.c             | 2 +-
 src/socket.c            | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

Comments

Jan Engelhardt June 5, 2018, 8:13 a.m. UTC | #1
On Tuesday 2018-06-05 08:20, Duncan Roe wrote:

>libmnl carries a private copy of a number of system headers. These were mostly
>still being included with angle brackets as though they were system headers.

These headers are willingly used in exactly that context: they are 
system headers, just at another location.

>Tested configurations of gcc would pick up the private copy in these cases but
>it has been reported that others do not.

Seeing that report would be helpful.

>By using double quotes, developers are reminded that the code is using a
>private header which may differ from the system one, in fact
>./include/linux/netlink.h differs considerably from /usr/include/linux/netlink.h
>at kernel-headers-4.4.14 and even more so at kernel-headers-4.16.12.

A new copy may be due.

--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Duncan Roe June 5, 2018, 5:03 p.m. UTC | #2
On Tue, Jun 05, 2018 at 10:13:18AM +0200, Jan Engelhardt wrote:
> On Tuesday 2018-06-05 08:20, Duncan Roe wrote:
>
> >libmnl carries a private copy of a number of system headers. These were mostly
> >still being included with angle brackets as though they were system headers.
>
> These headers are willingly used in exactly that context: they are
> system headers, just at another location.
>
> >Tested configurations of gcc would pick up the private copy in these cases but
> >it has been reported that others do not.
>
> Seeing that report would be helpful.

https://marc.info/?l=netfilter-devel&m=152739396729786&w=3
>
[...]
>
Additionally, the following message was copied to the list, but I can't find it
in the archive:

----------

Date: Sun, 27 May 2018 01:02:46 -0400
From: Edriss Mirzadeh <edriss@gmail.com>
To: Duncan Roe <duncan_roe@optusnet.com.au>
Cc: Netfilter Development <netfilter-devel@vger.kernel.org>
Subject: Re: ebtables commit
X-Mailer: iPhone Mail (15E302)

Hi there,

I'm actually cross compiling Tomato Firmware using 64 bit Debian 9.

The build instructions are good at the below URL, except for the repo name which
recently changed but hasn't yet been updated in the readme instructions.

https://bitbucket.org/kille72/freshtomato-arm/src

This could well be due to either the cross-compilation or the very old tool
chain, or ancient kernel 2.6 (with many back ports), but I do agree that local
headers should be double quoted, so your thought on patch rings true in terms
of portability.

----------

Cheers ... Duncan.
--
To unsubscribe from this list: send the line "unsubscribe netfilter-devel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox series

Patch

diff --git a/include/libmnl/libmnl.h b/include/libmnl/libmnl.h
index 0331da7..471b468 100644
--- a/include/libmnl/libmnl.h
+++ b/include/libmnl/libmnl.h
@@ -6,7 +6,7 @@ 
 #include <stdint.h>
 #include <unistd.h>
 #include <sys/socket.h> /* for sa_family_t */
-#include <linux/netlink.h>
+#include "linux/netlink.h"
 
 #ifdef __cplusplus
 extern "C" {
diff --git a/include/linux/netlink.h b/include/linux/netlink.h
index ced0e1a..80f3fad 100644
--- a/include/linux/netlink.h
+++ b/include/linux/netlink.h
@@ -1,7 +1,7 @@ 
 #ifndef __LINUX_NETLINK_H
 #define __LINUX_NETLINK_H
 
-#include <linux/socket.h> /* for __kernel_sa_family_t */
+#include "linux/socket.h" /* for __kernel_sa_family_t */
 #include <linux/types.h>
 
 #define NETLINK_ROUTE		0	/* Routing/device hook				*/
diff --git a/src/attr.c b/src/attr.c
index 0359ba9..ad83461 100644
--- a/src/attr.c
+++ b/src/attr.c
@@ -7,7 +7,7 @@ 
  * (at your option) any later version.
  */
 #include <limits.h>	/* for INT_MAX */
-#include <libmnl/libmnl.h>
+#include "libmnl/libmnl.h"
 #include <string.h>
 #include <errno.h>
 #include "internal.h"
diff --git a/src/callback.c b/src/callback.c
index 01181e6..b17edf6 100644
--- a/src/callback.c
+++ b/src/callback.c
@@ -8,7 +8,7 @@ 
  */
 
 #include <errno.h>
-#include <libmnl/libmnl.h>
+#include "libmnl/libmnl.h"
 #include "internal.h"
 
 static int mnl_cb_noop(const struct nlmsghdr *nlh, void *data)
diff --git a/src/nlmsg.c b/src/nlmsg.c
index f9448a5..673259f 100644
--- a/src/nlmsg.c
+++ b/src/nlmsg.c
@@ -12,7 +12,7 @@ 
 #include <ctype.h>
 #include <errno.h>
 #include <string.h>
-#include <libmnl/libmnl.h>
+#include "libmnl/libmnl.h"
 #include "internal.h"
 
 /**
diff --git a/src/socket.c b/src/socket.c
index 31d6fbe..fea234a 100644
--- a/src/socket.c
+++ b/src/socket.c
@@ -7,7 +7,7 @@ 
  * (at your option) any later version.
  */
 
-#include <libmnl/libmnl.h>
+#include "libmnl/libmnl.h"
 #include <sys/types.h>
 #include <sys/socket.h>
 #include <stdlib.h>