[PATCH 1/2] cmd: fdt: Correct checking of configuration node

fit_conf_get_node() returns a negative value on error.
Signed-off-by: Bin Meng bmeng@tinylab.org ---
cmd/fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/cmd/fdt.c b/cmd/fdt.c index aae3278526..2401ea8b44 100644 --- a/cmd/fdt.c +++ b/cmd/fdt.c @@ -733,7 +733,7 @@ static int do_fdt(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
gd->fdt_blob = blob; cfg_noffset = fit_conf_get_node(working_fdt, NULL); - if (!cfg_noffset) { + if (cfg_noffset < 0) { printf("Could not find configuration node: %s\n", fdt_strerror(cfg_noffset)); return CMD_RET_FAILURE;

Per the fit_conf_get_node() API doc, it returns configuration node offset when found (>=0).
Signed-off-by: Bin Meng bmeng@tinylab.org ---
common/spl/spl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/common/spl/spl.c b/common/spl/spl.c index a630e79866..7c0aff93e7 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -329,7 +329,7 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
conf_noffset = fit_conf_get_node((const void *)header, fit_uname_config); - if (conf_noffset <= 0) + if (conf_noffset < 0) return 0;
for (idx = 0;

On Sun, 30 Apr 2023 at 21:35, Bin Meng bmeng@tinylab.org wrote:
Per the fit_conf_get_node() API doc, it returns configuration node offset when found (>=0).
Signed-off-by: Bin Meng bmeng@tinylab.org
common/spl/spl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org
diff --git a/common/spl/spl.c b/common/spl/spl.c index a630e79866..7c0aff93e7 100644 --- a/common/spl/spl.c +++ b/common/spl/spl.c @@ -329,7 +329,7 @@ static int spl_load_fit_image(struct spl_image_info *spl_image,
conf_noffset = fit_conf_get_node((const void *)header, fit_uname_config);
if (conf_noffset <= 0)
if (conf_noffset < 0) return 0; for (idx = 0;
-- 2.34.1
(note that it can never be 0 in fact, since 0 is the root node)

On Mon, May 01, 2023 at 11:35:26AM +0800, Bin Meng wrote:
Per the fit_conf_get_node() API doc, it returns configuration node offset when found (>=0).
Signed-off-by: Bin Meng bmeng@tinylab.org Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/next, thanks!

On Sun, 30 Apr 2023 at 21:35, Bin Meng bmeng@tinylab.org wrote:
fit_conf_get_node() returns a negative value on error.
Signed-off-by: Bin Meng bmeng@tinylab.org
cmd/fdt.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Reviewed-by: Simon Glass sjg@chromium.org

On Mon, May 01, 2023 at 11:35:25AM +0800, Bin Meng wrote:
fit_conf_get_node() returns a negative value on error.
Signed-off-by: Bin Meng bmeng@tinylab.org Reviewed-by: Simon Glass sjg@chromium.org
Applied to u-boot/next, thanks!
participants (3)
-
Bin Meng
-
Simon Glass
-
Tom Rini