libfdt_internal: fdt_find_string_len_()
Allow specifying string length to `fdt_find_string_`. fdt_find_string_() now internally uses this function. Reviewed-by: David Gibson <david@gibson.dropbear.id.au> Signed-off-by: Ayush Singh <ayush@beagleboard.org> Message-ID: <20241205-setprop-namelen-v2-2-0d85a3d2e7b1@beagleboard.org> Signed-off-by: David Gibson <david@gibson.dropbear.id.au>main
parent
56b2b30c5b
commit
0f69cedc08
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue