1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-24 21:34:08 +03:00

[PATCH] small cleanup udev-remove.c

Here is a small cleanup. It replaces the malloc in udev-remove.c
with a struct, like we do in udev-add.c
This commit is contained in:
kay.sievers@vrfy.org 2003-12-22 22:47:58 -08:00 committed by Greg KH
parent ca593541e6
commit 808423c90c

View File

@ -118,30 +118,26 @@ static int delete_node(struct udevice *dev)
*/
int udev_remove_device(char *path, char *subsystem)
{
struct udevice *dev;
struct udevice dev;
char *temp;
int retval;
dev = malloc(sizeof(*dev));
if (dev == NULL)
return -ENOMEM;
memset(dev, 0, sizeof(*dev));
memset(&dev, 0, sizeof(dev));
retval = udevdb_get_dev(path, dev);
retval = udevdb_get_dev(path, &dev);
if (retval) {
dbg("'%s' not found in database, falling back on default name", path);
temp = strrchr(path, '/');
if (temp == NULL)
return -ENODEV;
strncpy(dev->name, &temp[1], sizeof(dev->name));
strncpy(dev.name, &temp[1], sizeof(dev.name));
}
dbg("name is '%s'", dev->name);
dbg("name is '%s'", dev.name);
udevdb_delete_dev(path);
sysbus_send_remove(dev->name, path);
sysbus_send_remove(dev.name, path);
retval = delete_node(dev);
free(dev);
retval = delete_node(&dev);
return retval;
}