Message ID | 20221207085137.445249-21-sjg@chromium.org |
---|---|
State | Superseded |
Delegated to: | Tom Rini |
Headers | show
Return-Path: <u-boot-bounces@lists.denx.de> X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=<UNKNOWN>) Authentication-Results: legolas.ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=chromium.org header.i=@chromium.org header.a=rsa-sha256 header.s=google header.b=NU/+XK0i; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384)) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4NRrmD08MSz23yq for <incoming@patchwork.ozlabs.org>; Wed, 7 Dec 2022 19:58:20 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E473985161; Wed, 7 Dec 2022 09:55:18 +0100 (CET) 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="NU/+XK0i"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 0DDC085431; Wed, 7 Dec 2022 09:55:07 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.2 Received: from mail-pj1-x1032.google.com (mail-pj1-x1032.google.com [IPv6:2607:f8b0:4864:20::1032]) (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 59CD7855A2 for <u-boot@lists.denx.de>; Wed, 7 Dec 2022 09:55:02 +0100 (CET) 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-pj1-x1032.google.com with SMTP id b13-20020a17090a5a0d00b0021906102d05so929891pjd.5 for <u-boot@lists.denx.de>; Wed, 07 Dec 2022 00:55:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=kT5MZQzrOpBWaCbzuTL5Cj7O92Eqb+xLO4fG3pDBxB4=; b=NU/+XK0igeApR9A83CENrL4PQxeRJVpF5h3BPHue6vG/iyvHMMj7E1tdhDRBqpMdsg cJ42s6Oc3VQTST0xeZ5MM5S3mF/jKMZSG1IWDrkkvBV6NUtBDklkVxAeAWAbmb1jHtRW 8Z7DP+gFEoV0iPHfkKXN8HL7N17gDoMmMdp5M= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=kT5MZQzrOpBWaCbzuTL5Cj7O92Eqb+xLO4fG3pDBxB4=; b=DFN+NT7Kjy+xVWwkA5881EFQbwE+JFRux4CcrEO4fE2QZYwlEP00Uyc0epyUNVUheg sVM63Kbt4Ulhx3eDVYvufReW4lw295fKJi4Ozc8j+TrD5O4aUVhG8vl88TeYzeZS2BN2 QwpssWNsuuP628TF9Wi1/VPlI5jjx9iKbcweD7lTPovil0YM8pmMdkWekmcaXpjTwjmU NcTnyDupzagwn0Xon0k/cS/K9tshx25oK421A+PtcG9PQRd+ckG4NNJ/T0k7DHQ0OVg3 bhFb9U8RnbEgo6LqCLuVOymqU7+A1juC2WQ1pVZ/LFoz/fFPQWK8qi5etA5ZO+FQN6Er qWOA== X-Gm-Message-State: ANoB5pn7I7jVXxKhRm4es8/82DPOUb8rsCwJ4qPcXM4T+lanpZiQ9Yps mXLwPpUBP6u5MU0sjSGWCkxsON59NOootk4e X-Google-Smtp-Source: AA0mqf79D1Z4py+tiu5vBRKA511jeCt6hKOQQ0C2nvIbscOGK0QWfZBvgbOTJiTWdLf22V9TnwF+JQ== X-Received: by 2002:a17:90a:8c96:b0:218:7e9d:8d0a with SMTP id b22-20020a17090a8c9600b002187e9d8d0amr92539239pjo.41.1670403300580; Wed, 07 Dec 2022 00:55:00 -0800 (PST) Received: from localhost.localdomain ([27.110.126.54]) by smtp.gmail.com with ESMTPSA id l16-20020a170903121000b0018157b415dbsm14145514plh.63.2022.12.07.00.54.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Dec 2022 00:55:00 -0800 (PST) From: Simon Glass <sjg@chromium.org> To: U-Boot Mailing List <u-boot@lists.denx.de> Cc: U-Boot Custodians <u-boot-custodians@lists.denx.de>, Simon Glass <sjg@chromium.org>, Heinrich Schuchardt <xypron.glpk@gmx.de>, Ramon Fried <rfried.dev@gmail.com>, Viacheslav Mitrofanov <v.v.mitrofanov@yadro.com> Subject: [PATCH 20/71] lib: Support printing an error string Date: Wed, 7 Dec 2022 21:50:46 +1300 Message-Id: <20221207085137.445249-21-sjg@chromium.org> X-Mailer: git-send-email 2.39.0.rc0.267.gcb52ba06e7-goog In-Reply-To: <20221207085137.445249-1-sjg@chromium.org> References: <20221207085137.445249-1-sjg@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion <u-boot.lists.denx.de> List-Unsubscribe: <https://lists.denx.de/options/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=unsubscribe> List-Archive: <https://lists.denx.de/pipermail/u-boot/> List-Post: <mailto:u-boot@lists.denx.de> List-Help: <mailto:u-boot-request@lists.denx.de?subject=help> List-Subscribe: <https://lists.denx.de/listinfo/u-boot>, <mailto:u-boot-request@lists.denx.de?subject=subscribe> Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" <u-boot-bounces@lists.denx.de> X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean |
Series |
bootstd: Allow migration from distro_bootcmd scripts
|
expand
|
diff --git a/lib/vsprintf.c b/lib/vsprintf.c index 530d8088c7f..8de3882fb6c 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -145,6 +145,7 @@ static noinline char *put_dec(char *buf, uint64_t num) #define LEFT 16 /* left justified */ #define SMALL 32 /* Must be 32 == 0x20 */ #define SPECIAL 64 /* 0x */ +#define ERRSTR 128 /* %dE showing error string if enabled */ /* * Macro to add a new character to our output string, but only if it will @@ -678,6 +679,8 @@ repeat: break; case 'd': + if (fmt[1] == 'E') + flags |= ERRSTR; case 'i': flags |= SIGN; case 'u': @@ -712,6 +715,15 @@ repeat: } str = number(str, end, num, base, field_width, precision, flags); + if (IS_ENABLED(CONFIG_ERRNO_STR) && (flags & ERRSTR)) { + const char *p; + + ADDCH(str, ':'); + ADDCH(str, ' '); + for (p = errno_str(num); *p; p++) + ADDCH(str, *p); + fmt++; + } } if (size > 0) {
It is often useful to show an error code to give the user a clue as to what went wrong. When error strings are compiled into U-Boot it is possible to show a message as well. But at present it is not very convenient, since code must check if the error strings are present, then obtain the error string and use it in a printf() string. Add a %dE option which shows an error code along with an error string, if available. This makes it easy to show one or both. Signed-off-by: Simon Glass <sjg@chromium.org> --- lib/vsprintf.c | 12 ++++++++++++ 1 file changed, 12 insertions(+)