<div dir="ltr"><div dir="ltr">This commit refers to todo list in <a href="https://www.wireguard.com/todo/#fixup-includes">https://www.wireguard.com/todo/#fixup-includes</a>. There are include redundancy in wireguard and this commit consist of cleanup. Finding redundancy is analyzed by using dependencies graph that doxygen produced. And fix it until there are no redundancy. I'm not sure if it is the right approach for this issue. Let me know what you think :)</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Wed, 23 Jan 2019 at 14:07, donkeysnore <<a href="mailto:donkeysnore@gmail.com">donkeysnore@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Signed-off-by: donkeysnore <<a href="mailto:donkeysnore@gmail.com" target="_blank">donkeysnore@gmail.com</a>><br>
---<br>
src/allowedips.c | 1 -<br>
src/cookie.c | 6 ------<br>
src/crypto/zinc/blake2s/blake2s.c | 3 ---<br>
src/crypto/zinc/chacha20/chacha20.c | 1 -<br>
src/crypto/zinc/poly1305/poly1305.c | 1 -<br>
src/device.c | 3 ---<br>
src/device.h | 3 ---<br>
src/hashtables.c | 2 --<br>
src/main.c | 2 --<br>
src/messages.h | 1 -<br>
src/netlink.c | 2 --<br>
src/noise.c | 5 -----<br>
src/noise.h | 3 ---<br>
src/peer.c | 5 -----<br>
src/peer.h | 5 -----<br>
src/queueing.h | 4 ----<br>
src/receive.c | 7 -------<br>
src/send.c | 4 ----<br>
src/socket.c | 5 -----<br>
src/timers.c | 2 --<br>
src/tools/config.c | 3 ---<br>
src/tools/curve25519.c | 1 -<br>
src/tools/encoding.h | 1 -<br>
src/tools/genkey.c | 1 -<br>
src/tools/ipc.c | 10 ----------<br>
src/tools/set.c | 1 -<br>
src/tools/setconf.c | 1 -<br>
src/tools/show.c | 8 --------<br>
src/tools/showconf.c | 5 -----<br>
29 files changed, 96 deletions(-)<br>
<br>
diff --git a/src/allowedips.c b/src/allowedips.c<br>
index 30b66f4..ace5ac7 100644<br>
--- a/src/allowedips.c<br>
+++ b/src/allowedips.c<br>
@@ -3,7 +3,6 @@<br>
* Copyright (C) 2015-2019 Jason A. Donenfeld <<a href="mailto:Jason@zx2c4.com" target="_blank">Jason@zx2c4.com</a>>. All Rights Reserved.<br>
*/<br>
<br>
-#include "allowedips.h"<br>
#include "peer.h"<br>
<br>
struct allowedips_node {<br>
diff --git a/src/cookie.c b/src/cookie.c<br>
index 97ab28a..f4095dc 100644<br>
--- a/src/cookie.c<br>
+++ b/src/cookie.c<br>
@@ -3,16 +3,10 @@<br>
* Copyright (C) 2015-2019 Jason A. Donenfeld <<a href="mailto:Jason@zx2c4.com" target="_blank">Jason@zx2c4.com</a>>. All Rights Reserved.<br>
*/<br>
<br>
-#include "cookie.h"<br>
#include "peer.h"<br>
-#include "device.h"<br>
-#include "messages.h"<br>
#include "ratelimiter.h"<br>
#include "timers.h"<br>
<br>
-#include <zinc/blake2s.h><br>
-#include <zinc/chacha20poly1305.h><br>
-<br>
#include <net/ipv6.h><br>
#include <crypto/algapi.h><br>
<br>
diff --git a/src/crypto/zinc/blake2s/blake2s.c b/src/crypto/zinc/blake2s/blake2s.c<br>
index b881db0..c0c88ee 100644<br>
--- a/src/crypto/zinc/blake2s/blake2s.c<br>
+++ b/src/crypto/zinc/blake2s/blake2s.c<br>
@@ -12,12 +12,9 @@<br>
#include <zinc/blake2s.h><br>
#include "../selftest/run.h"<br>
<br>
-#include <linux/types.h><br>
#include <linux/string.h><br>
-#include <linux/kernel.h><br>
#include <linux/module.h><br>
#include <linux/init.h><br>
-#include <linux/bug.h><br>
#include <asm/unaligned.h><br>
<br>
typedef union {<br>
diff --git a/src/crypto/zinc/chacha20/chacha20.c b/src/crypto/zinc/chacha20/chacha20.c<br>
index b4763c8..6859c83 100644<br>
--- a/src/crypto/zinc/chacha20/chacha20.c<br>
+++ b/src/crypto/zinc/chacha20/chacha20.c<br>
@@ -10,7 +10,6 @@<br>
#include <zinc/chacha20.h><br>
#include "../selftest/run.h"<br>
<br>
-#include <linux/kernel.h><br>
#include <linux/module.h><br>
#include <linux/init.h><br>
#include <linux/vmalloc.h><br>
diff --git a/src/crypto/zinc/poly1305/poly1305.c b/src/crypto/zinc/poly1305/poly1305.c<br>
index 7d373b9..c476719 100644<br>
--- a/src/crypto/zinc/poly1305/poly1305.c<br>
+++ b/src/crypto/zinc/poly1305/poly1305.c<br>
@@ -11,7 +11,6 @@<br>
#include "../selftest/run.h"<br>
<br>
#include <asm/unaligned.h><br>
-#include <linux/kernel.h><br>
#include <linux/string.h><br>
#include <linux/module.h><br>
#include <linux/init.h><br>
diff --git a/src/device.c b/src/device.c<br>
index 98c05bc..e1f6bb0 100644<br>
--- a/src/device.c<br>
+++ b/src/device.c<br>
@@ -6,15 +6,12 @@<br>
#include "queueing.h"<br>
#include "socket.h"<br>
#include "timers.h"<br>
-#include "device.h"<br>
#include "ratelimiter.h"<br>
-#include "peer.h"<br>
#include "messages.h"<br>
<br>
#include <linux/module.h><br>
#include <linux/rtnetlink.h><br>
#include <linux/inet.h><br>
-#include <linux/netdevice.h><br>
#include <linux/inetdevice.h><br>
#include <linux/if_arp.h><br>
#include <linux/icmp.h><br>
diff --git a/src/device.h b/src/device.h<br>
index b85638c..c53c463 100644<br>
--- a/src/device.h<br>
+++ b/src/device.h<br>
@@ -8,13 +8,10 @@<br>
<br>
#include "noise.h"<br>
#include "allowedips.h"<br>
-#include "hashtables.h"<br>
#include "cookie.h"<br>
<br>
-#include <linux/types.h><br>
#include <linux/netdevice.h><br>
#include <linux/workqueue.h><br>
-#include <linux/mutex.h><br>
#include <linux/net.h><br>
#include <linux/ptr_ring.h><br>
<br>
diff --git a/src/hashtables.c b/src/hashtables.c<br>
index 18cac91..242f27d 100644<br>
--- a/src/hashtables.c<br>
+++ b/src/hashtables.c<br>
@@ -3,9 +3,7 @@<br>
* Copyright (C) 2015-2019 Jason A. Donenfeld <<a href="mailto:Jason@zx2c4.com" target="_blank">Jason@zx2c4.com</a>>. All Rights Reserved.<br>
*/<br>
<br>
-#include "hashtables.h"<br>
#include "peer.h"<br>
-#include "noise.h"<br>
<br>
static struct hlist_head *pubkey_bucket(struct pubkey_hashtable *table,<br>
const u8 pubkey[NOISE_PUBLIC_KEY_LEN])<br>
diff --git a/src/main.c b/src/main.c<br>
index 4b5b58e..7aa3e97 100644<br>
--- a/src/main.c<br>
+++ b/src/main.c<br>
@@ -4,8 +4,6 @@<br>
*/<br>
<br>
#include "version.h"<br>
-#include "device.h"<br>
-#include "noise.h"<br>
#include "queueing.h"<br>
#include "ratelimiter.h"<br>
#include "netlink.h"<br>
diff --git a/src/messages.h b/src/messages.h<br>
index 3cfd1c5..c8d6d76 100644<br>
--- a/src/messages.h<br>
+++ b/src/messages.h<br>
@@ -10,7 +10,6 @@<br>
#include <zinc/chacha20poly1305.h><br>
#include <zinc/blake2s.h><br>
<br>
-#include <linux/kernel.h><br>
#include <linux/param.h><br>
#include <linux/skbuff.h><br>
<br>
diff --git a/src/netlink.c b/src/netlink.c<br>
index bdd3150..0bac1d0 100644<br>
--- a/src/netlink.c<br>
+++ b/src/netlink.c<br>
@@ -4,11 +4,9 @@<br>
*/<br>
<br>
#include "netlink.h"<br>
-#include "device.h"<br>
#include "peer.h"<br>
#include "socket.h"<br>
#include "queueing.h"<br>
-#include "messages.h"<br>
#include "uapi/wireguard.h"<br>
#include <linux/if.h><br>
#include <net/genetlink.h><br>
diff --git a/src/noise.c b/src/noise.c<br>
index e629307..1efddd8 100644<br>
--- a/src/noise.c<br>
+++ b/src/noise.c<br>
@@ -3,12 +3,7 @@<br>
* Copyright (C) 2015-2019 Jason A. Donenfeld <<a href="mailto:Jason@zx2c4.com" target="_blank">Jason@zx2c4.com</a>>. All Rights Reserved.<br>
*/<br>
<br>
-#include "noise.h"<br>
-#include "device.h"<br>
-#include "peer.h"<br>
-#include "messages.h"<br>
#include "queueing.h"<br>
-#include "hashtables.h"<br>
<br>
#include <linux/rcupdate.h><br>
#include <linux/slab.h><br>
diff --git a/src/noise.h b/src/noise.h<br>
index 8e5cc0a..7ad0cfc 100644<br>
--- a/src/noise.h<br>
+++ b/src/noise.h<br>
@@ -5,14 +5,11 @@<br>
#ifndef _WG_NOISE_H<br>
#define _WG_NOISE_H<br>
<br>
-#include "messages.h"<br>
#include "hashtables.h"<br>
<br>
-#include <linux/types.h><br>
#include <linux/spinlock.h><br>
#include <linux/atomic.h><br>
#include <linux/rwsem.h><br>
-#include <linux/mutex.h><br>
#include <linux/ktime.h><br>
#include <linux/kref.h><br>
<br>
diff --git a/src/peer.c b/src/peer.c<br>
index 020a97b..778c4fc 100644<br>
--- a/src/peer.c<br>
+++ b/src/peer.c<br>
@@ -3,14 +3,9 @@<br>
* Copyright (C) 2015-2019 Jason A. Donenfeld <<a href="mailto:Jason@zx2c4.com" target="_blank">Jason@zx2c4.com</a>>. All Rights Reserved.<br>
*/<br>
<br>
-#include "peer.h"<br>
-#include "device.h"<br>
#include "queueing.h"<br>
#include "timers.h"<br>
-#include "hashtables.h"<br>
-#include "noise.h"<br>
<br>
-#include <linux/kref.h><br>
#include <linux/lockdep.h><br>
#include <linux/rcupdate.h><br>
#include <linux/list.h><br>
diff --git a/src/peer.h b/src/peer.h<br>
index f3cf255..996afe6 100644<br>
--- a/src/peer.h<br>
+++ b/src/peer.h<br>
@@ -7,13 +7,8 @@<br>
#define _WG_PEER_H<br>
<br>
#include "device.h"<br>
-#include "noise.h"<br>
-#include "cookie.h"<br>
<br>
-#include <linux/types.h><br>
#include <linux/netfilter.h><br>
-#include <linux/spinlock.h><br>
-#include <linux/kref.h><br>
#include <net/dst_cache.h><br>
<br>
struct wg_device;<br>
diff --git a/src/queueing.h b/src/queueing.h<br>
index d2866aa..ae35660 100644<br>
--- a/src/queueing.h<br>
+++ b/src/queueing.h<br>
@@ -7,10 +7,6 @@<br>
#define _WG_QUEUEING_H<br>
<br>
#include "peer.h"<br>
-#include <linux/types.h><br>
-#include <linux/skbuff.h><br>
-#include <linux/ip.h><br>
-#include <linux/ipv6.h><br>
<br>
struct wg_device;<br>
struct wg_peer;<br>
diff --git a/src/receive.c b/src/receive.c<br>
index 693ec57..a7db35e 100644<br>
--- a/src/receive.c<br>
+++ b/src/receive.c<br>
@@ -4,17 +4,10 @@<br>
*/<br>
<br>
#include "queueing.h"<br>
-#include "device.h"<br>
-#include "peer.h"<br>
#include "timers.h"<br>
-#include "messages.h"<br>
-#include "cookie.h"<br>
#include "socket.h"<br>
<br>
#include <linux/simd.h><br>
-#include <linux/ip.h><br>
-#include <linux/ipv6.h><br>
-#include <linux/udp.h><br>
#include <net/ip_tunnels.h><br>
<br>
/* Must be called with bh disabled. */<br>
diff --git a/src/send.c b/src/send.c<br>
index b0df5c7..c928367 100644<br>
--- a/src/send.c<br>
+++ b/src/send.c<br>
@@ -5,11 +5,7 @@<br>
<br>
#include "queueing.h"<br>
#include "timers.h"<br>
-#include "device.h"<br>
-#include "peer.h"<br>
#include "socket.h"<br>
-#include "messages.h"<br>
-#include "cookie.h"<br>
<br>
#include <linux/simd.h><br>
#include <linux/uio.h><br>
diff --git a/src/socket.c b/src/socket.c<br>
index 652d798..d93df29 100644<br>
--- a/src/socket.c<br>
+++ b/src/socket.c<br>
@@ -3,16 +3,11 @@<br>
* Copyright (C) 2015-2019 Jason A. Donenfeld <<a href="mailto:Jason@zx2c4.com" target="_blank">Jason@zx2c4.com</a>>. All Rights Reserved.<br>
*/<br>
<br>
-#include "device.h"<br>
#include "peer.h"<br>
#include "socket.h"<br>
#include "queueing.h"<br>
-#include "messages.h"<br>
<br>
#include <linux/ctype.h><br>
-#include <linux/net.h><br>
-#include <linux/if_vlan.h><br>
-#include <linux/if_ether.h><br>
#include <linux/inetdevice.h><br>
#include <net/udp_tunnel.h><br>
#include <net/ipv6.h><br>
diff --git a/src/timers.c b/src/timers.c<br>
index ee16c56..f2ad4f6 100644<br>
--- a/src/timers.c<br>
+++ b/src/timers.c<br>
@@ -4,8 +4,6 @@<br>
*/<br>
<br>
#include "timers.h"<br>
-#include "device.h"<br>
-#include "peer.h"<br>
#include "queueing.h"<br>
#include "socket.h"<br>
<br>
diff --git a/src/tools/config.c b/src/tools/config.c<br>
index 5d15356..360721b 100644<br>
--- a/src/tools/config.c<br>
+++ b/src/tools/config.c<br>
@@ -8,15 +8,12 @@<br>
#include <ctype.h><br>
#include <netdb.h><br>
#include <stdio.h><br>
-#include <stdlib.h><br>
#include <string.h><br>
#include <unistd.h><br>
-#include <sys/socket.h><br>
#include <sys/stat.h><br>
#include <errno.h><br>
<br>
#include "config.h"<br>
-#include "containers.h"<br>
#include "ipc.h"<br>
#include "encoding.h"<br>
<br>
diff --git a/src/tools/curve25519.c b/src/tools/curve25519.c<br>
index 7949933..609ff6e 100644<br>
--- a/src/tools/curve25519.c<br>
+++ b/src/tools/curve25519.c<br>
@@ -5,7 +5,6 @@<br>
<br>
#include "curve25519.h"<br>
<br>
-#include <stdint.h><br>
#include <string.h><br>
<br>
#ifndef __BYTE_ORDER__<br>
diff --git a/src/tools/encoding.h b/src/tools/encoding.h<br>
index f977ee9..41a2fb2 100644<br>
--- a/src/tools/encoding.h<br>
+++ b/src/tools/encoding.h<br>
@@ -7,7 +7,6 @@<br>
#define ENCODING_H<br>
<br>
#include <stdbool.h><br>
-#include <stdint.h><br>
#include "containers.h"<br>
<br>
#define WG_KEY_LEN_BASE64 ((((WG_KEY_LEN) + 2) / 3) * 4 + 1)<br>
diff --git a/src/tools/genkey.c b/src/tools/genkey.c<br>
index 65711e1..c3d2642 100644<br>
--- a/src/tools/genkey.c<br>
+++ b/src/tools/genkey.c<br>
@@ -6,7 +6,6 @@<br>
#include <errno.h><br>
#include <stdio.h><br>
#include <unistd.h><br>
-#include <sys/types.h><br>
#include <sys/stat.h><br>
#include <string.h><br>
#include <fcntl.h><br>
diff --git a/src/tools/ipc.c b/src/tools/ipc.c<br>
index da31eff..e22a9a5 100644<br>
--- a/src/tools/ipc.c<br>
+++ b/src/tools/ipc.c<br>
@@ -11,34 +11,24 @@<br>
#include <linux/genetlink.h><br>
#include "mnlg.h"<br>
#endif<br>
-#include <netinet/in.h><br>
-#include <sys/socket.h><br>
-#include <net/if.h><br>
#include <errno.h><br>
-#include <stdbool.h><br>
#include <stddef.h><br>
#include <stdio.h><br>
-#include <stdlib.h><br>
#include <string.h><br>
#include <ctype.h><br>
#include <unistd.h><br>
-#include <time.h><br>
#include <dirent.h><br>
#include <signal.h><br>
#include <netdb.h><br>
#include <limits.h><br>
-#include <sys/types.h><br>
#include <sys/ioctl.h><br>
-#include <sys/types.h><br>
#include <sys/stat.h><br>
#include <sys/un.h><br>
#include <arpa/inet.h><br>
<br>
#include "ipc.h"<br>
-#include "containers.h"<br>
#include "encoding.h"<br>
#include "curve25519.h"<br>
-#include "../uapi/wireguard.h"<br>
<br>
#define SOCK_PATH RUNSTATEDIR "/wireguard/"<br>
#define SOCK_SUFFIX ".sock"<br>
diff --git a/src/tools/set.c b/src/tools/set.c<br>
index 19f4b92..f50f368 100644<br>
--- a/src/tools/set.c<br>
+++ b/src/tools/set.c<br>
@@ -4,7 +4,6 @@<br>
*/<br>
<br>
#include <stdio.h><br>
-#include <stdlib.h><br>
#include <string.h><br>
<br>
#include "containers.h"<br>
diff --git a/src/tools/setconf.c b/src/tools/setconf.c<br>
index 8211ebd..7a0295a 100644<br>
--- a/src/tools/setconf.c<br>
+++ b/src/tools/setconf.c<br>
@@ -5,7 +5,6 @@<br>
<br>
#include <stddef.h><br>
#include <stdio.h><br>
-#include <stdlib.h><br>
#include <string.h><br>
<br>
#include "containers.h"<br>
diff --git a/src/tools/show.c b/src/tools/show.c<br>
index ba6f115..870860d 100644<br>
--- a/src/tools/show.c<br>
+++ b/src/tools/show.c<br>
@@ -5,20 +5,12 @@<br>
<br>
#include <arpa/inet.h><br>
#include <inttypes.h><br>
-#include <netinet/in.h><br>
-#include <sys/socket.h><br>
-#include <net/if.h><br>
-#include <stdbool.h><br>
#include <stddef.h><br>
-#include <stdint.h><br>
-#include <stdlib.h><br>
#include <stdio.h><br>
#include <string.h><br>
#include <errno.h><br>
-#include <time.h><br>
#include <netdb.h><br>
<br>
-#include "containers.h"<br>
#include "ipc.h"<br>
#include "terminal.h"<br>
#include "encoding.h"<br>
diff --git a/src/tools/showconf.c b/src/tools/showconf.c<br>
index ad76b7f..a57985f 100644<br>
--- a/src/tools/showconf.c<br>
+++ b/src/tools/showconf.c<br>
@@ -4,16 +4,11 @@<br>
*/<br>
<br>
#include <arpa/inet.h><br>
-#include <netinet/in.h><br>
-#include <sys/socket.h><br>
-#include <net/if.h><br>
#include <stddef.h><br>
#include <stdio.h><br>
#include <string.h><br>
-#include <stdlib.h><br>
#include <netdb.h><br>
<br>
-#include "containers.h"<br>
#include "encoding.h"<br>
#include "ipc.h"<br>
#include "subcommands.h"<br>
-- <br>
2.17.1<br>
<br>
</blockquote></div>