Skip to content

Commit 872c984

Browse files
committed
Fix omitted casts in template member function
1 parent 33a6487 commit 872c984

File tree

2 files changed

+8
-8
lines changed

2 files changed

+8
-8
lines changed

cores/esp32/Ticker.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ class Ticker
5858
// C-cast serves two purposes:
5959
// static_cast for smaller integer types,
6060
// reinterpret_cast + const_cast for pointer types
61-
_attach_ms(seconds * 1000, true, callback, arg);
61+
_attach_ms(seconds * 1000, true, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);
6262
}
6363

6464
template<typename TArg>
6565
void attach_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg)
6666
{
6767
static_assert(sizeof(TArg) <= sizeof(void*), "attach() callback argument size must be <= sizeof(void*)");
68-
_attach_ms(milliseconds, true, callback, arg);
68+
_attach_ms(milliseconds, true, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);
6969
}
7070

7171
void once(float seconds, callback_function_t callback)
@@ -84,14 +84,14 @@ class Ticker
8484
void once(float seconds, void (*callback)(TArg), TArg arg)
8585
{
8686
static_assert(sizeof(TArg) <= sizeof(void*), "attach() callback argument size must be <= sizeof(void*)");
87-
_attach_ms(seconds * 1000, false, callback, arg);
87+
_attach_ms(seconds * 1000, false, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);
8888
}
8989

9090
template<typename TArg>
9191
void once_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg)
9292
{
9393
static_assert(sizeof(TArg) <= sizeof(void*), "attach() callback argument size must be <= sizeof(void*)");
94-
_attach_ms(milliseconds, false, callback, arg);
94+
_attach_ms(milliseconds, false, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);
9595
}
9696

9797
void detach();

libraries/Ticker/src/Ticker.h

+4-4
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ class Ticker
5858
// C-cast serves two purposes:
5959
// static_cast for smaller integer types,
6060
// reinterpret_cast + const_cast for pointer types
61-
_attach_ms(seconds * 1000, true, callback, arg);
61+
_attach_ms(seconds * 1000, true, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);
6262
}
6363

6464
template<typename TArg>
6565
void attach_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg)
6666
{
6767
static_assert(sizeof(TArg) <= sizeof(void*), "attach() callback argument size must be <= sizeof(void*)");
68-
_attach_ms(milliseconds, true, callback, arg);
68+
_attach_ms(milliseconds, true, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);
6969
}
7070

7171
void once(float seconds, callback_function_t callback)
@@ -84,14 +84,14 @@ class Ticker
8484
void once(float seconds, void (*callback)(TArg), TArg arg)
8585
{
8686
static_assert(sizeof(TArg) <= sizeof(void*), "attach() callback argument size must be <= sizeof(void*)");
87-
_attach_ms(seconds * 1000, false, callback, arg);
87+
_attach_ms(seconds * 1000, false, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);
8888
}
8989

9090
template<typename TArg>
9191
void once_ms(uint32_t milliseconds, void (*callback)(TArg), TArg arg)
9292
{
9393
static_assert(sizeof(TArg) <= sizeof(void*), "attach() callback argument size must be <= sizeof(void*)");
94-
_attach_ms(milliseconds, false, callback, arg);
94+
_attach_ms(milliseconds, false, reinterpret_cast<callback_with_arg_t>(callback), (void*)arg);
9595
}
9696

9797
void detach();

0 commit comments

Comments
 (0)