[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZrMMOUQai27N-W3T@sunil-laptop>
Date: Wed, 7 Aug 2024 11:25:05 +0530
From: Sunil V L <sunilvl@...tanamicro.com>
To: Stephen Rothwell <sfr@...b.auug.org.au>
Cc: linux-kernel@...r.kernel.org, linux-serial@...r.kernel.org,
Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
Jiri Slaby <jirislaby@...nel.org>,
kernel test robot <lkp@...el.com>
Subject: Re: [PATCH] serial: 8250_platform: Fix structure initialization
warning
Hi Stephen,
On Wed, Aug 07, 2024 at 03:13:52PM +1000, Stephen Rothwell wrote:
> Hi Sunil,
>
> On Wed, 7 Aug 2024 09:52:10 +0530 Sunil V L <sunilvl@...tanamicro.com> wrote:
> >
>
> > diff --git a/drivers/tty/serial/8250/8250_platform.c b/drivers/tty/serial/8250/8250_platform.c
> > index bdfb16bed4f2..d8c3c169a620 100644
> > --- a/drivers/tty/serial/8250/8250_platform.c
> > +++ b/drivers/tty/serial/8250/8250_platform.c
> > @@ -108,11 +108,12 @@ void __init serial8250_isa_init_ports(void)
> > static int serial8250_platform_probe(struct platform_device *pdev)
> > {
> > struct device *dev = &pdev->dev;
> > - struct uart_8250_port uart = { 0 };
> > + struct uart_8250_port uart;
>
> Does just using "{ }" as an initialiser work without warning?
>
I tried that and at least on this architecture/compiler combination, the
warning is gone. However, I was not sure about it since gcc man page
indicates such initialization is valid for C++.
Quoting gcc manpage:
-Wmissing-field-initializers
In C this option does not warn about the universal zero initializer ‘{ 0 }’:
struct s { int f, g, h; };
struct s x = { 0 };
Likewise, in C++ this option does not warn about the empty { } initializer, for
example:
struct s { int f, g, h; };
s x = { };
So, I thought doing memset is probably safer which should work across
architectures/compiler combinations.
Thanks,
Sunil
Powered by blists - more mailing lists