From nobody Tue Feb 10 17:14:54 2026 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; 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 1633599661879131.5821959409725; Thu, 7 Oct 2021 02:41:01 -0700 (PDT) Received: from localhost ([::1]:33726 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1mYPtc-0002X0-DU for importer@patchew.org; Thu, 07 Oct 2021 05:41:00 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:36524) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYPnG-0007uc-R4 for qemu-devel@nongnu.org; Thu, 07 Oct 2021 05:34:27 -0400 Received: from mail.ilande.co.uk ([2001:41c9:1:41f::167]:40664 helo=mail.default.ilande.bv.iomart.io) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1mYPnB-0007zE-Kl for qemu-devel@nongnu.org; Thu, 07 Oct 2021 05:34:25 -0400 Received: from [2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1] (helo=kentang.home) by mail.default.ilande.bv.iomart.io with esmtpsa (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1mYPmw-0000tc-H5; Thu, 07 Oct 2021 10:34:10 +0100 From: Mark Cave-Ayland To: qemu-devel@nongnu.org, laurent@vivier.eu Date: Thu, 7 Oct 2021 10:33:56 +0100 Message-Id: <20211007093407.3329-3-mark.cave-ayland@ilande.co.uk> X-Mailer: git-send-email 2.20.1 In-Reply-To: <20211007093407.3329-1-mark.cave-ayland@ilande.co.uk> References: <20211007093407.3329-1-mark.cave-ayland@ilande.co.uk> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-SA-Exim-Connect-IP: 2a00:23c4:8b9d:4100:5d98:71b5:90ca:dad1 X-SA-Exim-Mail-From: mark.cave-ayland@ilande.co.uk Subject: [PATCH v3 02/13] macfb: update macfb.c to use the Error API best practices X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on mail.default.ilande.bv.iomart.io) 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; Received-SPF: pass client-ip=2001:41c9:1:41f::167; envelope-from=mark.cave-ayland@ilande.co.uk; helo=mail.default.ilande.bv.iomart.io X-Spam_score_int: -18 X-Spam_score: -1.9 X-Spam_bar: - X-Spam_report: (-1.9 / 5.0 requ) BAYES_00=-1.9, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=ham autolearn_force=no X-Spam_action: no action 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: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZM-MESSAGEID: 1633599664322100001 Content-Type: text/plain; charset="utf-8" As per the current Error API best practices, change macfb_commom_realize() = to return a boolean indicating success to reduce errp boiler-plate handling code. Not= e that memory_region_init_ram_nomigrate() is also updated to use &error_abort to i= ndicate a non-recoverable error, matching the behaviour recommended after similar discussions on memory API failures for the recent nubus changes. Signed-off-by: Mark Cave-Ayland Reviewed-by: Laurent Vivier --- hw/display/macfb.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/hw/display/macfb.c b/hw/display/macfb.c index 2b747a8de8..2ec25c5d6f 100644 --- a/hw/display/macfb.c +++ b/hw/display/macfb.c @@ -343,14 +343,14 @@ static const GraphicHwOps macfb_ops =3D { .gfx_update =3D macfb_update_display, }; =20 -static void macfb_common_realize(DeviceState *dev, MacfbState *s, Error **= errp) +static bool macfb_common_realize(DeviceState *dev, MacfbState *s, Error **= errp) { DisplaySurface *surface; =20 if (s->depth !=3D 1 && s->depth !=3D 2 && s->depth !=3D 4 && s->depth = !=3D 8 && s->depth !=3D 16 && s->depth !=3D 24) { error_setg(errp, "unknown guest depth %d", s->depth); - return; + return false; } =20 s->con =3D graphic_console_init(dev, 0, &macfb_ops, s); @@ -359,18 +359,20 @@ static void macfb_common_realize(DeviceState *dev, Ma= cfbState *s, Error **errp) if (surface_bits_per_pixel(surface) !=3D 32) { error_setg(errp, "unknown host depth %d", surface_bits_per_pixel(surface)); - return; + return false; } =20 memory_region_init_io(&s->mem_ctrl, OBJECT(dev), &macfb_ctrl_ops, s, "macfb-ctrl", 0x1000); =20 memory_region_init_ram_nomigrate(&s->mem_vram, OBJECT(s), "macfb-vram", - MACFB_VRAM_SIZE, errp); + MACFB_VRAM_SIZE, &error_abort); s->vram =3D memory_region_get_ram_ptr(&s->mem_vram); s->vram_bit_mask =3D MACFB_VRAM_SIZE - 1; vmstate_register_ram(&s->mem_vram, dev); memory_region_set_coalescing(&s->mem_vram); + + return true; } =20 static void macfb_sysbus_realize(DeviceState *dev, Error **errp) @@ -378,8 +380,7 @@ static void macfb_sysbus_realize(DeviceState *dev, Erro= r **errp) MacfbSysBusState *s =3D MACFB(dev); MacfbState *ms =3D &s->macfb; =20 - macfb_common_realize(dev, ms, errp); - if (*errp) { + if (!macfb_common_realize(dev, ms, errp)) { return; } =20 @@ -399,8 +400,7 @@ static void macfb_nubus_realize(DeviceState *dev, Error= **errp) return; } =20 - macfb_common_realize(dev, ms, errp); - if (*errp) { + if (!macfb_common_realize(dev, ms, errp)) { return; } =20 --=20 2.20.1