qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Eric Blake <eblake@redhat.com>
To: Markus Armbruster <armbru@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/4] error: Strip trailing '\n' from error string arguments (again)
Date: Thu, 4 Aug 2016 14:47:37 -0600	[thread overview]
Message-ID: <57A3A9E9.2050506@redhat.com> (raw)
In-Reply-To: <1470224274-31522-2-git-send-email-armbru@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 1255 bytes --]

On 08/03/2016 05:37 AM, Markus Armbruster wrote:
> Commit 9af9e0f, 6daf194d, be62a2eb and 312fd5f got rid of a bunch, but
> they keep coming back.  checkpatch.pl tries to flag them since commit
> 5d596c2, but it's not very good at it.  Offenders tracked down with
> Coccinelle script scripts/coccinelle/err-bad-newline.cocci, an updated
> version of the script from commit 312fd5f.
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---

> +++ b/scripts/coccinelle/err-bad-newline.cocci
> @@ -0,0 +1,29 @@
> +// Error messages should not contain newlines.  This script finds
> +// messages that do.  Fixing them is manual.
> +@r@
> +expression errp, eno, cls, fmt;
> +position p;
> +@@
> +(
> +error_report(fmt, ...)@p

So you use Coccinelle to find error messages...

> +@script:python@
> +fmt << r.fmt;
> +p << r.p;
> +@@
> +if "\\n" in str(fmt):
> +    print "%s:%s:%s:%s" % (p[0].file, p[0].line, p[0].column, fmt)

...and python to then parse the format string and flag violations.
Slick.  Does it still work across formats like "foo %" PRIdMAX "\n"?

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
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-08-04 20:47 UTC|newest]

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-03 11:37 [Qemu-devel] [PATCH 0/4] error: Newline fixes Markus Armbruster
2016-08-03 11:37 ` [Qemu-devel] [PATCH 1/4] error: Strip trailing '\n' from error string arguments (again) Markus Armbruster
2016-08-04 20:47   ` Eric Blake [this message]
2016-08-05  6:57     ` Markus Armbruster
2016-08-03 11:37 ` [Qemu-devel] [PATCH 2/4] checkpatch: Fix newline detection in error_setg() & friends Markus Armbruster
2016-08-04 20:49   ` Eric Blake
2016-08-03 11:37 ` [Qemu-devel] [PATCH 3/4] vfio: Use error_report() instead of error_printf() for errors Markus Armbruster
2016-08-04 20:51   ` Eric Blake
2016-08-03 11:37 ` [Qemu-devel] [PATCH 4/4] error: Fix error_printf() calls lacking newlines Markus Armbruster
2016-08-04 20:52   ` Eric Blake
2016-08-05  6:58     ` Markus Armbruster
  -- strict thread matches above, loose matches on Subject: below --
2015-12-10 17:23 [Qemu-devel] [PATCH 0/4] Error reporting cleanups Markus Armbruster
2015-12-10 17:23 ` [Qemu-devel] [PATCH 1/4] error: Strip trailing '\n' from error string arguments (again) Markus Armbruster
2015-12-10 17:31   ` Dr. David Alan Gilbert
2015-12-10 18:16   ` Cornelia Huck
2015-12-11  9:01     ` Hailiang Zhang
2015-12-11  3:09   ` Bharata B Rao
2015-12-11  5:26   ` Fam Zheng

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=57A3A9E9.2050506@redhat.com \
    --to=eblake@redhat.com \
    --cc=armbru@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /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).