Development discussion of WireGuard
 help / color / mirror / Atom feed
From: Hangbin Liu <liuhangbin@gmail.com>
To: wireguard@lists.zx2c4.com
Cc: netdev@vger.kernel.org, "Jason A . Donenfeld" <Jason@zx2c4.com>,
	"Toke Høiland-Jørgensen" <toke@redhat.com>,
	"Hangbin Liu" <liuhangbin@gmail.com>
Subject: [PATCH wireguard] wireguard: remove redundancy include files
Date: Tue,  7 Dec 2021 10:54:21 +0800	[thread overview]
Message-ID: <20211207025421.1903782-1-liuhangbin@gmail.com> (raw)

Remove redundancy include files based on tool include-what-you-use
result. The tool will suggest using direct include headers and removing
some big headers. e.g. it will suggests to use linux/spinlock_types.h
for spinlock_t. But actually, we only need to include linux/spinlock.h
directly. So I just take the result as a reference and remove the include
files I do not find related structure/functions.

Tested with gcc-8.5.0 and the compilation passed.

Signed-off-by: Hangbin Liu <liuhangbin@gmail.com>
---
 drivers/net/wireguard/device.c   | 1 -
 drivers/net/wireguard/device.h   | 1 -
 drivers/net/wireguard/noise.c    | 4 ----
 drivers/net/wireguard/noise.h    | 1 -
 drivers/net/wireguard/peer.h     | 1 -
 drivers/net/wireguard/queueing.h | 2 --
 drivers/net/wireguard/send.c     | 5 -----
 drivers/net/wireguard/socket.c   | 2 --
 drivers/net/wireguard/socket.h   | 5 -----
 9 files changed, 22 deletions(-)

diff --git a/drivers/net/wireguard/device.c b/drivers/net/wireguard/device.c
index a46067c38bf5..06b74da2133f 100644
--- a/drivers/net/wireguard/device.c
+++ b/drivers/net/wireguard/device.c
@@ -11,7 +11,6 @@
 #include "peer.h"
 #include "messages.h"
 
-#include <linux/module.h>
 #include <linux/rtnetlink.h>
 #include <linux/inet.h>
 #include <linux/netdevice.h>
diff --git a/drivers/net/wireguard/device.h b/drivers/net/wireguard/device.h
index 43c7cebbf50b..0782dcef9fc1 100644
--- a/drivers/net/wireguard/device.h
+++ b/drivers/net/wireguard/device.h
@@ -8,7 +8,6 @@
 
 #include "noise.h"
 #include "allowedips.h"
-#include "peerlookup.h"
 #include "cookie.h"
 
 #include <linux/types.h>
diff --git a/drivers/net/wireguard/noise.c b/drivers/net/wireguard/noise.c
index c0cfd9b36c0b..59be94077767 100644
--- a/drivers/net/wireguard/noise.c
+++ b/drivers/net/wireguard/noise.c
@@ -7,14 +7,10 @@
 #include "device.h"
 #include "peer.h"
 #include "messages.h"
-#include "queueing.h"
 #include "peerlookup.h"
 
 #include <linux/rcupdate.h>
 #include <linux/slab.h>
-#include <linux/bitmap.h>
-#include <linux/scatterlist.h>
-#include <linux/highmem.h>
 #include <crypto/algapi.h>
 
 /* This implements Noise_IKpsk2:
diff --git a/drivers/net/wireguard/noise.h b/drivers/net/wireguard/noise.h
index c527253dba80..75b8f0d50084 100644
--- a/drivers/net/wireguard/noise.h
+++ b/drivers/net/wireguard/noise.h
@@ -12,7 +12,6 @@
 #include <linux/spinlock.h>
 #include <linux/atomic.h>
 #include <linux/rwsem.h>
-#include <linux/mutex.h>
 #include <linux/kref.h>
 
 struct noise_replay_counter {
diff --git a/drivers/net/wireguard/peer.h b/drivers/net/wireguard/peer.h
index 76e4d3128ad4..05af76b62583 100644
--- a/drivers/net/wireguard/peer.h
+++ b/drivers/net/wireguard/peer.h
@@ -11,7 +11,6 @@
 #include "cookie.h"
 
 #include <linux/types.h>
-#include <linux/netfilter.h>
 #include <linux/spinlock.h>
 #include <linux/kref.h>
 #include <net/dst_cache.h>
diff --git a/drivers/net/wireguard/queueing.h b/drivers/net/wireguard/queueing.h
index e2388107f7fd..bd54373b4485 100644
--- a/drivers/net/wireguard/queueing.h
+++ b/drivers/net/wireguard/queueing.h
@@ -9,8 +9,6 @@
 #include "peer.h"
 #include <linux/types.h>
 #include <linux/skbuff.h>
-#include <linux/ip.h>
-#include <linux/ipv6.h>
 #include <net/ip_tunnels.h>
 
 struct wg_device;
diff --git a/drivers/net/wireguard/send.c b/drivers/net/wireguard/send.c
index 5368f7c35b4b..f5b25f6fc55b 100644
--- a/drivers/net/wireguard/send.c
+++ b/drivers/net/wireguard/send.c
@@ -11,12 +11,7 @@
 #include "messages.h"
 #include "cookie.h"
 
-#include <linux/uio.h>
-#include <linux/inetdevice.h>
-#include <linux/socket.h>
 #include <net/ip_tunnels.h>
-#include <net/udp.h>
-#include <net/sock.h>
 
 static void wg_packet_send_handshake_initiation(struct wg_peer *peer)
 {
diff --git a/drivers/net/wireguard/socket.c b/drivers/net/wireguard/socket.c
index 6f07b949cb81..0d645613349a 100644
--- a/drivers/net/wireguard/socket.c
+++ b/drivers/net/wireguard/socket.c
@@ -9,9 +9,7 @@
 #include "queueing.h"
 #include "messages.h"
 
-#include <linux/ctype.h>
 #include <linux/net.h>
-#include <linux/if_vlan.h>
 #include <linux/if_ether.h>
 #include <linux/inetdevice.h>
 #include <net/udp_tunnel.h>
diff --git a/drivers/net/wireguard/socket.h b/drivers/net/wireguard/socket.h
index bab5848efbcd..d69c84f12e66 100644
--- a/drivers/net/wireguard/socket.h
+++ b/drivers/net/wireguard/socket.h
@@ -6,11 +6,6 @@
 #ifndef _WG_SOCKET_H
 #define _WG_SOCKET_H
 
-#include <linux/netdevice.h>
-#include <linux/udp.h>
-#include <linux/if_vlan.h>
-#include <linux/if_ether.h>
-
 int wg_socket_init(struct wg_device *wg, u16 port);
 void wg_socket_reinit(struct wg_device *wg, struct sock *new4,
 		      struct sock *new6);
-- 
2.31.1


                 reply	other threads:[~2021-12-07  2:54 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211207025421.1903782-1-liuhangbin@gmail.com \
    --to=liuhangbin@gmail.com \
    --cc=Jason@zx2c4.com \
    --cc=netdev@vger.kernel.org \
    --cc=toke@redhat.com \
    --cc=wireguard@lists.zx2c4.com \
    --subject='Re: [PATCH wireguard] wireguard: remove redundancy include files' \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).