Skip to content

Commit

Permalink
Code review feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Eeems committed Oct 3, 2024
1 parent 8091cd9 commit c5a7177
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 16 deletions.
22 changes: 7 additions & 15 deletions shared/liboxide/udev.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -109,25 +109,16 @@ namespace Oxide {

void UDev::addMonitor(QString subsystem, QString deviceType){
O_DEBUG("UDev::Adding" << subsystem << deviceType);
auto& list = monitors[subsystem];
if (!list) {
list = QSharedPointer<QStringList>::create();
}
if(!list->contains(deviceType)){
list->append(deviceType);
QStringList& list = monitors[subsystem];
if(!list.contains(deviceType)){
list.append(deviceType);
update = true;
}
}
void UDev::removeMonitor(QString subsystem, QString deviceType){
O_DEBUG("UDev::Removing" << subsystem << deviceType);
if(monitors.contains(subsystem)){
monitors[subsystem]->removeAll(deviceType);
update = true;
}

auto it = monitors.find(subsystem);
if(it != monitors.end() && *it){
(*it)->removeAll(deviceType);
monitors[subsystem].removeAll(deviceType);
update = true;
}
}
Expand Down Expand Up @@ -186,7 +177,8 @@ namespace Oxide {
if(udevDevice == nullptr){
return Unknown;
}
return getActionType(QString(udev_device_get_action(udevDevice)).trimmed().toUpper());
auto devType = udev_device_get_action(udevDevice);
return getActionType(QString(devType ? devType : "").trimmed().toUpper());
}

UDev::ActionType UDev::getActionType(const QString& actionType){
Expand Down Expand Up @@ -219,7 +211,7 @@ namespace Oxide {
}
O_DEBUG("UDev::Monitor applying filters...");
for(QString subsystem : monitors.keys()){
for(QString deviceType : *monitors[subsystem]){
for(QString deviceType : monitors[subsystem]){
O_DEBUG("UDev::Monitor filter" << subsystem << deviceType);
int err = udev_monitor_filter_add_match_subsystem_devtype(
mon,
Expand Down
2 changes: 1 addition & 1 deletion shared/liboxide/udev.h
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ namespace Oxide {
bool running = false;
bool exitRequested = false;
bool update = false;
QMap<QString, QSharedPointer<QStringList>> monitors;
QMap<QString, QStringList> monitors;
QThread _thread;
QMutex statelock;

Expand Down

0 comments on commit c5a7177

Please sign in to comment.