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

David Gibson <[email protected]> Mon, 23 Feb 2026 16:38:09 +1100
Newsgroups org.kernel.vger.devicetree-spec,org.kernel.vger.devicetree-compiler,org.kernel.vger.linux-devicetree,org.kernel.vger.linux-kernel
Message-ID <aZvnwbRVoX73DyLJ@zatzit>
--xlAR6RpopEeYBJuX
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

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.
>=20
> Having a wrong tag is really a failure. Indeed, the processing cannot
> continue.
>=20
> Be more strict. Stop the processing, print a message and return an
> error code. In other words, call die().
>=20
> Signed-off-by: Herve Codina <[email protected]>

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(-)
>=20
> 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;
>  		}
> =20
> -		fprintf(stderr, "%*s ** Unknown tag 0x%08"PRIx32"\n", depth * shift, "=
", tag);
> -		break;
> +		die("** Unknown tag 0x%08"PRIx32"\n", tag);
>  	}
>  }
> =20
> --=20
> 2.52.0
>=20
>=20

--=20
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

--xlAR6RpopEeYBJuX
Content-Type: application/pgp-signature; name=signature.asc

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCgAdFiEEO+dNsU4E3yXUXRK2zQJF27ox2GcFAmmb57wACgkQzQJF27ox
2Gcttw/+KRSgyBJ9wsyo7qlt9bU7bMRr57wwEBrQMDKLUG1kBqqerumaYpwTh6Ky
LzB6UDxypFKx5m/QiN+VN7VitQRyeTwNKqhhoJrlfva3XXD6LVNvxIiV666GznOt
gBTFmIVbP2LVIx8elwbCg700RjAgOa2zInSsBVgg9f5m70s3uq58gxiOF++AqsbA
BHsninCO1RXNTDPuV9TxkrSb25XuqGsCiukvSreggta6SwUA6Wlt9503YmAYUxEl
OKC/2i5PfvCYfqGZG52NIn3ey8G8V/VKt21dg4amGA7MMXkrQ125Ims8R9qiatFG
N6Kxji9Dlyt/JnA4pWsHvSJR4B3WSMlNfj3j4OdcKQHs+jfO8nIgX8/+xedvleKA
SE083+jIlQ+vgFOGSDWAZ8UX4eEb34yE026sSWwgyVo1tkA9qLAp+tTiLdQ/Q7oA
bMuONDOXgpJH414Tjmgel39wUEvvNmbV5fHTSM5PEh/p6zKZYP6FGuB6OPWL9ytY
PzvkAOCg3cm7EOPapNR/AbHzk85QADh3wIXxmCcQ+gT9xla8VfbmDoiIsMMhOqt/
eMUOWsyI1TzyOS69RVwxDrvuEy4HiZYav+speuaGVcJbgh8e0WGwU653nhcvPQgA
EzMf4WmKqeRNP//12M1jflR5jqGZBBobZ6RBCzJpJxsYyNWeGrw=
=6XGn
-----END PGP SIGNATURE-----

--xlAR6RpopEeYBJuX--