[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Xen-devel] Re: [PATCH 01/04] Kexec / Kdump: Generic code

> > The comment attached to every use of xchg() is dubious. We don't specify
> > warn_unused_result on that function so there's no good reason for the
> > compiler to complain about discarding the result. If it's a reproducible
> > problem it needs investigating. We shouldn't work around a broken
> > compiler.
> Ok, this seems to be a new 'feature' of gcc4, which has widened the class
> of things it will complain about with -Wunused-value. Basically any cast of
> a value causes the compiler to see an expression whose value must not be
> discarded -- what a pain! This seems to me that it could mean that ignoring
> return value of any function becomes potentially dangerous, as the function
> may be a macro that includes a cast on the return value.
> I think the fix is -Wno-unused-value. :-) It's about the least useful of
> the -Wunused-<foo> warnings anyway.
> I'll check this in, so please just get rid of the if(xchg()) hacky
> workaround.

If you wanted to leave the warning on, you should be able to cast to (void) 
instead of using the if

(void)xchg(&kexec_crash_lock, 0))

in order to explicitly indicate the value is unused.  Alternatively I imagine 
there's a gcc attribute somewhere to tell it not to worry about unused 
returns from xchg (like for printf)


Xen-devel mailing list



Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.