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]
Date:	Tue, 11 Aug 2009 16:34:15 -0700
From:	Joe Perches <joe@...ches.com>
To:	"Luis R. Rodriguez" <lrodriguez@...eros.com>
Cc:	akpm@...ux-foundation.org, linux-kernel@...r.kernel.org,
	devel@...verdev.osuosl.org
Subject: Re: [PATCH] scripts: add typdef removal tool

On Tue, 2009-08-11 at 15:51 -0700, Luis R. Rodriguez wrote:
> If you are porting drivers and need to remove tydpefs you can use
> this to help you port the driver quicker.

> +	# This replaces the typdef declaration for a simple struct declaration - style 1
> +	perl -i -e "local $/; while(<>) { s/\btypedef\s+struct\s+_$from\s*\{([\d\D]+?)\}\s*struct\s+$to\b[^;]*;/struct $to \{\1\};/g; print; }" $1
> +
> +	# This replaces the typdef declaration for a simple struct declaration - style 2
> +	perl -i -e "local $/; while(<>) { s/\btypedef\s+struct\s+$to\s*\{([\d\D]+?)\}\s*$from\b[^;]*;/struct $to \{\1\};/g; print; }" $1
> +
> +	# This replaces the typdef usages with simple structs
> +	sed -r -i -e "s/\b$from\b/struct $to/g" $1
> +	sed -r -i -e "s/\bP$from\b/struct $to \*/g" $1
> +	sed -r -i -e "s/struct $to\s*\*\s*\b/struct $to \*/g" $1
> +	sed -r -i -e "s/\(struct $to\s*\*\)\s*/\(struct $to \*\)/g" $1

Hi Luis.

A couple of comments:

In the comments "typdef" should be "typedef".

I believe the sed statements need to be run before the perl statements.

Another common microsoft form is

	typedef struct tagFOO {
		members
	} FOO [, *PFOO [, **PPFOO ];

So maybe perl statement 1 could be:

s/\btypedef\s+struct\s+$to\s*(_{0,1}|tag)$from etc

and another sed statement might be:

sed -r -i -e "s/\(struct $to\s*\*\s*\*\s*\)\s*/\(struct $to \*\*\)/g" $1

Maybe you could test this against next:drivers/staging/hv/ to see
how well this works.

cheers, Joe

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