Re: [PATCH v3 02/15] libfdt: overlay: Drop redundant *sep != ':' checks after memchr()

From: David Gibson

Date: Sun Nov 01 2026 - 23:30:37 EST


On Sun, Nov 01, 2026 at 02:01:09PM -0800, Douglas Anderson wrote:
> In `overlay_fixup_phandle()`, `sep` is obtained via `memchr(..., ':',
> ...)`. When `sep` is non-NULL, `*sep` is guaranteed to be `':'`, so the
> `|| *sep != ':'` checks are redundant. Drop them.
>
> Assisted-by: Gemini:gemini-pro-prerelease
> Signed-off-by: Douglas Anderson <dianders@xxxxxxxxxxxx>

Reviewed-by: David Gibson <david@xxxxxxxxxxxxxxxxxxxxx>

> ---
>
> Changes in v3:
> - Split the removal of redundant *sep != ':' checks out of "libfdt:
> overlay: Prepare fixup and fragment path helpers for reuse" into a
> standalone patch
>
> libfdt/fdt_overlay.c | 4 ++--
> 1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/libfdt/fdt_overlay.c b/libfdt/fdt_overlay.c
> index c6dc4774cff3..8d96428af04f 100644
> --- a/libfdt/fdt_overlay.c
> +++ b/libfdt/fdt_overlay.c
> @@ -432,7 +432,7 @@ static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
>
> path = fixup_str;
> sep = memchr(fixup_str, ':', fixup_len);
> - if (!sep || *sep != ':')
> + if (!sep)
> return -FDT_ERR_BADOVERLAY;
>
> path_len = sep - path;
> @@ -442,7 +442,7 @@ static int overlay_fixup_phandle(void *fdt, void *fdto, int symbols_off,
> fixup_len -= path_len + 1;
> name = sep + 1;
> sep = memchr(name, ':', fixup_len);
> - if (!sep || *sep != ':')
> + if (!sep)
> return -FDT_ERR_BADOVERLAY;
>
> name_len = sep - name;
> --
> 2.56.0.317.g454f8302e1-goog
>
>

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