Re: [PATCH] lkdtm: cleanup headers and module_param/MODULE_PARM_DESC

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ankita Garg wrote:
Hi,

 #include <linux/kernel.h>
+#include <linux/fs.h>
 #include <linux/module.h>
+#include <linux/buffer_head.h>
 #include <linux/kprobes.h>
-#include <linux/kallsyms.h>
+#include <linux/list.h>
 #include <linux/init.h>
-#include <linux/irq.h>
 #include <linux/interrupt.h>
+#include <linux/hrtimer.h>
 #include <scsi/scsi_cmnd.h>

Why does the module require fs.h, hrtimer.h, list.h and buffer_head.h? It works fine for me without these header files. I do not get any gcc warning. Moreover, I found that even init.h and interrupt.h are also not required.

fs.h:  struct file *, struct block_device *
hrtimer.h:  struct hrtimer *
list.h:  struct list_head *
buffer_head.h:  struct buffer_head *

struct buffer_head is what triggered this.  gcc warns like this:

 CC [M]  drivers/misc/lkdtm.o
drivers/misc/lkdtm.c:150: warning: 'struct buffer_head' declared inside parameter list
drivers/misc/lkdtm.c:150: warning: its scope is only this definition or declaration, which is probably not what you want

or you could not #include those files and just do new source code lines like:

struct hrtimer;
struct buffer_head;
struct file;
struct block_dev;
struct list_head;

What we want to see is that source files explicly #include all header files
that they need or use, for structs, unions, extern data, function APIs, etc.
What is happening with lkdtm is that one or more header files is doing
this for you.  We want it to be more explicit than that.

--
~Randy
-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

[Index of Archives]     [Kernel Newbies]     [Netfilter]     [Bugtraq]     [Photo]     [Stuff]     [Gimp]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Video 4 Linux]     [Linux for the blind]     [Linux Resources]
  Powered by Linux