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:
parent
8d7181d1e0
commit
4a4b4c98f5
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=334790
@ -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);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user