From patchwork Fri Jan 9 23:11:28 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 1415 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=1768000426; bh=cjCaFHW3SHC7DNbPxfqMUzuC5qMa6dozq1LcMDvVzUM=; 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=SH3Jy39Lc99oN+q0PhUGJZGqiN+2iJUQb6RcoBpnlP+/8u1F/JA4zbFpq51Q4gC1W uQ5jI5wHnyeLBckUf3+L27OSAgQCFBMptKDH/OFLgkEm75jl9SG2xqVd1kAmttGL2q ZLhAGOISZ+BBY8TmgVNq8HQ6x+qzU54eiL2MZQv+PuYeuLKKZHgfBU4Zpgwi6P6eQo RzkA90qkBAlXaTag3bhW7mq8yUKZvTpTfOSmO1b3h5S2KaGoHLeRvXVGZdKY52OdQ9 vZ0vzn3pJZqwxXQXxhbd5Qdu151RMj4jhfTWUMbRAoBvSnmC1Zuf+e4/lQ8DtyKsdG pIUNJdzzWvSgA== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 68B6F69243 for ; Fri, 9 Jan 2026 16:13:46 -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 IbD3ANpLmSo0 for ; Fri, 9 Jan 2026 16:13:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000426; bh=cjCaFHW3SHC7DNbPxfqMUzuC5qMa6dozq1LcMDvVzUM=; 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=SH3Jy39Lc99oN+q0PhUGJZGqiN+2iJUQb6RcoBpnlP+/8u1F/JA4zbFpq51Q4gC1W uQ5jI5wHnyeLBckUf3+L27OSAgQCFBMptKDH/OFLgkEm75jl9SG2xqVd1kAmttGL2q ZLhAGOISZ+BBY8TmgVNq8HQ6x+qzU54eiL2MZQv+PuYeuLKKZHgfBU4Zpgwi6P6eQo RzkA90qkBAlXaTag3bhW7mq8yUKZvTpTfOSmO1b3h5S2KaGoHLeRvXVGZdKY52OdQ9 vZ0vzn3pJZqwxXQXxhbd5Qdu151RMj4jhfTWUMbRAoBvSnmC1Zuf+e4/lQ8DtyKsdG pIUNJdzzWvSgA== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 39A7869240 for ; Fri, 9 Jan 2026 16:13:46 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000422; bh=GXzhIt9/yeOqjJ2Svo53PxTNeK/w6erZ20i/lhTqvLA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=ME26Y45qwfZWuc5dc2+oNypXHLgeE9I37DgT0K+EVWmuw/ABwNCvyf6kDalS+NWcs Ul+P3re2TKZTlgzEacMUqC3ea9Ujki688HZkTk71uOo7j8OFJ+Dmqw2AThSCNQeu2R tbj81jwHx1fR+nFWVbo0qcx+6mxYMa6w2bNtypfk4k/JDXD5sllGqjHoLxI1hIYC9k tR/qjGMNeQI4D9IaPitAyCUhGdjJIb9KZKWoxwRMyO8XspF3r45bzC8Ks8cfnJLqG1 tgSAne9WAufp3zhTbzArc77FrXsZ8nAaDfZ2N146DRDE0UoWjXm0+kob3uyhCQ6GsR uSKYu630fKTvQ== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 54DFF6924E; Fri, 9 Jan 2026 16:13:42 -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 9fvmGmnPsEir; Fri, 9 Jan 2026 16:13:42 -0700 (MST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1768000416; bh=twTe9hLdc4FS8tAiJ+Vpr+jknq71YgSdat1dyzaqdZQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=eENml8s0iKVBFiduz10RU997354++1mH3gs4+yN4v875/QiSpPZTYi5o/KJaAVJ7k 4XGePZFUt+oJLqF+W+7CktyHa5oZzJdORKRI5vJV8yHWdiM9Xb0M3hVOeKM+3pQ7LE 5ASBr44ZX00SYWx2ntMl6uwKtToRBkRE3lw/NyzTMmSs1tJJIUSgCHlVOb3VYQBi0Z eHAXjjgRm5d0l4rnxLAp8JpUUGKy2C3L35uhy+EhHTVuW+NuTHpBi8zCWXLRngrau3 Ucdw0oPLERoYwUWTa3UcpBPWpOv9tw7wJ1NQOq155eqUDaew+ZvKCB3HFMkYnHUuvD J6eNSts1WI0LA== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id 6CC8769243; Fri, 9 Jan 2026 16:13:36 -0700 (MST) From: Simon Glass To: U-Boot Concept Date: Fri, 9 Jan 2026 16:11:28 -0700 Message-ID: <20260109231151.4056804-20-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260109231151.4056804-1-sjg@u-boot.org> References: <20260109231151.4056804-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 6QT6QBOYBZ6BIDS7A4XJDACSSUEJTBGY X-Message-ID-Hash: 6QT6QBOYBZ6BIDS7A4XJDACSSUEJTBGY 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 Opus 4 . 5" X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 19/32] boot: pxe: Use early return in label_load_fdt() 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 Return early if no FDT file is specified, rather than using an else branch. This flattens the code and makes the control flow clearer. Co-developed-by: Claude Opus 4.5 Signed-off-by: Simon Glass --- boot/pxe_utils.c | 54 ++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/boot/pxe_utils.c b/boot/pxe_utils.c index f6ad3f905b9..c0ef524f3f1 100644 --- a/boot/pxe_utils.c +++ b/boot/pxe_utils.c @@ -526,39 +526,39 @@ static int label_load_fdt(struct pxe_context *ctx, struct pxe_label *label, if (ret) return ret; - if (fdtfile) { - ret = get_relfile_envaddr(ctx, fdtfile, "fdt_addr_r", SZ_4K, - (enum bootflow_img_t)IH_TYPE_FLATDT, - &addr, NULL); - - free(fdtfile); - if (ret < 0) { - *fdt_argp = NULL; - - if (label->fdt) { - printf("Skipping %s for failure retrieving FDT\n", - label->name); - return -ENOENT; - } + if (!fdtfile) { + *fdt_argp = NULL; + return 0; + } - if (label->fdtdir) { - printf("Skipping fdtdir %s for failure retrieving dts\n", - label->fdtdir); - } - } else { - ctx->fdt = map_sysmem(addr, 0); + ret = get_relfile_envaddr(ctx, fdtfile, "fdt_addr_r", SZ_4K, + (enum bootflow_img_t)IH_TYPE_FLATDT, + &addr, NULL); + free(fdtfile); + if (ret < 0) { + *fdt_argp = NULL; - if (label->kaslrseed) - label_boot_kaslrseed(ctx); + if (label->fdt) { + printf("Skipping %s for failure retrieving FDT\n", + label->name); + return -ENOENT; + } - if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY) && - label->fdtoverlays) - label_boot_fdtoverlay(ctx, label); + if (label->fdtdir) { + printf("Skipping fdtdir %s for failure retrieving dts\n", + label->fdtdir); } - } else { - *fdt_argp = NULL; + return 0; } + ctx->fdt = map_sysmem(addr, 0); + + if (label->kaslrseed) + label_boot_kaslrseed(ctx); + + if (IS_ENABLED(CONFIG_OF_LIBFDT_OVERLAY) && label->fdtoverlays) + label_boot_fdtoverlay(ctx, label); + return 0; } /**