aboutsummaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorBreno Leitao <leitao@FreeBSD.org>2018-06-07 15:59:08 +0000
committerBreno Leitao <leitao@FreeBSD.org>2018-06-07 15:59:08 +0000
commit4a4b4c98f538b3ba47699824423cbf1e31219428 (patch)
treecb05380431ee39a0fdb98f16fde2a44bb2f4ea3b /sys/dev
parent8d7181d1e089a176b2c2944d98aab4774aa61e60 (diff)
downloadsrc-4a4b4c98f538b3ba47699824423cbf1e31219428.tar.gz
src-4a4b4c98f538b3ba47699824423cbf1e31219428.zip
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
Notes
Notes: svn path=/head/; revision=334790
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ofw/ofw_fdt.c7
1 files changed, 2 insertions, 5 deletions
diff --git a/sys/dev/ofw/ofw_fdt.c b/sys/dev/ofw/ofw_fdt.c
index 92c71c710a5e..aa7eadfdb022 100644
--- a/sys/dev/ofw/ofw_fdt.c
+++ b/sys/dev/ofw/ofw_fdt.c
@@ -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);
}