docs: specifically mention that braces in if blocks do not need to be symmetric

The claude bot keeps getting this wrong again and again:

  Claude: nit: systemd coding style requires braces on both branches of
               an if/else when one branch uses them. Here the if branch
               is a single statement without braces but the else branch
               uses braces

Specifically mention this is not the case in the coding style doc
to hopefully make it stop hallucinating this rule
This commit is contained in:
Luca Boccassi
2026-06-01 10:55:40 +01:00
parent d0443c6d1a
commit 36896a27b1
+22
View File
@@ -94,6 +94,28 @@ SPDX-License-Identifier: LGPL-2.1-or-later
}
```
- Braces in `if` blocks are not required to be symmetric. Write this:
```c
if (foobar)
waldo();
else {
foo();
bar();
}
```
instead of this:
```c
if (foobar) {
waldo();
} else {
foo();
bar();
}
```
- Do not write `foo ()`, write `foo()`.
- `else` blocks should generally start on the same line as the closing `}`: