[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] [PATCH 1/4] error: Strip trailing '\n' from error strin
From: |
Markus Armbruster |
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 |
User-agent: |
Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) |
Eric Blake <address@hidden> 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 <address@hidden>
>> ---
>
>> +++ 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.
>> address@hidden@
>> +expression errp, eno, cls, fmt;
>> +position p;
>> +@@
>> +(
>> +error_report(fmt, ...)@p
>
> So you use Coccinelle to find error messages...
>
>> address@hidden: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 <address@hidden>
Thanks!