Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id EAA0DC77B7D for ; Wed, 10 May 2023 22:34:39 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 52642860A8; Thu, 11 May 2023 00:34:37 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.b="DK1CkKHn"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 8C0A9860BC; Thu, 11 May 2023 00:34:35 +0200 (CEST) Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 14DD18477F for ; Thu, 11 May 2023 00:34:32 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=sjg@chromium.org Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-76c63a98f88so54413939f.2 for ; Wed, 10 May 2023 15:34:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1683758070; x=1686350070; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=R+Zy226C06B5iXFYF7LzLF01hM8M3Kpri8OTn5mnYdY=; b=DK1CkKHnCIjxuvXnQSNPcg6ArF9ucydi9PGjqV/8bV8quKW7C2hOJb2q+DesJT+qEw p5/eGwd/nDAVtMwYncY76tOPMP8xB36cIbI/pjvUCZTciKhHBnrGTvv2IoBM0fa6iohJ sj+UPBLzk8pO/oiQbrKvUrTI1r8A8y+qgStq0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683758070; x=1686350070; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=R+Zy226C06B5iXFYF7LzLF01hM8M3Kpri8OTn5mnYdY=; b=h91DSDttRxQdO/0MpAI7PZtmLHYVnjKRTkaHu8umSdLgIvNonLo/sJlJ//MejVO47/ NIcsPytTI+VL5p/1QOFpdU7/QuQH2pcEY0eBxeZ8/X7yPBIoR0E5S5yJW7QG6jsFnFuX DVcTqFkKrxMl95tJkpHj82DrrL3Ljm4ym5u4MfUXiDj+tfI+3X0aWcOBEAFYPX1/BpeK XGFM/rE/L3YEASN/nX+yunA0vqVuufH6gwZw9CyHzhWujakjJGceQ6/7Xk9jZkL2YgOk L5fAbbMklAmE5azVxpv0uF3okGc4fXWAyCYp6QKIABqA9Tsz6R6mzYPqYreKvILqyRie vScQ== X-Gm-Message-State: AC+VfDxHN2Znh4gSzX/VTNOufa/0nyE++368QRxHrKJktYDuNeMp4Ejk BHJ/jEYzCdYjCVlLh3YQUqf+A59X3qCDgk1ni+0= X-Google-Smtp-Source: ACHHUZ7EU98Jh5p7We2bWnSVXYbTpCZmRiwVsNR0HGhNaA54hQKOIPPj3QEhV2tWK6ZRPilyQZBdbg== X-Received: by 2002:a05:6e02:78e:b0:335:4a17:6a3c with SMTP id q14-20020a056e02078e00b003354a176a3cmr8229790ils.21.1683758070380; Wed, 10 May 2023 15:34:30 -0700 (PDT) Received: from kea.bld.corp.google.com ([2620:15c:183:200:b37f:b05b:6e27:bdcf]) by smtp.gmail.com with ESMTPSA id x7-20020a056638160700b0041400216550sm3770645jas.97.2023.05.10.15.34.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 10 May 2023 15:34:29 -0700 (PDT) From: Simon Glass To: U-Boot Mailing List Cc: Tom Rini , =?UTF-8?q?Vincent=20Stehl=C3=A9?= , Simon Glass Subject: [PATCH v2] bootstd: Tidy up reporting of errors Date: Wed, 10 May 2023 16:34:26 -0600 Message-ID: <20230510223427.209539-1-sjg@chromium.org> X-Mailer: git-send-email 2.40.1.521.gf1e218fcd8-goog MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.8 at phobos.denx.de X-Virus-Status: Clean In a few cases the error handling is not quite right. Make sure we return the actual error in distro_efi_read_bootflow_file() rather than -EINVAL. Return -IO when a file cannot be read. Also show the error name if available. This does not change operation, but does make it easier to diagnose problems. Signed-off-by: Simon Glass --- Changes in v2: - Update affected tests too boot/bootmeth-uclass.c | 2 +- boot/bootmeth_efi.c | 2 +- cmd/bootflow.c | 2 +- test/boot/bootflow.c | 10 +++++----- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/boot/bootmeth-uclass.c b/boot/bootmeth-uclass.c index 2aee1e0f0c5..3b3e0614daf 100644 --- a/boot/bootmeth-uclass.c +++ b/boot/bootmeth-uclass.c @@ -319,7 +319,7 @@ static int alloc_file(const char *fname, uint size, void **bufp) return log_msg_ret("read", ret); } if (size != bytes_read) - return log_msg_ret("bread", -EINVAL); + return log_msg_ret("bread", -EIO); buf[size] = '\0'; *bufp = buf; diff --git a/boot/bootmeth_efi.c b/boot/bootmeth_efi.c index 6f70f2229b9..af31fbfc85d 100644 --- a/boot/bootmeth_efi.c +++ b/boot/bootmeth_efi.c @@ -235,7 +235,7 @@ static int distro_efi_read_bootflow_file(struct udevice *dev, ret = efiload_read_file(desc, bflow); if (ret) - return log_msg_ret("read", -EINVAL); + return log_msg_ret("read", ret); fdt_addr = env_get_hex("fdt_addr_r", 0); diff --git a/cmd/bootflow.c b/cmd/bootflow.c index 6cc58e48c7d..5c61286a2a7 100644 --- a/cmd/bootflow.c +++ b/cmd/bootflow.c @@ -55,7 +55,7 @@ static void report_bootflow_err(struct bootflow *bflow, int err) break; } - printf(", err=%d\n", err); + printf(", err=%dE\n", err); } /** diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index fd0e1d62435..bb53bab0c0c 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -168,21 +168,21 @@ static int bootflow_cmd_scan_e(struct unit_test_state *uts) ut_assert_nextlinen("---"); ut_assert_nextline("Scanning bootdev 'mmc2.bootdev':"); ut_assert_nextline(" 0 syslinux media mmc 0 mmc2.bootdev.whole "); - ut_assert_nextline(" ** No partition found, err=-93"); + ut_assert_nextline(" ** No partition found, err=-93: Protocol not supported"); ut_assert_nextline(" 1 efi media mmc 0 mmc2.bootdev.whole "); - ut_assert_nextline(" ** No partition found, err=-93"); + ut_assert_nextline(" ** No partition found, err=-93: Protocol not supported"); ut_assert_nextline("Scanning bootdev 'mmc1.bootdev':"); ut_assert_nextline(" 2 syslinux media mmc 0 mmc1.bootdev.whole "); - ut_assert_nextline(" ** No partition found, err=-2"); + ut_assert_nextline(" ** No partition found, err=-2: No such file or directory"); ut_assert_nextline(" 3 efi media mmc 0 mmc1.bootdev.whole "); - ut_assert_nextline(" ** No partition found, err=-2"); + ut_assert_nextline(" ** No partition found, err=-2: No such file or directory"); ut_assert_nextline(" 4 syslinux ready mmc 1 mmc1.bootdev.part_1 /extlinux/extlinux.conf"); ut_assert_nextline(" 5 efi fs mmc 1 mmc1.bootdev.part_1 efi/boot/bootsbox.efi"); ut_assert_skip_to_line("Scanning bootdev 'mmc0.bootdev':"); ut_assert_skip_to_line(" 3f efi media mmc 0 mmc0.bootdev.whole "); - ut_assert_nextline(" ** No partition found, err=-93"); + ut_assert_nextline(" ** No partition found, err=-93: Protocol not supported"); ut_assert_nextline("No more bootdevs"); ut_assert_nextlinen("---"); ut_assert_nextline("(64 bootflows, 1 valid)"); -- 2.40.1.521.gf1e218fcd8-goog