From patchwork Thu Jun 21 11:40:15 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Philippe_Mathieu-Daud=C3=A9?= X-Patchwork-Id: 932692 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=amsat.org Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="Z/M7RKB+"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41BKbT0lFLz9s2L for ; Thu, 21 Jun 2018 21:43:49 +1000 (AEST) Received: from localhost ([::1]:54654 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1fVy0A-0001th-QH for incoming@patchwork.ozlabs.org; Thu, 21 Jun 2018 07:43:46 -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) 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) 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) From: =?utf-8?q?Philippe_Mathieu-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 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_Mathieu-Daud=C3=A9?= , David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" 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 --- 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 *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; }