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] [day] [month] [year] [list]
Date:	Fri, 17 Aug 2007 14:03:59 +0200 (CEST)
From:	Jan Engelhardt <jengelh@...putergmbh.de>
To:	Andy Whitcroft <apw@...dowen.org>
cc:	Eugene Teo <eugeneteo@...nel.sg>, linux-kernel@...r.kernel.org,
	auke-jan.h.kok@...el.com
Subject: Re: [PATCH] Make checkpatch rant about trailing ; at the end of "if"
 expr


On Aug 16 2007 10:21, Andy Whitcroft wrote:
>> +		if ($line =~ /\bif\s*\([^\)]*\)\s*\;/) {
>
>Heh, you are the second person to suggest this check today, do I detect
>some ripped out hair due to one of these!
>
>I've taken this idea and expanded it to cover if, for and while which
>can all suffer from this.  Using the relative indent to work out which
>are valid combinations:

But. The above regex does not seem to handle

	if ((a = b));
		oops;

I have tried to come up with a superduper regex that handles multiple 
(), but my regex fu seems to stop above two pairs of ().

#!/usr/bin/perl

@check = (
	q"if ((ptr = malloc(bong, GFP)) == NULL)  ; (oopsie) ;",
	q"if ((ptr = malloc(bong, GFP)) == NULL)    (alright);",
	q"if (  ({ bool evil = (true); evil; }) ) ; (oopsie) ;",
	q"if (  ({ bool evil = (true); evil; }) )   (alright);",
	q"if((()));",
);

my $r = qr/\s*\(\s*(??{$r})?\s*\)\s*|\s*\(\s*[^()]+\s*\)\s*/;

foreach (@check) {
	if ($_ =~ /(if|for|while)$r;/) {
		print "ok $_\n";
	}
}


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