public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Andi Kleen <andi@firstfloor.org>
To: Dave Chinner <david@fromorbit.com>
Cc: Andi Kleen <andi@firstfloor.org>,
	xfs@oss.sgi.com, akpm@linux-foundation.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] [16/23] XFS: Fix gcc 4.6 set but not read and unused statement warnings
Date: Mon, 14 Jun 2010 09:43:09 +0200	[thread overview]
Message-ID: <20100614074309.GA17092@basil.fritz.box> (raw)
In-Reply-To: <20100614042700.GC6590@dastard>

On Mon, Jun 14, 2010 at 02:27:00PM +1000, Dave Chinner wrote:
> > Unused statements were mostly related to stub macros for disabled
> > features like QUOTA or RT ALLOC. I replace those with
> > inlines.
> 
> Did you compile with/without XFS_DEBUG (I don't think so)? when

No.

I merely made my own config work with relatively little warnings.

> changing code that affects ASSERT statements, CONFIG_XFS_DEBUG needs to
> be selected to test that this code compiles. Most XFs developers
> build with XFS_CONFIG_DEBUG for everything other than performance
> testing, so ensuring this builds is definitely required. ;)

Ok fair enough.

> 
> I'd also be interested if any fixes are needed with all options
> enabled. Seems silly just to fix a few warnings in just one
> particular configuration rather than all of them...

There are tons more warnings with allyesconfig I'm sure,
not only in xfs.  They will need time to work out.

This will happen over time as people eventually move
to gcc 4.6 (after it's released)

Some of the warnings are also related
to not enabling everything (e.g. no quota)

> 
> > There were also some problems with variables used in ASSERT()
> > I partly moved those into the ASSERT itself and partly
> > used a new QASSERT that always evaluates.
> 
> That's a pretty ugly hack for a single occurrence of a warning.
> Re-arrnaging the code is a much better idea than introducing a new
> ASSERT type. e.g:

I originally planned to use it for more, but then ended up
changing other code in other ways.

I still don't think it's a ugly hack, it's a relatively
simple way to handle this. But I can change this single occurrence.

> FWIW, we've now got a situation where external static code checkers
> will tell us that we are not handling an error case (which is where
> this code and comment came from), and now the compiler will warn us
> we are assigning but not using the return value. It's a bit of a
> Catch-22 situation. Hence my question is this - how are we supposed
> to "safely" ignore a return value seeing as the compiler is now
> making the current method rather noisy?

Fix the problem?  

Otherwise you can use a (void) cast, but that's a bad way
if there's a real problem.

> >  	dp->i_d.di_size = 0;
> >  	xfs_trans_log_inode(tp, dp, XFS_ILOG_CORE);
> >  	/*
> 
> Just remove the buf_len variable in this case.

I think the code looks cleaner when using buf_len

> These are all "unused" because they are used in debug code only. i.e.
> in XFS_FILESTREAMS_TRACE configs. This is manual debug code that
> needs to be converted to the trace infrastructure - the compiler may

I have no plans to do that.

> say it is unused, but it is not dead code, so shoul dnot be removed.

I did not remove anything.

> >  			(uint)(msbp - msb), rsvd);
> >  		ASSERT(error == 0);
> > +		/* FIXME: need real error handling here, error can be ENOSPC */
> 
> That comment is wrong and hence is not needed.  By design, we should
> never, ever get an error here because we've already reserved all the
> space we need and this is just an accounting call.  That's what the
> ASSERT(error == 0) is documenting. It's ben placed there to catch

Ok. But I must say ASSERT() is not really a good way to 
document things like that. Whoever wrote this gets
what he deserves now ...

> function head comment during development.  Anyway, if we do get an
> error here, we cannot handle it anyway - it's too late to do
> anything short of a complete shutdown as we've already written the
> transaction to the log.

Well I guess it should be unconditional BUG_ON then.


-Andi
-- 
ak@linux.intel.com -- Speaking for myself only.

  reply	other threads:[~2010-06-14  7:43 UTC|newest]

Thread overview: 58+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-06-10 11:10 [PATCH] [0/23] Fix gcc 4.6 set but unused variable warnings Andi Kleen
2010-06-10 11:10 ` [PATCH] [1/23] x86: percpu: Avoid warnings of unused variables in per cpu Andi Kleen
2010-06-10 11:14   ` Tejun Heo
2010-06-10 12:09     ` Ingo Molnar
2010-06-10 17:43       ` Justin P. Mattock
2010-06-10 18:10         ` Andi Kleen
2010-06-10 18:26           ` Justin P. Mattock
2010-06-10 20:10           ` Justin P. Mattock
2010-06-10 12:24     ` [tip:x86/urgent] percpu, x86: " tip-bot for Andi Kleen
2010-06-10 11:10 ` [PATCH] [2/23] IRQ: Move alloc_desk_mask variables inside ifdef Andi Kleen
2010-06-10 11:10 ` [PATCH] [3/23] x86: Avoid unused by set variables in rdmsr Andi Kleen
2010-06-10 11:10 ` [PATCH] [4/23] pagemap: Avoid unused-but-set variable Andi Kleen
2010-06-18 23:28   ` Andrew Morton
2010-06-19  7:44     ` Andi Kleen
2010-06-10 11:10 ` [PATCH] [5/23] x86 boot: Set ax register in boot vga query Andi Kleen
2010-06-10 17:13   ` H. Peter Anvin
2010-06-10 23:42   ` [tip:x86/urgent] x86, setup: " tip-bot for Andi Kleen
2010-06-10 11:10 ` [PATCH] [6/23] perf: Fix set but unused variables in perf Andi Kleen
2010-06-10 11:10 ` [PATCH] [7/23] x86: fix set but not read variables Andi Kleen
2010-06-10 11:10 ` [PATCH] [8/23] KGDB: Remove set but unused newPC Andi Kleen
2010-07-30 11:59   ` Jason Wessel
2010-06-10 11:10 ` [PATCH] [9/23] PRINTK: Use stable variable to dump kmsg buffer Andi Kleen
2010-06-10 11:10 ` [PATCH] [10/23] SCHED: Only allocate per cpu cpu mask buffer with offstack cpumasks Andi Kleen
2010-06-10 14:43   ` Peter Zijlstra
2010-06-10 14:52     ` Andi Kleen
2010-06-10 14:55       ` Peter Zijlstra
2010-06-10 15:06         ` Andi Kleen
2010-06-10 15:19           ` Peter Zijlstra
2010-06-10 15:34             ` Andi Kleen
2010-06-10 11:10 ` [PATCH] [11/23] KVM: Fix KVM_SET_SIGNAL_MASK Andi Kleen
2010-06-10 14:16   ` Avi Kivity
2010-06-10 11:10 ` [PATCH] [12/23] BTRFS: Clean up unused variables -- bugs Andi Kleen
2010-06-10 11:10 ` [PATCH] [13/23] BTRFS: Clean up unused variables -- nonbugs Andi Kleen
2010-06-10 11:10 ` [PATCH] [14/23] NFSD: Fix initialized but not read warnings Andi Kleen
2010-06-10 11:10 ` [PATCH] [15/23] EXT4: Fix initialized but not read variables Andi Kleen
2010-06-14 17:20   ` tytso
2010-06-10 11:10 ` [PATCH] [16/23] XFS: Fix gcc 4.6 set but not read and unused statement warnings Andi Kleen
2010-06-11 16:20   ` Christoph Hellwig
2010-06-11 16:36     ` Andi Kleen
2010-06-14  4:27   ` Dave Chinner
2010-06-14  7:43     ` Andi Kleen [this message]
2010-06-14 13:37       ` Dave Chinner
2010-06-14 14:37         ` Andi Kleen
2010-06-14 22:24           ` Dave Chinner
2010-06-15  7:02             ` Andi Kleen
2010-06-15  7:40               ` Christoph Hellwig
2010-06-15  7:46                 ` Andi Kleen
2010-06-10 11:10 ` [PATCH] [17/23] EXT3: Fix set but unused variables Andi Kleen
2010-06-14 17:21   ` tytso
2010-06-14 17:27   ` tytso
2010-06-15 14:01     ` Jan Kara
2010-06-10 11:10 ` [PATCH] [18/23] ACPI: Fix unused but set variables in ACPI Andi Kleen
2010-06-10 11:10 ` [PATCH] [19/23] KVM: Fix unused but set warnings Andi Kleen
2010-06-10 14:19   ` Avi Kivity
2010-06-10 11:10 ` [PATCH] [20/23] MM: " Andi Kleen
2010-06-10 11:10 ` [PATCH] [21/23] kernel/*: " Andi Kleen
2010-06-10 11:10 ` [PATCH] [22/23] BLOCK: Fix unused but set variables in blk-merge Andi Kleen
2010-06-10 11:10 ` [PATCH] [23/23] FS: Fix unused but set warnings Andi Kleen

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=20100614074309.GA17092@basil.fritz.box \
    --to=andi@firstfloor.org \
    --cc=akpm@linux-foundation.org \
    --cc=david@fromorbit.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xfs@oss.sgi.com \
    /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