[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-trivial] [PULL 21/23] scripts/clean-includes: added duplicate #inc
From: |
Michael Tokarev |
Subject: |
[Qemu-trivial] [PULL 21/23] scripts/clean-includes: added duplicate #include check |
Date: |
Fri, 28 Oct 2016 18:18:52 +0300 |
From: Anand J <address@hidden>
Enhance the clean-includes script to optionally check for duplicate #include
entries.
Script might output false positive entries as well. Such entries should
not be removed. So if it finds any duplicate entries script will
terminate with an exit status 1. Then each and every file should be
checked manually and corrected if necessary.
In order to enable the check use --check-dup-head option with
scripts/clean-includes.
Reviewed-by: Thomas Huth <address@hidden>
Signed-off-by: Anand J <address@hidden>
Signed-off-by: Michael Tokarev <address@hidden>
---
scripts/clean-includes | 56 +++++++++++++++++++++++++++++++++++++-------------
1 file changed, 42 insertions(+), 14 deletions(-)
diff --git a/scripts/clean-includes b/scripts/clean-includes
index 4412a55..dd938da 100755
--- a/scripts/clean-includes
+++ b/scripts/clean-includes
@@ -14,15 +14,18 @@
# the top-level directory.
# Usage:
-# clean-includes [--git subjectprefix] file ...
+# clean-includes [--git subjectprefix] [--check-dup-head] file ...
# or
-# clean-includes [--git subjectprefix] --all
+# clean-includes [--git subjectprefix] [--check-dup-head] --all
#
# If the --git subjectprefix option is given, then after making
# the changes to the files this script will create a git commit
# with the subject line "subjectprefix: Clean up includes"
# and a boilerplate commit message.
#
+# If --check-dup-head is specified, additionally check for duplicate
+# header includes.
+#
# Using --all will cause clean-includes to run on the whole source
# tree (excluding certain directories which are known not to need
# handling).
@@ -45,23 +48,40 @@
GIT=no
+DUPHEAD=no
# Extended regular expression defining files to ignore when using --all
XDIRREGEX='^(tests/tcg|tests/multiboot|pc-bios|disas/libvixl)'
-if [ $# -ne 0 ] && [ "$1" = "--git" ]; then
- if [ $# -eq 1 ]; then
- echo "--git option requires an argument"
- exit 1
- fi
- GITSUBJ="$2"
- GIT=yes
- shift
- shift
-fi
+while true
+do
+ case $1 in
+ "--git")
+ if [ $# -eq 1 ]; then
+ echo "--git option requires an argument"
+ exit 1
+ fi
+ GITSUBJ="$2"
+ GIT=yes
+ shift
+ shift
+ ;;
+ "--check-dup-head")
+ DUPHEAD=yes
+ shift
+ ;;
+ "--")
+ shift
+ break
+ ;;
+ *)
+ break
+ ;;
+ esac
+done
if [ $# -eq 0 ]; then
- echo "Usage: clean-includes [--git subjectprefix] [--all | foo.c ...]"
+ echo "Usage: clean-includes [--git subjectprefix] [--check-dup-head]
[--all | foo.c ...]"
echo "(modifies the files in place)"
exit 1
fi
@@ -91,7 +111,6 @@ cat >"$COCCIFILE" <<EOT
)
EOT
-
for f in "$@"; do
case "$f" in
*.inc.c)
@@ -154,6 +173,15 @@ for f in "$@"; do
done
+if [ "$DUPHEAD" = "yes" ]; then
+ egrep "^[[:space:]]*#[[:space:]]*include" "$@" | tr -d '[:blank:]' \
+ | sort | uniq -c | awk '{if ($1 > 1) print $0}'
+ if [ $? -eq 0 ]; then
+ echo "Found duplicate header file includes. Please check the above
files manually."
+ exit 1
+ fi
+fi
+
if [ "$GIT" = "yes" ]; then
git add -- "$@"
git commit --signoff -F - <<EOF
--
2.1.4
- [Qemu-trivial] [PULL 06/23] target-lm32: disable asm logging via LOG_DIS(), (continued)
- [Qemu-trivial] [PULL 06/23] target-lm32: disable asm logging via LOG_DIS(), Michael Tokarev, 2016/10/28
- [Qemu-trivial] [PULL 17/23] s390: avoid always-true comparison in s390_pci_generate_fid(), Michael Tokarev, 2016/10/28
- [Qemu-trivial] [PULL 04/23] target-lm32: fix LOG_DIS operand order, Michael Tokarev, 2016/10/28
- [Qemu-trivial] [PULL 23/23] Fix build for less common build directories names, Michael Tokarev, 2016/10/28
- [Qemu-trivial] [PULL 20/23] monitor: deprecate 'default' option, Michael Tokarev, 2016/10/28
- [Qemu-trivial] [PULL 03/23] target-lm32: fix style issue, Michael Tokarev, 2016/10/28
- [Qemu-trivial] [PULL 15/23] scripts/hxtool: fix undefined behavour of echo, Michael Tokarev, 2016/10/28
- [Qemu-trivial] [PULL 18/23] Makefile: Fix help text for target 'installer', Michael Tokarev, 2016/10/28
- [Qemu-trivial] [PULL 14/23] qemu-options.hx: set: fix copy-paste error, Michael Tokarev, 2016/10/28
- [Qemu-trivial] [PULL 16/23] migration: Remove unneeded NULL check from migrate_fd_error(), Michael Tokarev, 2016/10/28
- [Qemu-trivial] [PULL 21/23] scripts/clean-includes: added duplicate #include check,
Michael Tokarev <=
- [Qemu-trivial] [PULL 10/23] milkymist-pfpu: fix potential integer overflow, Michael Tokarev, 2016/10/28
- [Qemu-trivial] [PULL 09/23] hw/block/nvme: Simplify if-statements a little bit, Michael Tokarev, 2016/10/28
- [Qemu-trivial] [PULL 12/23] MAINTAINERS: qemu-trivial information, Michael Tokarev, 2016/10/28
- [Qemu-trivial] [PULL 22/23] clean-up: removed duplicate #includes, Michael Tokarev, 2016/10/28
- Re: [Qemu-trivial] [Qemu-devel] [PULL 00/23] Trivial patches for 2016-10-28, Peter Maydell, 2016/10/31