qemu-trivial.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Anand J <anand.indukala@gmail.com>, qemu-devel@nongnu.org
Cc: qemu-trivial@nongnu.org, thuth@redhat.com
Subject: Re: [Qemu-trivial] [Qemu-devel] [PATCH v3 1/2] scripts/clean-includes: added duplicate #include check
Date: Thu, 20 Oct 2016 11:04:21 -0500	[thread overview]
Message-ID: <bf11b091-8705-e96b-cfab-028dcb5c719b@redhat.com> (raw)
In-Reply-To: <1476978482-13108-2-git-send-email-anand.indukala@gmail.com>


[-- Attachment #1.1: Type: text/plain, Size: 2148 bytes --]

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.
> 
> 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 <thuth@redhat.com>
> Signed-off-by: Anand J <anand.indukala@gmail.com>
> ---
>  scripts/clean-includes | 54 ++++++++++++++++++++++++++++++++++++++------------
>  1 file changed, 41 insertions(+), 13 deletions(-)
> 

> +if [ "$DUPHEAD" = "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. <sys/endian.h>).  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.

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


[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 604 bytes --]

  reply	other threads:[~2016-10-20 16:04 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-10-20 15:48 [Qemu-trivial] [Qemu-devel] [PATCH v3 0/2] Script changes to find duplicate #include entries Anand J
2016-10-20 15:48 ` [Qemu-trivial] [Qemu-devel] [PATCH v3 1/2] scripts/clean-includes: added duplicate #include check Anand J
2016-10-20 16:04   ` Eric Blake [this message]
2016-10-20 15:48 ` [Qemu-trivial] [Qemu-devel] [PATCH v3 2/2] clean-up: removed duplicate #includes Anand J

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bf11b091-8705-e96b-cfab-028dcb5c719b@redhat.com \
    --to=eblake@redhat.com \
    --cc=anand.indukala@gmail.com \
    --cc=qemu-devel@nongnu.org \
    --cc=qemu-trivial@nongnu.org \
    --cc=thuth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).