lkml.org 
[lkml]   [2010]   [May]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH] removing redundant ifdefs
    On Thu, May 06, 2010 at 10:43:43AM -0700, Randy Dunlap wrote:
    > On Thu, 6 May 2010 19:36:04 +0200 Jiri Olsa wrote:
    >
    > > removing redundant ifdefs.
    > >
    > > the pattern is
    > >
    > > #ifdef DEF1
    > > ...
    > > #ifdef DEF1
    > > ...
    > > #endif
    > > ...
    > > #endif
    > >
    > > and removing the inner ifdef.
    > >
    > > I found them using script all over the kernel so
    > > I haven't even compile-tested some of them.
    >
    > what script, please?
    >
    > ---
    > ~Randy
    > *** Remember to use Documentation/SubmitChecklist when testing your code ***

    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);
    }
    }



    \
     
     \ /
      Last update: 2010-05-07 10:03    [W:0.026 / U:119.920 seconds]
    ©2003-2016 Jasper Spaans. hosted at Digital OceanAdvertise on this site