Re: style(9) question

From: Robert Watson <rwatson_at_FreeBSD.org>
Date: Thu, 2 Mar 2006 16:40:01 +0000 (GMT)
On Thu, 2 Mar 2006, Dmitry Pryanishnikov wrote:

>  I apologize for asking here my question (it should belong to -questions, 
> but the most developers are available here, and I just hope it won't hurt). 
> What's the historical reason of the following style(9) advise:
>
> 	Values in return statements should be enclosed in parentheses.
>
> What's the rationale of this? From time to time I see small commits just 
> changing "return foo;" -> "return (foo);". I think the first form is quite 
> natural and not ambiguous. Shouldn't we remove this advise from style(9)?

Usually, these changes are a precursor to a larger semantic rewrite of code, 
where the new code being written conforms more to style(9) than the old code. 
This breaks out the style changes from the semantic changes.  You generally 
won't see style changes for the sake of style changes (although there are some 
exceptions: for example, license formatting to make it mechanically parseable, 
or changing the C prototype style so that more type checking can be 
performed).

Regarding the contents of style(9) -- generally, we try hard not to change the 
style guide, as style proves to be a rather contentious topic, as it is 
typically guided much more by opinion and taste than function.  Often, 
ambiguities in the style guide are resolved by looking at what "most" cases in 
the kernel tree currently do, then documenting that as the right way to do it. 
I can't really think of a good reason for return (foo) over return foo, but 
changing it will just make a bunch of code that previously conformed to the 
style guide cease to do so, which probably doesn't really improve matters :-).

Robert N M Watson
Received on Thu Mar 02 2006 - 15:35:31 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:38:53 UTC