public inbox for linux-next@vger.kernel.org
 help / color / mirror / Atom feed
From: Jan Kara <jack@suse.cz>
To: Olof Johansson <olof@lixom.net>
Cc: Jan Kara <jack@suse.cz>,
	Geert Uytterhoeven <geert@linux-m68k.org>,
	Stephen Rothwell <sfr@canb.auug.org.au>,
	Al Viro <viro@zeniv.linux.org.uk>,
	Linux-Next <linux-next@vger.kernel.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Christoph Hellwig <hch@infradead.org>
Subject: Re: linux-next: build warning after merge of the final tree (Linus' tree related - vai vfs tree)
Date: Mon, 9 Sep 2013 21:20:28 +0200	[thread overview]
Message-ID: <20130909192028.GA29973@quack.suse.cz> (raw)
In-Reply-To: <CAOesGMjyFVGXGiK9uccg+jeANP6EH4nbbpCHgkucvo9au8kjvQ@mail.gmail.com>

On Mon 09-09-13 09:45:52, Olof Johansson wrote:
> On Mon, Sep 9, 2013 at 7:39 AM, Jan Kara <jack@suse.cz> wrote:
> > On Sun 08-09-13 20:21:54, Olof Johansson wrote:
> >> On Fri, Sep 06, 2013 at 10:52:52AM +0200, Geert Uytterhoeven wrote:
> >> > On Fri, Sep 6, 2013 at 9:19 AM, Stephen Rothwell <sfr@canb.auug.org.au> wrote:
> >> > > After merging the final tree, today's linux-next build (arm defconfig)
> >> > > produced this warning:
> >> > >
> >> > > fs/direct-io.c: In function 'sb_init_dio_done_wq':
> >> > > fs/direct-io.c:557:2: warning: value computed is not used [-Wunused-value]
> >> > >
> >> > > This is:
> >> > >
> >> > >         cmpxchg(&sb->s_dio_done_wq, NULL, wq);
> >> > >
> >> > > Introduced by commit 7b7a8665edd8 ("direct-io: Implement generic deferred
> >> > > AIO completions").
> >> >
> >> > This happens for include/asm-generic/cmpxchg.h and several other
> >> > arch-specific implementations that cast the return value of cmpxchg()
> >> > like
> >> >
> >> > #define cmpxchg(ptr, o, n)   ((__typeof__(*(ptr)))__cmpxchg(....
> >> >
> >> > If the caller of cmpxchg() doesn't use the return value, we get a
> >> > compiler warning,
> >> > at least with some versions of gcc.
> >> >
> >> > Any idea how to fix this once and for good?
> >>
> >> Should it be fixed? Chances are that the caller needs to do actions
> >> depending on if the change happened, and checking the value afterwards
> >> is inherently racy.
> >>
> >> For this specific fs/direct-io.c case it seems to be safe since the
> >> workqueue is only ever set and never cleared, but it might still be a
> >> good idea to do:
> >   I'm not against this change - feel free to add my:
> > Reviewed-by: Jan Kara <jack@suse.cz>
> >
> >   to it and merge it. However I maintain there are valid usecases where you
> > do not care about the return value so warning about it doesn't seem right.
> 
> Yes, similar to (some) __must_check-annotated functions.
> 
> > OTOH thinking about it some more I agree we have other precedents where
> > sometimes-correct-often-bugs constructs are warned about and I can see how
> > people can consider cmpxchg() to be that case. But in that case we should:
> >   a) be consistent among architectures about the warning
> >   b) comment at cmpxchg definition that you are supposed to check its
> >      return value. If you really know what you are doing, you can cast the
> >      return value to (void) and comment why it's safe.
> 
> Unfortunately cmpxchg() is a #define since it needs to use __typeof__.
> Marking it __must_check isn't feasible. I'm open for better
> suggestions.
  Well, if you explicitely type return value of cmpxchg() to its type like
some architectures do, then recent gccs will complain when the return value
isn't used. But I agree this probably isn't very futureproof.

								Honza
-- 
Jan Kara <jack@suse.cz>
SUSE Labs, CR

      reply	other threads:[~2013-09-09 19:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-06  7:19 linux-next: build warning after merge of the final tree (Linus' tree related - vai vfs tree) Stephen Rothwell
2013-09-06  8:52 ` Geert Uytterhoeven
2013-09-09  3:21   ` Olof Johansson
2013-09-09 14:39     ` Jan Kara
2013-09-09 16:45       ` Olof Johansson
2013-09-09 19:20         ` Jan Kara [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=20130909192028.GA29973@quack.suse.cz \
    --to=jack@suse.cz \
    --cc=geert@linux-m68k.org \
    --cc=hch@infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-next@vger.kernel.org \
    --cc=olof@lixom.net \
    --cc=sfr@canb.auug.org.au \
    --cc=viro@zeniv.linux.org.uk \
    /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