From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:43239) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVZ4S-0005tK-48 for qemu-devel@nongnu.org; Fri, 05 Aug 2016 02:57:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bVZ4N-0004HC-Vd for qemu-devel@nongnu.org; Fri, 05 Aug 2016 02:57:27 -0400 Received: from mx1.redhat.com ([209.132.183.28]:57344) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bVZ4N-0004H7-Pw for qemu-devel@nongnu.org; Fri, 05 Aug 2016 02:57:23 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6AFA585A06 for ; Fri, 5 Aug 2016 06:57:22 +0000 (UTC) From: Markus Armbruster References: <1470224274-31522-1-git-send-email-armbru@redhat.com> <1470224274-31522-2-git-send-email-armbru@redhat.com> <57A3A9E9.2050506@redhat.com> Date: Fri, 05 Aug 2016 08:57:19 +0200 In-Reply-To: <57A3A9E9.2050506@redhat.com> (Eric Blake's message of "Thu, 4 Aug 2016 14:47:37 -0600") Message-ID: <87oa577lf4.fsf@dusky.pond.sub.org> MIME-Version: 1.0 Content-Type: text/plain Subject: Re: [Qemu-devel] [PATCH 1/4] error: Strip trailing '\n' from error string arguments (again) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Blake Cc: qemu-devel@nongnu.org Eric Blake 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 >> --- > >> +++ 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 Thanks!