All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 1/4] error: Strip trailing '\n' from error string arguments (again)
Date: Fri, 05 Aug 2016 08:57:19 +0200	[thread overview]
Message-ID: <87oa577lf4.fsf@dusky.pond.sub.org> (raw)
In-Reply-To: <57A3A9E9.2050506@redhat.com> (Eric Blake's message of "Thu, 4 Aug 2016 14:47:37 -0600")

Eric Blake <eblake@redhat.com> writes:

> 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"?

Testing... yes, it does.

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

Thanks!

  reply	other threads:[~2016-08-05  6:57 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
2016-08-05  6:57     ` Markus Armbruster [this message]
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=87oa577lf4.fsf@dusky.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=eblake@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.