Re: [PATCH] removing redundant ifdefs

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jiri Olsa
Date: Friday, May 7, 2010 - 12:59 am

On Thu, May 06, 2010 at 10:43:43AM -0700, Randy Dunlap wrote:

I made one after I spot one place like that.. it's simple
perl script, which spits many false warnings (attached).
I took what I thought was right. I did not want to spend
much time with that. ;)

wbr,
jirka

---
#!/usr/bin/perl

my @ifdefs;
my $lnb = 0;
my $file = $ARGV[0];

open FILE, $file or die $!;

while($line = <FILE>) {
        chop $line;
        $lnb++;

        if ($line =~ /^#[ ]*ifdef|^#[ ]*if/) {
                my @ifdef = split(/\s/, $line);
                my $def = $ifdef[1];

                foreach $d(@ifdefs) {
                        next if ($d ne $def);
                        print "$file: [$line]\n";
                        print "$file:  got duplicate $def, line $lnb\n";
                }

                push(@ifdefs, $def);
        }

        if ($line =~ /^#[ ]*endif/) {
                pop(@ifdefs);
        }
}

--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
Re: [PATCH] removing redundant ifdefs, Randy Dunlap, (Thu May 6, 10:43 am)
Re: [PATCH] removing redundant ifdefs, Jiri Olsa, (Fri May 7, 12:59 am)