Hi,
I went through the build_test.git's testhelpers/kernel_mappings.iwyu and cleaned that up a little bit. This requires that we have to adjust the batman-adv sources slighty.
I have also found a build problem when you try to build B.A.T.M.A.N. V against Linux < 3.7 and fixed it in the same patchset.
Kind regards, Sven
Sven Eckelmann (6): batman-adv: include gfp.h for GFP_* defines batman-adv: include build_bug.h for BUILD_BUG_ON define batman-adv: Include net.h for net_ratelimited_function batman-adv: include kobject.h for kobject_* functions batman-adv: Remove unused sched.h include batman-adv: compat: Map to linux/nl80211.h for Linux < 3.7
compat-include/linux/build_bug.h | 34 ++++++++++++++++++++++++++++++++++ compat-include/uapi/linux/nl80211.h | 4 ++++ net/batman-adv/bat_iv_ogm.c | 2 +- net/batman-adv/bat_v_elp.c | 2 +- net/batman-adv/bat_v_ogm.c | 2 +- net/batman-adv/bridge_loop_avoidance.c | 2 +- net/batman-adv/debugfs.c | 1 - net/batman-adv/distributed-arp-table.c | 2 +- net/batman-adv/fragmentation.c | 2 +- net/batman-adv/gateway_client.c | 2 +- net/batman-adv/hard-interface.c | 2 +- net/batman-adv/hash.c | 2 +- net/batman-adv/icmp_socket.c | 1 + net/batman-adv/log.c | 1 + net/batman-adv/main.c | 4 ++-- net/batman-adv/multicast.c | 2 +- net/batman-adv/netlink.c | 2 +- net/batman-adv/network-coding.c | 3 ++- net/batman-adv/originator.c | 2 +- net/batman-adv/send.c | 2 +- net/batman-adv/soft-interface.c | 2 +- net/batman-adv/sysfs.c | 3 ++- net/batman-adv/tp_meter.c | 4 ++-- net/batman-adv/translation-table.c | 5 +++-- net/batman-adv/tvlv.c | 2 +- 25 files changed, 66 insertions(+), 24 deletions(-) create mode 100644 compat-include/linux/build_bug.h
The linux/gfp.h provides the GFP_ATOMIC and GFP_KERNEL define. It should therefore be included instead of linux/fs.h.
Signed-off-by: Sven Eckelmann sven@narfation.org --- net/batman-adv/bat_iv_ogm.c | 2 +- net/batman-adv/bat_v_elp.c | 2 +- net/batman-adv/bat_v_ogm.c | 2 +- net/batman-adv/bridge_loop_avoidance.c | 2 +- net/batman-adv/distributed-arp-table.c | 2 +- net/batman-adv/fragmentation.c | 2 +- net/batman-adv/gateway_client.c | 2 +- net/batman-adv/hard-interface.c | 2 +- net/batman-adv/hash.c | 2 +- net/batman-adv/icmp_socket.c | 1 + net/batman-adv/log.c | 1 + net/batman-adv/main.c | 2 +- net/batman-adv/multicast.c | 2 +- net/batman-adv/netlink.c | 2 +- net/batman-adv/network-coding.c | 2 +- net/batman-adv/originator.c | 2 +- net/batman-adv/send.c | 2 +- net/batman-adv/soft-interface.c | 2 +- net/batman-adv/sysfs.c | 2 +- net/batman-adv/tp_meter.c | 2 +- net/batman-adv/translation-table.c | 2 +- net/batman-adv/tvlv.c | 2 +- 22 files changed, 22 insertions(+), 20 deletions(-)
diff --git a/net/batman-adv/bat_iv_ogm.c b/net/batman-adv/bat_iv_ogm.c index 4de912c8..250cb4fb 100644 --- a/net/batman-adv/bat_iv_ogm.c +++ b/net/batman-adv/bat_iv_ogm.c @@ -29,7 +29,7 @@ #include <linux/cache.h> #include <linux/errno.h> #include <linux/etherdevice.h> -#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/if_ether.h> #include <linux/init.h> #include <linux/jiffies.h> diff --git a/net/batman-adv/bat_v_elp.c b/net/batman-adv/bat_v_elp.c index 1aa175a4..39fbed58 100644 --- a/net/batman-adv/bat_v_elp.c +++ b/net/batman-adv/bat_v_elp.c @@ -27,7 +27,7 @@ #include <linux/errno.h> #include <linux/etherdevice.h> #include <linux/ethtool.h> -#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/if_ether.h> #include <linux/jiffies.h> #include <linux/kernel.h> diff --git a/net/batman-adv/bat_v_ogm.c b/net/batman-adv/bat_v_ogm.c index 0ce2d95a..3cc5cd2f 100644 --- a/net/batman-adv/bat_v_ogm.c +++ b/net/batman-adv/bat_v_ogm.c @@ -25,7 +25,7 @@ #include <linux/byteorder/generic.h> #include <linux/errno.h> #include <linux/etherdevice.h> -#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/if_ether.h> #include <linux/jiffies.h> #include <linux/kernel.h> diff --git a/net/batman-adv/bridge_loop_avoidance.c b/net/batman-adv/bridge_loop_avoidance.c index f5b917b6..2f12a556 100644 --- a/net/batman-adv/bridge_loop_avoidance.c +++ b/net/batman-adv/bridge_loop_avoidance.c @@ -27,7 +27,7 @@ #include <linux/crc16.h> #include <linux/errno.h> #include <linux/etherdevice.h> -#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/if_arp.h> #include <linux/if_ether.h> #include <linux/if_vlan.h> diff --git a/net/batman-adv/distributed-arp-table.c b/net/batman-adv/distributed-arp-table.c index e708fda4..1035c53a 100644 --- a/net/batman-adv/distributed-arp-table.c +++ b/net/batman-adv/distributed-arp-table.c @@ -26,7 +26,7 @@ #include <linux/byteorder/generic.h> #include <linux/errno.h> #include <linux/etherdevice.h> -#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/if_arp.h> #include <linux/if_ether.h> #include <linux/if_vlan.h> diff --git a/net/batman-adv/fragmentation.c b/net/batman-adv/fragmentation.c index c49ca050..1c202448 100644 --- a/net/batman-adv/fragmentation.c +++ b/net/batman-adv/fragmentation.c @@ -25,7 +25,7 @@ #include <linux/byteorder/generic.h> #include <linux/errno.h> #include <linux/etherdevice.h> -#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/if_ether.h> #include <linux/jiffies.h> #include <linux/kernel.h> diff --git a/net/batman-adv/gateway_client.c b/net/batman-adv/gateway_client.c index b962430a..cffa9e7f 100644 --- a/net/batman-adv/gateway_client.c +++ b/net/batman-adv/gateway_client.c @@ -25,7 +25,7 @@ #include <linux/byteorder/generic.h> #include <linux/errno.h> #include <linux/etherdevice.h> -#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/if_ether.h> #include <linux/if_vlan.h> #include <linux/in.h> diff --git a/net/batman-adv/hard-interface.c b/net/batman-adv/hard-interface.c index 464c98f2..7f459679 100644 --- a/net/batman-adv/hard-interface.c +++ b/net/batman-adv/hard-interface.c @@ -25,7 +25,7 @@ #include <linux/bug.h> #include <linux/byteorder/generic.h> #include <linux/errno.h> -#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/if.h> #include <linux/if_arp.h> #include <linux/if_ether.h> diff --git a/net/batman-adv/hash.c b/net/batman-adv/hash.c index 33fd8fae..0569ee47 100644 --- a/net/batman-adv/hash.c +++ b/net/batman-adv/hash.c @@ -21,7 +21,7 @@ #include "hash.h" #include "main.h"
-#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/lockdep.h> #include <linux/slab.h>
diff --git a/net/batman-adv/icmp_socket.c b/net/batman-adv/icmp_socket.c index ca51c488..f1a67eaa 100644 --- a/net/batman-adv/icmp_socket.c +++ b/net/batman-adv/icmp_socket.c @@ -29,6 +29,7 @@ #include <linux/export.h> #include <linux/fcntl.h> #include <linux/fs.h> +#include <linux/gfp.h> #include <linux/if_ether.h> #include <linux/kernel.h> #include <linux/list.h> diff --git a/net/batman-adv/log.c b/net/batman-adv/log.c index 78e4dddb..59a1eb13 100644 --- a/net/batman-adv/log.c +++ b/net/batman-adv/log.c @@ -27,6 +27,7 @@ #include <linux/export.h> #include <linux/fcntl.h> #include <linux/fs.h> +#include <linux/gfp.h> #include <linux/jiffies.h> #include <linux/kernel.h> #include <linux/module.h> diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index 6b3db9b4..45f0f4ff 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -25,8 +25,8 @@ #include <linux/byteorder/generic.h> #include <linux/crc32c.h> #include <linux/errno.h> -#include <linux/fs.h> #include <linux/genetlink.h> +#include <linux/gfp.h> #include <linux/if_ether.h> #include <linux/if_vlan.h> #include <linux/init.h> diff --git a/net/batman-adv/multicast.c b/net/batman-adv/multicast.c index 3cef5a76..30c442e4 100644 --- a/net/batman-adv/multicast.c +++ b/net/batman-adv/multicast.c @@ -27,7 +27,7 @@ #include <linux/byteorder/generic.h> #include <linux/errno.h> #include <linux/etherdevice.h> -#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/icmpv6.h> #include <linux/if_bridge.h> #include <linux/if_ether.h> diff --git a/net/batman-adv/netlink.c b/net/batman-adv/netlink.c index d70d0e2d..a06a2cd4 100644 --- a/net/batman-adv/netlink.c +++ b/net/batman-adv/netlink.c @@ -26,8 +26,8 @@ #include <linux/cache.h> #include <linux/errno.h> #include <linux/export.h> -#include <linux/fs.h> #include <linux/genetlink.h> +#include <linux/gfp.h> #include <linux/if_ether.h> #include <linux/init.h> #include <linux/kernel.h> diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index c3d65af3..f614d74f 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c @@ -28,7 +28,7 @@ #include <linux/debugfs.h> #include <linux/errno.h> #include <linux/etherdevice.h> -#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/if_ether.h> #include <linux/if_packet.h> #include <linux/init.h> diff --git a/net/batman-adv/originator.c b/net/batman-adv/originator.c index f365de37..4018ecba 100644 --- a/net/batman-adv/originator.c +++ b/net/batman-adv/originator.c @@ -24,7 +24,7 @@ #include <linux/atomic.h> #include <linux/errno.h> #include <linux/etherdevice.h> -#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/jiffies.h> #include <linux/kernel.h> #include <linux/kref.h> diff --git a/net/batman-adv/send.c b/net/batman-adv/send.c index a9c505b7..68b0bb1a 100644 --- a/net/batman-adv/send.c +++ b/net/batman-adv/send.c @@ -26,7 +26,7 @@ #include <linux/byteorder/generic.h> #include <linux/errno.h> #include <linux/etherdevice.h> -#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/if.h> #include <linux/if_ether.h> #include <linux/jiffies.h> diff --git a/net/batman-adv/soft-interface.c b/net/batman-adv/soft-interface.c index 178d998b..aea576f3 100644 --- a/net/batman-adv/soft-interface.c +++ b/net/batman-adv/soft-interface.c @@ -29,7 +29,7 @@ #include <linux/errno.h> #include <linux/etherdevice.h> #include <linux/ethtool.h> -#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/if_ether.h> #include <linux/if_vlan.h> #include <linux/jiffies.h> diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c index e54a662b..5c29e38a 100644 --- a/net/batman-adv/sysfs.c +++ b/net/batman-adv/sysfs.c @@ -25,7 +25,7 @@ #include <linux/compiler.h> #include <linux/device.h> #include <linux/errno.h> -#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/if.h> #include <linux/if_vlan.h> #include <linux/kernel.h> diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c index f890319b..52e667ec 100644 --- a/net/batman-adv/tp_meter.c +++ b/net/batman-adv/tp_meter.c @@ -28,7 +28,7 @@ #include <linux/compiler.h> #include <linux/err.h> #include <linux/etherdevice.h> -#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/if_ether.h> #include <linux/init.h> #include <linux/jiffies.h> diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index efa4ef02..66092c6b 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -30,7 +30,7 @@ #include <linux/crc32c.h> #include <linux/errno.h> #include <linux/etherdevice.h> -#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/if_ether.h> #include <linux/init.h> #include <linux/jhash.h> diff --git a/net/batman-adv/tvlv.c b/net/batman-adv/tvlv.c index fcaa7bd4..308a0f31 100644 --- a/net/batman-adv/tvlv.c +++ b/net/batman-adv/tvlv.c @@ -22,7 +22,7 @@
#include <linux/byteorder/generic.h> #include <linux/etherdevice.h> -#include <linux/fs.h> +#include <linux/gfp.h> #include <linux/if_ether.h> #include <linux/kernel.h> #include <linux/kref.h>
commit bc6245e5efd7 ("bug: split BUILD_BUG stuff out into <linux/build_bug.h>") added a new header for BUILD_BUG_ON. It should therefore be included instead of linux/bug.h
Signed-off-by: Sven Eckelmann sven@narfation.org --- compat-include/linux/build_bug.h | 34 ++++++++++++++++++++++++++++++++++ net/batman-adv/main.c | 2 +- net/batman-adv/tp_meter.c | 2 +- net/batman-adv/translation-table.c | 2 +- 4 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 compat-include/linux/build_bug.h
diff --git a/compat-include/linux/build_bug.h b/compat-include/linux/build_bug.h new file mode 100644 index 00000000..d1ebfa71 --- /dev/null +++ b/compat-include/linux/build_bug.h @@ -0,0 +1,34 @@ +/* SPDX-License-Identifier: GPL-2.0 */ +/* Copyright (C) 2007-2017 B.A.T.M.A.N. contributors: + * + * Marek Lindner, Simon Wunderlich + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of version 2 of the GNU General Public + * License as published by the Free Software Foundation. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, see http://www.gnu.org/licenses/. + * + * License-Filename: LICENSES/preferred/GPL-2.0 + * + * This file contains macros for maintaining compatibility with older versions + * of the Linux kernel. + */ + +#ifndef _NET_BATMAN_ADV_COMPAT_LINUX_BUILD_BUG_H_ +#define _NET_BATMAN_ADV_COMPAT_LINUX_BUILD_BUG_H_ + +#include <linux/version.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 13, 0) +#include_next <linux/build_bug.h> +#else +#include <linux/bug.h> +#endif + +#endif /* _NET_BATMAN_ADV_COMPAT_LINUX_BUILD_BUG_H_ */ diff --git a/net/batman-adv/main.c b/net/batman-adv/main.c index 45f0f4ff..107b50e5 100644 --- a/net/batman-adv/main.c +++ b/net/batman-adv/main.c @@ -21,7 +21,7 @@ #include "main.h"
#include <linux/atomic.h> -#include <linux/bug.h> +#include <linux/build_bug.h> #include <linux/byteorder/generic.h> #include <linux/crc32c.h> #include <linux/errno.h> diff --git a/net/batman-adv/tp_meter.c b/net/batman-adv/tp_meter.c index 52e667ec..6b044717 100644 --- a/net/batman-adv/tp_meter.c +++ b/net/batman-adv/tp_meter.c @@ -22,7 +22,7 @@ #include "main.h"
#include <linux/atomic.h> -#include <linux/bug.h> +#include <linux/build_bug.h> #include <linux/byteorder/generic.h> #include <linux/cache.h> #include <linux/compiler.h> diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index 66092c6b..db7a67ee 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -23,7 +23,7 @@
#include <linux/atomic.h> #include <linux/bitops.h> -#include <linux/bug.h> +#include <linux/build_bug.h> #include <linux/byteorder/generic.h> #include <linux/cache.h> #include <linux/compiler.h>
The linux/net.h provides the net_ratelimited_function. It should therefore be included directly before it is used.
Signed-off-by: Sven Eckelmann sven@narfation.org --- net/batman-adv/network-coding.c | 1 + net/batman-adv/translation-table.c | 1 + 2 files changed, 2 insertions(+)
diff --git a/net/batman-adv/network-coding.c b/net/batman-adv/network-coding.c index f614d74f..64f14f66 100644 --- a/net/batman-adv/network-coding.c +++ b/net/batman-adv/network-coding.c @@ -38,6 +38,7 @@ #include <linux/kref.h> #include <linux/list.h> #include <linux/lockdep.h> +#include <linux/net.h> #include <linux/netdevice.h> #include <linux/printk.h> #include <linux/random.h> diff --git a/net/batman-adv/translation-table.c b/net/batman-adv/translation-table.c index db7a67ee..ce90bfd7 100644 --- a/net/batman-adv/translation-table.c +++ b/net/batman-adv/translation-table.c @@ -39,6 +39,7 @@ #include <linux/kref.h> #include <linux/list.h> #include <linux/lockdep.h> +#include <linux/net.h> #include <linux/netdevice.h> #include <linux/netlink.h> #include <linux/rculist.h>
The linux/kobject.h provides the kobject_* function declarations and should therefore be included directly before they are used.
Signed-off-by: Sven Eckelmann sven@narfation.org --- net/batman-adv/sysfs.c | 1 + 1 file changed, 1 insertion(+)
diff --git a/net/batman-adv/sysfs.c b/net/batman-adv/sysfs.c index 5c29e38a..9eed0664 100644 --- a/net/batman-adv/sysfs.c +++ b/net/batman-adv/sysfs.c @@ -29,6 +29,7 @@ #include <linux/if.h> #include <linux/if_vlan.h> #include <linux/kernel.h> +#include <linux/kobject.h> #include <linux/kref.h> #include <linux/netdevice.h> #include <linux/printk.h>
The linux/wait.h include was removed with commit 421d988b2c08 ("batman-adv: Consolidate logging related functions"). The previously required (but not unused) linux/sched.h include can also be dropped now.
Signed-off-by: Sven Eckelmann sven@narfation.org --- net/batman-adv/debugfs.c | 1 - 1 file changed, 1 deletion(-)
diff --git a/net/batman-adv/debugfs.c b/net/batman-adv/debugfs.c index e5f76c76..96df3959 100644 --- a/net/batman-adv/debugfs.c +++ b/net/batman-adv/debugfs.c @@ -28,7 +28,6 @@ #include <linux/fs.h> #include <linux/netdevice.h> #include <linux/printk.h> -#include <linux/sched.h> /* for linux/wait.h */ #include <linux/seq_file.h> #include <linux/stat.h> #include <linux/stddef.h>
The uapi header of linux/nl80211.h was introduced with 3.7. Older version have to rely on the linux/nl80211.h header.
Signed-off-by: Sven Eckelmann sven@narfation.org --- compat-include/uapi/linux/nl80211.h | 4 ++++ 1 file changed, 4 insertions(+)
diff --git a/compat-include/uapi/linux/nl80211.h b/compat-include/uapi/linux/nl80211.h index 9b18178e..ead4c6dd 100644 --- a/compat-include/uapi/linux/nl80211.h +++ b/compat-include/uapi/linux/nl80211.h @@ -25,7 +25,11 @@ #define _NET_BATMAN_ADV_COMPAT_UAPI_LINUX_NL80211_H_
#include <linux/version.h> +#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 7, 0) #include_next <uapi/linux/nl80211.h> +#else +#include <linux/nl80211.h> +#endif
#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 0, 0)
On Sonntag, 19. November 2017 17:12:01 CET Sven Eckelmann wrote:
Hi,
I went through the build_test.git's testhelpers/kernel_mappings.iwyu and cleaned that up a little bit. This requires that we have to adjust the batman-adv sources slighty.
I have also found a build problem when you try to build B.A.T.M.A.N. V against Linux < 3.7 and fixed it in the same patchset.
Applied in 8de104e049ea..cfcb3be43ef5
Kind regards, Sven
b.a.t.m.a.n@lists.open-mesh.org