]> www.infradead.org Git - users/dwmw2/qemu.git/commitdiff
scripts/clean-includes: Don't claim duplicate headers found when not
authorMarkus Armbruster <armbru@redhat.com>
Thu, 2 Feb 2023 13:38:12 +0000 (14:38 +0100)
committerMarkus Armbruster <armbru@redhat.com>
Wed, 8 Feb 2023 06:16:23 +0000 (07:16 +0100)
When running with --check-dup-head, the script always claims it "Found
duplicate header file includes."  Fix to do it only when it actually
found some.

Fixes: d66253e46ae2 ("scripts/clean-includes: added duplicate #include check")
Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Message-Id: <20230202133830.2152150-3-armbru@redhat.com>

scripts/clean-includes

index 86944f27fc8612af7f48f08f0480dd41521f1b19..8e8420d785074c31b1e5ec3e1f3100acb58b4449 100755 (executable)
@@ -177,9 +177,8 @@ for f in "$@"; do
 done
 
 if [ "$DUPHEAD" = "yes" ] && [ -n "$files" ]; then
-    egrep "^[[:space:]]*#[[:space:]]*include" $files | tr -d '[:blank:]' \
-        | sort | uniq -c | awk '{if ($1 > 1) print $0}'
-    if [ $? -eq 0 ]; then
+    if egrep "^[[:space:]]*#[[:space:]]*include" $files | tr -d '[:blank:]' \
+        | sort | uniq -c | grep -v '^ *1 '; then
         echo "Found duplicate header file includes. Please check the above files manually."
         exit 1
     fi