callback-job: Replace return_false() in constructors with dedicated function
Besides being clearer, this fixes issues with GCC 15. The latter uses C23 by default, which changes the meaning of function declarations without parameters such as bool return false(); Instead of "this function takes an unknown number of arguments", this now equals (void), that is, "this function takes no arguments". So we run into incompatible pointer type warnings all over when using such functions. They could be cast to (void*) but this seems the cleaner solution for this use case.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2009-2012 Tobias Brunner
|
||||
* Copyright (C) 2009-2025 Tobias Brunner
|
||||
* Copyright (C) 2007-2011 Martin Willi
|
||||
*
|
||||
* Copyright (C) secunet Security Networks AG
|
||||
@@ -131,3 +131,11 @@ callback_job_t *callback_job_create(callback_job_cb_t cb, void *data,
|
||||
return callback_job_create_with_prio(cb, data, cleanup, cancel,
|
||||
JOB_PRIO_MEDIUM);
|
||||
}
|
||||
|
||||
/*
|
||||
* Described in header
|
||||
*/
|
||||
bool callback_job_cancel_thread(void *data)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Tobias Brunner
|
||||
* Copyright (C) 2012-2025 Tobias Brunner
|
||||
* Copyright (C) 2007-2011 Martin Willi
|
||||
*
|
||||
* Copyright (C) secunet Security Networks AG
|
||||
@@ -62,6 +62,15 @@ typedef void (*callback_job_cleanup_t)(void *data);
|
||||
*/
|
||||
typedef bool (*callback_job_cancel_t)(void *data);
|
||||
|
||||
/**
|
||||
* Default implementation of callback_job_cancel_t that simply returns FALSE
|
||||
* to force cancellation of the thread by the processor.
|
||||
*
|
||||
* @param data ignored argument
|
||||
* @return always returns FALSE
|
||||
*/
|
||||
bool callback_job_cancel_thread(void *data);
|
||||
|
||||
/**
|
||||
* Class representing an callback Job.
|
||||
*
|
||||
|
||||
@@ -329,7 +329,8 @@ scheduler_t * scheduler_create()
|
||||
this->heap = (event_t**)calloc(this->heap_size + 1, sizeof(event_t*));
|
||||
|
||||
job = callback_job_create_with_prio((callback_job_cb_t)schedule, this,
|
||||
NULL, return_false, JOB_PRIO_CRITICAL);
|
||||
NULL, callback_job_cancel_thread,
|
||||
JOB_PRIO_CRITICAL);
|
||||
lib->processor->queue_job(lib->processor, (job_t*)job);
|
||||
|
||||
return &this->public;
|
||||
|
||||
@@ -291,7 +291,7 @@ static void notify(private_watcher_t *this, entry_t *entry,
|
||||
|
||||
this->jobs->insert_last(this->jobs,
|
||||
callback_job_create_with_prio((void*)notify_async, data,
|
||||
(void*)notify_end, (callback_job_cancel_t)return_false,
|
||||
(void*)notify_end, callback_job_cancel_thread,
|
||||
JOB_PRIO_CRITICAL));
|
||||
}
|
||||
|
||||
@@ -559,7 +559,7 @@ METHOD(watcher_t, add, void,
|
||||
|
||||
lib->processor->queue_job(lib->processor,
|
||||
(job_t*)callback_job_create_with_prio((void*)watch, this,
|
||||
NULL, (callback_job_cancel_t)return_false, JOB_PRIO_CRITICAL));
|
||||
NULL, callback_job_cancel_thread, JOB_PRIO_CRITICAL));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user