Message ID | 1449845523-22177-1-git-send-email-jjherne@linux.vnet.ibm.com |
---|---|
State | New |
Headers | show |
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 :)
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);
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(+)