[libvirt] [PATCH 01/10] cleanup: Remove the duplicate header

Osier Yang jyang at redhat.com
Wed Apr 17 08:03:55 UTC 2013


On 17/04/13 10:50, Eric Blake wrote:
> On 04/16/2013 07:41 AM, Osier Yang wrote:
>> Detected by a simple Shell script:
>>
>> for i in $(find -type f -name "*.[ch]" | grep -v gnulib); do
> You can limit things to version-controlled files a bit faster with:
>
> for i in $(git ls-files -- '*.[ch]'); do

Nice.

>
>>      awk 'BEGIN {
>>          FS=" "
>>          fail=0
>>      }
>>      /^# *include.*\.h[">]$/{
> This pattern misses files that include a header with a comment saying
> why, such as this one:
>
> src/util/virxml.c:#include <math.h>               /* for isnan() */
>
>
>>          arr[$NF]++
> This doesn't catch duplication between "" and <> in the same file, since
> it includes the delimiter as part of the key name.  Slightly more
> powerful is:
>
> /# *include/{
>      match($0, /["<][^">]*[">]/)
>      arr[substr($0, RSTART+1, RLENGTH-2)]++
> }

Nice too. But it detects:

2 "virsh-edit.c" are included
Duplicate header(s) in virsh-domain.c

I changed it a bit to avoid it:

/# *include.*\.h/{
     match($0, /["<][^">]*[">]/)
     arr[substr($0, RSTART+1, RLENGTH-2)]++
}

Osier




More information about the libvir-list mailing list