NFS uses either the kernel's DNS service or its own depending on whether
CONFIG_NFS_USE_KERNEL_DNS is enabled or not.

4 header files which are:
(i) #include <linux/module.h>
(ii) #include <linux/sunrpc/clnt.h>
(iii) #include <linux/sunrpc/addr.h>
(iv) #include "dns_resolve.h"

These 4 header files are used regardless of whether
CONFIG_NFS_USE_KERNEL_DNS is enabled or not. But they have been included
under #ifdef CONFIG_NFS_USE_KERNEL_DNS and also the #else section(if
CONFIG_NFS_USE_KERNEL_DNS is not enabled).

Move these redundant headers to the top of the file i.e include them
before #ifdef CONFIG_NFS_USE_KERNEL_DNS.

Tested by compiling the kernel and also running
./scripts/checkincludes.pl on fs/nfs/dns_resolve.c

Signed-off-by: Bharath Vedartham <linux.b...@gmail.com>
---
 fs/nfs/dns_resolve.c | 12 ++++--------
 1 file changed, 4 insertions(+), 8 deletions(-)

diff --git a/fs/nfs/dns_resolve.c b/fs/nfs/dns_resolve.c
index a7d3df8..b34e575 100644
--- a/fs/nfs/dns_resolve.c
+++ b/fs/nfs/dns_resolve.c
@@ -7,14 +7,15 @@
  * Resolves DNS hostnames into valid ip addresses
  */
 
-#ifdef CONFIG_NFS_USE_KERNEL_DNS
-
 #include <linux/module.h>
 #include <linux/sunrpc/clnt.h>
 #include <linux/sunrpc/addr.h>
-#include <linux/dns_resolver.h>
 #include "dns_resolve.h"
 
+#ifdef CONFIG_NFS_USE_KERNEL_DNS
+
+#include <linux/dns_resolver.h>
+
 ssize_t nfs_dns_resolve_name(struct net *net, char *name, size_t namelen,
                struct sockaddr *sa, size_t salen)
 {
@@ -33,24 +34,19 @@ ssize_t nfs_dns_resolve_name(struct net *net, char *name, 
size_t namelen,
 
 #else
 
-#include <linux/module.h>
 #include <linux/hash.h>
 #include <linux/string.h>
 #include <linux/kmod.h>
 #include <linux/slab.h>
-#include <linux/module.h>
 #include <linux/socket.h>
 #include <linux/seq_file.h>
 #include <linux/inet.h>
-#include <linux/sunrpc/clnt.h>
-#include <linux/sunrpc/addr.h>
 #include <linux/sunrpc/cache.h>
 #include <linux/sunrpc/svcauth.h>
 #include <linux/sunrpc/rpc_pipe_fs.h>
 #include <linux/nfs_fs.h>
 
 #include "nfs4_fs.h"
-#include "dns_resolve.h"
 #include "cache_lib.h"
 #include "netns.h"
 
-- 
2.7.4

Reply via email to