From patchwork Fri Jun 29 14:52:55 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 140582 Delivered-To: patch@linaro.org Received: by 2002:a2e:9754:0:0:0:0:0 with SMTP id f20-v6csp969205ljj; Fri, 29 Jun 2018 08:14:43 -0700 (PDT) X-Google-Smtp-Source: AAOMgpf5ZycB42Bo6grTbcJz1P/XqjGg6fJGpg9/UG27yrPpX5ZbVVAuIvWsCHokWo9oQsIrE26y X-Received: by 2002:aed:2457:: with SMTP id s23-v6mr13924845qtc.366.1530285282972; Fri, 29 Jun 2018 08:14:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1530285282; cv=none; d=google.com; s=arc-20160816; b=zsVG/xr0U855DNpwyb+idW+e4Gvz0G6X5jaz16U6vyp04K5BByuPGX31rGqc0w3vhM cqplRGTmqinboR21jVFeSPiuhhDXY00Thsus4k/mhTvedkaXA1WAMCNRXcn1wEd5O9nt 7HVZer+vp9X+q5FzalNsQgNT+f9koPig9PGr1pOpOjVzHxtnkQwDVQntLvQxz+Rvl7Lu LkjTYexG/l1FKQvFN61fJdzufXxoYkhozA1v2/ols7OGyskS/NSldm8tkO7a8io5ZiWU bfhL6qXzFMBvNKaZiBT6qfD5PGfg8h0RR8B5hlFiotG6QgcIjgYm410FMZjNNScu8t1Y BU+w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject :content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:to:from:arc-authentication-results; bh=u4wCeSBOhB8eB8Yfw7fNanyTvk19UaqJuxTdFmQLhIU=; b=l82MRkX2+P96imcK68gofiTVyuGWlcrhx2bw+fiEU60eKUzPcnLvnrem8x9idG7Qe+ NXxFsSek3gS9UTxkwXk4AnhUQBG8hwBpjJKu3k53i4HVLGaRszayxPr1biDrhY+h96Hy q4UJvepSHkHlW4/Dg71cFh06DQK2Qctr8Z59dsNunbMYZ/noVcITdxjyNF4zuXgjvgkT zz/DFqPSF8t0jOHTACBJ/HCVEpR1w/Ecb5LjOXd4lU8LUDl0B3nHslEM/7vk8jbKAVA+ t0wjvKySprYcN738S2Vi63ShBncooSFYiUwIQDxyMJazI4r94G48tn4Xd1fwLkKH0392 zijA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id k5-v6si8878729qkb.128.2018.06.29.08.14.42 for (version=TLS1 cipher=AES128-SHA bits=128/128); Fri, 29 Jun 2018 08:14:42 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1]:42872 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYv6g-0007qn-Dc for patch@linaro.org; Fri, 29 Jun 2018 11:14:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:33744) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fYumi-0007OE-AT for qemu-devel@nongnu.org; Fri, 29 Jun 2018 10:54:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1fYumg-0006M9-0A for qemu-devel@nongnu.org; Fri, 29 Jun 2018 10:54:04 -0400 Received: from orth.archaic.org.uk ([2001:8b0:1d0::2]:43090) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1fYumf-00069Y-Ka for qemu-devel@nongnu.org; Fri, 29 Jun 2018 10:54:01 -0400 Received: from pm215 by orth.archaic.org.uk with local (Exim 4.89) (envelope-from ) id 1fYumU-0004Ur-V6 for qemu-devel@nongnu.org; Fri, 29 Jun 2018 15:53:50 +0100 From: Peter Maydell To: qemu-devel@nongnu.org Date: Fri, 29 Jun 2018 15:52:55 +0100 Message-Id: <20180629145347.652-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20180629145347.652-1-peter.maydell@linaro.org> References: <20180629145347.652-1-peter.maydell@linaro.org> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2001:8b0:1d0::2 Subject: [Qemu-devel] [PULL 03/55] 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: , Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Philippe Mathieu-Daudé 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é Reviewed-by: Eric Auger Reviewed-by: Markus Armbruster Reviewed-by: David Gibson Message-id: 20180625165749.3910-4-f4bug@amsat.org Signed-off-by: Peter Maydell --- device_tree.c | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) -- 2.17.1 diff --git a/device_tree.c b/device_tree.c index 52c3358a558..3553819257b 100644 --- a/device_tree.c +++ b/device_tree.c @@ -140,15 +140,16 @@ static void read_fstree(void *fdt, const char *dirname) const char *parent_node; if (strstr(dirname, root_dir) != 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 = &dirname[strlen(SYSFS_DT_BASEDIR)]; d = 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); } while ((de = readdir(d)) != NULL) { @@ -162,7 +163,8 @@ static void read_fstree(void *fdt, const char *dirname) tmpnam = g_strdup_printf("%s/%s", dirname, de->d_name); if (lstat(tmpnam, &st) < 0) { - error_setg(&error_fatal, "%s cannot lstat %s", __func__, tmpnam); + error_report("%s cannot lstat %s", __func__, tmpnam); + exit(1); } if (S_ISREG(st.st_mode)) { @@ -170,8 +172,9 @@ static void read_fstree(void *fdt, const char *dirname) gsize len; 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); } if (strlen(parent_node) > 0) { @@ -206,9 +209,9 @@ void *load_device_tree_from_sysfs(void) host_fdt = 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; }