Astyle Incorrectly Formatting Linux Style Braces

311 Views Asked by At

According to the Linux kernel coding style, if only one branch of a conditional statement is a single statement, then braces should be used in both branches. For example:

    if (condition) {
            do_this();
            do_that();
    } else {
            otherwise();
    }

This can be found in Section 3 of the official Linux kernel coding style document.

Astyle's latest release 3.0.1 incorrectly formats conditionals like this. For example, Astyle leaves the following untouched:

if (condition) {
        do_this();
        do_that();
} else
        otherwise();

Is there a known fix for this in Astyle? If not, are current development efforts underway? If not, could someone point me in the right direction to get this fix integrated into the tool.

1

There are 1 best solutions below

0
andalevor On

Astyle option "--style=1tbs" could be used to fix that.