Date: Wed, 20 Jan 2016 14:49:01 +0000 (UTC) From: Michal Meloun <mmel@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r294440 - head/sys/dev/ofw Message-ID: <201601201449.u0KEn1a5085931@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201601201449.u0KEn1a5085931>