svn commit: r294440 - head/sys/dev/ofw
Michal Meloun
mmel at FreeBSD.org
Wed Jan 20 14:49:02 UTC 2016
Author: mmel
Date: Wed Jan 20 14:49:01 2016
New Revision: 294440
URL: https://svnweb.freebsd.org/changeset/base/294440
Log:
OFW: Fix ofw_bus_string_list_to_array() function.
Originally committed version was unfinished and didn't work at all,
because I took it from the wrong WIP branch by mistake.
Approved by: kib (mentor)
Modified:
head/sys/dev/ofw/ofw_bus_subr.c
Modified: head/sys/dev/ofw/ofw_bus_subr.c
==============================================================================
--- head/sys/dev/ofw/ofw_bus_subr.c Wed Jan 20 14:45:54 2016 (r294439)
+++ head/sys/dev/ofw/ofw_bus_subr.c Wed Jan 20 14:49:01 2016 (r294440)
@@ -716,9 +716,10 @@ ofw_bus_find_string_index(phandle_t node
*/
int
ofw_bus_string_list_to_array(phandle_t node, const char *list_name,
- const char ***array)
+ const char ***out_array)
{
char *elems, *tptr;
+ const char **array;
int i, cnt, nelems, len;
elems = NULL;
@@ -731,11 +732,11 @@ ofw_bus_string_list_to_array(phandle_t n
i += strlen(elems + i) + 1;
/* Allocate space for arrays and all strings. */
- *array = malloc((cnt + 1) * sizeof(char *) + nelems, M_OFWPROP,
+ array = malloc((cnt + 1) * sizeof(char *) + nelems, M_OFWPROP,
M_WAITOK);
/* Get address of first string. */
- tptr = (char *)(*array + cnt);
+ tptr = (char *)(array + cnt + 1);
/* Copy strings. */
memcpy(tptr, elems, nelems);
@@ -743,12 +744,13 @@ ofw_bus_string_list_to_array(phandle_t n
/* Fill string pointers. */
for (i = 0, cnt = 0; i < nelems; cnt++) {
- len = strlen(tptr + i) + 1;
- *array[cnt] = tptr;
+ len = strlen(tptr) + 1;
+ array[cnt] = tptr;
i += len;
tptr += len;
}
- *array[cnt] = 0;
+ array[cnt] = 0;
+ *out_array = array;
return (cnt);
}
More information about the svn-src-head
mailing list