lkdtm: cleanup headers and module_param/MODULE_PARM_DESC
PATCH 1/1 lkdtm: cleanup headers and module_param/MODULE_PARM_DESC
From: Randy Dunlap <[email protected]>
Fix module_param/sysfs file permission typo.
Clean up MODULE_PARM_DESC strings to avoid fancy (and incorrect) formatting.
Fix header includes for lkdtm; add some needed ones, remove unused ones;
and fix this gcc warning: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
--- drivers/misc/lkdtm.c | 24 +++++++++++++----------- 1 files changed, 13 insertions(+), 11 deletions(-)
drivers/misc/lkdtm.c +13 -11
@@ -44,12 +44,14 @@*/ #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> #ifdef CONFIG_IDE
@@ -116,16 +118,16 @@ static enum ctype cptype = NONE;static int count =DEFAULT_COUNT ;module_param (recur_count, int,0644 ); -MODULE_PARM_DESC (recur_count,"Recurcion level for the stack overflow test,\ -default is 10" ); +MODULE_PARM_DESC (recur_count," Recursion level for the stack overflow test, " \ +"default is 10" );module_param (cpoint_name, charp,0644 ); -MODULE_PARM_DESC (cpoint_name,"Crash Point, where kernel is to be crashed" ); -module_param (cpoint_type, charp,06444 ); -MODULE_PARM_DESC (cpoint_type,"Crash Point Type, action to be taken on\ -hitting the crash point" ); -module_param (cpoint_count, int,06444 ); -MODULE_PARM_DESC (cpoint_count,"Crash Point Count, number of times the \ -crash point is to be hit to trigger action" ); +MODULE_PARM_DESC (cpoint_name," Crash Point, where kernel is to be crashed" ); +module_param (cpoint_type, charp,0644 ); +MODULE_PARM_DESC (cpoint_type," Crash Point Type, action to be taken on " \ +"hitting the crash point" ); +module_param (cpoint_count, int,0644 ); +MODULE_PARM_DESC (cpoint_count," Crash Point Count, number of times the " \ +"crash point is to be hit to trigger action" );unsigned int jp_do_irq (unsigned int irq) {
---
~Randy
Hi,
drivers/misc/lkdtm.c line 55
Quoted 12 lines
#include <
linux/kernel.h>drivers/misc/lkdtm.c +4
-2+#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.
drivers/misc/lkdtm.c static enum ctype cptype = NONE; · line 129
Quoted 6 lines
drivers/misc/lkdtm.c +6
-0+MODULE_PARM_DESC (cpoint_name," Crash Point, where kernel is to be crashed" ); +module_param (cpoint_type, charp,0644 ); +MODULE_PARM_DESC (cpoint_type," Crash Point Type, action to be taken on " \ +"hitting the crash point" ); +module_param (cpoint_count, int,0644 ); +MODULE_PARM_DESC(cpoint_count, " Crash Point Count, number of times the "\
^^not required now!
drivers/misc/lkdtm.c static enum ctype cptype = NONE; · line 130
Quoted 2 lines
drivers/misc/lkdtm.c +1
-0+ "crash point is to be hit to trigger action");
Thanks for fixing the typo.
Quoted 2 lines
---
~Randy
Signature · 2 lines
Ankita Garg Linux Technology Center
Quoted 16 lines · Ankita Garg
Hi,
drivers/misc/lkdtm.c line 55
Quoted 12 lines
#include <
linux/kernel.h>drivers/misc/lkdtm.c +4
-2+#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.handbuffer_head.h? It works fine for me without these header files. I do not get any gcc warning. Moreover, I found that eveninit.handinterrupt.hare 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.odrivers/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.
Signature · 1 line
~Randy