Skip to content

Commit

Permalink
batman-adv: Use includes instead of fwdecls
Browse files Browse the repository at this point in the history
While it can be slightly beneficial for the build performance to use
forward declarations instead of includes, the handling of them together
with changes in the included headers makes it unnecessary complicated and
fragile. Just replace them with actual includes since some parts (hwmon,
..) of the kernel even request avoidance of forward declarations and net/
is mostly not using them in *.c file.

Signed-off-by: Sven Eckelmann <[email protected]>
Signed-off-by: Simon Wunderlich <[email protected]>
  • Loading branch information
ecsv authored and simonwunderlich committed May 25, 2019
1 parent 47d4522 commit 68a600d
Show file tree
Hide file tree
Showing 28 changed files with 60 additions and 80 deletions.
7 changes: 3 additions & 4 deletions net/batman-adv/bat_algo.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@

#include "main.h"

#include <linux/netlink.h>
#include <linux/seq_file.h>
#include <linux/skbuff.h>
#include <linux/types.h>

struct netlink_callback;
struct seq_file;
struct sk_buff;

extern char batadv_routing_algo[];
extern struct list_head batadv_hardif_list;

Expand Down
3 changes: 1 addition & 2 deletions net/batman-adv/bat_v.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
#include <linux/rculist.h>
#include <linux/rcupdate.h>
#include <linux/seq_file.h>
#include <linux/skbuff.h>
#include <linux/spinlock.h>
#include <linux/stddef.h>
#include <linux/types.h>
Expand All @@ -41,8 +42,6 @@
#include "netlink.h"
#include "originator.h"

struct sk_buff;

static void batadv_v_iface_activate(struct batadv_hard_iface *hard_iface)
{
struct batadv_priv *bat_priv = netdev_priv(hard_iface->soft_iface);
Expand Down
4 changes: 2 additions & 2 deletions net/batman-adv/bat_v_elp.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

#include "main.h"

struct sk_buff;
struct work_struct;
#include <linux/skbuff.h>
#include <linux/workqueue.h>

int batadv_v_elp_iface_enable(struct batadv_hard_iface *hard_iface);
void batadv_v_elp_iface_disable(struct batadv_hard_iface *hard_iface);
Expand Down
3 changes: 1 addition & 2 deletions net/batman-adv/bat_v_ogm.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

#include "main.h"

#include <linux/skbuff.h>
#include <linux/types.h>

struct sk_buff;

int batadv_v_ogm_init(struct batadv_priv *bat_priv);
void batadv_v_ogm_free(struct batadv_priv *bat_priv);
int batadv_v_ogm_iface_enable(struct batadv_hard_iface *hard_iface);
Expand Down
9 changes: 4 additions & 5 deletions net/batman-adv/bridge_loop_avoidance.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,13 @@
#include "main.h"

#include <linux/compiler.h>
#include <linux/netdevice.h>
#include <linux/netlink.h>
#include <linux/seq_file.h>
#include <linux/skbuff.h>
#include <linux/stddef.h>
#include <linux/types.h>

struct net_device;
struct netlink_callback;
struct seq_file;
struct sk_buff;

/**
* batadv_bla_is_loopdetect_mac() - check if the mac address is from a loop
* detect frame sent by bridge loop avoidance
Expand Down
4 changes: 2 additions & 2 deletions net/batman-adv/debugfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@

#include "main.h"

struct file;
struct net_device;
#include <linux/fs.h>
#include <linux/netdevice.h>

#define BATADV_DEBUGFS_SUBDIR "batman_adv"

Expand Down
7 changes: 3 additions & 4 deletions net/batman-adv/distributed-arp-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,14 @@

#include <linux/compiler.h>
#include <linux/netdevice.h>
#include <linux/netlink.h>
#include <linux/seq_file.h>
#include <linux/skbuff.h>
#include <linux/types.h>
#include <uapi/linux/batadv_packet.h>

#include "originator.h"

struct netlink_callback;
struct seq_file;
struct sk_buff;

#ifdef CONFIG_BATMAN_ADV_DAT

/* BATADV_DAT_ADDR_MAX - maximum address value in the DHT space */
Expand Down
3 changes: 1 addition & 2 deletions net/batman-adv/fragmentation.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,10 @@

#include <linux/compiler.h>
#include <linux/list.h>
#include <linux/skbuff.h>
#include <linux/stddef.h>
#include <linux/types.h>

struct sk_buff;

void batadv_frag_purge_orig(struct batadv_orig_node *orig,
bool (*check_cb)(struct batadv_frag_table_entry *));
bool batadv_frag_skb_fwd(struct sk_buff *skb,
Expand Down
9 changes: 4 additions & 5 deletions net/batman-adv/gateway_client.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@

#include "main.h"

#include <linux/netlink.h>
#include <linux/seq_file.h>
#include <linux/skbuff.h>
#include <linux/types.h>

struct batadv_tvlv_gateway_data;
struct netlink_callback;
struct seq_file;
struct sk_buff;
#include <uapi/linux/batadv_packet.h>

void batadv_gw_check_client_stop(struct batadv_priv *bat_priv);
void batadv_gw_reselect(struct batadv_priv *bat_priv);
Expand Down
3 changes: 1 addition & 2 deletions net/batman-adv/gateway_common.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

#include "main.h"

#include <linux/netdevice.h>
#include <linux/types.h>

struct net_device;

/**
* enum batadv_bandwidth_units - bandwidth unit types
*/
Expand Down
5 changes: 2 additions & 3 deletions net/batman-adv/hard-interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,12 @@

#include <linux/compiler.h>
#include <linux/kref.h>
#include <linux/netdevice.h>
#include <linux/notifier.h>
#include <linux/rcupdate.h>
#include <linux/stddef.h>
#include <linux/types.h>

struct net_device;
struct net;
#include <net/net_namespace.h>

/**
* enum batadv_hard_if_state - State of a hard interface
Expand Down
3 changes: 1 addition & 2 deletions net/batman-adv/hash.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,12 @@
#include <linux/atomic.h>
#include <linux/compiler.h>
#include <linux/list.h>
#include <linux/lockdep.h>
#include <linux/rculist.h>
#include <linux/spinlock.h>
#include <linux/stddef.h>
#include <linux/types.h>

struct lock_class_key;

/* callback to a compare function. should compare 2 element datas for their
* keys
*
Expand Down
3 changes: 1 addition & 2 deletions net/batman-adv/icmp_socket.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
#include "main.h"

#include <linux/types.h>

struct batadv_icmp_header;
#include <uapi/linux/batadv_packet.h>

#define BATADV_ICMP_SOCKET "socket"

Expand Down
9 changes: 4 additions & 5 deletions net/batman-adv/main.h
Original file line number Diff line number Diff line change
Expand Up @@ -210,16 +210,15 @@ enum batadv_uev_type {
#include <linux/etherdevice.h>
#include <linux/if_vlan.h>
#include <linux/jiffies.h>
#include <linux/netdevice.h>
#include <linux/percpu.h>
#include <linux/seq_file.h>
#include <linux/skbuff.h>
#include <linux/types.h>
#include <uapi/linux/batadv_packet.h>

#include "types.h"

struct net_device;
struct packet_type;
struct seq_file;
struct sk_buff;
#include "main.h"

/**
* batadv_print_vid() - return printable version of vid information
Expand Down
6 changes: 3 additions & 3 deletions net/batman-adv/multicast.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@

#include "main.h"

struct netlink_callback;
struct seq_file;
struct sk_buff;
#include <linux/netlink.h>
#include <linux/seq_file.h>
#include <linux/skbuff.h>

/**
* enum batadv_forw_mode - the way a packet should be forwarded as
Expand Down
3 changes: 1 addition & 2 deletions net/batman-adv/netlink.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
#include <linux/stddef.h>
#include <linux/types.h>
#include <net/genetlink.h>
#include <net/net_namespace.h>
#include <net/netlink.h>
#include <net/sock.h>
#include <uapi/linux/batadv_packet.h>
Expand All @@ -50,8 +51,6 @@
#include "tp_meter.h"
#include "translation-table.h"

struct net;

struct genl_family batadv_netlink_family;

/* multicast groups */
Expand Down
3 changes: 1 addition & 2 deletions net/batman-adv/netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@

#include "main.h"

#include <linux/netlink.h>
#include <linux/types.h>
#include <net/genetlink.h>

struct nlmsghdr;

void batadv_netlink_register(void);
void batadv_netlink_unregister(void);
int batadv_netlink_get_ifindex(const struct nlmsghdr *nlh, int attrtype);
Expand Down
9 changes: 4 additions & 5 deletions net/batman-adv/network-coding.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@

#include "main.h"

#include <linux/netdevice.h>
#include <linux/seq_file.h>
#include <linux/skbuff.h>
#include <linux/types.h>

struct batadv_ogm_packet;
struct net_device;
struct seq_file;
struct sk_buff;
#include <uapi/linux/batadv_packet.h>

#ifdef CONFIG_BATMAN_ADV_NC

Expand Down
7 changes: 3 additions & 4 deletions net/batman-adv/originator.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,11 @@
#include <linux/compiler.h>
#include <linux/if_ether.h>
#include <linux/jhash.h>
#include <linux/netlink.h>
#include <linux/seq_file.h>
#include <linux/skbuff.h>
#include <linux/types.h>

struct netlink_callback;
struct seq_file;
struct sk_buff;

bool batadv_compare_orig(const struct hlist_node *node, const void *data2);
int batadv_originator_init(struct batadv_priv *bat_priv);
void batadv_originator_free(struct batadv_priv *bat_priv);
Expand Down
3 changes: 1 addition & 2 deletions net/batman-adv/routing.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

#include "main.h"

#include <linux/skbuff.h>
#include <linux/types.h>

struct sk_buff;

bool batadv_check_management_packet(struct sk_buff *skb,
struct batadv_hard_iface *hard_iface,
int header_len);
Expand Down
3 changes: 1 addition & 2 deletions net/batman-adv/send.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,11 @@
#include "main.h"

#include <linux/compiler.h>
#include <linux/skbuff.h>
#include <linux/spinlock.h>
#include <linux/types.h>
#include <uapi/linux/batadv_packet.h>

struct sk_buff;

void batadv_forw_packet_free(struct batadv_forw_packet *forw_packet,
bool dropped);
struct batadv_forw_packet *
Expand Down
1 change: 1 addition & 0 deletions net/batman-adv/soft-interface.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
#include <linux/list.h>
#include <linux/lockdep.h>
#include <linux/netdevice.h>
#include <linux/netlink.h>
#include <linux/percpu.h>
#include <linux/printk.h>
#include <linux/random.h>
Expand Down
7 changes: 3 additions & 4 deletions net/batman-adv/soft-interface.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@

#include "main.h"

#include <linux/netdevice.h>
#include <linux/skbuff.h>
#include <linux/types.h>
#include <net/net_namespace.h>
#include <net/rtnetlink.h>

struct net_device;
struct net;
struct sk_buff;

int batadv_skb_head_push(struct sk_buff *skb, unsigned int len);
void batadv_interface_rx(struct net_device *soft_iface,
struct sk_buff *skb, int hdr_size,
Expand Down
5 changes: 2 additions & 3 deletions net/batman-adv/sysfs.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,11 @@

#include "main.h"

#include <linux/kobject.h>
#include <linux/netdevice.h>
#include <linux/sysfs.h>
#include <linux/types.h>

struct kobject;
struct net_device;

#define BATADV_SYSFS_IF_MESH_SUBDIR "mesh"
#define BATADV_SYSFS_IF_BAT_SUBDIR "batman_adv"
/**
Expand Down
3 changes: 1 addition & 2 deletions net/batman-adv/tp_meter.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,9 @@

#include "main.h"

#include <linux/skbuff.h>
#include <linux/types.h>

struct sk_buff;

void batadv_tp_meter_init(void);
void batadv_tp_start(struct batadv_priv *bat_priv, const u8 *dst,
u32 test_length, u32 *cookie);
Expand Down
9 changes: 4 additions & 5 deletions net/batman-adv/translation-table.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,12 @@

#include "main.h"

#include <linux/netdevice.h>
#include <linux/netlink.h>
#include <linux/seq_file.h>
#include <linux/skbuff.h>
#include <linux/types.h>

struct netlink_callback;
struct net_device;
struct seq_file;
struct sk_buff;

int batadv_tt_init(struct batadv_priv *bat_priv);
bool batadv_tt_local_add(struct net_device *soft_iface, const u8 *addr,
unsigned short vid, int ifindex, u32 mark);
Expand Down
3 changes: 1 addition & 2 deletions net/batman-adv/tvlv.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@
#include "main.h"

#include <linux/types.h>

struct batadv_ogm_packet;
#include <uapi/linux/batadv_packet.h>

void batadv_tvlv_container_register(struct batadv_priv *bat_priv,
u8 type, u8 version,
Expand Down
Loading

0 comments on commit 68a600d

Please sign in to comment.