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: <1337618463.13010.4.camel@joe2Laptop>
Date:	Mon, 21 May 2012 09:41:03 -0700
From:	Joe Perches <joe@...ches.com>
To:	Phil Carmody <ext-phil.2.carmody@...ia.com>
Cc:	linux-kernel@...r.kernel.org, apw@...onical.com
Subject: Re: [PATCH 1/1] checkpatch: don't fake typedefs with #define

On Mon, 2012-05-21 at 15:05 +0300, Phil Carmody wrote:
> On 17/05/12 14:24 -0700, ext Joe Perches wrote:
> > On Fri, 2012-05-18 at 00:16 +0300, Phil Carmody wrote:
> > > On 17/05/12 13:54 -0700, ext Joe Perches wrote:
> > > > > +# check for deliberate avoidance of the above anti-typedef rule
> > > > > +		if ($line =~ /#\s*define\s+$Ident\s+$Type\b/) {
> > > > > +			WARN("NEW_TYPEDEFS",
> > > > > +			     "do not fake typedefs using #define\n" . $herecurr);
> > > > > +		}
> > > > > +
> > > > 
> > > > I think the false positive rate is pretty high.
> > > > I used this and don't see too many I'd remove.
> > > > 
> > > > $ git grep -E "#\s*define\s+\w+\s+(struct|unsigned|char|short|int|long|const)\b"
> 
> I hadn't actually run that before, but to be honest, I think
> few of them have much justification. Or at least, were that
> code to be written today by one of the regular contributors,
> it probably wouldn't be written with such a #define. A lot
> do go directly against the advice in Documentation/CodingStyle.
> 
> > > > Got an example you want this to find?
> > > 
> > > Too many. Alas I can't share them.
> > 
> > Too bad.
> > 
> > If all the defines end in _t maybe you could use
> > 	if ($line =~ /^\+\s*#\s*define\s+\w+_t\s+$Type\b/) {
> > etc...
> > 
> 
> Well, certainly structs are the majority of the immediate ones I'd
> most like to nail, so how about this:
> 
> diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
> index faea0ec..0db7f84 100755
> --- a/scripts/checkpatch.pl
> +++ b/scripts/checkpatch.pl
> @@ -2299,6 +2299,12 @@ sub process {
>                              "do not add new typedefs\n" . $herecurr);
>                 }
>  
> +# check for deliberate avoidance of the above anti-typedef rule
> +               if ($line =~ /#\s*define\s+$Ident\s+(enum|union|struct)\s+$Ident\b/) {
> +                       WARN("NEW_TYPEDEFS",
> +                            "do not fake typedefs using #define\n" . $herecurr);
> +               }

I believe this would not catch,

#define typedeflike_define_t	\
	struct foo

If it's deliberate, you probably want to.

So maybe you want to move this and use
the $stat tests like the extern or memset
tests do (look around line 3200).


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