Skip to contentSkip to conversation

vlan:remove duplicate <linux/if_vlan.h>

PATCH In review Weiping Pan 2 participants 5 messages Jul 28, 2011

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

cover vlan:remove duplicate <linux/if_vlan.h>

As net/8021q/vlan.h already includes <linux/if_vlan.h>, so other files that includes vlan.h need not to include it.

But before we remove it from net/8021q/vlan_gvrp.c, we should first add add netdevice.h into stp.h.

[PATCH net-next 1/2]:add netdevice.h into stp.h [PATCH net-next 2/2]:remove duplicate <linux/if_vlan.h>

Weiping Pan (2):
stp:add netdevice.h into stp.h
vlan:remove duplicate <linux/if_vlan.h>

 include/net/stp.h        |    2 ++
 net/8021q/vlan.c         |    1 -
 net/8021q/vlan_core.c    |    1 -
 net/8021q/vlan_dev.c     |    1 -
 net/8021q/vlan_gvrp.c    |    1 -
 net/8021q/vlan_netlink.c |    1 -
 net/8021q/vlanproc.c     |    1 -
 7 files changed, 2 insertions(+), 6 deletions(-)
Signature · 1 line
1.7.4.4
#1 lore raw

PATCH 1/2 stp:add netdevice.h into stp.h

We don't meet a compile error becasue <linux/netdevice.h> is added by ohter header files, luckily.

I find this problem when I want to remove the duplicate <linux/if_vlan.h>. As net/8021q/vlan.h already includes it, so other files that includes vlan.h need not to include it.

But when I remove <linux/if_vlan.h> from net/8021q/vlan_gvrp.c, I met a compile error.
[pwp@localhost net-next]$ make O=../net-next_build/ M=net/8021q

  CC      net/8021q/vlan_core.o
  LD      net/8021q/built-in.o
  CC [M]  net/8021q/vlan.o
  CC [M]  net/8021q/vlan_dev.o
  CC [M]  net/8021q/vlan_netlink.o
  CC [M]  net/8021q/vlan_gvrp.o
In file included from /home/pwp/mysvn/linux/net-next/include/net/garp.h:4:0,
                 from /home/pwp/mysvn/linux/net-next/net/8021q/vlan_gvrp.c:12:

/home/pwp/mysvn/linux/net-next/include/net/stp.h:5:30: error: ‘ETH_ALEN’ undeclared here (not in a function) /home/pwp/mysvn/linux/net-next/include/net/stp.h:7:18: warning: ‘struct net_device’ declared inside parameter list /home/pwp/mysvn/linux/net-next/include/net/stp.h:7:18: warning: its scope is only this definition or declaration, which is probably not what you want /home/pwp/mysvn/linux/net-next/include/net/stp.h:7:18: warning: ‘struct sk_buff’ declared inside parameter list
In file included from /home/pwp/mysvn/linux/net-next/net/8021q/vlan_gvrp.c:12:0:
/home/pwp/mysvn/linux/net-next/include/net/garp.h:36:50: warning: ‘struct sk_buff’ declared inside parameter list /home/pwp/mysvn/linux/net-next/include/net/garp.h: In function ‘garp_cb’:
/home/pwp/mysvn/linux/net-next/include/net/garp.h:38:2: error: implicit declaration of function ‘BUILD_BUG_ON’ /home/pwp/mysvn/linux/net-next/include/net/garp.h:39:8: error: implicit declaration of function ‘FIELD_SIZEOF’ /home/pwp/mysvn/linux/net-next/include/net/garp.h:39:21: error: expected expression before ‘struct’ /home/pwp/mysvn/linux/net-next/include/net/garp.h:40:34: error: dereferencing pointer to incomplete type /home/pwp/mysvn/linux/net-next/include/net/garp.h: At top level:
/home/pwp/mysvn/linux/net-next/include/net/garp.h:79:19: error: field ‘node’ has incomplete type /home/pwp/mysvn/linux/net-next/include/net/garp.h:101:20: error: field ‘join_timer’ has incomplete type /home/pwp/mysvn/linux/net-next/include/net/garp.h:103:2: error: expected specifier-qualifier-list before ‘spinlock_t’ /home/pwp/mysvn/linux/net-next/include/net/garp.h:112:20: error: field ‘rcu’ has incomplete type
make[2]: *** [net/8021q/vlan_gvrp.o] Error 1
make[1]: *** [_module_net/8021q] Error 2
make: *** [sub-make] Error 2

---
 include/net/stp.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
include/net/stp.h +2 -0
index ad447f1..13318f3 100644
@@ -1,6 +1,8 @@
 #ifndef _NET_STP_H
 #define _NET_STP_H
 
+#include <linux/netdevice.h>
+
 struct stp_proto {
 	unsigned char	group_address[ETH_ALEN];
 	void		(*rcv)(const struct stp_proto *, struct sk_buff *,
Signature · 1 line
1.7.4.4
#2 lore raw

PATCH 2/2 vlan:remove duplicate <linux/if_vlan.h>

In reply to Weiping Pan

As net/8021q/vlan.h already includes <linux/if_vlan.h>, so other files that includes vlan.h need not to include it.

---
 net/8021q/vlan.c         |    1 -
 net/8021q/vlan_core.c    |    1 -
 net/8021q/vlan_dev.c     |    1 -
 net/8021q/vlan_gvrp.c    |    1 -
 net/8021q/vlan_netlink.c |    1 -
 net/8021q/vlanproc.c     |    1 -
 6 files changed, 0 insertions(+), 6 deletions(-)
net/8021q/vlan.c +0 -1
index 8970ba1..60030b6 100644
@@ -36,7 +36,6 @@
 #include <net/netns/generic.h>
 #include <asm/uaccess.h>
 
-#include <linux/if_vlan.h>
 #include "vlan.h"
 #include "vlanproc.h"
 
net/8021q/vlan_core.c +0 -1
index 5f27f8e..66190dc 100644
@@ -1,6 +1,5 @@
 #include <linux/skbuff.h>
 #include <linux/netdevice.h>
-#include <linux/if_vlan.h>
 #include <linux/netpoll.h>
 #include "vlan.h"
 
net/8021q/vlan_dev.c +0 -1
index 934e221..1793ffb 100644
@@ -32,7 +32,6 @@
 
 #include "vlan.h"
 #include "vlanproc.h"
-#include <linux/if_vlan.h>
 
 /*
  *	Rebuild the Ethernet MAC header. This is called after an ARP
net/8021q/vlan_gvrp.c +0 -1
index 061cece..6153c72 100644
@@ -8,7 +8,6 @@
  *	version 2 as published by the Free Software Foundation.
  */
 #include <linux/types.h>
-#include <linux/if_vlan.h>
 #include <net/garp.h>
 #include "vlan.h"
 
net/8021q/vlan_netlink.c +0 -1
index be9a5c1..687ee4f 100644
@@ -10,7 +10,6 @@
 
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
-#include <linux/if_vlan.h>
 #include <net/net_namespace.h>
 #include <net/netlink.h>
 #include <net/rtnetlink.h>
net/8021q/vlanproc.c +0 -1
index d34b6da..47c99c8 100644
@@ -27,7 +27,6 @@
 #include <linux/seq_file.h>
 #include <linux/fs.h>
 #include <linux/netdevice.h>
-#include <linux/if_vlan.h>
 #include <net/net_namespace.h>
 #include <net/netns/generic.h>
 #include "vlanproc.h"
Signature · 1 line
1.7.4.4
maintainer
#3 lore raw
In reply to Weiping Pan

From: Weiping Pan <[email protected]>
Date: Thu, 28 Jul 2011 16:37:38 +0800

Quoted 2 lines

As net/8021q/vlan.h already includes <linux/if_vlan.h>, so other files that includes vlan.h need not to include it.

Please do not do this.

If someone wants to remove this implicit header dependency, that someone will need to add all of the includes back.

It is better for people to include all the headers they need, rather than rely upon such indirect inclusions.

I am not applying these patches.

author
#4 lore raw
Quoted 5 lines · David Miller

From: Weiping Pan<[email protected]>
Date: Thu, 28 Jul 2011 16:37:38 +0800

Quoted 2 lines

As net/8021q/vlan.h already includes<linux/if_vlan.h>, so other files that includes vlan.h need not to include it.

Quoted 7 lines

Please do not do this.

If someone wants to remove this implicit header dependency, that someone will need to add all of the includes back.

It is better for people to include all the headers they need, rather than rely upon such indirect inclusions.

Ok, thanks.

Weiping Pan

Quoted 2 lines

I am not applying these patches.