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-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <alpine.DEB.2.00.1207091640170.8185@chino.kir.corp.google.com>
Date:	Mon, 9 Jul 2012 16:47:31 -0700 (PDT)
From:	David Rientjes <rientjes@...gle.com>
To:	Linus Torvalds <torvalds@...ux-foundation.org>,
	Joe Perches <joe@...ches.com>
cc:	linux-kernel@...r.kernel.org, mm-commits@...r.kernel.org,
	apw@...onical.com
Subject: Re: + checkpatch-add-check-for-use-of-sizeof-without-parenthesis.patch
 added to -mm tree

On Mon, 9 Jul 2012, Joe Perches wrote:

> > So, nack, don't start enforcing your own coding style and preferences in 
> > checkpatch.pl.
> 
> Not just my opinion.
> 
> https://lkml.org/lkml/2008/12/23/138
> --------------------------------------------------------
> Date: Tue, 23 Dec 2008 10:08:50 -0800 (PST)
> From: Linus Torvalds <>
> []
> Another example of this is "sizeof". The kernel universally (I hope) has 
> parenthesis around the sizeof argument, even though it's clearly not 
> required by the C language. 
> 

Well, let's add Linus to the cc then because it's certainly not a C 
standard.  The sizeof operator requires parenthesis for type names, you 
can't do "sizeof unsigned long", for example, it requires 
"sizeof (unsigned long)".  All other unary operators do not need the 
parenthesis by ANY C standard.

Documentation/CodingStyle does not ask for the parenthesis to be added 
just like it doesn't ask for parenthesis to do things like (i++); which is 
another unary operator.  You would complain that (i++) has unnecessary 
parenthesis, and I claim the same for sizeof (*foo).

The fact that the kernel has over 1000 occurrences of "sizeof ..." without 
parenthesis shows that people actually know what _is_ standard, otherwise 
you'd get an error at compile time.  Taking just unary operators with 
pointers as an example, it spans the entire kernel:

$ grep -lr 'sizeof \*' * | cut -f1 -d / | uniq
arch
crypto
Documentation
drivers
fs
include
ipc
kernel
lib
net
security
sound
tools

So, for people like me who don't use checkpatch.pl at all, please modify 
Documentation/CodingStyle and get Linus to merge it to add this as a 
stylistic preference.  Saying it's a standard, though, is wrong.
--
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