From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33698) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7P3R-0007ON-2L for qemu-devel@nongnu.org; Fri, 11 Dec 2015 09:52:17 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1a7P3L-0001t9-3Y for qemu-devel@nongnu.org; Fri, 11 Dec 2015 09:52:16 -0500 Received: from e17.ny.us.ibm.com ([129.33.205.207]:35973) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7P3K-0001t0-Uk for qemu-devel@nongnu.org; Fri, 11 Dec 2015 09:52:11 -0500 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 11 Dec 2015 09:52:09 -0500 Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by d01dlp02.pok.ibm.com (Postfix) with ESMTP id 284636E804A for ; Fri, 11 Dec 2015 09:40:15 -0500 (EST) Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id tBBEq5v326804310 for ; Fri, 11 Dec 2015 14:52:05 GMT Received: from d01av02.pok.ibm.com (localhost [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVout) with ESMTP id tBBEq50x017949 for ; Fri, 11 Dec 2015 09:52:05 -0500 From: "Jason J. Herne" Date: Fri, 11 Dec 2015 09:52:03 -0500 Message-Id: <1449845523-22177-1-git-send-email-jjherne@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH] checkpatch: Detect newlines in error_report and other error functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: blauwirbel@gmail.com, cornelia.huck@de.ibm.com, qemu-devel@nongnu.org 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 --- 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