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
This commit is contained in:
Breno Leitao 2018-06-07 15:59:08 +00:00
parent 8d7181d1e0
commit 4a4b4c98f5
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=334790

View File

@ -279,8 +279,6 @@ ofw_fdt_getprop(ofw_t ofw, phandle_t package, const char *propname, void *buf,
/* 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 char *propname, void *buf,
if (prop == NULL)
return (-1);
if (len > buflen)
len = buflen;
bcopy(prop, buf, len);
bcopy(prop, buf, min(len, buflen));
return (len);
}