tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: style change: explicitly permit braces for single statements



Luke Mewburn <lukem%netbsd.org@localhost> wrote:

> I propose that the NetBSD C style guide in to /usr/share/misc/style
> is reworded to more explicitly permit braces around single statements,
> instead of the current discourgement.
> 
> IMHO, permitting braces to be consistently used:
> - Adds to clarity of intent.
> - Aids code review.
> - Avoids gotofail: https://en.wikipedia.org/wiki/Unreachable_code#goto_fail_bug

Yes, please.
 
My primary reason to prefer them is minimizing diffs when you do need
to add another statement.  If the OTBS opening brace is already there
then you don't need to spend any mental effort on parsing:

-	if (complex condition full of alphabet soup and punctuation)
+	if (complex condition full of alphabet suop and punctuation) {

to check whether the condition was changed or if it's just the brace.

-uwe



Home | Main Index | Thread Index | Old Index