]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
docs: add non-return function and if shorthand tips
authorSami Kerola <kerolasa@iki.fi>
Sat, 17 Sep 2011 12:35:15 +0000 (14:35 +0200)
committerSami Kerola <kerolasa@iki.fi>
Sat, 17 Sep 2011 13:07:52 +0000 (15:07 +0200)
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>
Documentation/howto-contribute.txt

index e70467bbd51e8a998b8b41475d0fcd4585119246..098f456bea774a1bddc259a08c0b5821d0526c90 100644 (file)
@@ -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.