Re: [PATCH 09/10] misc: fix returning void-valued expression warnings

From: Boaz Harrosh
Date: Thu May 01 2008 - 08:42:40 EST


On Thu, May 01 2008 at 15:00 +0300, Al Viro <viro@xxxxxxxxxxxxxxxxxx> wrote:
> On Thu, May 01, 2008 at 02:43:50PM +0300, Boaz Harrosh wrote:
>
>> I don't know who invented sparse, but I like this form of return.
>> 1 - It saves me the curly brackets and extra return line. But mainly
>> 2 - It is a programing statement that says: "Me here I'm an equivalent
>> to that other call". So if in the future that inner function starts
>> to return, say, an error value, with the first style the compiler will
>> error. But with the second style the new error return will be silently
>> ignored. So these are not equivalent replacements. The former is a much
>> stronger bond between the caller and the callie.
>
> 3. 6.8.6.4(1): A return statement with an expression shall not appear in
> a function whose return type is void.
>

Please forgive my ignorance, where is this quote from?

> Write in C, please.

I have used this style for ages. I thought it is C, and the compiler never
complained. You must agree that the two statements are not equivalent. Is it
a bad style? I saw it's merits, perhaps it's just me.

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