printk cleanups
cover printk cleanups
Hello,
This patchset tries to remove sparse warnings on printk routines. All patches in this series are simple, one-liner and don't waste your time much. Please take a look and consider applying it. :-)
Thanks.
---
Namhyung Kim (4):
printk: Fixup declaration of kmsg_reasons
printk: Add lock context annotation
printk: Change type of 'boot_delay' to int *
printk: Declare printk_ratelimit_state in ratelimit.h
include/linux/ratelimit.h | 4 ++++ kernel/printk.c | 5 +++-- kernel/sysctl.c | 2 -- 3 files changed, 7 insertions(+), 4 deletions(-)
PATCH 1/4 printk: Fixup declaration of kmsg_reasons
Move redundant 'const' after '*' to make pointer itself const
--- kernel/printk.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/printk.c +1 -1
@@ -1511,7 +1511,7 @@ int kmsg_dump_unregister(struct kmsg_dumper *dumper) }EXPORT_SYMBOL_GPL (kmsg_dump_unregister); -static const char const *kmsg_reasons[] = { +static const char *const kmsg_reasons[] = { [KMSG_DUMP_OOPS ] ="oops" , [KMSG_DUMP_PANIC ] ="panic" , [KMSG_DUMP_KEXEC ] ="kexec" ,
Signature · 1 line
1.7.0.4
PATCH 2/4 printk: Add lock context annotation
In reply to Namhyung Kimacquire_console_semaphore_for_printk() releases logbuf_lock but was missing proper annotation. Add it.
--- kernel/printk.c | 1 + 1 files changed, 1 insertions(+), 0 deletions(-)
kernel/printk.c +1 -0
@@ -647,6 +647,7 @@ static inline int can_use_console(unsigned int cpu)* released but interrupts still disabled. */ static int acquire_console_semaphore_for_printk (unsigned int cpu) + __releases(&logbuf_lock) {int retval =0 ;
Signature · 1 line
1.7.0.4
PATCH 3/4 printk: Change type of 'boot_delay' to int *
In reply to Namhyung Kimget_option() takes its 2nd arg as int * so passing boot_delay to it caused following warnings from sparse:
kernel/printk.c:223:27: warning: incorrect type in argument 2 (different signedness)
kernel/printk.c:223:27: expected int *pint
kernel/printk.c:223:27: got unsigned int static [toplevel] *<noident>
Since boot_delay can't grow more than 10,000 changing it to 'int *' will not produce any problem.
--- kernel/printk.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
kernel/printk.c +1 -1
@@ -210,7 +210,7 @@ __setup("log_buf_len=", log_buf_len_setup);#ifdef CONFIG_BOOT_PRINTK_DELAY -static unsigned int boot_delay;/* msecs delay after each printk during bootup */ +static int boot_delay;/* msecs delay after each printk during bootup */ static unsigned long long loops_per_msec;/* based on boot_delay */ static int __init boot_delay_setup (char *str)
Signature · 1 line
1.7.0.4
PATCH 4/4 printk: Declare printk_ratelimit_state in ratelimit.h
In reply to Namhyung KimAdding declaration of printk_ratelimit_state in ratelimit.h removes potential build breakage and following sparse warning:
kernel/printk.c:1426:1: warning: symbol 'printk_ratelimit_state' was not declared. Should it be static?
--- include/linux/ratelimit.h | 4 ++++ kernel/sysctl.c | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-)
include/linux/ratelimit.h +4 -0
@@ -36,6 +36,10 @@ static inline void ratelimit_state_init(struct ratelimit_state *rs, rs->begin =0 ; } +#ifdef CONFIG_PRINTK +extern struct ratelimit_state printk_ratelimit_state; +#endif +extern int ___ratelimit (struct ratelimit_state *rs,const char *func);#define __ratelimit (state) ___ratelimit(state, __func__)
kernel/sysctl.c +0 -2
@@ -161,8 +161,6 @@ extern int no_unaligned_warning;extern int unaligned_dump_stack;#endif -extern struct ratelimit_state printk_ratelimit_state; -#ifdef CONFIG_PROC_SYSCTL static int proc_do_cad_pid (struct ctl_table *table,int write,void __user *buffer,size_t *lenp,loff_t *ppos);
Signature · 1 line
1.7.0.4
Re: [PATCH 4/4] printk: Declare printk_ratelimit_state in ratelimit.h
Quoted 16 lines · On Sun, 19 Sep 2010 00:53:02 +0900 Namhyung Kim <[email protected]> wrote:
Adding declaration of
printk_ratelimit_stateinratelimit.hremoves potential build breakage and following sparse warning:
kernel/printk.c:1426:1: warning: symbol 'printk_ratelimit_state' was not declared. Should it be static?Signed-off-by Namhyung Kim <[email protected]>--- include/linux/ratelimit.h | 4 ++++ kernel/sysctl.c | 2 -- 2 files changed, 4 insertions(+), 2 deletions(-)include/linux/ratelimit.h +0
-0
include/linux/ratelimit.h static inline void ratelimit_state_init(struct ratelimit_state *rs, · line 42
Quoted 7 lines
include/linux/ratelimit.h +4
-0@@ -36,6 +36,10 @@ static inline void ratelimit_state_init(struct ratelimit_state *rs, rs->begin =0 ; } +#ifdef CONFIG_PRINTK +extern struct ratelimit_state printk_ratelimit_state; +#endif +
We don't actually need the ifdefs there.
If we remove them then it adds a risk that someone will discover their error at link-timer rather than at compile-time. On the other hand, removing the ifdefs deuglifies the code for everyone, for ever. Personally I prefer to not have the ifdefs.
include/linux/ratelimit.h renamed from include/linux/ratelimit.h~printk-declare-printk_ratelimit_state-in-ratelimith-fix +0 -2
@@ -36,9 +36,7 @@ static inline void ratelimit_state_init( rs->begin =0 ; } -#ifdef CONFIG_PRINTK extern struct ratelimit_state printk_ratelimit_state; -#endif extern int ___ratelimit (struct ratelimit_state *rs,const char *func);#define __ratelimit (state) ___ratelimit(state, __func__)
diff -puN kernel/sysctl.c~printk-declare-printk_ratelimit_state-in-ratelimith-fix kernel/sysctl.c _