Beware that this post is related to an SDK in maintenance mode
More Info: Consider nRF Connect SDK for new designs
This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

app_sched_event_put NULL data pointer is not NULL

Hello,

This behavior within the SDK has bitten me a couple times so I thought it would be a good thing to share. If you call app_sched_event_put(NULL, 0, &my_function), when "my_function" is called, the data pointer is not NULL for the size parameter is zero. Therefore the following will not work.

Caller:

extern void event_handler(void* data, size_t data_len);

app_sched_event_put(NULL, 0, event_handler);

Callee:

void event_handler(void* data, size_t data_len)
{
    // This will not work, check data+len instead
    if (data == NULL) {
        do_something();
    }
}

Related