From: David Gibson <david@gibson.dropbear.id.au>
To: Ayush Singh <ayush@beagleboard.org>
Cc: d-gole@ti.com, lorforlinux@beagleboard.org,
jkridner@beagleboard.org, robertcnelson@beagleboard.org,
nenad.marinkovic@mikroe.com, Andrew Davis <afd@ti.com>,
Geert Uytterhoeven <geert@linux-m68k.org>,
Robert Nelson <robertcnelson@gmail.com>,
devicetree-compiler@vger.kernel.org
Subject: Re: [PATCH 2/4] libfdt_internal: fdt_find_string_len_()
Date: Wed, 4 Dec 2024 11:22:19 +1100 [thread overview]
Message-ID: <Z0-gu8wQVGRtmjMM@zatzit> (raw)
In-Reply-To: <20241203-setprop-namelen-v1-2-d1ea333fbd6c@beagleboard.org>
[-- Attachment #1: Type: text/plain, Size: 2656 bytes --]
On Wed, Dec 04, 2024 at 12:00:00AM +0530, Ayush Singh wrote:
> Allow specifying string length to `fdt_find_string_`.
> fdt_find_string_() now internally uses this function.
>
> Signed-off-by: Ayush Singh <ayush@beagleboard.org>
Reviewed-by: David Gibson <david@gibson.dropbear.id.au>
> ---
> libfdt/fdt.c | 8 ++++----
> libfdt/libfdt_internal.h | 11 ++++++++++-
> 2 files changed, 14 insertions(+), 5 deletions(-)
>
> diff --git a/libfdt/fdt.c b/libfdt/fdt.c
> index 20c6415b9ced113d9fcce25b69007a6b0f9e68e7..95f644c31f9431eb597b6f683741ff9be375cebf 100644
> --- a/libfdt/fdt.c
> +++ b/libfdt/fdt.c
> @@ -312,14 +312,14 @@ int fdt_next_subnode(const void *fdt, int offset)
> return offset;
> }
>
> -const char *fdt_find_string_(const char *strtab, int tabsize, const char *s)
> +const char *fdt_find_string_len_(const char *strtab, int tabsize, const char *s,
> + int slen)
> {
> - int len = strlen(s) + 1;
> - const char *last = strtab + tabsize - len;
> + const char *last = strtab + tabsize - (slen + 1);
> const char *p;
>
> for (p = strtab; p <= last; p++)
> - if (memcmp(p, s, len) == 0)
> + if (memcmp(p, s, slen) == 0 && p[slen] == '\0')
> return p;
> return NULL;
> }
> diff --git a/libfdt/libfdt_internal.h b/libfdt/libfdt_internal.h
> index 16bda1906a7b335519b9f748d1be6110de551e79..1fd35f364e9af15df19ae5b8b7231584804e96a4 100644
> --- a/libfdt/libfdt_internal.h
> +++ b/libfdt/libfdt_internal.h
> @@ -6,6 +6,7 @@
> * Copyright (C) 2006 David Gibson, IBM Corporation.
> */
> #include <fdt.h>
> +#include <string.h>
>
> #define FDT_ALIGN(x, a) (((x) + (a) - 1) & ~((a) - 1))
> #define FDT_TAGALIGN(x) (FDT_ALIGN((x), FDT_TAGSIZE))
> @@ -20,7 +21,15 @@ int32_t fdt_ro_probe_(const void *fdt);
>
> int fdt_check_node_offset_(const void *fdt, int offset);
> int fdt_check_prop_offset_(const void *fdt, int offset);
> -const char *fdt_find_string_(const char *strtab, int tabsize, const char *s);
> +
> +const char *fdt_find_string_len_(const char *strtab, int tabsize, const char *s,
> + int s_len);
> +static inline const char *fdt_find_string_(const char *strtab, int tabsize,
> + const char *s)
> +{
> + return fdt_find_string_len_(strtab, tabsize, s, strlen(s));
> +}
> +
> int fdt_node_end_offset_(void *fdt, int nodeoffset);
>
> static inline const void *fdt_offset_ptr_(const void *fdt, int offset)
>
--
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 #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2024-12-04 0:34 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-03 18:29 [PATCH 0/4] libfdt: Add namelen variants for setprop Ayush Singh
2024-12-03 18:29 ` [PATCH 1/4] libfdt: add fdt_get_property_namelen_w() Ayush Singh
2024-12-04 0:21 ` David Gibson
2024-12-03 18:30 ` [PATCH 2/4] libfdt_internal: fdt_find_string_len_() Ayush Singh
2024-12-04 0:22 ` David Gibson [this message]
2024-12-03 18:30 ` [PATCH 3/4] libfdt: Add fdt_setprop_namelen() Ayush Singh
2024-12-04 0:29 ` David Gibson
2024-12-04 7:39 ` Ayush Singh
2024-12-04 23:45 ` David Gibson
2024-12-03 18:30 ` [PATCH 4/4] libfdt: Add fdt_setprop_namelen_string() Ayush Singh
2024-12-04 0:32 ` David Gibson
2024-12-04 0:34 ` [PATCH 0/4] libfdt: Add namelen variants for setprop David Gibson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z0-gu8wQVGRtmjMM@zatzit \
--to=david@gibson.dropbear.id.au \
--cc=afd@ti.com \
--cc=ayush@beagleboard.org \
--cc=d-gole@ti.com \
--cc=devicetree-compiler@vger.kernel.org \
--cc=geert@linux-m68k.org \
--cc=jkridner@beagleboard.org \
--cc=lorforlinux@beagleboard.org \
--cc=nenad.marinkovic@mikroe.com \
--cc=robertcnelson@beagleboard.org \
--cc=robertcnelson@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.