git: sbin/newfs_hammer: Cleanup blocks with a single statement
Thomas Nikolajsen
thomas.nikolajsen at mail.dk
Tue Apr 11 11:49:47 PDT 2017
No need to refer to linux, we have style.9, see below.
Regarding braces: as I read style.9 the focus is on code redability,
not only what can be inferred from syntax.
If you would like to change style.9, please do that.
-thomas
- git: sbin/newfs_hammer: Cleanup blocks with a single statement
http://lists.dragonflybsd.org/pipermail/commits/2017-April/625746.html
-
commit 46689eca8a09cfe7b1c83f9db32e528e29b1f168
Author: Tomohiro Kusumi <kusumi.tomohiro at gmail.com>
Date: Sun Apr 9 03:05:29 2017 +0300
sbin/newfs_hammer: Cleanup blocks with a single statement
This commit basically does the same as what Linux kernel's coding
style mentions for braces, which is basically the same with BSDs.
https://github.com/torvalds/linux/blob/master/Documentation/process/coding-style.rst#3-placing-braces-and-spaces
No diff in sbin/newfs_hammer/newfs_hammer binary when assert(3)
is disabled.
Summary of changes:
sbin/newfs_hammer/newfs_hammer.c | 63 ++++++++++++++--------------------------
1 file changed, 21 insertions(+), 42 deletions(-)
http://gitweb.dragonflybsd.org/dragonfly.git/commitdiff/46689eca8a09cfe7b1c83f9db32e528e29b1f168
..
- for (i = 0; i < nvols; ++i) {
+ for (i = 0; i < nvols; ++i)
if (i != HAMMER_ROOT_VOLNO)
format_volume(get_volume(i), nvols, label);
- }
..
- 'man style'
https://leaf.dragonflybsd.org/cgi/web-man?command=style§ion=9
..
Braces that
are not necessary may be left out, but always use braces around complex
or confusing sequences, for example if any part of a conditional is
multi-line, use braces for all parts of the conditional, and use braces
around multi-line substatements of loops or conditionals even if they are
theoretically one statement from the compiler's point of view.
..
/* THIS IS ALSO WRONG, USE BRACES AROUND THE OUTER CONDITIONAL */
if (fubar)
if (barbaz)
x = 1;
More information about the Commits
mailing list