[asterisk-dev] Coding guidelines change (proposed)

Atis Lezdins atis at iq-labs.net
Wed Feb 27 10:28:38 CST 2008


On 2/26/08, Tilghman Lesher <tilghman at mail.jeffandtilghman.com> wrote:
> I'd like to propose a change to the coding guidelines, and I'm airing it here
>  for specific feedback before we make this change.  Currently, our standard
>  is that if you have a single statement following an if/for/while construct,
>  then we do not require parentheses around the single statement.  While this
>  is legal C, it has caused a number of issues in the past, where another
>  statement was added at that indentation level, but without adding the
>  necessary braces.

+1

>
>  I'd like to change the coding guidelines that the braces are no longer
>  optional; that they are mandatory, and if this change is approved, a janitor
>  project will be posted shortly to convert legacy code to the new standard.

-1 for janitor

>
>  Are there any comments or objections before we implement this change?

How about allowing single line if's, when they are short and simple
construction (let's say - up to 60 symbols):

  if(a!=1) b=2;
  if(!ast_strlen_zero(c)) ast_do_something(c);

They don't have mis-indentation and when adding another line, it's
very noticeable that braces need to be added. IMHO this would allow
easier reading of code.

Regards,
Atis

-- 
Atis Lezdins
VoIP Project Manager,
IQ Labs Inc.
atis at iq-labs.net
Skype: atis.lezdins
Cell Phone: +371 28806004
Work phone: +1 800 7502835



More information about the asterisk-dev mailing list