diff options
author | Sami Kerola | 2011-09-17 14:35:15 +0200 |
---|---|---|
committer | Sami Kerola | 2011-09-17 15:07:52 +0200 |
commit | 0c121348742d1f59751a72d37c4f656b21a08068 (patch) | |
tree | 14179d972c2db9e5e52d83d3eb115b693e946304 /Documentation/howto-contribute.txt | |
parent | build-sys: fixes to USAGE_* macros (diff) | |
download | kernel-qcow2-util-linux-0c121348742d1f59751a72d37c4f656b21a08068.tar.gz kernel-qcow2-util-linux-0c121348742d1f59751a72d37c4f656b21a08068.tar.xz kernel-qcow2-util-linux-0c121348742d1f59751a72d37c4f656b21a08068.zip |
docs: add non-return function and if shorthand tips
Non-return functions should not be combined with `else' clause.
The if shorthands `var = e ? t : f;' need to fit to single line,
and if that does not look good use normal "if else" syntax.
Both tips are mentioned in email bellow.
http://www.spinics.net/lists/util-linux-ng/msg05152.html
Signed-off-by: Sami Kerola <kerolasa@iki.fi>
Diffstat (limited to 'Documentation/howto-contribute.txt')
-rw-r--r-- | Documentation/howto-contribute.txt | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/Documentation/howto-contribute.txt b/Documentation/howto-contribute.txt index e70467bbd..098f456be 100644 --- a/Documentation/howto-contribute.txt +++ b/Documentation/howto-contribute.txt @@ -98,3 +98,21 @@ Various notes * Patches relying on features that are not in Linus' tree are not accepted. + + * Do not use `else' after non-returning functions. For + example + + if (this) + err(EXIT_FAIL, "this failed"); + else + err(EXIT_FAIL, "that failed"); + + is wrong and should be wrote + + if (this) + err(EXIT_FAIL, "this failed"); + err(EXIT_FAIL, "that failed"); + + * When you use if shortshort hand make sure it is not wrapped to + multiple lines. In case the shorthand does not look good on one + line use normal "if () else" syntax. |