Re: [PATCH 4/4] printk: Declare printk_ratelimit_state inratelimit.h

From: Andrew Morton
Date: Tue Sep 21 2010 - 19:14:32 EST


On Sun, 19 Sep 2010 00:53:02 +0900
Namhyung Kim <namhyung@xxxxxxxxx> wrote:

> Adding 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?
>
> Signed-off-by: Namhyung Kim <namhyung@xxxxxxxxx>
> ---
> include/linux/ratelimit.h | 4 ++++
> kernel/sysctl.c | 2 --
> 2 files changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/include/linux/ratelimit.h b/include/linux/ratelimit.h
> index 8f69d09..55e1bbc 100644
> --- a/include/linux/ratelimit.h
> +++ b/include/linux/ratelimit.h
> @@ -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.

--- a/include/linux/ratelimit.h~printk-declare-printk_ratelimit_state-in-ratelimith-fix
+++ a/include/linux/ratelimit.h
@@ -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
_


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