Re: linux-next: build failure

!MAILaRCHIVE_VOTE_RePLACE
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Ingo Molnar <mingo@...>
Cc: Stephen Rothwell <sfr@...>, David Miller <davem@...>, <linux-next@...>, LKML <linux-kernel@...>, Andrew Morton <akpm@...>, Mike Travis <travis@...>
Date: Tuesday, July 29, 2008 - 12:26 pm

On Tue, 29 Jul 2008, Ingo Molnar wrote:

Not necessarily. The code is fragile.

Doing a statement expression basically creates a new temporary variable 
with pretty much undefined scope. Taking the address of it *may* be 
optimized away to the original cpu_mask pointer, but it's not really a 
well-defined operation: there really _is_ a local temporary variable, and 
if you were to change things through the address-of thing, gcc would be 
buggy if it had done the optimization.

So the "address-of statement expression" really is a dubious construct.

That said, the change that Stephen introduces is _not_ a no-op. It very 
fundamentally changes the code - exactly because now there is no temporary 
value created any more: it's a real lvalue, and now anybody who does 
&cpumask_of_cpu(cpu) will fundamentally get the original pointer back, 
except it has lost the "const".

And that's actually dangerous - exactly because it now loses the "const" 
thing, there may be people who end up modifying the result without 
getting any compile-time warnings.

I would _seriously_ suggest that both the original code and Stephen's 
modified version is really bad. And you should have taken my interface 
as-is - one that returns a "const cpumask_t *", and nothing else. 

Anything else is simply fundamentally broken.

			Linus
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
linux-next: build failure, Stephen Rothwell, (Tue Jul 29, 2:23 am)
Re: linux-next: build failure, Ingo Molnar, (Tue Jul 29, 4:00 am)
Re: linux-next: build failure, Linus Torvalds, (Tue Jul 29, 12:26 pm)
Re: linux-next: build failure, Wenji Huang, (Tue Jul 29, 4:14 am)
Re: linux-next: build failure, Stephen Rothwell, (Tue Jul 29, 4:03 am)
Re: linux-next: build failure, Ingo Molnar, (Tue Jul 29, 4:58 am)
Re: linux-next: build failure, KOSAKI Motohiro, (Tue Jul 29, 7:28 am)
Re: linux-next: build failure, Ingo Molnar, (Tue Jul 29, 7:40 am)
Re: linux-next: build failure, Linus Torvalds, (Tue Jul 29, 12:33 pm)
Re: linux-next: build failure, Linus Torvalds, (Tue Jul 29, 12:44 pm)
Re: linux-next: build failure, Ingo Molnar, (Tue Jul 29, 12:42 pm)
Re: linux-next: build failure, Mike Travis, (Tue Jul 29, 10:31 am)
Re: linux-next: build failure, Mike Travis, (Tue Jul 29, 10:33 am)