MCPcopy Create free account
hub / github.com/F-Stack/f-stack / fdt_stringlist_get

Function fdt_stringlist_get

freebsd/contrib/libfdt/fdt_ro.c:692–735  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

690}
691
692const char *fdt_stringlist_get(const void *fdt, int nodeoffset,
693 const char *property, int idx,
694 int *lenp)
695{
696 const char *list, *end;
697 int length;
698
699 list = fdt_getprop(fdt, nodeoffset, property, &length);
700 if (!list) {
701 if (lenp)
702 *lenp = length;
703
704 return NULL;
705 }
706
707 end = list + length;
708
709 while (list < end) {
710 length = strnlen(list, end - list) + 1;
711
712 /* Abort if the last string isn't properly NUL-terminated. */
713 if (list + length > end) {
714 if (lenp)
715 *lenp = -FDT_ERR_BADVALUE;
716
717 return NULL;
718 }
719
720 if (idx == 0) {
721 if (lenp)
722 *lenp = length - 1;
723
724 return list;
725 }
726
727 list += length;
728 idx--;
729 }
730
731 if (lenp)
732 *lenp = -FDT_ERR_NOTFOUND;
733
734 return NULL;
735}
736
737int fdt_node_check_compatible(const void *fdt, int nodeoffset,
738 const char *compatible)

Callers

nothing calls this directly

Calls 2

fdt_getpropFunction · 0.85
strnlenFunction · 0.85

Tested by

no test coverage detected