1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00
RIOT/sys/event/callback.c
Francisco Molina 797f19d4cd sys/event/callback: in init set list_node.next to NULL
When using static initializers uninitialized fields are set to 0, or
NULL for pointers. But when using event_callback_init() on non
static variables event_callback_t structure may hold non 0 values.
This will lead to the event never being called since if super.list_node.next
is not NULL as it is considered already in the event queue and therefore
not touched.
2022-02-09 13:08:21 +01:00

26 lines
804 B
C

/*
* Copyright (C) 2017 Inria
* 2017 Freie Universität Berlin
* 2017 Kaspar Schleiser <kaspar@schleiser.de>
*
* This file is subject to the terms and conditions of the GNU Lesser
* General Public License v2.1. See the file LICENSE in the top level
* directory for more details.
*/
#include "event/callback.h"
void _event_callback_handler(event_t *event)
{
event_callback_t *event_callback = (event_callback_t *) event;
event_callback->callback(event_callback->arg);
}
void event_callback_init(event_callback_t *event_callback, void (callback)(void *), void *arg)
{
memset(event_callback, 0, sizeof(*event_callback));
event_callback->super.handler = _event_callback_handler;
event_callback->callback = callback;
event_callback->arg = arg;
}