From nobody Tue Nov 4 21:46:13 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; dkim=fail; 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 Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1531122795402135.89947911991283; Mon, 9 Jul 2018 00:53:15 -0700 (PDT) Received: from localhost ([::1]:39753 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcQyr-0003SW-0H for importer@patchew.org; Mon, 09 Jul 2018 03:53:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:44343) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fcQqB-00056D-AJ for qemu-devel@nongnu.org; Mon, 09 Jul 2018 03:44:12 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fcQqA-0002HP-8Z for qemu-devel@nongnu.org; Mon, 09 Jul 2018 03:44:11 -0400 Received: from ozlabs.org ([203.11.71.1]:44799) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fcQq9-0002E4-QI; Mon, 09 Jul 2018 03:44:10 -0400 Received: by ozlabs.org (Postfix, from userid 1007) id 41PHQT3229z9s7G; Mon, 9 Jul 2018 17:44:00 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gibson.dropbear.id.au; s=201602; t=1531122241; bh=hd+Fel4FBBvWm5X/tHf38tuGGLNU5nTCwfgcP87OTUQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E/SVj4Aw41wN31URqcTSTGg8kx8VjLt9/cQkNOTEp4K/3fChWUaeUJAr9tiKu9kvx 14ygiUM/YKMhB7bX6Eoa9fNJW0AU3bz3qmps6942/jkJH/iHeS9TdOpCKrUbIXJW4/ UlS3xjgWCpxuOvmlEt89GXdgSW7AH1zj55A5snVk= From: David Gibson To: peter.maydell@linaro.org Date: Mon, 9 Jul 2018 17:43:50 +1000 Message-Id: <20180709074350.27086-17-david@gibson.dropbear.id.au> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180709074350.27086-1-david@gibson.dropbear.id.au> References: <20180709074350.27086-1-david@gibson.dropbear.id.au> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 203.11.71.1 Subject: [Qemu-devel] [PULL 16/16] sam460ex: Make sam460ex_load_device_tree() handle all errors internally 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: qemu-devel@nongnu.org, groug@kaod.org, qemu-ppc@nongnu.org, clg@kaod.org, David Gibson Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" sam460ex_load_device_tree() handles nearly all possible errors by simply exiting (within helper functions and macros). It handles two early error cases by returning an error. There's no particular point to this, so make it handle those directly as well, removing the need for the caller to handle a failure. As a bonus it gives us more specific error messages. Signed-off-by: David Gibson --- hw/ppc/sam460ex.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/hw/ppc/sam460ex.c b/hw/ppc/sam460ex.c index 8194f32cd3..e2b7028843 100644 --- a/hw/ppc/sam460ex.c +++ b/hw/ppc/sam460ex.c @@ -255,7 +255,6 @@ static int sam460ex_load_device_tree(hwaddr addr, hwaddr initrd_size, const char *kernel_cmdline) { - int ret =3D -1; uint32_t mem_reg_property[] =3D { 0, 0, cpu_to_be32(ramsize) }; char *filename; int fdt_size; @@ -266,12 +265,14 @@ static int sam460ex_load_device_tree(hwaddr addr, =20 filename =3D qemu_find_file(QEMU_FILE_TYPE_BIOS, BINARY_DEVICE_TREE_FI= LE); if (!filename) { - goto out; + error_report("Couldn't find dtb file `%s'", BINARY_DEVICE_TREE_FIL= E); + exit(1); } fdt =3D load_device_tree(filename, &fdt_size); g_free(filename); - if (fdt =3D=3D NULL) { - goto out; + if (!fdt) { + error_report("Couldn't load dtb file `%s'", filename); + exit(1); } =20 /* Manipulate device tree in memory. */ @@ -325,11 +326,8 @@ static int sam460ex_load_device_tree(hwaddr addr, =20 rom_add_blob_fixed(BINARY_DEVICE_TREE_FILE, fdt, fdt_size, addr); g_free(fdt); - ret =3D fdt_size; - -out: =20 - return ret; + return fdt_size; } =20 /* Create reset TLB entries for BookE, mapping only the flash memory. */ @@ -599,10 +597,6 @@ static void sam460ex_init(MachineState *machine) dt_size =3D sam460ex_load_device_tree(FDT_ADDR, machine->ram_size, RAMDISK_ADDR, initrd_size, machine->kernel_cmdline); - if (dt_size < 0) { - error_report("couldn't load device tree"); - exit(1); - } =20 boot_info->dt_base =3D FDT_ADDR; boot_info->dt_size =3D dt_size; --=20 2.17.1