Simplify string table access functions
The range sanity checking on the fdt_string_cmp() function causes problems for the sequential write code (or at least for using RO functions on an incomplete SW tree). Plus they didn't really fit with the philosphy for the RO code of working as widely as possible on weirdly constructed trees.main
parent
156649d4f6
commit
3aa4cfd66b
20
fdt.c
20
fdt.c
|
@ -34,26 +34,6 @@ void *fdt_offset_ptr(const struct fdt_header *fdt, int offset, int len)
|
|||
return p;
|
||||
}
|
||||
|
||||
char *fdt_string(const struct fdt_header *fdt, int stroffset)
|
||||
{
|
||||
return (char *)fdt + fdt32_to_cpu(fdt->off_dt_strings) + stroffset;
|
||||
}
|
||||
|
||||
int fdt_string_cmp(const struct fdt_header *fdt, int stroffset, const char *s2)
|
||||
{
|
||||
const char *s1 = fdt_string(fdt, stroffset);
|
||||
int len = strlen(s2) + 1;
|
||||
|
||||
if (! s1)
|
||||
return 0;
|
||||
|
||||
if ((stroffset + len < stroffset)
|
||||
|| (stroffset + len > fdt32_to_cpu(fdt->size_dt_strings)))
|
||||
return -2;
|
||||
|
||||
return strcmp(s1, s2);
|
||||
}
|
||||
|
||||
uint32_t _fdt_next_tag(const struct fdt_header *fdt, int offset, int *nextoffset)
|
||||
{
|
||||
const uint32_t *tagp, *lenp;
|
||||
|
|
7
fdt_ro.c
7
fdt_ro.c
|
@ -59,6 +59,11 @@ static int offset_streq(const struct fdt_header *fdt, int offset,
|
|||
return 1;
|
||||
}
|
||||
|
||||
char *fdt_string(const struct fdt_header *fdt, int stroffset)
|
||||
{
|
||||
return (char *)fdt + fdt32_to_cpu(fdt->off_dt_strings) + stroffset;
|
||||
}
|
||||
|
||||
int fdt_property_offset(const struct fdt_header *fdt, int nodeoffset,
|
||||
const char *name)
|
||||
{
|
||||
|
@ -103,7 +108,7 @@ int fdt_property_offset(const struct fdt_header *fdt, int nodeoffset,
|
|||
if (! prop)
|
||||
return OFFSET_ERROR(FDT_ERR_BADSTRUCTURE);
|
||||
namestroff = fdt32_to_cpu(prop->nameoff);
|
||||
if (fdt_string_cmp(fdt, namestroff, name) == 0)
|
||||
if (streq(fdt_string(fdt, namestroff), name))
|
||||
/* Found it! */
|
||||
return offset;
|
||||
break;
|
||||
|
|
5
libfdt.h
5
libfdt.h
|
@ -54,10 +54,9 @@ void *fdt_offset_ptr(const struct fdt_header *fdt, int offset, int checklen);
|
|||
#define fdt_ptr_error(ptr) \
|
||||
( (((long)(ptr) < 0) && ((long)(ptr) >= -FDT_ERR_MAX)) ? -(long)(ptr) : 0 )
|
||||
|
||||
char *fdt_string(const struct fdt_header *fdt, int stroffset);
|
||||
int fdt_string_cmp(const struct fdt_header *fdt, int stroffset, const char *s2);
|
||||
|
||||
/* Read-only functions */
|
||||
char *fdt_string(const struct fdt_header *fdt, int stroffset);
|
||||
|
||||
int fdt_property_offset(const struct fdt_header *fdt, int nodeoffset,
|
||||
const char *name);
|
||||
int fdt_subnode_offset_namelen(const struct fdt_header *fdt, int parentoffset,
|
||||
|
|
Loading…
Reference in New Issue