From patchwork Thu Nov 20 02:55:57 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 750 Return-Path: X-Original-To: u-boot-concept@u-boot.org Delivered-To: u-boot-concept@u-boot.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607447; bh=/lIM/w1o/LZ4WJq7NuRq1sZp4LWh1G7oOXgtNjvwUcY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=JaeQR1uxMIFnb51vE9R70D7ve/SCMGlCSPjV9wHAO00tDLHOwGnknmxH0LbUITBbW 0lSehhHO64ymLFUFKVB4KaGS2RDT+UntR7EjZ9PSzY/NdoYk6uS4i2CY8gpWEP0m+5 si9eAhm5aOgUObnkXyU1B/pWqkMSTFPjVqm6b8ctZQUJicNmvFkEIrSYzXxwy9kZcj POhWtuMmwrC3Hb/6ktVdXR9t96C67a9BN3IVATbZ00+BjN76bAimW8roJbWNpq02VT Ut/2wMY/s5khAAeAFysT8Wtk/xJJBTGC0DF3MWkwj5w7MBx+nhPt44c8ydNLtkxu6d o494TdE/gvMrg== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 8FE4F686C9 for ; Wed, 19 Nov 2025 19:57:27 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10024) with ESMTP id Bae-8yfB-YkG for ; Wed, 19 Nov 2025 19:57:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607447; bh=/lIM/w1o/LZ4WJq7NuRq1sZp4LWh1G7oOXgtNjvwUcY=; h=From:To:Date:In-Reply-To:References:CC:Subject:List-Id: List-Archive:List-Help:List-Owner:List-Post:List-Subscribe: List-Unsubscribe:From; b=JaeQR1uxMIFnb51vE9R70D7ve/SCMGlCSPjV9wHAO00tDLHOwGnknmxH0LbUITBbW 0lSehhHO64ymLFUFKVB4KaGS2RDT+UntR7EjZ9PSzY/NdoYk6uS4i2CY8gpWEP0m+5 si9eAhm5aOgUObnkXyU1B/pWqkMSTFPjVqm6b8ctZQUJicNmvFkEIrSYzXxwy9kZcj POhWtuMmwrC3Hb/6ktVdXR9t96C67a9BN3IVATbZ00+BjN76bAimW8roJbWNpq02VT Ut/2wMY/s5khAAeAFysT8Wtk/xJJBTGC0DF3MWkwj5w7MBx+nhPt44c8ydNLtkxu6d o494TdE/gvMrg== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 7FDF4686B2 for ; Wed, 19 Nov 2025 19:57:27 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607445; bh=Vi6Ckc2O0bNhBckO63BI6IXyG1bHC1qDYclgpugt68o=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=nTVtUedRvUMM7N1cZt7d8ZIrJYWV0wv+OWX3LhcdFA+HCW87aZe3mhKOGP5ILLNjS /m9/Re9q6iXfgrYlC6qWDmctF9su+AD1R2KaZUCacP6tU7qZSiANUewtEftGYu/box M172Twm4e6RlQydhPfWgm8zqGoeiMqkloL7fAjmKWG6vtn7ndTr14aO5a9+P9Kd7bP 2oRq0VaSOjPTlrZAH5JSc8xrNW5E4PI8ypJVLOjlU/1FJgWDkMmv7sg8kkqFQ/56LA E5h482xQ3LobhEq/l2iYOCxghuUi+gmyqUT7XSlrzeGA1+bpkNwZqRz129s9Ip+YaN isZuZZXxoVf5A== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 51F295E7DA; Wed, 19 Nov 2025 19:57:25 -0700 (MST) X-Virus-Scanned: Debian amavis at Received: from mail.u-boot.org ([127.0.0.1]) by localhost (mail.u-boot.org [127.0.0.1]) (amavis, port 10026) with ESMTP id bW9dhICQM0tG; Wed, 19 Nov 2025 19:57:25 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1763607441; bh=dtgTJ5M7oSFsRUtB9DXf4LJDI9Chrxo98XPEzzlHr0g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=WARuvuN2GsbT/+iwHt5q+B95qT6YSamC2Yr0yU3aW78y4g/XsY4AovP07lqW0FdOQ RaBjlWB723VjEmnkDlEbCyQQEdXwBUXH9QHKtP39Axl/J1HJmR3D6BbwM8hLjemAPX +M6H60S3XPWcPnqy/zpBg999hVm1iK9RUh6vVW92JeVsMeEvsIGGHjr8jI3zXYCv5e uFRTgZgNGrRLRHlxayhRjQo5rT4ASlOVPj0truQVSdg6vrAC7tYgP34VtHXuvsRRSU aQQjX2ChIBzLKrpLiEG4fLZHAKVKQJfuUUOEypr6vXMHj5JBcGrqluMHrOizzxrX5p 7xee5B+5P9/SA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id EFF59686ED; Wed, 19 Nov 2025 19:57:20 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Wed, 19 Nov 2025 19:55:57 -0700 Message-ID: <20251120025614.2215587-23-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20251120025614.2215587-1-sjg@u-boot.org> References: <20251120025614.2215587-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: WI2OXR6OYQCYUM2RCJYFDYP3MEWJFOZU X-Message-ID-Hash: WI2OXR6OYQCYUM2RCJYFDYP3MEWJFOZU X-MailFrom: sjg@u-boot.org X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header CC: Heinrich Schuchardt , Simon Glass , Claude X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 22/30] fit: Use emit_label_val() where possible List-Id: Discussion and patches related to U-Boot Concept Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Simon Glass Refactor the printing of multi-line properties to use the emit_label_val() helper function instead of custom formatting. Update emit_label() to deal with an empty label and not show a colon in that case. Co-developed-by: Claude Signed-off-by: Simon Glass --- boot/fit_print.c | 36 ++++++++---------------------------- 1 file changed, 8 insertions(+), 28 deletions(-) diff --git a/boot/fit_print.c b/boot/fit_print.c index e26f2294229..628d6108bea 100644 --- a/boot/fit_print.c +++ b/boot/fit_print.c @@ -69,7 +69,7 @@ static void emit_label(struct fit_print_ctx *ctx, const char *label) { int len; - len = printf("%*s%s:", ctx->indent, "", label); + len = printf("%*s%s%c", ctx->indent, "", label, *label ? ':' : ' '); printf("%*s", ctx->tab - len, ""); } @@ -315,7 +315,6 @@ void fit_image_print(struct fit_print_ctx *ctx, int image_noffset) static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) { const void *fit = ctx->fit; - int p = ctx->indent; const char *uname, *desc; int ret, ndepth, i; @@ -338,13 +337,8 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) for (i = 0; uname = fdt_stringlist_get(fit, noffset, FIT_FDT_PROP, i, NULL), uname; - i++) { - if (!i) - emit_label(ctx, "FDT"); - else - printf("%*s ", p, ""); - printf("%s\n", uname); - } + i++) + emit_label_val(ctx, i ? "" : "FDT", uname); uname = fdt_getprop(fit, noffset, FIT_FPGA_PROP, NULL); if (uname) @@ -354,23 +348,13 @@ static void fit_conf_print(struct fit_print_ctx *ctx, int noffset) for (i = 0; uname = fdt_stringlist_get(fit, noffset, FIT_LOADABLE_PROP, i, NULL), uname; - i++) { - if (!i) - emit_label(ctx, "Loadables"); - else - printf("%*s ", p, ""); - printf("%s\n", uname); - } + i++) + emit_label_val(ctx, i ? "" : "Loadables", uname); /* Show the list of compatible strings */ for (i = 0; uname = fdt_stringlist_get(fit, noffset, - FIT_COMPATIBLE_PROP, i, NULL), uname; i++) { - if (!i) - emit_label(ctx, "Compatible"); - else - printf("%*s ", p, ""); - printf("%s\n", uname); - } + FIT_COMPATIBLE_PROP, i, NULL), uname; i++) + emit_label_val(ctx, i ? "" : "Compatible", uname); /* Process all hash subnodes of the component configuration node */ for (ndepth = 0, noffset = fdt_next_node(fit, noffset, &ndepth); @@ -399,11 +383,7 @@ void fit_print(struct fit_print_ctx *ctx) /* Root node properties */ ret = fit_get_desc(fit, 0, &desc); - printf("%*sFIT description: ", p, ""); - if (ret) - printf("unavailable\n"); - else - printf("%s\n", desc); + emit_label_val(ctx, "FIT description", ret ? "unavailable" : desc); if (IMAGE_ENABLE_TIMESTAMP) { ret = fit_get_timestamp(fit, 0, ×tamp);