Re: mm: Don't touch uninitialized variable indo_pages_stat_array()

From: Linus Torvalds
Date: Tue Dec 16 2008 - 15:36:39 EST




On Tue, 16 Dec 2008, Joe Perches wrote:
>
> Perhaps this is more legible and avoids
> the unnecessary assignments to err.

Not only is it less legible to me, but the "unnecessary" assignments are
the ones that make the flow control much simpler.

I think it's a _lot_ easier to read

retval = BADNESS;
if (something bad)
goto out;

than it is to make the insides of the conditional more complex. It also
tends to generate better code, although gcc's code movement often makes it
not matter (and equally often makes a mess of it). That's because a

if (something)
goto somewhere;

is actually how the CPU itself ends up executing things, while a

if (something) {
retval = something;
goto somewhere;
}

actually ends up becoming

if (!someting)
goto over;
retval = something;
goto somewhere;
over:

by the time the CPU actually has to execute it.

Linus
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/