Skip to content

Commit

Permalink
Merge pull request PixlOne#375 from PixlOne/udev-enum-fix
Browse files Browse the repository at this point in the history
Do not terminate on bad udev device
  • Loading branch information
PixlOne authored May 11, 2023
2 parents be840b3 + eb5b3ca commit 30ade71
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions src/logid/backend/raw/DeviceMonitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -135,13 +135,17 @@ void DeviceMonitor::enumerate() {
const char* name = udev_list_entry_get_name(udev_enum_entry);

struct udev_device* device = udev_device_new_from_syspath(_udev_context, name);
if (!device)
throw std::runtime_error("udev_device_new_from_syspath failed");

std::string dev_node = udev_device_get_devnode(device);
udev_device_unref(device);
if (device) {
const char* dev_node_cstr = udev_device_get_devnode(device);
if (dev_node_cstr) {
const std::string dev_node {dev_node_cstr};
udev_device_unref(device);

_addHandler(dev_node);
_addHandler(dev_node);
} else {
udev_device_unref(device);
}
}
}

udev_enumerate_unref(udev_enum);
Expand Down

0 comments on commit 30ade71

Please sign in to comment.