From nobody Tue Feb 10 21:39:57 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org ARC-Seal: i=1; a=rsa-sha256; t=1586196572; cv=none; d=zohomail.com; s=zohoarc; b=KdM2stc3M9RFKxn/yCQdGaGpQMnvEs4PYYmZ6Xh5JJE2o1dsJ4mgCgb0xFsRIobidgIl3PEIB5fxeCinJC1qpdouVwKra2vMhVlvJbGMrCRwgTfbCBc3cKNwl845nKhd7ATYPYSK2bpEVn60ATk2l6+OcwLAQgBeMqlX8wEhpxU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1586196572; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=YhVPUQsfht6jA/IUTaj+buf6eqXAxfk/bBYv1XmJLk4=; b=InMl9xdhp39NRPY3MHISSp1p3okWieeumo16w9nz+WxkTlQjXw+8pZKW6BCMkh0amOsVd9uudGIpNjpNTh6PCsayUeIqKxDvafu8xAt9F7NZeE3aGLKo2Nw7DJghZmBdHVbvZfm4zEYNEKkymO9xazwz7m+qwe6xdUoJyxd761A= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1586196572507475.8633411152198; Mon, 6 Apr 2020 11:09:32 -0700 (PDT) Received: from localhost ([::1]:36278 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLWBf-0006GX-9B for importer@patchew.org; Mon, 06 Apr 2020 14:09:31 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36354) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1jLVrD-0002FC-R0 for qemu-devel@nongnu.org; Mon, 06 Apr 2020 13:48:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1jLVrB-00037s-MD for qemu-devel@nongnu.org; Mon, 06 Apr 2020 13:48:23 -0400 Received: from mail-wm1-x329.google.com ([2a00:1450:4864:20::329]:40470) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1jLVrB-00037R-GR for qemu-devel@nongnu.org; Mon, 06 Apr 2020 13:48:21 -0400 Received: by mail-wm1-x329.google.com with SMTP id a81so298429wmf.5 for ; Mon, 06 Apr 2020 10:48:21 -0700 (PDT) Received: from x1w.redhat.com (116.red-83-42-57.dynamicip.rima-tde.net. [83.42.57.116]) by smtp.gmail.com with ESMTPSA id a67sm364880wmc.30.2020.04.06.10.48.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 06 Apr 2020 10:48:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YhVPUQsfht6jA/IUTaj+buf6eqXAxfk/bBYv1XmJLk4=; b=ok4WPrVUixwIKypERf9YDPnea3W9Jvy7sanmZCZ+u9uMZMV0TH+h1feoKfAQYSCia8 aKVETMkgPqRtKV8RFGFlosxY5dcheaR53J56AWxRC+WN8A2DzL6MTUDRuuMODdrknKxK bkXjAganl6WsOl5iBU3GAo2UTdCjldIL9JyeYnAdSoKtfpDVoQHIv9HGCfqJa0pL4MJC di1OSYsrTpiRA3X91/YG7grAFgRt4Ocxk4utXW4ouE/YOrZs/ujnjPs7o5WYSfHRanD9 0JX2VpHs8JBQ/kzOLblGZ4T0vl8nH9zO8XN4QGAU4pnURoHNxmrmuNxEaVdtzWAcd40y xoNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references:mime-version:content-transfer-encoding; bh=YhVPUQsfht6jA/IUTaj+buf6eqXAxfk/bBYv1XmJLk4=; b=XoTDMhSTbm/02aSi04JEye4G4VXFWMOTjXquHkIK80FCTVBSNl2Fc19espPZAQ3g8e 3HUejHi4IvD9Gp9vbSeEOw3vHNdXLNLn6aQHPJ3fd14kqOVzzlGlsyJ22cMElBwRyqFO /eCdhZo+Wqy0aZnelAUHtQc0N0VMxto/QkRwOhpsNOq1TwoD9tmFh7o4lFp5xLBOhciF S6sElYLcana5yf+B4PE7ML+BIag8ld8lLR/QUnz90OKImy5BTqIWkGB9b2RPELSsc8le oV/QnEow+kLEjW6ECbYvE3nS9Y0/U/BdfFtaR3jt29eLNKkj6Zt+bQU4uPx6faQlprpI F12Q== X-Gm-Message-State: AGi0PubeyU5zwUG3WHhtwqdD2blOBR9NRKSeRTW4X/320flWE3JS2xuX MocstZZTa0j0gB4iRbrXCgPxjN+NPNg= X-Google-Smtp-Source: APiQypIiSUddRW6GrDP1x9LqwJu4HPIC+MyntKbNyZdQRmc6Zn7xN1OrxmXLbGwi5yjCUEDF0VqzBQ== X-Received: by 2002:a1c:4d13:: with SMTP id o19mr205798wmh.82.1586195300185; Mon, 06 Apr 2020 10:48:20 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: qemu-devel@nongnu.org, Markus Armbruster Subject: [PATCH-for-5.1 v2 25/54] scripts/coccinelle: Catch missing error_propagate() calls in realize() Date: Mon, 6 Apr 2020 19:47:14 +0200 Message-Id: <20200406174743.16956-26-f4bug@amsat.org> X-Mailer: git-send-email 2.21.1 In-Reply-To: <20200406174743.16956-1-f4bug@amsat.org> References: <20200406174743.16956-1-f4bug@amsat.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::329 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: Peter Maydell , Vladimir Sementsov-Ogievskiy , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) In some DeviceClass::realize() while we can propagate errors to the caller, we forgot to do so. Add a Coccinelle patch to automatically add the missing code. Inspired-by: Peter Maydell Signed-off-by: Philippe Mathieu-Daud=C3=A9 --- .../use-error_propagate-in-realize.cocci | 54 +++++++++++++++++++ MAINTAINERS | 1 + 2 files changed, 55 insertions(+) create mode 100644 scripts/coccinelle/use-error_propagate-in-realize.cocci diff --git a/scripts/coccinelle/use-error_propagate-in-realize.cocci b/scri= pts/coccinelle/use-error_propagate-in-realize.cocci new file mode 100644 index 0000000000..7b59277a50 --- /dev/null +++ b/scripts/coccinelle/use-error_propagate-in-realize.cocci @@ -0,0 +1,54 @@ +// Add missing error-propagation code in DeviceClass::realize() +// +// Copyright: (C) 2020 Philippe Mathieu-Daud=C3=A9 +// This work is licensed under the terms of the GNU GPLv2 or later. +// +// spatch \ +// --macro-file scripts/cocci-macro-file.h --include-headers \ +// --sp-file scripts/coccinelle/use-error_abort-in-instance_init.cocci \ +// --keep-comments --timeout 60 --in-place +// +// Inspired by https://www.mail-archive.com/qemu-devel@nongnu.org/msg69163= 8.html + + +@ match_class_init @ +TypeInfo info; +identifier class_initfn; +@@ + info.class_init =3D class_initfn; + + +@ match_realize @ +identifier match_class_init.class_initfn; +DeviceClass *dc; +identifier realizefn; +@@ +void class_initfn(...) +{ + ... + dc->realize =3D realizefn; + ... +} + + +@ propagate_in_realize @ +identifier match_realize.realizefn; +identifier err; +identifier errp; +identifier func_with_errp; +symbol error_abort, error_fatal; +@@ +void realizefn(..., Error **errp) +{ + ... + Error *err =3D NULL; + <+... + func_with_errp(..., +- \(&error_abort\|&error_fatal\)); ++ &err); ++ if (err) { ++ error_propagate(errp, err); ++ return; ++ } + ...+> +} diff --git a/MAINTAINERS b/MAINTAINERS index d06ffeddd5..7b58f02efb 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -2059,6 +2059,7 @@ F: scripts/coccinelle/error_propagate_null.cocci F: scripts/coccinelle/remove_local_err.cocci F: scripts/coccinelle/simplify-init-realize-error_propagate.cocci F: scripts/coccinelle/use-error_fatal.cocci +F: scripts/coccinelle/use-error_propagate-in-realize.cocci =20 GDB stub M: Alex Benn=C3=A9e --=20 2.21.1