[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZCLi8kWOdq8dwxSH@alley>
Date: Tue, 28 Mar 2023 14:52:02 +0200
From: Petr Mladek <pmladek@...e.com>
To: John Ogness <john.ogness@...utronix.de>
Cc: Sergey Senozhatsky <senozhatsky@...omium.org>,
Steven Rostedt <rostedt@...dmis.org>,
Thomas Gleixner <tglx@...utronix.de>,
linux-kernel@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
linux-fsdevel@...r.kernel.org
Subject: Re: union: was: Re: [PATCH printk v1 05/18] printk: Add non-BKL
console basic infrastructure
On Tue 2023-03-28 11:48:06, John Ogness wrote:
> On 2023-03-28, Petr Mladek <pmladek@...e.com> wrote:
> >> A compilation check would be nice. Is that possible?
> >
> > I think the following might do the trick:
> >
> > static_assert(sizeof(struct cons_state) == sizeof(atomic_long_t));
>
> I never realized the kernel code was allowed to have that. But it is
> everywhere! :-) Thanks. I've added and tested the following:
>
> /*
> * The nbcon_state struct is used to easily create and interpret values that
> * are stored in the console.nbcon_state variable. Make sure this struct stays
> * within the size boundaries of that atomic variable's underlying type in
> * order to avoid any accidental truncation.
> */
> static_assert(sizeof(struct nbcon_state) <= sizeof(long));
>
> Note that I am checking against sizeof(long), the underlying variable
> type. We probably shouldn't assume sizeof(atomic_long_t) is always
> sizeof(long).
Makes sense and looks good to me.
Best Regards,
Petr
Powered by blists - more mailing lists