Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

tipc: simplify include dependencies

When we try to add new inline functions in the code, we sometimes
run into circular include dependencies.

The main problem is that the file core.h, which really should be at
the root of the dependency chain, instead is a leaf. I.e., core.h
includes a number of header files that themselves should be allowed
to include core.h. In reality this is unnecessary, because core.h does
not need to know the full signature of any of the structs it refers to,
only their type declaration.

In this commit, we remove all dependencies from core.h towards any
other tipc header file.

As a consequence of this change, we can now move the function
tipc_own_addr(net) from addr.c to addr.h, and make it inline.

There are no functional changes in this commit.

Reviewed-by: Erik Hugne <erik.hugne@ericsson.com>
Reviewed-by: Ying Xue <ying.xue@windriver.com>
Signed-off-by: Jon Maloy <jon.maloy@ericsson.com>
Signed-off-by: David S. Miller <davem@davemloft.net>

authored by

Jon Paul Maloy and committed by
David S. Miller
a6bf70f7 75b44b01

+22 -17
-7
net/tipc/addr.c
··· 38 38 #include "addr.h" 39 39 #include "core.h" 40 40 41 - u32 tipc_own_addr(struct net *net) 42 - { 43 - struct tipc_net *tn = net_generic(net, tipc_net_id); 44 - 45 - return tn->own_addr; 46 - } 47 - 48 41 /** 49 42 * in_own_cluster - test for cluster inclusion; <0.0.0> always matches 50 43 */
+8
net/tipc/addr.h
··· 41 41 #include <linux/tipc.h> 42 42 #include <net/net_namespace.h> 43 43 #include <net/netns/generic.h> 44 + #include "core.h" 44 45 45 46 #define TIPC_ZONE_MASK 0xff000000u 46 47 #define TIPC_CLUSTER_MASK 0xfffff000u 48 + 49 + static inline u32 tipc_own_addr(struct net *net) 50 + { 51 + struct tipc_net *tn = net_generic(net, tipc_net_id); 52 + 53 + return tn->own_addr; 54 + } 47 55 48 56 static inline u32 tipc_zone_mask(u32 addr) 49 57 {
+1 -1
net/tipc/bearer.h
··· 38 38 #define _TIPC_BEARER_H 39 39 40 40 #include "netlink.h" 41 + #include "core.h" 41 42 #include <net/genetlink.h> 42 43 43 - #define MAX_BEARERS 2 44 44 #define MAX_MEDIA 3 45 45 #define MAX_NODES 4096 46 46 #define WSIZE 32
+10 -7
net/tipc/core.h
··· 60 60 #include <net/netns/generic.h> 61 61 #include <linux/rhashtable.h> 62 62 63 - #include "node.h" 64 - #include "bearer.h" 65 - #include "bcast.h" 66 - #include "netlink.h" 67 - #include "link.h" 68 - #include "node.h" 69 - #include "msg.h" 63 + struct tipc_node; 64 + struct tipc_bearer; 65 + struct tipc_bcbearer; 66 + struct tipc_bclink; 67 + struct tipc_link; 68 + struct tipc_name_table; 69 + struct tipc_server; 70 70 71 71 #define TIPC_MOD_VER "2.0.0" 72 + 73 + #define NODE_HTABLE_SIZE 512 74 + #define MAX_BEARERS 3 72 75 73 76 extern int tipc_net_id __read_mostly; 74 77 extern int sysctl_tipc_rmem[3] __read_mostly;
+1
net/tipc/net.c
··· 40 40 #include "subscr.h" 41 41 #include "socket.h" 42 42 #include "node.h" 43 + #include "bcast.h" 43 44 44 45 static const struct nla_policy tipc_nl_net_policy[TIPC_NLA_NET_MAX + 1] = { 45 46 [TIPC_NLA_NET_UNSPEC] = { .type = NLA_UNSPEC },
+1
net/tipc/node.c
··· 39 39 #include "node.h" 40 40 #include "name_distr.h" 41 41 #include "socket.h" 42 + #include "bcast.h" 42 43 43 44 static void node_lost_contact(struct tipc_node *n_ptr); 44 45 static void node_established_contact(struct tipc_node *n_ptr);
-2
net/tipc/node.h
··· 45 45 /* Out-of-range value for node signature */ 46 46 #define INVALID_NODE_SIG 0x10000 47 47 48 - #define NODE_HTABLE_SIZE 512 49 - 50 48 /* Flags used to take different actions according to flag type 51 49 * TIPC_WAIT_PEER_LINKS_DOWN: wait to see that peer's links are down 52 50 * TIPC_WAIT_OWN_LINKS_DOWN: wait until peer node is declared down
+1
net/tipc/socket.c
··· 41 41 #include "link.h" 42 42 #include "name_distr.h" 43 43 #include "socket.h" 44 + #include "bcast.h" 44 45 45 46 #define SS_LISTENING -1 /* socket is listening */ 46 47 #define SS_READY -2 /* socket is connectionless */