forked from drath/libratbag
Allow a NULL udev device for ratbag_device_new
The client-exposed API requires a valid device, but internally we can handle NULL - this way we can hook up the test suite easier. Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This commit is contained in:
committed by
Benjamin Tissoires
parent
9deaedbfc5
commit
04fa488a22
@@ -260,7 +260,8 @@ ratbag_device_new(struct ratbag *ratbag, struct udev_device *udev_device,
|
||||
device->ratbag = ratbag_ref(ratbag);
|
||||
device->hidraw_fd = -1;
|
||||
device->refcount = 1;
|
||||
device->udev_device = udev_device_ref(udev_device);
|
||||
if (udev_device)
|
||||
device->udev_device = udev_device_ref(udev_device);
|
||||
|
||||
device->ids = *id;
|
||||
list_init(&device->profiles);
|
||||
@@ -476,6 +477,10 @@ ratbag_device_new_from_udev_device(struct ratbag *ratbag,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!udev_device) {
|
||||
log_bug_client(ratbag, "udev device is NULL.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (get_product_id(udev_device, &id) != 0)
|
||||
goto out_err;
|
||||
|
||||
Reference in New Issue
Block a user