Skip to content

Commit

Permalink
Fix(NetworkEvents): Don't skip event callbacks in NetworkEvents::remo…
Browse files Browse the repository at this point in the history
…veEvent

Fixes Issue 10318
Includes pull request 10321 that fixes 10316

This change:
* Adds code to find the event callbacks
* Issues warning when duplicate callbacks insertion attempts are made
* Issues warning when callbacks are not found during removal
  • Loading branch information
LeeLeahy2 committed Sep 15, 2024
1 parent 0c8809e commit 33a77d8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions libraries/Network/src/NetworkEvents.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ network_event_handle_t NetworkEvents::onEvent(NetworkEventCb cbEvent, arduino_ev
}

if (findEvent(cbEvent, event) < cbEventList.size()) {
log_e("Attempt to add duplicate event handler!");
log_w("Attempt to add duplicate event handler!");
return 0;
}

Expand All @@ -216,7 +216,7 @@ network_event_handle_t NetworkEvents::onEvent(NetworkEventFuncCb cbEvent, arduin
}

if (findEvent(cbEvent, event) < cbEventList.size()) {
log_e("Attempt to add duplicate event handler!");
log_w("Attempt to add duplicate event handler!");
return 0;
}

Expand All @@ -235,7 +235,7 @@ network_event_handle_t NetworkEvents::onEvent(NetworkEventSysCb cbEvent, arduino
}

if (findEvent(cbEvent, event) < cbEventList.size()) {
log_e("Attempt to add duplicate event handler!");
log_w("Attempt to add duplicate event handler!");
return 0;
}

Expand All @@ -254,7 +254,7 @@ network_event_handle_t NetworkEvents::onSysEvent(NetworkEventCb cbEvent, arduino
}

if (findEvent(cbEvent, event) < cbEventList.size()) {
log_e("Attempt to add duplicate event handler!");
log_w("Attempt to add duplicate event handler!");
return 0;
}

Expand All @@ -273,7 +273,7 @@ network_event_handle_t NetworkEvents::onSysEvent(NetworkEventFuncCb cbEvent, ard
}

if (findEvent(cbEvent, event) < cbEventList.size()) {
log_e("Attempt to add duplicate event handler!");
log_w("Attempt to add duplicate event handler!");
return 0;
}

Expand All @@ -292,7 +292,7 @@ network_event_handle_t NetworkEvents::onSysEvent(NetworkEventSysCb cbEvent, ardu
}

if (findEvent(cbEvent, event) < cbEventList.size()) {
log_e("Attempt to add duplicate event handler!");
log_w("Attempt to add duplicate event handler!");
return 0;
}

Expand All @@ -314,7 +314,7 @@ void NetworkEvents::removeEvent(NetworkEventCb cbEvent, arduino_event_id_t event

i = findEvent(cbEvent, event);
if (i >= cbEventList.size()) {
log_e("Event handler not found!");
log_w("Event handler not found!");
return;
}

Expand All @@ -330,7 +330,7 @@ void NetworkEvents::removeEvent(NetworkEventFuncCb cbEvent, arduino_event_id_t e

i = findEvent(cbEvent, event);
if (i >= cbEventList.size()) {
log_e("Event handler not found!");
log_w("Event handler not found!");
return;
}

Expand All @@ -346,7 +346,7 @@ void NetworkEvents::removeEvent(NetworkEventSysCb cbEvent, arduino_event_id_t ev

i = findEvent(cbEvent, event);
if (i >= cbEventList.size()) {
log_e("Event handler not found!");
log_w("Event handler not found!");
return;
}

Expand All @@ -361,7 +361,7 @@ void NetworkEvents::removeEvent(network_event_handle_t id) {
return;
}
}
log_e("Event handler not found!");
log_w("Event handler not found!");
}

int NetworkEvents::setStatusBits(int bits) {
Expand Down

0 comments on commit 33a77d8

Please sign in to comment.