[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

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



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

>     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)]++
}

which uses the array name of just the filename regardless of delimiters.

>     }
>     END {
>         for (key in arr) {
>             if (arr[key] > 1) {
>                 fail=1
>                 printf("%d %s\n", arr[key], key)
>             }
>         }
>         if (fail == 1)
>             exit 1
>     }' $i
> 
>     if test $? != 0; then
>         echo "Duplicate header(s) in $i"
>     fi
> done;
> 
> A later patch will add the syntax-check to avoid duplicate
> headers.
> ---

What you have works, but with my improvements to the script, I still see
this after your patch:

2 testutils.h
Duplicate header(s) in ./tests/qemumonitortest.c
2 testutils.h
Duplicate header(s) in ./tests/qemuxmlnstest.c
2 testutils.h
Duplicate header(s) in ./tests/qemuxml2argvtest.c
2 testutils.h
Duplicate header(s) in ./tests/qemuargv2xmltest.c
2 testutils.h
Duplicate header(s) in ./tests/shunloadtest.c
2 testutils.h
Duplicate header(s) in ./tests/vmx2xmltest.c
2 testutils.h
Duplicate header(s) in ./tests/domainsnapshotxml2xmltest.c
2 testutils.h
Duplicate header(s) in ./tests/qemuhelptest.c
2 testutils.h
Duplicate header(s) in ./tests/lxcxml2xmltest.c
2 testutils.h
Duplicate header(s) in ./tests/xml2vmxtest.c
2 testutils.h
Duplicate header(s) in ./tests/qemuxml2xmltest.c
2 testutils.h
Duplicate header(s) in ./tests/esxutilstest.c
2 testutils.h
Duplicate header(s) in ./tests/openvzutilstest.c
2 libxl.h
Duplicate header(s) in ./src/libxl/libxl_driver.c

testutils.h is cleaned up in patch 2; but the duplicate libxl.h in
libxl_driver.c is still buggy.

ACK with libxl_driver.c also fixed (you can touch up the commit message
if you like, but that's not required; as long as we later get the syntax
check right).

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]