From owner-svn-src-head@freebsd.org Wed Jan 20 14:49:02 2016 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id AEAFEA883C6; Wed, 20 Jan 2016 14:49:02 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 7517F19DC; Wed, 20 Jan 2016 14:49:02 +0000 (UTC) (envelope-from mmel@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id u0KEn1Pd085932; Wed, 20 Jan 2016 14:49:01 GMT (envelope-from mmel@FreeBSD.org) Received: (from mmel@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id u0KEn1a5085931; Wed, 20 Jan 2016 14:49:01 GMT (envelope-from mmel@FreeBSD.org) Message-Id: <201601201449.u0KEn1a5085931@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: mmel set sender to mmel@FreeBSD.org using -f From: Michal Meloun Date: Wed, 20 Jan 2016 14:49:01 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r294440 - head/sys/dev/ofw X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 20 Jan 2016 14:49:02 -0000 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); }