Received: from eggs.gnu.org ([2001:4830:134:3::10]:46054) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bxFpU-000364-1n for qemu-devel@nongnu.org; Thu, 20 Oct 2016 12:04:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bxFpP-0004jG-W3 for qemu-devel@nongnu.org; Thu, 20 Oct 2016 12:04:28 -0400 References: <1476978482-13108-1-git-send-email-anand.indukala@gmail.com> <1476978482-13108-2-git-send-email-anand.indukala@gmail.com> From: Eric Blake Message-ID: Date: Thu, 20 Oct 2016 11:04:21 -0500 MIME-Version: 1.0 In-Reply-To: <1476978482-13108-2-git-send-email-anand.indukala@gmail.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="8gGm2U6saOVMfh0lPOuFph4WALirsS9ee" Subject: Re: [Qemu-devel] [PATCH v3 1/2] scripts/clean-includes: added duplicate #include check List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anand J , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, thuth@redhat.com This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --8gGm2U6saOVMfh0lPOuFph4WALirsS9ee From: Eric Blake To: Anand J , qemu-devel@nongnu.org Cc: qemu-trivial@nongnu.org, thuth@redhat.com Message-ID: Subject: Re: [Qemu-devel] [PATCH v3 1/2] scripts/clean-includes: added duplicate #include check References: <1476978482-13108-1-git-send-email-anand.indukala@gmail.com> <1476978482-13108-2-git-send-email-anand.indukala@gmail.com> In-Reply-To: <1476978482-13108-2-git-send-email-anand.indukala@gmail.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable On 10/20/2016 10:48 AM, Anand J wrote: > Added script to check duplicate #include entries. This check will scan You didn't actually add a script, but enhanced an existing one. Also, "Added" is past tense, but commit messages are best written in imperative tense. Better might be: Enhance the clean-includes script to optionally check for duplicate #include entries. (But be careful of line wraps; git eats lines starting with # if the wrap happens at the wrong place while editing your message) > and print the files in which duplicate #include entries are present. >=20 > 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. >=20 > In order to enable the check use --check-dup-head option with > scripts/clean-includes. >=20 > Reviewed-by: Thomas Huth > Signed-off-by: Anand J > --- > scripts/clean-includes | 54 ++++++++++++++++++++++++++++++++++++++----= -------- > 1 file changed, 41 insertions(+), 13 deletions(-) >=20 > +if [ "$DUPHEAD" =3D "yes" ]; then > + grep "^#include" "$@" | sort | uniq -c | awk '{if ($1 > 1) print $= 0}' Includes can be indented. It is valid to write: #include ... or # include ... or even # include ... (of those three, we most commonly use the style: # include ... to delineate includes inside an #if conditional). So a better expression might be grep "# *include" "$@", which may in turn find more duplicates; on the other hand, those duplicates are more likely to be conditionals where the duplication is necessary (see for exampel include/qemu/bswap.h vs. ). Then again, if you allow whitespace in your grep, you have to remove that whitespace before passing things to sort and uniq, if you want a fair comparison that finds two duplicate includes that differ only by whitespace. --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --8gGm2U6saOVMfh0lPOuFph4WALirsS9ee Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJYCOsFAAoJEKeha0olJ0NqXzgH/jq0fM+l5kcYW0cy1QEJbmn3 ldF+xBJQcu+SyxsiXDgawkpaqR5TEbzXwbSyJ97KohXfZFHXtIwAbDZVHG2Trrle 6iSI9zqHSE0zAovnb6qcjz2fE9zvNCZ87HQcjjFpLSC+0uvvn4+ed4eTRavSh9oO Lv8ZMLAFY/chtof+jEGPgXxkLZOEvqsifhl05TY27VZ5oLI6UEKVpe01UGcE79ZH HApBvTxMME47i/+L3xsr3pnlQauoGHi82rAgX9FZNE70mB212ZgNuPLihdpZHyFg MXSzJ0slXhiK/q8BuJ1tNGT1xpFkgm+jZAjoEcEBev6WaHVEmLlkGtMykK8RoPg= =1+gk -----END PGP SIGNATURE----- --8gGm2U6saOVMfh0lPOuFph4WALirsS9ee--