From: Sami Kerola Date: Sat, 17 Sep 2011 12:35:15 +0000 (+0200) Subject: docs: add non-return function and if shorthand tips X-Git-Tag: v2.21-rc1~402^2 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=0c121348742d1f59751a72d37c4f656b21a08068;p=thirdparty%2Futil-linux.git 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 --- diff --git a/Documentation/howto-contribute.txt b/Documentation/howto-contribute.txt index e70467bbd5..098f456bea 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.