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

On Tue, Aug 11, 2009 at 04:34:15PM -0700, Joe Perches wrote:
> 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".

Fixed.

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

OK, swapped it around.

> 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

Yeah I just spotted another form:

typedef struct whatever {
	members
} FOO;

So we need to ignore 'whatever', I've tested this. I'll send a v2 with this and
addressing the other comments you've made.

Mind sending these as a patch on top of the script?

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

I'm testing against some ar9271 driver I'm porting but I get a chance
I'll test it hv, not sure if I will though. Feel free to do so though
and let me know how it goes.

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