qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] checkpatch: Detect newlines in error_report and other error functions
@ 2015-12-11 14:52 Jason J. Herne
  2015-12-11 18:31 ` Jason J. Herne
  0 siblings, 1 reply; 2+ messages in thread
From: Jason J. Herne @ 2015-12-11 14:52 UTC (permalink / raw)
  To: blauwirbel, cornelia.huck, qemu-devel; +Cc: Jason J. Herne

We don't want newlines embedded in error messages. This seems to be a common
problem with new code so let's try to catch it with checkpatch.

This does not catch the newline when it is in a multiline statement. This is
quite a bit more difficult and can be handled as follow on work.

Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
---
 scripts/checkpatch.pl | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index b0f6e11..476ac13 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2511,6 +2511,22 @@ sub process {
 			WARN("use QEMU instead of Qemu or QEmu\n" . $herecurr);
 		}
 
+# Qemu error function tests
+# FIXME: This does not work for multiline statements
+	my $qemu_error_funcs = qr{error_setg|
+				error_setg_errno|
+				error_setg_win32|
+				error_set|
+				error_vprintf|
+				error_printf|
+				error_printf_unless_qmp|
+				error_vreport|
+				error_report}x;
+
+	if ($rawline =~ /\b(?:$qemu_error_funcs)\s*\(\s*\".*\\n/) {
+		WARN("Error function text should not contain newlines\n" . $herecurr);
+	}
+
 # check for non-portable ffs() calls that have portable alternatives in QEMU
 		if ($line =~ /\bffs\(/) {
 			ERROR("use ctz32() instead of ffs()\n" . $herecurr);
-- 
1.9.1

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [Qemu-devel] [PATCH] checkpatch: Detect newlines in error_report and other error functions
  2015-12-11 14:52 [Qemu-devel] [PATCH] checkpatch: Detect newlines in error_report and other error functions Jason J. Herne
@ 2015-12-11 18:31 ` Jason J. Herne
  0 siblings, 0 replies; 2+ messages in thread
From: Jason J. Herne @ 2015-12-11 18:31 UTC (permalink / raw)
  To: blauwirbel, cornelia.huck, qemu-devel

On 12/11/2015 09:52 AM, Jason J. Herne wrote:
> We don't want newlines embedded in error messages. This seems to be a common
> problem with new code so let's try to catch it with checkpatch.
>
> This does not catch the newline when it is in a multiline statement. This is
> quite a bit more difficult and can be handled as follow on work.
>
> Signed-off-by: Jason J. Herne <jjherne@linux.vnet.ibm.com>
> ...

Ignore this one, I found some time to write up a better version that 
handles the most common multi-line cases. See v2. Sorry for the spam :)

-- 
-- Jason J. Herne (jjherne@linux.vnet.ibm.com)

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2015-12-11 18:32 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-12-11 14:52 [Qemu-devel] [PATCH] checkpatch: Detect newlines in error_report and other error functions Jason J. Herne
2015-12-11 18:31 ` Jason J. Herne

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).