At Sun, 12 Jul 2020 10:01:36 +1000, Luke Mewburn <lu...@netbsd.org> 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 <gwo...@acm.org> Kelowna, BC +1 250 762-7675 RoboHack <wo...@robohack.ca> Planix, Inc. <wo...@planix.com> Avoncote Farms <wo...@avoncote.ca>
pgp07ateykbKh.pgp
Description: OpenPGP Digital Signature