<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  </head>
  <body text="#000000" bgcolor="#FFFFFF">
    <p>On 01/08/2021 06:26 AM, Kris Van Hees wrote:<br>
    </p>
    <blockquote type="cite" cite="mid:20210108142636.GQ1535@oracle.com">
      <pre wrap="">On Wed, Jan 06, 2021 at 03:30:40PM -0500, <a class="moz-txt-link-abbreviated" href="mailto:eugene.loh@oracle.com" moz-do-not-send="true">eugene.loh@oracle.com</a> wrote:
</pre>
      <blockquote type="cite" style="color: #000000;">
        <pre wrap="">diff --git a/CODING-STYLE b/CODING-STYLE
+Braces should typically be avoided on single-statement branches.  E.g.,
+        if (foo1) {
+                bar1();
+                bar2();
+        } else
+                bar3();
</pre>
      </blockquote>
      <pre wrap="">Braces should be avoided on single-statement branches, unless one of the
branches (other than the else-branch) contains multiple statements.

GOOD:
        if (foo1) {
                bar1();
        } else if (foo2) {
                bar2();
                bar3();
        } else
                bar4();</pre>
    </blockquote>
    <br>
    It seems to me that the rule and the example conflict.  Here, one of
    the branches other than the else branch contains multiple
    statements.  Therefore, the "unless" condition is triggered. 
    Therefore, the "avoid braces" practice should not be used, not even
    on the "else bar4()" branch.  Complicated.<br>
    <br>
    And, do "else" branches include "else if" branches?<br>
    <br>
    The rule that I think is being illustrated seems hard to state and
    not present in any style guide I managed to find.  Do you mean:<br>
    <br>
            When a simple-else branch has only a single, simple
    statement,<br>
            its braces should be omitted.  Further, when the other
    branches<br>
            are all, each, single, simple statements, their braces
    should also<br>
            be omitted.<br>
    <br>
    Or, how about employing a simpler rule, like the one in the Linux
    kernel?  That is, omit the "other than the else-branch" exception.<br>
    <br>
    <blockquote type="cite" cite="mid:20210108142636.GQ1535@oracle.com">
      <pre wrap="">BAD:
        if (foo1)
                bar1();
        else if (foo2) {
                bar2();
                bar3();
        } else
                bar4();
</pre>
    </blockquote>
  </body>
</html>