Change snprintf to strncpy.

Also add a comment about a bogus assumption in the current code found at
bsdcon by jhb.
This commit is contained in:
Warner Losh 2000-10-26 19:45:42 +00:00
parent bc367918c8
commit 85cc5e3588

View File

@ -255,8 +255,15 @@ allocate_driver(struct slot *slt, struct dev_desc *desc)
goto err;
}
err = device_probe_and_attach(child);
snprintf(desc->name, sizeof(desc->name), "%s",
device_get_nameunit(child));
/*
* XXX We unwisely assume that the detach code won't run while the
* XXX the attach code is attaching. Someone should put some
* XXX interlock code. This can happen if probe/attach takes a while
* XXX and the user ejects the card, which causes the detach
* XXX function to be called.
*/
strncpy(desc->name, device_get_nameunit(child), sizeof(desc->name));
desc->name[sizeof(desc->name) - 1] = '\0';
err:
if (err)
device_delete_child(pccarddev, child);