From nobody Mon May 6 08:53:41 2024 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529581335608563.0664778261253; Thu, 21 Jun 2018 04:42:15 -0700 (PDT) Received: from localhost ([::1]:54644 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVxyc-0000l0-MC for importer@patchew.org; Thu, 21 Jun 2018 07:42:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVxwx-0008GV-BP for qemu-devel@nongnu.org; Thu, 21 Jun 2018 07:40:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVxww-0004Gp-A6 for qemu-devel@nongnu.org; Thu, 21 Jun 2018 07:40:27 -0400 Received: from mail-qt0-x243.google.com ([2607:f8b0:400d:c0d::243]:44990) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fVxww-0004Gh-3v; Thu, 21 Jun 2018 07:40:26 -0400 Received: by mail-qt0-x243.google.com with SMTP id x5-v6so1761758qte.11; Thu, 21 Jun 2018 04:40:25 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id o25-v6sm2690685qtp.72.2018.06.21.04.40.22 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jun 2018 04:40:25 -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=jaWdFZsaQ82hsmTt8wZLeSqOJKO8Dw6mbuu7zloy5MQ=; b=Zz5zVq8jK6TYp86D3yYhav2XhKL2CDEqdNwEyFl6JQxdOOGHXawQHdJN56AY9wlXTE 4ruxa6zeavQFOElZ2Rr+uOZwP6zdYLCThZEZ7tnnCx5d/Gp7fdJVaWsBVNBLGDDfHFpg f3B2oC7EWaJ9teDrRhriUno20oc8xnN15lV7O+Y7CD4mZYu01O/EQ2Uh/q9Nv9uzwomn 90aPC7kYFNxpM8E8Vv8WCpWYs9X2WsB2gdPcAqSdzxLiYRiKVD4K0Hms7cf3AdhUprsR jGGBeG3lubrax6l73VcNOJX4SLtpeeL/lI6ZXl4ZEETYKLUNKAWuGwjVJJKFAHnR+tJm 7Mpg== 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=jaWdFZsaQ82hsmTt8wZLeSqOJKO8Dw6mbuu7zloy5MQ=; b=cM7++IycFwVUxNAkQerRaC8sVPHvwklcPE/ikafAp9I3r1jPUKfE3ENIhS4Ww0+TuR Dean4CcqciNZWRFlQGjokNeeS29ObJf7HI39NmHhzUA/mxU8l2RxxXGIamwUfciGA14I yzmUHoe7YTtUeBZKf6qVAdFgHGij9brveKvNzkzWbiMp4xZ+Aj4lPXtz2cqCoIgDUf6b PzylGJ5D49v6kOQuEcRv9XWoU+8pLoNcyGNMhE5/Tj8I8R4mWaT802Xbs9HvaeAtsrlP n8gd0Wdd6zN0GDxygpSEtSDfGxaFNtUBMfp0hVg7q6bpqJSwznYtBLBAjDzSvjHwuTN5 u2Pw== X-Gm-Message-State: APt69E18jFijyVDvDNA+to3ZtoK8sRS8D/GddDnMi7RyI3U5WAPauhH0 XLbJDjCKQ5zNJ+4mx5Vu+ts= X-Google-Smtp-Source: ADUXVKIT4SPo+aDa0kZrXdmsk0dw7KId71Dt9CkpOq3oaHaxhuBJNNZpck58mI25Cm9szwb6obiWpA== X-Received: by 2002:ac8:503:: with SMTP id u3-v6mr23240212qtg.114.1529581225517; Thu, 21 Jun 2018 04:40:25 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Markus Armbruster Date: Thu, 21 Jun 2018 08:40:13 -0300 Message-Id: <20180621114015.9207-2-f4bug@amsat.org> X-Mailer: git-send-email 2.18.0.rc2 In-Reply-To: <20180621114015.9207-1-f4bug@amsat.org> References: <20180621114015.9207-1-f4bug@amsat.org> MIME-Version: 1.0 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: 2607:f8b0:400d:c0d::243 Subject: [Qemu-devel] [PATCH v3 1/3] hw/block/fdc: Replace error_setg(&error_abort) by assert() 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: Kevin Wolf , qemu-block@nongnu.org, qemu-devel@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , Max Reitz , John Snow 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 Use assert() instead of error_setg(&error_abort), as suggested by the "qapi/error.h" documentation: Please don't error_setg(&error_fatal, ...), use error_report() and exit(), because that's more obvious. Likewise, don't error_setg(&error_abort, ...), use assert(). Signed-off-by: Philippe Mathieu-Daud=C3=A9 Acked-by: John Snow --- hw/block/fdc.c | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/hw/block/fdc.c b/hw/block/fdc.c index cd29e27d8f..7c1c57f57f 100644 --- a/hw/block/fdc.c +++ b/hw/block/fdc.c @@ -396,16 +396,9 @@ static int pick_geometry(FDrive *drv) nb_sectors, FloppyDriveType_str(parse->drive)); } + assert(type_match !=3D -1 && "misconfigured fd_format"); match =3D type_match; } - - /* No match of any kind found -- fd_format is misconfigured, abort. */ - if (match =3D=3D -1) { - error_setg(&error_abort, "No candidate geometries present in table= " - " for floppy drive type '%s'", - FloppyDriveType_str(drv->drive)); - } - parse =3D &(fd_formats[match]); =20 out: --=20 2.18.0.rc2 From nobody Mon May 6 08:53:41 2024 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529581335976190.25865767576977; Thu, 21 Jun 2018 04:42:15 -0700 (PDT) Received: from localhost ([::1]:54645 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVxyh-0000o0-3b for importer@patchew.org; Thu, 21 Jun 2018 07:42:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40219) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVxx0-0008Hn-EC for qemu-devel@nongnu.org; Thu, 21 Jun 2018 07:40:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVxwz-0004Hl-8F for qemu-devel@nongnu.org; Thu, 21 Jun 2018 07:40:30 -0400 Received: from mail-qt0-x235.google.com ([2607:f8b0:400d:c0d::235]:46504) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fVxwy-0004HU-O4; Thu, 21 Jun 2018 07:40:28 -0400 Received: by mail-qt0-x235.google.com with SMTP id h5-v6so2456891qtm.13; Thu, 21 Jun 2018 04:40:28 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id o25-v6sm2690685qtp.72.2018.06.21.04.40.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jun 2018 04:40:27 -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=9xbGZU664IWw07LPfqy0VDg31c0I7uUxClHcwzVk6Kk=; b=DyS23ZVl1/Axn0ORQ0H8FUJWHjlM0uhs/1aiwf+TpvwT/7peyD+IH9we37mMIOjDIC DylH8hlmfJSdzeCasRVMwahIT2gESnJkZBr1uELIsz9th3yLLGwbvPv9oUVs40DisNNC HQq0TZ/aGXJV460TrUy6jxSHFsD9ExJxgVq+nuo9Hz2QNxQpK0Su9AoAmDB+NV+nPyXR hlGx4ZxgQcO/z3G18iZ8mCmF1wnJf4GU+EvrWhDrgpY2r1RnXee0YZAq0U0MJTcjEmRs ZmvN2CdFaSQSqNAxHNL8+vrloGMGHApTBJWmEUv9HPlN8ui3ez0AdcfESTOZWcMH5f/+ xoMQ== 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=9xbGZU664IWw07LPfqy0VDg31c0I7uUxClHcwzVk6Kk=; b=PjYJ40Gk8WvY0CMyZ7I4XT3Crl1JGyGbyZn8ZL0hiUU/HabX5ZxbZk0PobIGVQbxOR xwbCKBwBeTef3f343WlW1rM3sD0sAchCgsE7VpdQ6uK6rswmNoPceBPlyE5zNHnYxYvr MFhWlE8tVvYqC7dCcnHkgTRlhfELgdUUBH9EVM5J6g6Z0108aRwDchCdSDdA9cBBHsuR RXCQtKCBfxX60SqiLuNOMDmqdyOmrC1oUv/JnYkIe5dPjhSAUciEkdXXHrUPTefgTCZr UJA9dfH92zQbzlR44KKsHSJCOIonMUH5E1wffNcAo0EL6hNhMWaroIa9bEoklsJy6hPQ rZfg== X-Gm-Message-State: APt69E14W7awN5HWON57BUSmvrWuLHytJ0OEjXvXPfULVWW2E3lm+H4N 4522/NN6sj+B+bv+141GQX0= X-Google-Smtp-Source: ADUXVKLnZpo+EsjU0JI60oiSZsC38gTGWFFvatZE4r5M+weRrQy8Yfzp9Z1DFS3j/4JXkLpYPgN8sQ== X-Received: by 2002:aed:359d:: with SMTP id c29-v6mr21907185qte.240.1529581228165; Thu, 21 Jun 2018 04:40:28 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Markus Armbruster Date: Thu, 21 Jun 2018 08:40:14 -0300 Message-Id: <20180621114015.9207-3-f4bug@amsat.org> X-Mailer: git-send-email 2.18.0.rc2 In-Reply-To: <20180621114015.9207-1-f4bug@amsat.org> References: <20180621114015.9207-1-f4bug@amsat.org> MIME-Version: 1.0 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: 2607:f8b0:400d:c0d::235 Subject: [Qemu-devel] [PATCH v3 2/3] hw/arm/sysbus-fdt: Replace error_setg(&error_fatal) by error_report() + exit() 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: Peter Maydell , qemu-arm@nongnu.org, =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , qemu-devel@nongnu.org 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 Use error_report() + exit() instead of error_setg(&error_fatal), as suggested by the "qapi/error.h" documentation: Please don't error_setg(&error_fatal, ...), use error_report() and exit(), because that's more obvious. This fixes CID 1352173: "Passing null pointer dt_name to qemu_fdt_node_path, which dereferences= it." And this also fixes: hw/arm/sysbus-fdt.c:322:9: warning: Array access (from variable 'node_p= ath') results in a null pointer dereference if (node_path[1]) { ^~~~~~~~~~~~ Fixes: Coverity CID 1352173 (Dereference after null check) Suggested-by: Eric Blake Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Markus Armbruster --- hw/arm/sysbus-fdt.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/hw/arm/sysbus-fdt.c b/hw/arm/sysbus-fdt.c index 277ed872e7..63b74a353e 100644 --- a/hw/arm/sysbus-fdt.c +++ b/hw/arm/sysbus-fdt.c @@ -92,7 +92,7 @@ static void copy_properties_from_host(HostProperty *props= , int nb_props, r =3D qemu_fdt_getprop(host_fdt, node_path, props[i].name, &prop_len, - props[i].optional ? &err : &error_fatal); + &err); if (r) { qemu_fdt_setprop(guest_fdt, nodename, props[i].name, r, prop_len); @@ -103,6 +103,10 @@ static void copy_properties_from_host(HostProperty *pr= ops, int nb_props, } else { error_free(err); } + if (!props[i].optional) { + /* mandatory property not found: bail out */ + exit(1); + } } } } @@ -138,9 +142,9 @@ static void fdt_build_clock_node(void *host_fdt, void *= guest_fdt, =20 node_offset =3D fdt_node_offset_by_phandle(host_fdt, host_phandle); if (node_offset <=3D 0) { - error_setg(&error_fatal, - "not able to locate clock handle %d in host device tree= ", - host_phandle); + error_report("not able to locate clock handle %d in host device tr= ee", + host_phandle); + exit(1); } node_path =3D g_malloc(path_len); while ((ret =3D fdt_get_path(host_fdt, node_offset, node_path, path_le= n)) @@ -149,16 +153,16 @@ static void fdt_build_clock_node(void *host_fdt, void= *guest_fdt, node_path =3D g_realloc(node_path, path_len); } if (ret < 0) { - error_setg(&error_fatal, - "not able to retrieve node path for clock handle %d", - host_phandle); + error_report("not able to retrieve node path for clock handle %d", + host_phandle); + exit(1); } =20 r =3D qemu_fdt_getprop(host_fdt, node_path, "compatible", &prop_len, &error_fatal); if (strcmp(r, "fixed-clock")) { - error_setg(&error_fatal, - "clock handle %d is not a fixed clock", host_phandle); + error_report("clock handle %d is not a fixed clock", host_phandle); + exit(1); } =20 nodename =3D strrchr(node_path, '/'); @@ -301,34 +305,37 @@ static int add_amd_xgbe_fdt_node(SysBusDevice *sbdev,= void *opaque) =20 dt_name =3D sysfs_to_dt_name(vbasedev->name); if (!dt_name) { - error_setg(&error_fatal, "%s incorrect sysfs device name %s", - __func__, vbasedev->name); + error_report("%s incorrect sysfs device name %s", + __func__, vbasedev->name); + exit(1); } node_path =3D qemu_fdt_node_path(host_fdt, dt_name, vdev->compat, &error_fatal); if (!node_path || !node_path[0]) { - error_setg(&error_fatal, "%s unable to retrieve node path for %s/%= s", - __func__, dt_name, vdev->compat); + error_report("%s unable to retrieve node path for %s/%s", + __func__, dt_name, vdev->compat); + exit(1); } =20 if (node_path[1]) { - error_setg(&error_fatal, "%s more than one node matching %s/%s!", - __func__, dt_name, vdev->compat); + error_report("%s more than one node matching %s/%s!", + __func__, dt_name, vdev->compat); + exit(1); } =20 g_free(dt_name); =20 if (vbasedev->num_regions !=3D 5) { - error_setg(&error_fatal, "%s Does the host dt node combine XGBE/PH= Y?", - __func__); + error_report("%s Does the host dt node combine XGBE/PHY?", __func_= _); + exit(1); } =20 /* generate nodes for DMA_CLK and PTP_CLK */ r =3D qemu_fdt_getprop(host_fdt, node_path[0], "clocks", &prop_len, &error_fatal); if (prop_len !=3D 8) { - error_setg(&error_fatal, "%s clocks property should contain 2 hand= les", - __func__); + error_report("%s clocks property should contain 2 handles", __func= __); + exit(1); } host_clock_phandles =3D (uint32_t *)r; guest_clock_phandles[0] =3D qemu_fdt_alloc_phandle(guest_fdt); --=20 2.18.0.rc2 From nobody Mon May 6 08:53:41 2024 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 (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1529581504895267.1743123872674; Thu, 21 Jun 2018 04:45:04 -0700 (PDT) Received: from localhost ([::1]:54659 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVy1Q-0002rT-6G for importer@patchew.org; Thu, 21 Jun 2018 07:45:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:40240) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVxx2-0008Jl-PF for qemu-devel@nongnu.org; Thu, 21 Jun 2018 07:40:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fVxx1-0004Ia-M1 for qemu-devel@nongnu.org; Thu, 21 Jun 2018 07:40:32 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:42574) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fVxx1-0004IQ-Gb for qemu-devel@nongnu.org; Thu, 21 Jun 2018 07:40:31 -0400 Received: by mail-qk0-x241.google.com with SMTP id j80-v6so1513842qke.9 for ; Thu, 21 Jun 2018 04:40:31 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id o25-v6sm2690685qtp.72.2018.06.21.04.40.28 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 21 Jun 2018 04:40:30 -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=oo+ID43d/uHEVnF7x+sEvWN4/tB92N49wnFDRMbzNHY=; b=Z/M7RKB+o2FbV4oyeOLfDweDl6Av1fzJZFoxnTNi6MjBQGCPh+Mu6rQw/ii9gtmOpZ xk+PIPuojL5gtQU+paMlc0aPi5xbGuI5icCrhiS69OsHSjcEXg5FwhheE7/pMW8HA6QX sdBK2g3IRS8hjOslGx/UdBZ9HaRpYkcyfhdsVUX0gmtJ4p2GM795E08rCU1wTMUzQfHc PTwqzszHtCgH5LZpwdabPYnzvSoNtXwV90tyWetCXudJ0c2Y0zIQScpdUZV8yD1DAAZE 6kh+9z/HcSIRd3ordQ49R/x2rZYaP9MFYYXvgfxTOhCKKTnI9cmw727Ud/y+N+31PVMH FDug== 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=oo+ID43d/uHEVnF7x+sEvWN4/tB92N49wnFDRMbzNHY=; b=DE8A0h5yxjbY1IW5BWTPgMbLgioDhmjD3kTW4AGt83KxYcs2pFRvIi2Ks0tAISHiry SGcBtKxnqZD6bjbudAeXq59jCcLkmT2pK+ss5HV+G8qab9t0LrWmPaZw1Depg08uzmYx WvDRdS5lnu08PiKyCjKvtCPGWn4Y6JnxKdtm8jXOsfLxfI9rRFzk6LCM/Jc9c9QJ5yxs OJ52zNMVaEDocS4fYYfNTTPovqav3+XI0QlOtcpg01cQdj0W+irBrYLSSrlycH9IoC+p 282pKrZ58PjALyeQ0eHm6cegtChUPz09NQnqXwZqEl38UNGvB4TZ3ozx0KxyedMVeZtF fDWg== X-Gm-Message-State: APt69E1kdPeyeoIIbMMii/cTYx2SExUSReTaQz409bM7WimGiAm4P+OU nx+ea1TjyLMZN3MkMETQYjc= X-Google-Smtp-Source: ADUXVKKF6TQfQNUxJKBkRl+CrW9qJlYKslNK/tOkqCtVifn5TWECNxpYTESCEPEBxiLgt8/+yKtoaw== X-Received: by 2002:a37:c350:: with SMTP id a77-v6mr20748675qkj.252.1529581230963; Thu, 21 Jun 2018 04:40:30 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Markus Armbruster Date: Thu, 21 Jun 2018 08:40:15 -0300 Message-Id: <20180621114015.9207-4-f4bug@amsat.org> X-Mailer: git-send-email 2.18.0.rc2 In-Reply-To: <20180621114015.9207-1-f4bug@amsat.org> References: <20180621114015.9207-1-f4bug@amsat.org> MIME-Version: 1.0 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: 2607:f8b0:400d:c09::241 Subject: [Qemu-devel] [PATCH v3 3/3] device_tree: Replace error_setg(&error_fatal) by error_report() + exit() 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: Peter Crosthwaite , qemu-devel@nongnu.org, Alexander Graf , =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= , 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 Use error_report() + exit() instead of error_setg(&error_fatal), as suggested by the "qapi/error.h" documentation: Please don't error_setg(&error_fatal, ...), use error_report() and exit(), because that's more obvious. Signed-off-by: Philippe Mathieu-Daud=C3=A9 Reviewed-by: Eric Auger Reviewed-by: Markus Armbruster Reviewed-by: David Gibson --- device_tree.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/device_tree.c b/device_tree.c index 52c3358a55..3553819257 100644 --- a/device_tree.c +++ b/device_tree.c @@ -140,15 +140,16 @@ static void read_fstree(void *fdt, const char *dirnam= e) const char *parent_node; =20 if (strstr(dirname, root_dir) !=3D dirname) { - error_setg(&error_fatal, "%s: %s must be searched within %s", - __func__, dirname, root_dir); + error_report("%s: %s must be searched within %s", + __func__, dirname, root_dir); + exit(1); } parent_node =3D &dirname[strlen(SYSFS_DT_BASEDIR)]; =20 d =3D opendir(dirname); if (!d) { - error_setg(&error_fatal, "%s cannot open %s", __func__, dirname); - return; + error_report("%s cannot open %s", __func__, dirname); + exit(1); } =20 while ((de =3D readdir(d)) !=3D NULL) { @@ -162,7 +163,8 @@ static void read_fstree(void *fdt, const char *dirname) tmpnam =3D g_strdup_printf("%s/%s", dirname, de->d_name); =20 if (lstat(tmpnam, &st) < 0) { - error_setg(&error_fatal, "%s cannot lstat %s", __func__, tmpna= m); + error_report("%s cannot lstat %s", __func__, tmpnam); + exit(1); } =20 if (S_ISREG(st.st_mode)) { @@ -170,8 +172,9 @@ static void read_fstree(void *fdt, const char *dirname) gsize len; =20 if (!g_file_get_contents(tmpnam, &val, &len, NULL)) { - error_setg(&error_fatal, "%s not able to extract info from= %s", - __func__, tmpnam); + error_report("%s not able to extract info from %s", + __func__, tmpnam); + exit(1); } =20 if (strlen(parent_node) > 0) { @@ -206,9 +209,9 @@ void *load_device_tree_from_sysfs(void) host_fdt =3D create_device_tree(&host_fdt_size); read_fstree(host_fdt, SYSFS_DT_BASEDIR); if (fdt_check_header(host_fdt)) { - error_setg(&error_fatal, - "%s host device tree extracted into memory is invalid", - __func__); + error_report("%s host device tree extracted into memory is invalid= ", + __func__); + exit(1); } return host_fdt; } --=20 2.18.0.rc2