linux-xfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Joe Perches <joe@perches.com>
To: "Darrick J. Wong" <darrick.wong@oracle.com>,
	Arnd Bergmann <arnd@arndb.de>
Cc: Geert Uytterhoeven <geert@linux-m68k.org>,
	linux-xfs <linux-xfs@vger.kernel.org>,
	Linux Kernel Mailing List <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] xfs: Add missing braces around xfs_scrub_agfl_info initializer
Date: Thu, 01 Feb 2018 09:24:12 -0800	[thread overview]
Message-ID: <1517505852.7489.38.camel@perches.com> (raw)
In-Reply-To: <20180201170826.GP4849@magnolia>

On Thu, 2018-02-01 at 09:08 -0800, Darrick J. Wong wrote:
> On Thu, Feb 01, 2018 at 12:31:36PM +0100, Arnd Bergmann wrote:
> > On Thu, Feb 1, 2018 at 11:23 AM, Geert Uytterhoeven
> > <geert@linux-m68k.org> wrote:
> > > With gcc-4.1.2:
> > > 
> > >     fs/xfs/scrub/agheader.c: In function ‘xfs_scrub_agfl’:
> > >     fs/xfs/scrub/agheader.c:770: warning: missing braces around initializer
> > >     fs/xfs/scrub/agheader.c:770: warning: (near initialization for ‘sai.oinfo’)
> > > 
> > > The first member of struct xfs_scrub_agfl_info is no longer an integral
> > > type, but a struct.  Add the missing curly braces to fix this.
> > 
> > I suspect gcc-4.5 is affected as well, but not 4.6+
> > 
> > > --- a/fs/xfs/scrub/agheader.c
> > > +++ b/fs/xfs/scrub/agheader.c
> > > @@ -767,7 +767,7 @@ int
> > >  xfs_scrub_agfl(
> > >         struct xfs_scrub_context        *sc)
> > >  {
> > > -       struct xfs_scrub_agfl_info      sai = { 0 };
> > > +       struct xfs_scrub_agfl_info      sai = { { 0 } };
> > >         struct xfs_agf                  *agf;
> > 
> > Looks ok to me, but
> > 
> >         struct xfs_scrub_agfl_info      sai = { };
> > 
> > might be slightly better in case the first member changes again.
> 
> Frankly I'd rather see it changed to memset(&sai, 0, sizeof(sai)); and
> stop having to field all these gcc warnings that vary depending on
> compiler version...

trivia:

memset should also be preferred if the structure
could be copied to userspace as the "= {}" is not
guaranteed to zero any possible padding or member
alignment holes.


      reply	other threads:[~2018-02-01 17:24 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-01 10:23 [PATCH] xfs: Add missing braces around xfs_scrub_agfl_info initializer Geert Uytterhoeven
2018-02-01 11:31 ` Arnd Bergmann
2018-02-01 17:08   ` Darrick J. Wong
2018-02-01 17:24     ` Joe Perches [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1517505852.7489.38.camel@perches.com \
    --to=joe@perches.com \
    --cc=arnd@arndb.de \
    --cc=darrick.wong@oracle.com \
    --cc=geert@linux-m68k.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-xfs@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).