chiark / gitweb /
[PATCH] small cleanup udev-remove.c
[elogind.git] / udev-remove.c
index 6d7e2ad..c5de6c8 100644 (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;
 }