Skip to content

Commit

Permalink
Don't force queueCallback with no parameter
Browse files Browse the repository at this point in the history
Sanitizer reports undefined behaviour passing parameter to function which doesn't expect one.
Works fine in practice but safer to add a lamba for dealing with it.
  • Loading branch information
mikee47 committed Jun 28, 2024
1 parent e16b785 commit cbb1781
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
6 changes: 6 additions & 0 deletions Sming/Platform/System.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,12 @@ bool SystemClass::queueCallback(TaskCallback callback, void* param)
reinterpret_cast<os_param_t>(param));
}

bool SystemClass::queueCallback(InterruptCallback callback)
{
return queueCallback([](void* param) { reinterpret_cast<InterruptCallback>(param)(); },
reinterpret_cast<void*>(callback));
}

bool SystemClass::queueCallback(TaskDelegate callback)
{
if(!callback) {
Expand Down
5 changes: 1 addition & 4 deletions Sming/Platform/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,7 @@ class SystemClass
/**
* @brief Queue a deferred callback with no callback parameter
*/
__forceinline static bool IRAM_ATTR queueCallback(InterruptCallback callback)
{
return queueCallback(reinterpret_cast<TaskCallback>(callback));
}
static bool IRAM_ATTR queueCallback(InterruptCallback callback);

/**
* @brief Queue a deferred Delegate callback
Expand Down

0 comments on commit cbb1781

Please sign in to comment.