Re: [PATCH] kernel/sysctl_binary.c: improve the usage of returnvalue 'result'

From: Joe Perches
Date: Tue Aug 06 2013 - 18:11:33 EST


On Tue, 2013-08-06 at 14:43 -0700, Andrew Morton wrote:
> On Tue, 06 Aug 2013 15:29:42 +0800 Chen Gang <gang.chen@xxxxxxxxxxx> wrote:
>
> > Improve the usage of return value 'result', so not only can make code
> > clearer to readers, but also can improve the performance.
>
> It used to be pervasive kernel style do to
>
> ret = -ENOMEM;
> foo = alloc(...);
> if (!foo)
> goto out;
>
> whereas nowadays people usually do the more straightforward
>
> foo = alloc(...);
> if (!foo) {
> ret = -ENOMEM;
> goto out;
> }
>
> The thinking was that the old style generated better code, but for the
> life of me I can't remember why :(

https://lkml.org/lkml/2008/12/16/383


--
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/