From patchwork Fri Dec 11 14:52:03 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Jason J. Herne" X-Patchwork-Id: 555797 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id BF7A3140157 for ; Sat, 12 Dec 2015 01:52:34 +1100 (AEDT) Received: from localhost ([::1]:47978 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1a7P3g-0007fa-Rd for incoming@patchwork.ozlabs.org; Fri, 11 Dec 2015 09:52:32 -0500 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 d01dlp02.pok.ibm.com (9.56.250.167) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Fri, 11 Dec 2015 09:52:06 -0500 X-IBM-Helo: d01dlp02.pok.ibm.com X-IBM-MailFrom: jjherne@linux.vnet.ibm.com X-IBM-RcptTo: qemu-devel@nongnu.org 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 Received: from jason-ThinkPad-W530.ibm.com ([9.80.54.216]) by d01av02.pok.ibm.com (8.14.4/8.14.4/NCO v10.0 AVin) with ESMTP id tBBEq3Ha017849; Fri, 11 Dec 2015 09:52:04 -0500 From: "Jason J. Herne" To: blauwirbel@gmail.com, cornelia.huck@de.ibm.com, qemu-devel@nongnu.org Date: Fri, 11 Dec 2015 09:52:03 -0500 Message-Id: <1449845523-22177-1-git-send-email-jjherne@linux.vnet.ibm.com> X-Mailer: git-send-email 1.9.1 X-TM-AS-MML: disable X-Content-Scanned: Fidelis XPS MAILER x-cbid: 15121114-0041-0000-0000-000002B2E4F6 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 129.33.205.207 Cc: "Jason J. Herne" Subject: [Qemu-devel] [PATCH] checkpatch: Detect newlines in error_report and other error functions X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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);