Re: [RFC PATCH 03/15] fdtdump: Return an error code on wrong tag value

From: David Gibson

Date: Mon Feb 23 2026 - 00:38:44 EST


On Tue, Feb 10, 2026 at 06:33:31PM +0100, Herve Codina wrote:
> fdtdump prints a message on stderr when it encounters a wrong tag and
> stop its processing without returning an error code.
>
> Having a wrong tag is really a failure. Indeed, the processing cannot
> continue.
>
> Be more strict. Stop the processing, print a message and return an
> error code. In other words, call die().
>
> Signed-off-by: Herve Codina <herve.codina@xxxxxxxxxxx>

The intention of fdtdump is that it's a fairly crude debugging tool -
it will generally attempt to produce at least partial output even on a
bad dtb file. If you want a polished tool for use on good dtbs, use
:dtc -I dtb -O dts".

That's why this didn't die() initially - the idea is if there's some
bogus stuff in the dtb, it might print a bunch of these warnings, but
eventually resynchronize on another valid tag.

So, I'm disinclined to apply this without a stronger case.

> ---
> fdtdump.c | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/fdtdump.c b/fdtdump.c
> index 6c9ad90..0e7a265 100644
> --- a/fdtdump.c
> +++ b/fdtdump.c
> @@ -146,8 +146,7 @@ static void dump_blob(void *blob, bool debug)
> continue;
> }
>
> - fprintf(stderr, "%*s ** Unknown tag 0x%08"PRIx32"\n", depth * shift, "", tag);
> - break;
> + die("** Unknown tag 0x%08"PRIx32"\n", tag);
> }
> }
>
> --
> 2.52.0
>
>

--
David Gibson (he or they) | I'll have my music baroque, and my code
david AT gibson.dropbear.id.au | minimalist, thank you, not the other way
| around.
http://www.ozlabs.org/~dgibson

Attachment: signature.asc
Description: PGP signature