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 <jjhe...@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