Re: [PATCH v1] printk: Declare log_wait as external variable

From: Andy Shevchenko
Date: Tue Feb 04 2020 - 04:05:39 EST


On Tue, Feb 04, 2020 at 11:16:20AM +0900, Sergey Senozhatsky wrote:
> On (20/02/03 15:15), Andy Shevchenko wrote:
> > Static analyzer is not happy:
> >
> > kernel/printk/printk.c:421:1: warning: symbol 'log_wait' was not declared. Should it be static?
> >
> > This is due to usage of log_wait in the other module without announcing
> > its declaration to the world. I wasn't able to dug into deep history of
> > reasons why it is so, and thus decide to make less invasive change, i.e.
> > declaring log_wait as external variable to make static analyzer happy.
>
> [..]
>
> > diff --git a/kernel/printk/printk.c b/kernel/printk/printk.c
> > index 633f41a11d75..43b5cb88c607 100644
> > --- a/kernel/printk/printk.c
> > +++ b/kernel/printk/printk.c
> > @@ -418,7 +418,14 @@ DEFINE_RAW_SPINLOCK(logbuf_lock);
> > } while (0)
> >
> > #ifdef CONFIG_PRINTK
> > +
> > +#ifdef CONFIG_PROC_FS
> > +extern wait_queue_head_t log_wait; /* Used in fs/proc/kmsg.c */
> > DECLARE_WAIT_QUEUE_HEAD(log_wait);
> > +#else
> > +static DECLARE_WAIT_QUEUE_HEAD(log_wait);
> > +#endif /* CONFIG_PROC_FS */
>
> [..]
>
> Since we are now introducing CONFIG_PROC_FS dependency to printk (and
> proc/kmsg already has CONFIG_PRINTK dependency),

I'm not sure I understood. The above does not introduce any dependencies.

> then I guess I wouldn't
> mind it if fs/proc/kmsg would just relocate to printk, next to devksmg
> implementation. Just saying.

--
With Best Regards,
Andy Shevchenko