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



At Sun, 12 Jul 2020 10:01:36 +1000, Luke Mewburn <lukem%NetBSD.org@localhost> wrote:
Subject: style change: explicitly permit braces for single statements
>
> 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

Well, if you s/permit/require/g, I strongly concur (with possibly one
tiny exception allowed in rare cases -- when there's no newline).

Personally I don't think there's any good excuse for not always putting
braces around all single-statement blocks.  The only bad execuse is that
the language doesn't strictly require them.  People are lazy, I get that
(I am too), but in my opinion C is just not really safe without them.

--
					Greg A. Woods <gwoods%acm.org@localhost>

Kelowna, BC     +1 250 762-7675           RoboHack <woods%robohack.ca@localhost>
Planix, Inc. <woods%planix.com@localhost>     Avoncote Farms <woods%avoncote.ca@localhost>

Attachment: pgpbkaJ9Lv0PF.pgp
Description: OpenPGP Digital Signature



Home | Main Index | Thread Index | Old Index