cleanup: Comply with new cimple callback rules.

* Function arguments must use `foo_cb *p` and can't just use `foo_cb p`
* You can no longer cast function pointers (if it's incompatible, you
  must wrap the callback). I'm avoiding this with tokstyle exclusions.
This commit is contained in:
iphydf 2022-02-06 16:37:24 +00:00
parent 4d4120214a
commit cde796f1f8
No known key found for this signature in database
GPG Key ID: 3855DBA2D74403C9
5 changed files with 15 additions and 10 deletions

View File

@ -1 +1 @@
64e519c68f23246ea4f490bdc2973d8bc1217da802596ad550048d3767b7214a /usr/local/bin/tox-bootstrapd 21bbf4e49911d31cef0f50195affe86138630703c7072c67ffd7802f7e588190 /usr/local/bin/tox-bootstrapd

View File

@ -854,7 +854,10 @@ static void set_friend_typing(const Messenger *m, int32_t friendnumber, uint8_t
/** Set the function that will be executed when a friend request is received. */ /** Set the function that will be executed when a friend request is received. */
void m_callback_friendrequest(Messenger *m, m_friend_request_cb *function) void m_callback_friendrequest(Messenger *m, m_friend_request_cb *function)
{ {
/* TODO(iphydf): Don't cast function pointers. */
//!TOKSTYLE-
callback_friendrequest(m->fr, (fr_friend_request_cb *)function, m); callback_friendrequest(m->fr, (fr_friend_request_cb *)function, m);
//!TOKSTYLE+
} }
/** Set the function that will be executed when a message from a friend is received. */ /** Set the function that will be executed when a message from a friend is received. */
@ -2818,9 +2821,9 @@ static uint32_t m_state_plugins_size(const Messenger *m)
* returns true on success * returns true on success
* returns false on error * returns false on error
*/ */
bool m_register_state_plugin(Messenger *m, State_Type type, m_state_size_cb size_callback, bool m_register_state_plugin(Messenger *m, State_Type type, m_state_size_cb *size_callback,
m_state_load_cb load_callback, m_state_load_cb *load_callback,
m_state_save_cb save_callback) m_state_save_cb *save_callback)
{ {
Messenger_State_Plugin *temp = (Messenger_State_Plugin *)realloc(m->options.state_plugins, Messenger_State_Plugin *temp = (Messenger_State_Plugin *)realloc(m->options.state_plugins,
sizeof(Messenger_State_Plugin) * (m->options.state_plugins_length + 1)); sizeof(Messenger_State_Plugin) * (m->options.state_plugins_length + 1));

View File

@ -744,8 +744,8 @@ uint32_t messenger_run_interval(const Messenger *m);
* returns true on success * returns true on success
* returns false on error * returns false on error
*/ */
bool m_register_state_plugin(Messenger *m, State_Type type, m_state_size_cb size_callback, bool m_register_state_plugin(Messenger *m, State_Type type, m_state_size_cb *size_callback,
m_state_load_cb load_callback, m_state_save_cb save_callback); m_state_load_cb *load_callback, m_state_save_cb *save_callback);
/** return size of the messenger data (for saving). */ /** return size of the messenger data (for saving). */
uint32_t messenger_size(const Messenger *m); uint32_t messenger_size(const Messenger *m);

View File

@ -724,15 +724,14 @@ void networking_poll(const Networking_Core *net, void *userdata)
continue; continue;
} }
packet_handler_cb *const cb = net->packethandlers[data[0]].function; const Packet_Handler *const handler = &net->packethandlers[data[0]];
void *const object = net->packethandlers[data[0]].object;
if (cb == nullptr) { if (handler->function == nullptr) {
LOGGER_WARNING(net->log, "[%02u] -- Packet has no handler", data[0]); LOGGER_WARNING(net->log, "[%02u] -- Packet has no handler", data[0]);
continue; continue;
} }
cb(object, &ip_port, data, length, userdata); handler->function(handler->object, &ip_port, data, length, userdata);
} }
} }

View File

@ -452,7 +452,10 @@ Tox *tox_new(const struct Tox_Options *options, Tox_Err_New *error)
m_options.hole_punching_enabled = tox_options_get_hole_punching_enabled(opts); m_options.hole_punching_enabled = tox_options_get_hole_punching_enabled(opts);
m_options.local_discovery_enabled = tox_options_get_local_discovery_enabled(opts); m_options.local_discovery_enabled = tox_options_get_local_discovery_enabled(opts);
// TODO(iphydf): Don't cast function pointers.
//!TOKSTYLE-
m_options.log_callback = (logger_cb *)tox_options_get_log_callback(opts); m_options.log_callback = (logger_cb *)tox_options_get_log_callback(opts);
//!TOKSTYLE+
m_options.log_context = tox; m_options.log_context = tox;
m_options.log_user_data = tox_options_get_log_user_data(opts); m_options.log_user_data = tox_options_get_log_user_data(opts);