Date: Thu, 7 Jun 2018 15:59:08 +0000 (UTC) From: Breno Leitao <leitao@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r334790 - head/sys/dev/ofw Message-ID: <201806071559.w57Fx8Xq007405@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: leitao Date: Thu Jun 7 15:59:08 2018 New Revision: 334790 URL: https://svnweb.freebsd.org/changeset/base/334790 Log: dev/ofw: Fix ofw_fdt_getprop() return values to match documentation Fix the behavior of ofw_fdt_getprop() and ofw_fdt_getprop() functions to match the documentation as the non-fdt code. Submitted by: Luis Pires <lffpires@ruabrasil.org> Reviewed by: manu, jhibbits Approved by: jhibbits (mentor) Differential Revision: https://reviews.freebsd.org/D15680 Modified: head/sys/dev/ofw/ofw_fdt.c Modified: head/sys/dev/ofw/ofw_fdt.c ============================================================================== --- head/sys/dev/ofw/ofw_fdt.c Thu Jun 7 15:51:23 2018 (r334789) +++ head/sys/dev/ofw/ofw_fdt.c Thu Jun 7 15:59:08 2018 (r334790) @@ -279,8 +279,6 @@ ofw_fdt_getprop(ofw_t ofw, phandle_t package, const ch /* Emulate the 'name' property */ name = fdt_get_name(fdtp, offset, &len); strncpy(buf, name, buflen); - if (len + 1 > buflen) - len = buflen; return (len + 1); } @@ -299,9 +297,8 @@ ofw_fdt_getprop(ofw_t ofw, phandle_t package, const ch if (prop == NULL) return (-1); - if (len > buflen) - len = buflen; - bcopy(prop, buf, len); + bcopy(prop, buf, min(len, buflen)); + return (len); }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201806071559.w57Fx8Xq007405>