I sfrongly support this idea. The list of bugs that have occurred due to simple lacking {} is long. It's even harder now that people who use Python and C sometimes glitch when moving back and forth and forget that indentation in C is meaningless. I ran a piece of broken C (multi-line if missing {}) by a Python/C programmer just now, with this error, and they did not even call it out, even after I gave them some hints. They were in Python mode today.
It's one extra set of {} but a huge amount of potential to reduce attack surface. A bit more text is worth the insurance.
ron
On Wed, May 16, 2018 at 8:17 AM Patrick Georgi via coreboot < coreboot@coreboot.org> wrote:
Hi everybody,
after just running into an issue on the EC code base, I hereby propose that going forward, we should always wrap conditional blocks in braces, even one-liners. That is:
if (foo) { bar(); }
instead of
if (foo) bar();
It doesn't hurt too much but saves us from accidentally adding baz() after bar(), forgetting to add the - now required - braces. If we get rough consensus over this, I'd change Coding_Style to match.
Thoughts? Patrick -- Google Germany GmbH, ABC-Str. 19, 20354 Hamburg https://maps.google.com/?q=ABC-Str.+19,+20354+Hamburg&entry=gmail&source=g Registergericht und -nummer: Hamburg, HRB 86891, Sitz der Gesellschaft: Hamburg Geschäftsführer: Paul Manicle, Halimah DeLaine Prado
-- coreboot mailing list: coreboot@coreboot.org https://mail.coreboot.org/mailman/listinfo/coreboot