From nobody Mon May 13 23:11:54 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 152994621535498.08526260343683; Mon, 25 Jun 2018 10:03:35 -0700 (PDT) Received: from localhost ([::1]:48362 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXUtq-0003bO-Kc for importer@patchew.org; Mon, 25 Jun 2018 13:03:34 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38788) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXUoU-0008US-BD for qemu-devel@nongnu.org; Mon, 25 Jun 2018 12:58:03 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXUoT-0006xD-F4 for qemu-devel@nongnu.org; Mon, 25 Jun 2018 12:58:02 -0400 Received: from mail-qk0-x241.google.com ([2607:f8b0:400d:c09::241]:42432) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fXUoT-0006wx-AA; Mon, 25 Jun 2018 12:58:01 -0400 Received: by mail-qk0-x241.google.com with SMTP id u62-v6so5345009qkf.9; Mon, 25 Jun 2018 09:58:01 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id k129-v6sm9856727qkd.13.2018.06.25.09.57.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 09:57:59 -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=RADF7hMp9Weyt1Sq/7gihEZu1AbDGdmEjjA4tp3I+DI=; b=n1dSS0XRUyTDKBqjKjrdtY+xFQPMs+R9O9fYs3E/vFDUYpvLKD2e7/ed/YD3xKxKvR FIkzpSUgc1+EmhkpWKJtVGGEKG72AkYz4ubdCC61qFHcJFTXP2mYH0taUiT0Ts+YAgi4 KHO1h2STVeHI6bQggMHAdz4f8wX9KfERB7+9sUb3RYFkR4Mo0uo5dyA77Z1qoi+LtugK Hg/UQCw9jxvvWqqIOqDlTyk/ckhBuaZU0Jws4eBwTecTgDhIEgdqHgsoX/nj83HUR61w WxBymIZyW9RKZASHWGppByS5guqrtAV3QWG65e0JtfvUi6rpPVXnXF1iDWfLjJFpuch8 6/xQ== 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=RADF7hMp9Weyt1Sq/7gihEZu1AbDGdmEjjA4tp3I+DI=; b=fEG1qKZGgjCtAJCYc61doJKanBu+SBY4JLw1CPbtsvM9Qneq3ATRdUWfd8UNz8Agt/ 7RY6b4l6jsuovXIvBcHE4p/k8aZpsCC2xZt5KcM2xgBu3RDllB7WobvhGH2IVOwTaqgR 0GFIMZPxV36ivuC5wXy9nJzw98VFXnee8anUcFdOaPizlsfKkmmmFAxGbq17jyaALETp FZ3FsBGgjnUvaVpphpZQ1ykDwYvk7M35GCSCxB4jrNwVqibnPy07J7cK70I1fHBGgXos vVQvM7saCxovkPSzVGpfeWcF6Gqv7viyBLcAtuNHXNW+seUmCqw4kGvfpuIZaXz3/m4d oOZA== X-Gm-Message-State: APt69E30ayrL3LHVG767tppgUdAZLyRQZSr2je4A7Nr9WWpZVvR8N5QX dMKE9i9N7z7aTCyMFwBuIMGPuc1DkHc= X-Google-Smtp-Source: AAOMgpdGtSP7YDsTTrTafGwLcohcE2Fg9s2+YPX28CKYf4F7cGtvKRTBtHN6sh5lZL27KlPHA8lRdA== X-Received: by 2002:ae9:eb89:: with SMTP id b131-v6mr10899437qkg.60.1529945880514; Mon, 25 Jun 2018 09:58:00 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Peter Maydell Date: Mon, 25 Jun 2018 13:57:47 -0300 Message-Id: <20180625165749.3910-2-f4bug@amsat.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180625165749.3910-1-f4bug@amsat.org> References: <20180625165749.3910-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 v4 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 , "open list:Floppy" , qemu-devel@nongnu.org, Markus Armbruster , =?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 From nobody Mon May 13 23:11:54 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 1529946031980408.8351209195595; Mon, 25 Jun 2018 10:00:31 -0700 (PDT) Received: from localhost ([::1]:48339 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXUqt-0001QL-3D for importer@patchew.org; Mon, 25 Jun 2018 13:00:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38846) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXUoX-000067-U0 for qemu-devel@nongnu.org; Mon, 25 Jun 2018 12:58:08 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXUoW-00070r-S8 for qemu-devel@nongnu.org; Mon, 25 Jun 2018 12:58:06 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:39736) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fXUoW-000704-Le; Mon, 25 Jun 2018 12:58:04 -0400 Received: by mail-qt0-x241.google.com with SMTP id c23-v6so3650516qtn.6; Mon, 25 Jun 2018 09:58:04 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id k129-v6sm9856727qkd.13.2018.06.25.09.58.00 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 09:58:03 -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=QeiPeokwUFZUcy7BROEsIlLnHLSoIbcdBHGtjnvFluU=; b=vJ0uuW1wddgq6lL90MWiaPmHG0Y5h4KEdc2RVncEazhSt0ydWNLrYBZdN6KSojKAeJ XlcGpeuL+XbeeD9X4PHAvcTDmtnQkPe2/Af+OwEI5nhTvUHHgrJicL51t57dG1eFtdGM 6HFGvHDcLtJVexfSA8yqb2tKWTSN1IliXrPWh6PqDEszeS931pUzhlxGowYr0mjrbKfu uHAnH9kz0+9GHep+Gmue+nGoyoCtMMnxR4b7BjyzFfDWtu2aOlA9yOb7uSriXVkI9ZCC h0AGQNVJ72/B4v+qZ6GpCIjKmvKoTi6GAXXJ3vPII6brk16JwnHbLvQTz9JIeBGLgeOP Ercg== 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=QeiPeokwUFZUcy7BROEsIlLnHLSoIbcdBHGtjnvFluU=; b=Qeq2nTDUqVbEB0YZidePxsAVUyEIxmO9VoxaajonmWLzDxKTIu5/imh7+xcsJruUfZ HAtyr484y7HPT2sm1vaXR/emTEnJhjbP5Bo+DHjwbSA0BcHtIVErd7D1kSvBtF7cqvUh loXaH41GqzxnovKGbgsm6mFgTow7tuwiVkgkJqt+AzOHK7FJP8CrI8SUhXA/7qfJu9nn ZNsK8VpT3vy+mou8DEdkhpqdfPWh9nAo3uA82zoRVtmYtLnCerZ+R/r7KgrvIZZVrKTg mnj9sLU/gjahx3C6pHEs/BJ9YA6iP4Reby76Q4DFknlPz5hyeYtItJIJB+Pw1v1HKmGX SDQw== X-Gm-Message-State: APt69E0MywynOAWu+le+5y8jtI+h9/I5QdHsVxy7XC+Xtbm9InpGaWTl cOwNG1aprQoYR/qrFZ7ccuY= X-Google-Smtp-Source: AAOMgpd3Hl+QQlaYsNlih9Td7f0aW6gPZ7Ge3qAd0kAyIb7ZqW+TIOuwJQH6HCjAkXVdBWncTibqzQ== X-Received: by 2002:a0c:ada5:: with SMTP id w34-v6mr11906299qvc.58.1529945883724; Mon, 25 Jun 2018 09:58:03 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Auger Eric , Markus Armbruster , Peter Maydell Date: Mon, 25 Jun 2018 13:57:48 -0300 Message-Id: <20180625165749.3910-3-f4bug@amsat.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180625165749.3910-1-f4bug@amsat.org> References: <20180625165749.3910-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::241 Subject: [Qemu-devel] [PATCH v4 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: "open list:ARM" , =?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: Eric Auger --- v3: display error if property required and returned -FDT_ERR_NOTFOUND hw/arm/sysbus-fdt.c | 53 +++++++++++++++++++++++++-------------------- 1 file changed, 30 insertions(+), 23 deletions(-) diff --git a/hw/arm/sysbus-fdt.c b/hw/arm/sysbus-fdt.c index 277ed872e7..0d4c75702c 100644 --- a/hw/arm/sysbus-fdt.c +++ b/hw/arm/sysbus-fdt.c @@ -92,16 +92,20 @@ static void copy_properties_from_host(HostProperty *pro= ps, 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); } else { - if (prop_len !=3D -FDT_ERR_NOTFOUND) { - /* optional property not returned although property exists= */ - error_report_err(err); - } else { + if (props[i].optional && prop_len =3D=3D -FDT_ERR_NOTFOUND) { + /* optional property does not exist */ error_free(err); + } else { + error_report_err(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 From nobody Mon May 13 23:11:54 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 1529946250846864.2552738582054; Mon, 25 Jun 2018 10:04:10 -0700 (PDT) Received: from localhost ([::1]:48363 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXUuQ-0003zM-4e for importer@patchew.org; Mon, 25 Jun 2018 13:04:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38876) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fXUob-00009Z-AN for qemu-devel@nongnu.org; Mon, 25 Jun 2018 12:58:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fXUoa-000723-AG for qemu-devel@nongnu.org; Mon, 25 Jun 2018 12:58:09 -0400 Received: from mail-qt0-x241.google.com ([2607:f8b0:400d:c0d::241]:34688) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1fXUoa-00071m-3v for qemu-devel@nongnu.org; Mon, 25 Jun 2018 12:58:08 -0400 Received: by mail-qt0-x241.google.com with SMTP id b20-v6so3341498qtp.1 for ; Mon, 25 Jun 2018 09:58:07 -0700 (PDT) Received: from x1.local ([138.117.48.222]) by smtp.gmail.com with ESMTPSA id k129-v6sm9856727qkd.13.2018.06.25.09.58.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 25 Jun 2018 09:58:06 -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=KuY8HupqKJhhbgS5c5q7gDc9jy9464PkYAHeB2x018s=; b=PLDslfvtms6SQ7xb5zliJht4m898IZH80M4rWtKXq+c8w0QAH88+D5tMVm6kS+4L0s d+vzR+bDeoEMI9lMKae1gHk3nVS76a92y9FRL9GO9BBCcBFHlg/kTNBBZGft6l7spZcr cOJ/BYkJapQPk21g0mZ45Rpcz1/n+0xz3cwQk4mVXiDrEeTvT7FuZmaV2LRAbbjHJccP L/dCHEN2/gHJRg6/y9hcqWykwTzExorefd3Z9TZvGEudxaj7ZqZH95ijjhB7kX70EPmB +aoVCE65acJKWnNuyJezT7V5JEyTcjpB1/AgS7OrPLJK8LqhPjmAqjobSYDpZDTQkSKG IurA== 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=KuY8HupqKJhhbgS5c5q7gDc9jy9464PkYAHeB2x018s=; b=HqsTcHPWnhVPzv5X04e/WxnecjW6mEDjWb8jE8H3EnVJGJ6kwgCWhfNl6oBcKWUkTX lhQfLTnbCJCZBX2SL1eGgs7nQrJvuu/h/ul13DzkfRska7I1AWSmlTwS+eVwvl/gTCgj 4Nk0Q9sGWTaBykoEWWx5z6ev14i4R3RBDyhMEUxSJDyvTqPEqUnVxT4PsE+UUY9YkHX7 gsTfUQ91+CO3GUwgp6eotQuF+YKo3rgFsQQFiF4CIjz2XO0OhjX08MgyFXwWi7DWRrVU +2SHh/L0uTD1JTqq8G7gUrOYNuqBLVruM8V71rGj7pqBJyf43sUd4vu9Lac9FLMhtI1R jxcg== X-Gm-Message-State: APt69E0gtBUD8VOi4NEdQxbAIJc4RhZSPIqAlJfuMWzX/4IgJRoW9wqA G7siW49/AJACZZ8sOwOeqQo= X-Google-Smtp-Source: ADUXVKIz5pvNQ1GEcJplrULmk83AQVlPV2MOPXyqE71DYlyk1bPjVTJAA/nRYH40JqcpDYu/NbsC5w== X-Received: by 2002:ac8:950:: with SMTP id z16-v6mr11713664qth.299.1529945887372; Mon, 25 Jun 2018 09:58:07 -0700 (PDT) From: =?UTF-8?q?Philippe=20Mathieu-Daud=C3=A9?= To: Peter Maydell Date: Mon, 25 Jun 2018 13:57:49 -0300 Message-Id: <20180625165749.3910-4-f4bug@amsat.org> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180625165749.3910-1-f4bug@amsat.org> References: <20180625165749.3910-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::241 Subject: [Qemu-devel] [PATCH v4 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, Markus Armbruster , Alexander Graf , =?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) 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