Re: [PATCH] libfdt: fdt_check_full: Add can_assume(PERFECT) check

Simon Glass <[email protected]> Tue, 26 May 2026 23:41:10 -0500
Newsgroups org.kernel.vger.devicetree-compiler
Message-ID <CAFLszTg661QLq3mDdckGChnM_g0s-06nHvEJpnM8QAYh5gVQ1w@mail.gmail.com>
On Tue, 26 May 2026 at 14:30, Tom Rini <[email protected]> wrote:
>
> In this function from fdt_check.c we have (reasonably and as the name
> implies) a number of checks on the DTB. However, there are cases where
> we may wish to assume that we have been given a perfect DTB already and
> do nothing here. Add a test for can_assume(PERFECT) as the first check
> in this function and if true, perform no checks.
>
> Signed-off-by: Tom Rini <[email protected]>
> ---
> Along the lines of the patches I posted back in December, in U-Boot SPL
> we just don't have the space for this check much of the time and so have
> always omitted it (going back to at least when Simon posted the initial
> patch to make libfdt/fdt_check.c here). This is another case where it's
> a noticeable size win for us. I had missed this change in particular
> because we had in turn missed catching up on fdt_check_full being moved
> out of fdt_ro.c and in to fdt_check.c.
> ---
>  libfdt/fdt_check.c | 2 ++
>  1 file changed, 2 insertions(+)

This does honour the flags so...

Reviewed-by: Simon Glass <[email protected]>


>
> diff --git a/libfdt/fdt_check.c b/libfdt/fdt_check.c
> index cca052353213..2fd5b61d016a 100644
> --- a/libfdt/fdt_check.c
> +++ b/libfdt/fdt_check.c
> @@ -21,6 +21,8 @@ int fdt_check_full(const void *fdt, size_t bufsize)
>         const char *propname;
>         bool expect_end = false;
>
> +       if (can_assume(PERFECT))
> +               return 0;
>         if (bufsize < FDT_V1_SIZE)
>                 return -FDT_ERR_TRUNCATED;
>         if (bufsize < fdt_header_size(fdt))
> --
> 2.43.0
>
>