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 for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ada7i9ufa7x.fsf@cisco.com>
Date:	Tue, 02 Sep 2008 15:34:42 -0700
From:	Roland Dreier <rdreier@...co.com>
To:	Hans Verkuil <hverkuil@...all.nl>
Cc:	LKML <linux-kernel@...r.kernel.org>,
	"v4l-dvb maintainer list" <v4l-dvb-maintainer@...uxtv.org>
Subject: Re: CodingStyle question: multiple statements on a single line

 > 2) No, never use the 'if (a) b;' construction. Put 'b;' on the next line 
 > instead.

This is correct.  Always write simple if statements as

	if (a)
		b;

 > And in general, why is this:
 > 
 > if (a) {
 > 	b;
 > }
 > 
 > not accepted by the CodingStyle? (At least as I understand it)

The braces take up another line of whitespace, which means less code
fits on the screen.  And in simple cases, they don't add anything.
Finally, the vast majority of the kernel leaves the braces off, so they
look funny to people who read a lot of kernel code.

And uniformity counts for a lot: most coding style rules are completely
arbitrary, but having a uniform kernel style makes reading kernel code
much easier.

Keep in mind that common sense always trumps any mechanical rule.  So if
there is some case where writing

	if (a) {
		b;
	}

is clearly easier to read than leaving the braces off, then that would
be OK.

 - R.
--
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