From patchwork Sun Mar 22 23:57:02 2026 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Simon Glass X-Patchwork-Id: 2036 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=1774223868; bh=VlJ2rC77L+2SHp7k51If2PGdjUf+in52MXI6dEmQJA8=; 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=rgfAhhuhxE0sAFTHrb1hwR/DImAUZvqLDrbyd21hW9k/umFj3rxCL7Ki0F1/riQkq DVvPVSzyP8oXqIoOMJdE3aXrsreC+/arl21u0wsm4dqiSqgEY8JwO3sdjOU/KlQge7 PcEWxBORpzv1x4vn+BSYTXYnLYiwyyw+FL0FArhBWOmZYrlhMjdjSptyUYiy1ZV1wB tMURTWJD4WytySO71MdOw0oEh+S3+dT05P30RFXgbu9hDgFLa1LEsDgQEwpl+7aTG5 uRjEy/fp84GX5FhykRiCPcNomy2TarTEFn5CPvujN9XX/bHeGdyulglbzBKMHUoqk0 D1Dl/zi+tzbig== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 1A4886A1F4 for ; Sun, 22 Mar 2026 17:57:48 -0600 (MDT) 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 NaznqYEQU4qD for ; Sun, 22 Mar 2026 17:57:48 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223866; bh=VlJ2rC77L+2SHp7k51If2PGdjUf+in52MXI6dEmQJA8=; 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=s47/E9uYv5l66gIAGJn1GjYdm6r0gxf0Xk1lxpWk4x1ti4h4H1ZIFfDCuF6Yl9eh0 9UHwf0rm1CqM9pwagLqbo5ybW7IdZygNiR6gG3Yj//WpJshGA3NHRDCncOjFpVPcwV WOqdR/su0Fbi0+oKGwEgvFpBiFKMx2ijjkJFoxeqiY2x/81YyNRVxyYprkrqh9hde8 EdXlBkxybdkeUMtDls2V6+wVnvWIYr1v7L6Sgk24HKBTzE8pgqizWB19bVSXzAKAYV T3ujSmmKSIxoWiq3ZUf1qY0l5jahegZaQPLUWMGgcU447g0r5GeQxOsSldVMWbjWu9 mKFL40aRROGFQ== Received: from mail.u-boot.org (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 93AA26A1DD for ; Sun, 22 Mar 2026 17:57:46 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223859; bh=Vb4Qbzzu/5n0MUq6F/J0qmTrOZWZ0JSMFOXkBB7Xjy8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=wRxKRGfTX5tUvN/A5LaOfXjE4IoH3fas31w/NjbGc4Q0jAf2A8J3sysvrQX01Xniv eSaIsxhDHqjAMZV5dUV1xG5waJP9LKVsswKUNdLY7WhlR5Y38e8JR8JKGfoR21Ovhm wXU1OAWuFIV55dH/3tFXakzNT+1hzhXAfPSbesQq20bCI1xeikZqrusTjhgI2kllnP LmGtgPaek0e1+C7FjUvPWIN9QSH5fVpzWQgrv5aK8ry+cdHzHXX4B8v+SeOUE/jeMA ea5ihOGLMdvtT+0GVFMmXw4m1y2MNOqW3t5ipipn8o3npapcsC2CNSYzEjfBUToQhF tyx7qqHCMkFCw== Received: from localhost (localhost [127.0.0.1]) by mail.u-boot.org (Postfix) with ESMTP id 3F57A66F0C; Sun, 22 Mar 2026 17:57:39 -0600 (MDT) 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 00CkVI2YP5n8; Sun, 22 Mar 2026 17:57:39 -0600 (MDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=u-boot.org; s=default; t=1774223858; bh=deYxZjbYzfVpa2zhp2BixToPfiqUKOQTvecNWzNvb08=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Ww3+CILWmrA/rD9rffQxBOjZwtEUbTj+ImLzVgP5DJlAfJdvRaY87bHTxBuvH72/l 1GzpCfC/v7C0OJEPgnxm4cWbzVT2+ZOzm1tWN2k74orZYimpsXsiOF4EySR0oNmJjj zqn4tmMUJBqDzshBSU2zvQcvoaPgBav5fkQjRcuTbh5Qy7N/lSGojMrqdd+EOvjGu+ JkxTKEDrXrUB/zoGO2E/haWl+j9AclFnEnq9QxEWfRFQrshVIyaTUEXH31f0d88jXR TSIA73gsJZabLxN+ru+VBcUVFi4K1Kgnqt2hTqoW6XLJo9W01+SIjA45vAenQrRWAU FRXXfVLJEJhEg== Received: from u-boot.org (unknown [73.34.74.121]) by mail.u-boot.org (Postfix) with ESMTPSA id AE1156A1D7; Sun, 22 Mar 2026 17:57:38 -0600 (MDT) From: Simon Glass To: U-Boot Concept Date: Sun, 22 Mar 2026 17:57:02 -0600 Message-ID: <20260322235719.1729267-5-sjg@u-boot.org> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20260322235719.1729267-1-sjg@u-boot.org> References: <20260322235719.1729267-1-sjg@u-boot.org> MIME-Version: 1.0 Message-ID-Hash: 3HVTVKZFEGVDDUBNTZMCDYXW5QYFTUYR X-Message-ID-Hash: 3HVTVKZFEGVDDUBNTZMCDYXW5QYFTUYR 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: Simon Glass X-Mailman-Version: 3.3.10 Precedence: list Subject: [Concept] [PATCH 04/14] bootstd: Clear iter->err on successful bootflow check 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 When bootflow_check() succeeds in bootflow_scan_next(), iter->err is not cleared. It retains the error from the previous failed iteration, so callers of iter_incr() cannot reliably determine whether the last bootflow was found successfully. Clear iter->err to 0 on success, matching the convention that iter->err reflects the result of the most recent bootflow check. Fixes: 5033e36637af ("bootstd: Add support for bootflows") Signed-off-by: Simon Glass --- boot/bootflow.c | 4 +++- test/boot/bootflow.c | 1 + 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/boot/bootflow.c b/boot/bootflow.c index a8a73ee0c7f..4a55cc637fa 100644 --- a/boot/bootflow.c +++ b/boot/bootflow.c @@ -687,8 +687,10 @@ int bootflow_scan_next(struct bootflow_iter *iter, struct bootflow *bflow) } ret = bootflow_check(iter, bflow); log_debug("check - ret=%d\n", ret); - if (!ret) + if (!ret) { + iter->err = 0; return 0; + } iter->err = ret; if (ret != BF_NO_MORE_PARTS && ret != -ENOSYS) { if (iter->flags & BOOTFLOWIF_ALL) diff --git a/test/boot/bootflow.c b/test/boot/bootflow.c index 5ecb5f557b1..3bea1cc6634 100644 --- a/test/boot/bootflow.c +++ b/test/boot/bootflow.c @@ -402,6 +402,7 @@ static int bootflow_iter(struct unit_test_state *uts) ut_asserteq(0x1e, iter.max_part); ut_asserteq_str("extlinux", iter.method->name); ut_asserteq(0, bflow.err); + ut_asserteq(0, iter.err); ut_asserteq(BOOTFLOWST_READY, bflow.state); bootflow_free(&bflow);