From nobody Thu Nov 6 10:20:08 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1540211967746565.6174957658129; Mon, 22 Oct 2018 05:39:27 -0700 (PDT) Received: from localhost ([::1]:34777 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEZUO-0006Zl-7o for importer@patchew.org; Mon, 22 Oct 2018 08:39:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:37963) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gEZPb-0002Gu-Aq for qemu-devel@nongnu.org; Mon, 22 Oct 2018 08:34:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gEZPV-0002uG-U2 for qemu-devel@nongnu.org; Mon, 22 Oct 2018 08:34:21 -0400 Received: from mx1.redhat.com ([209.132.183.28]:45250) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gEZPV-0002tA-Ho for qemu-devel@nongnu.org; Mon, 22 Oct 2018 08:34:17 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2D3D57F6A8; Mon, 22 Oct 2018 12:34:16 +0000 (UTC) Received: from blackfin.pond.sub.org (ovpn-117-34.ams2.redhat.com [10.36.117.34]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C26545B089; Mon, 22 Oct 2018 12:34:15 +0000 (UTC) Received: by blackfin.pond.sub.org (Postfix, from userid 1000) id E26641132F35; Mon, 22 Oct 2018 14:34:13 +0200 (CEST) From: Markus Armbruster To: qemu-devel@nongnu.org Date: Mon, 22 Oct 2018 14:33:37 +0200 Message-Id: <20181022123413.28044-5-armbru@redhat.com> In-Reply-To: <20181022123413.28044-1-armbru@redhat.com> References: <20181022123413.28044-1-armbru@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 22 Oct 2018 12:34:16 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 04/40] Use error_fatal to simplify obvious fatal errors (again) X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Paolo Bonzini , Alexander Graf , David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RDMRC_1 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Add a slight improvement of the Coccinelle semantic patch from commit 007b06578ab, and use it to clean up. It leaves dead Error * variables behind, cleaned up manually. Cc: David Gibson Cc: Alexander Graf Cc: Eric Blake Cc: Paolo Bonzini Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Acked-by: David Gibson Message-Id: <20181017082702.5581-3-armbru@redhat.com> --- hw/intc/xics_kvm.c | 7 +------ qemu-nbd.c | 6 +----- scripts/coccinelle/use-error_fatal.cocci | 20 ++++++++++++++++++++ vl.c | 7 +------ 4 files changed, 23 insertions(+), 17 deletions(-) create mode 100644 scripts/coccinelle/use-error_fatal.cocci diff --git a/hw/intc/xics_kvm.c b/hw/intc/xics_kvm.c index 30c3769a20..e8fa9a53ae 100644 --- a/hw/intc/xics_kvm.c +++ b/hw/intc/xics_kvm.c @@ -198,17 +198,12 @@ static void ics_get_kvm_state(ICSState *ics) { uint64_t state; int i; - Error *local_err =3D NULL; =20 for (i =3D 0; i < ics->nr_irqs; i++) { ICSIRQState *irq =3D &ics->irqs[i]; =20 kvm_device_access(kernel_xics_fd, KVM_DEV_XICS_GRP_SOURCES, - i + ics->offset, &state, false, &local_err); - if (local_err) { - error_report_err(local_err); - exit(1); - } + i + ics->offset, &state, false, &error_fatal); =20 irq->server =3D state & KVM_XICS_DESTINATION_MASK; irq->saved_priority =3D (state >> KVM_XICS_PRIORITY_SHIFT) diff --git a/qemu-nbd.c b/qemu-nbd.c index e76fe3082a..7874bc973c 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -1002,11 +1002,7 @@ int main(int argc, char **argv) } =20 exp =3D nbd_export_new(bs, dev_offset, fd_size, nbdflags, nbd_export_c= losed, - writethrough, NULL, &local_err); - if (!exp) { - error_report_err(local_err); - exit(EXIT_FAILURE); - } + writethrough, NULL, &error_fatal); nbd_export_set_name(exp, export_name); nbd_export_set_description(exp, export_description); =20 diff --git a/scripts/coccinelle/use-error_fatal.cocci b/scripts/coccinelle/= use-error_fatal.cocci new file mode 100644 index 0000000000..10fff0aec4 --- /dev/null +++ b/scripts/coccinelle/use-error_fatal.cocci @@ -0,0 +1,20 @@ +@@ +type T; +identifier FUN, RET; +expression list ARGS; +expression ERR, EC, FAIL; +@@ +( +- T RET =3D FUN(ARGS, &ERR); ++ T RET =3D FUN(ARGS, &error_fatal); +| +- RET =3D FUN(ARGS, &ERR); ++ RET =3D FUN(ARGS, &error_fatal); +| +- FUN(ARGS, &ERR); ++ FUN(ARGS, &error_fatal); +) +- if (FAIL) { +- error_report_err(ERR); +- exit(EC); +- } diff --git a/vl.c b/vl.c index 61305b5891..db83cfe2e9 100644 --- a/vl.c +++ b/vl.c @@ -2002,15 +2002,10 @@ static void select_vgahw(const char *p) =20 static void parse_display_qapi(const char *optarg) { - Error *err =3D NULL; DisplayOptions *opts; Visitor *v; =20 - v =3D qobject_input_visitor_new_str(optarg, "type", &err); - if (!v) { - error_report_err(err); - exit(1); - } + v =3D qobject_input_visitor_new_str(optarg, "type", &error_fatal); =20 visit_type_DisplayOptions(v, NULL, &opts, &error_fatal); QAPI_CLONE_MEMBERS(DisplayOptions, &dpy, opts); --=20 2.17.2