Stop adding an extra null terminator to strings, OF_getprop already returns

a null terminated string.
This commit is contained in:
andrew 2016-02-12 17:04:03 +00:00
parent d555ff6357
commit f0f0917197

View File

@ -401,10 +401,9 @@ mv_twsi_attach(device_t dev)
for (child = OF_child(ofw_bus_get_node(dev)); child != 0; for (child = OF_child(ofw_bus_get_node(dev)); child != 0;
child = OF_peer(child)) { child = OF_peer(child)) {
len = OF_getproplen(child, "model"); len = OF_getproplen(child, "model");
if (len <= 0 || len > sizeof(dname) - 1) if (len <= 0 || len > sizeof(dname))
continue; continue;
error = OF_getprop(child, "model", &dname, len); error = OF_getprop(child, "model", &dname, len);
dname[len + 1] = '\0';
if (error == -1) if (error == -1)
continue; continue;
len = strlen(dname); len = strlen(dname);
@ -428,10 +427,9 @@ mv_twsi_attach(device_t dev)
/* Get device driver name. */ /* Get device driver name. */
len = OF_getproplen(child, "model"); len = OF_getproplen(child, "model");
if (len <= 0 || len > sizeof(dname) - 1) if (len <= 0 || len > sizeof(dname))
continue; continue;
OF_getprop(child, "model", &dname, len); OF_getprop(child, "model", &dname, len);
dname[len + 1] = '\0';
if (bootverbose) if (bootverbose)
device_printf(dev, "adding a device %s at %d.\n", device_printf(dev, "adding a device %s at %d.\n",