From 0c121348742d1f59751a72d37c4f656b21a08068 Mon Sep 17 00:00:00 2001 From: Sami Kerola Date: Sat, 17 Sep 2011 14:35:15 +0200 Subject: 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 --- Documentation/howto-contribute.txt | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'Documentation/howto-contribute.txt') 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. -- cgit v1.2.3-55-g7522