lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date:	Thu, 26 Nov 2009 10:26:58 +0100
From:	Uwe Kleine-König 
	<u.kleine-koenig@...gutronix.de>
To:	linux-kernel@...r.kernel.org
Cc:	Junio C Hamano <gitster@...ox.com>,
	Randy Dunlap <rdunlap@...otime.net>,
	Teemu Likonen <tlikonen@....fi>, Jiri Kosina <jkosina@...e.cz>,
	Dan Carpenter <error27@...il.com>,
	Martin Olsson <martin@...imum.se>, linux-doc@...r.kernel.org
Subject: [PATCH RFC] Codingstyle: allow omitting braces for all single statement branches

Grepping for "} else$" in v2.6.32-rc8 yields 6440 hits.  So this seems
to be common practice and should be allowed.  checkpatch doesn't warn
about both variants.

Signed-off-by: Uwe Kleine-König <u.kleine-koenig@...gutronix.de>
Cc: Junio C Hamano <gitster@...ox.com>
Cc: Randy Dunlap <rdunlap@...otime.net>
Cc: Teemu Likonen <tlikonen@....fi>
Cc: Jiri Kosina <jkosina@...e.cz>
Cc: Dan Carpenter <error27@...il.com>
Cc: Martin Olsson <martin@...imum.se>
Cc: linux-doc@...r.kernel.org
---
 Documentation/CodingStyle |   26 +++++++++++++++++---------
 1 files changed, 17 insertions(+), 9 deletions(-)

diff --git a/Documentation/CodingStyle b/Documentation/CodingStyle
index 8bb3723..84563c6 100644
--- a/Documentation/CodingStyle
+++ b/Documentation/CodingStyle
@@ -168,15 +168,23 @@ Do not unnecessarily use braces where a single statement will do.
 if (condition)
 	action();
 
-This does not apply if one branch of a conditional statement is a single
-statement. Use braces in both branches.
-
-if (condition) {
-	do_this();
-	do_that();
-} else {
-	otherwise();
-}
+If not all branches of a conditional statement are single statements you might
+use braces for both branches.
+
+	if (condition) {
+		do_this();
+		do_that();
+	} else
+		otherwise();
+
+or
+
+	if (condition) {
+		do_this();
+		do_that();
+	} else {
+		otherwise();
+	}
 
 		3.1:  Spaces
 
-- 
1.6.5.2

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ