From patchwork Tue Oct 18 10:33:15 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anand J X-Patchwork-Id: 683612 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3syrzf4Ptyz9sBr for ; Tue, 18 Oct 2016 21:34:38 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b=hNtBclQ/; dkim-atps=neutral Received: from localhost ([::1]:40167 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwRj9-0000zA-BQ for incoming@patchwork.ozlabs.org; Tue, 18 Oct 2016 06:34:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36785) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bwRi8-0000NV-Qo for qemu-devel@nongnu.org; Tue, 18 Oct 2016 06:33:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bwRi4-0006BQ-Td for qemu-devel@nongnu.org; Tue, 18 Oct 2016 06:33:32 -0400 Received: from mail-pf0-x241.google.com ([2607:f8b0:400e:c00::241]:35809) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1bwRi4-0006B7-Nl for qemu-devel@nongnu.org; Tue, 18 Oct 2016 06:33:28 -0400 Received: by mail-pf0-x241.google.com with SMTP id s8so14804501pfj.2 for ; Tue, 18 Oct 2016 03:33:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id; bh=RP9vLf9BSQ+uv8FScyivno5qSfPE/RgsMFeN2vjCnzo=; b=hNtBclQ/xzFhoi+g15ow8RLBoGS1AM1a149xCve+2BgG+njpQql07ZBHQQ0YpdLMqC l/8NvQ4x2EWLE12rqTS6vpRaFrnaoPTVJL+Xv3nVtGHtgwPjMNzUN3+OPxofojzHqLvF EoMUxVk7KVZ589G4iIuXp10Yre0DJprHmnDh1Zzs9gghdEF1NZNvN+CmtGsmO0NG9gw1 jHcuAmFqa82BRMHdtTpzRAQiCpRQ/nhc4EDQB833cC2u+w3BuNpHkzuLIucCCN7M/NpN smWdPZcJCdDbLalZlsCbh9mtVlIvIgoqBVYemvAWY+q8cPoTvAAPaSQgteALhaMSw33I yvUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:subject:date:message-id; bh=RP9vLf9BSQ+uv8FScyivno5qSfPE/RgsMFeN2vjCnzo=; b=lPAe4ASO/3WnRh5myomiW2geoaNo1SLDxvb8H4bd8XTyt7fZ71bPP4xAjF+A6DOhiq mgVdJAWoNrIz8f2gfzaDWhvz703yvKPKldeEcx1gf4RQq3pjDnMaSoGv7SnXVaiWirp/ MBDDJ+oY7nQCR502ync8F4/zzxyqffytyNzszhMnmjEzcYw6GDGN6N5CQLT4Gcq7jrwd ZCgylW0XzVdaLjF7jbFm0WJ6UzfF01puZHEWR6iFfBpQCAShtk+BmaS2WoTBKQFtTMcT wA6QmC+u9XSRJj+U6GaLIaMmxV9dK6fBPFRqSUroxR0LV0UE96pC5eQcs1Pe5fb722Ea k09g== X-Gm-Message-State: AA6/9RkjZRR6p+7uUzA+9vlJjRT+E516ynik8s7NZabLRCrINgSU2WW3HLYF5AssGpSNYQ== X-Received: by 10.98.95.193 with SMTP id t184mr3661071pfb.85.1476786807316; Tue, 18 Oct 2016 03:33:27 -0700 (PDT) Received: from anand.j ([117.246.17.75]) by smtp.googlemail.com with ESMTPSA id w65sm54809232pfd.48.2016.10.18.03.33.25 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 18 Oct 2016 03:33:26 -0700 (PDT) From: Anand J To: qemu-devel@nongnu.org Date: Tue, 18 Oct 2016 16:03:15 +0530 Message-Id: <1476786796-15269-1-git-send-email-anand.indukala@gmail.com> X-Mailer: git-send-email 2.7.4 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 2607:f8b0:400e:c00::241 Subject: [Qemu-devel] [PATCH 1/2] script/clean-includes: added duplicate #include check X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Added script to check duplicate #include entries. This check will scan and print the files in which duplicate #include entries are present. 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-duphead option with script/clean-includes. Signed-off-by: Anand J Reviewed-by: Thomas Huth --- scripts/clean-includes | 50 +++++++++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 13 deletions(-) diff --git a/scripts/clean-includes b/scripts/clean-includes index 4412a55..76dd0e4 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-duphead] file ... # or -# clean-includes [--git subjectprefix] --all +# clean-includes [--git subjectprefix] [--check-duphead] --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-duphead option is used, then check for duplicate +# header files will be enabled. +# # 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,36 @@ 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-duphead") + DUPHEAD=yes + shift + ;; + *) + break + ;; + esac +done if [ $# -eq 0 ]; then - echo "Usage: clean-includes [--git subjectprefix] [--all | foo.c ...]" + echo "Usage: clean-includes [--git subjectprefix] [--check-duphead] [--all | foo.c ...]" echo "(modifies the files in place)" exit 1 fi @@ -154,6 +170,14 @@ for f in "$@"; do done +if [ "$DUPHEAD" = "yes" ]; then + grep "^#include" $@ | 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 - <