From patchwork Tue Sep 17 10:22:18 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 1163294 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=kaod.org Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46Xfk0291Cz9s00 for ; Tue, 17 Sep 2019 20:39:20 +1000 (AEST) Received: from localhost ([::1]:43852 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAAtB-00057P-Uj for incoming@patchwork.ozlabs.org; Tue, 17 Sep 2019 06:39:17 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:44059) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iAAcy-00085H-3f for qemu-devel@nongnu.org; Tue, 17 Sep 2019 06:22:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iAAcx-0004Ny-00 for qemu-devel@nongnu.org; Tue, 17 Sep 2019 06:22:31 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:17940 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iAAcw-0004NM-QR for qemu-devel@nongnu.org; Tue, 17 Sep 2019 06:22:30 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x8HAHlL0103506 for ; Tue, 17 Sep 2019 06:22:30 -0400 Received: from e06smtp07.uk.ibm.com (e06smtp07.uk.ibm.com [195.75.94.103]) by mx0b-001b2d01.pphosted.com with ESMTP id 2v2tk275js-1 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=NOT) for ; Tue, 17 Sep 2019 06:22:30 -0400 Received: from localhost by e06smtp07.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 17 Sep 2019 11:22:27 +0100 Received: from b06avi18878370.portsmouth.uk.ibm.com (9.149.26.194) by e06smtp07.uk.ibm.com (192.168.101.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; (version=TLSv1/SSLv3 cipher=AES256-GCM-SHA384 bits=256/256) Tue, 17 Sep 2019 11:22:21 +0100 Received: from d06av23.portsmouth.uk.ibm.com (d06av23.portsmouth.uk.ibm.com [9.149.105.59]) by b06avi18878370.portsmouth.uk.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id x8HAMJ9e46662000 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 17 Sep 2019 10:22:19 GMT Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ACB81A4040; Tue, 17 Sep 2019 10:22:19 +0000 (GMT) Received: from d06av23.portsmouth.uk.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ABAAEA4053; Tue, 17 Sep 2019 10:22:18 +0000 (GMT) Received: from bahia.lan (unknown [9.145.22.84]) by d06av23.portsmouth.uk.ibm.com (Postfix) with ESMTP; Tue, 17 Sep 2019 10:22:18 +0000 (GMT) From: Greg Kurz To: qemu-devel@nongnu.org Date: Tue, 17 Sep 2019 12:22:18 +0200 In-Reply-To: <156871562997.196432.17776290406203122029.stgit@bahia.lan> References: <156871562997.196432.17776290406203122029.stgit@bahia.lan> User-Agent: StGit/unknown-version MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 19091710-0028-0000-0000-0000039E0F00 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 19091710-0029-0000-0000-0000246087A9 Message-Id: <156871573833.196432.7906362695920387537.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:, , definitions=2019-09-17_05:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1034 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=445 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1908290000 definitions=main-1909170106 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 17/17] checkpatch: Warn when errp is passed to error_append_hint() X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Fam Zheng , Peter Maydell , "Michael S. Tsirkin" , Jeff Cody , "Daniel P. =?utf-8?q?Berrang=C3=A9=22?= , qemu-block@nongnu.org, qemu-arm@nongnu.org, qemu-ppc@nongnu.org, qemu-s390x@nongnu.org"@d06av23.portsmouth.uk.ibm.com, Mark Cave-Ayland , Michael Roth , Gerd Hoffmann , Subbaraya Sundeep , Juan Quintela , David Hildenbrand , Markus Armbruster , Halil Pasic , Christian Borntraeger , =?utf-8?q?Marc-Andr=C3=A9?= Lureau , David Gibson , Eric Farman , "Dr. David Alan Gilbert" , Yuval Shaia , Alex Williamson , John Snow , Richard Henderson , Kevin Wolf , Cornelia Huck , Max Reitz , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Passing errp from the argument list to error_append_hint() isn't recommended because it may cause unwanted behaviours when errp is equal to &error_fatal or &error_abort. First, error_append_hint() aborts QEMU when passed either of those. Second, consider the following: void foo(Error **errp) { error_setg(errp, "foo"); error_append_hint(errp, "Try bar\n"); } error_setg() causes QEMU to exit or abort, and hints aren't added. Signed-off-by: Greg Kurz Reviewed-by: Philippe Mathieu-Daudé --- scripts/checkpatch.pl | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl index aa9a354a0e7e..17ce026282a6 100755 --- a/scripts/checkpatch.pl +++ b/scripts/checkpatch.pl @@ -2902,6 +2902,10 @@ sub process { } } + if ($line =~ /error_append_hint\(errp/) { + WARN("suspicious errp passed to error_append_hint()\n" . + $herecurr); + } # check for non-portable libc calls that have portable alternatives in QEMU if ($line =~ /\bffs\(/) { ERROR("use ctz32() instead of ffs()\n" . $herecurr);