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 --
| Andrew Morton | -mm merge plans for 2.6.23 |
| David Miller | Re: [BUG] New Kernel Bugs |
| Greg KH | [GIT PATCH] driver core patches against 2.6.24 |
| Andrew Morton | Re: Linux 2.6.21-rc4 |
git: | |
| David Miller | [GIT]: Networking |
| Natalie Protasevich | [BUG] New Kernel Bugs |
| Jarek Poplawski | Re: [PATCH] pkt_sched: Destroy gen estimators under rtnl_lock(). |
| Eric W. Biederman | [PATCH] macvlan: Support creating macvlans from macvlans |
