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:	Wed, 3 Sep 2008 00:20:59 +0200
From:	Hans Verkuil <hverkuil@...all.nl>
To:	LKML <linux-kernel@...r.kernel.org>
Cc:	"v4l-dvb maintainer list" <v4l-dvb-maintainer@...uxtv.org>
Subject: CodingStyle question: multiple statements on a single line

Hi all,

On the v4l-dvb list there has been confusion on how to interpret the 
following in the CodingStyle document:

"Don't put multiple statements on a single line unless you have 
something to hide:

        if (condition) do_this;
          do_something_everytime;

Don't put multiple assignments on a single line either.  Kernel coding 
style is super simple.  Avoid tricky expressions."

Does this mean:

1) Yes, after an 'if' you can put a single statement like this:

	if (a) b;

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

It's the 'have something to hide' part that confuses people: is this 
literal or is this sarcastic? This should be reworded to whatever is 
really meant.

And in general, why is this:

if (a) {
	b;
}

not accepted by the CodingStyle? (At least as I understand it)

Many people find this more readable and certainly safer. Certainly in 
cases like this:

for (...)
	for (...)
		statement;

I would really prefer to have curly brackets as that is much clearer. I 
would suggest that having curly brackets around a single statement is 
made optional. Especially in view of the sentence 'Avoid tricky 
expressions' I would say that this:

if (a)
	b;

is definitely trickier than:

if (a) {
	b;
}

All it takes is a single indentation error to get into trouble here.

Regards,

	Hans
--
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