f = fopen(dbfile, "re");
if (f == NULL) {
- dbg(udev_device->udev, "no db file to read %s: %m\n", dbfile);
+ udev_dbg(udev_device->udev, "no db file to read %s: %m\n", dbfile);
return -1;
}
udev_device->is_initialized = true;
}
fclose(f);
- dbg(udev_device->udev, "device %p filled with db file data\n", udev_device);
+ udev_dbg(udev_device->udev, "device %p filled with db file data\n", udev_device);
return 0;
}
/* path starts in sys */
if (!startswith(syspath, TEST_PREFIX "/sys")) {
- dbg(udev, "not in sys :%s\n", syspath);
+ udev_dbg(udev, "not in sys :%s\n", syspath);
return NULL;
}
return NULL;
udev_device_set_syspath(udev_device, path);
- dbg(udev, "device %p has devpath '%s'\n", udev_device, udev_device_get_devpath(udev_device));
+ udev_dbg(udev, "device %p has devpath '%s'\n", udev_device, udev_device_get_devpath(udev_device));
return udev_device;
}
udev_device_add_property_from_string_parse(udev_device, environ[i]);
if (udev_device_add_property_from_string_parse_finish(udev_device) < 0) {
- dbg(udev, "missing values, invalid device\n");
+ udev_dbg(udev, "missing values, invalid device\n");
udev_device_unref(udev_device);
udev_device = NULL;
}
* Drop a reference of a udev device. If the refcount reaches zero,
* the resources of the device will be released.
*
+ * Returns: the passed udev device if it has still an active reference, or #NULL otherwise.
**/
-_public_ void udev_device_unref(struct udev_device *udev_device)
+_public_ struct udev_device *udev_device_unref(struct udev_device *udev_device)
{
if (udev_device == NULL)
- return;
+ return NULL;
udev_device->refcount--;
if (udev_device->refcount > 0)
- return;
+ return udev_device;
if (udev_device->parent_device != NULL)
udev_device_unref(udev_device->parent_device);
free(udev_device->syspath);
free(udev_device->envp);
free(udev_device->monitor_buf);
free(udev_device);
+ return NULL;
}
/**