Skip to content

Commit

Permalink
Parameter checks
Browse files Browse the repository at this point in the history
  • Loading branch information
tzarc committed Oct 18, 2021
1 parent 4d7bdee commit 0c7601b
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion quantum/deferred_exec.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ static uint32_t last_deferred_exec_check = 0;
static deferred_executor_t executors[MAX_DEFERRED_EXECUTORS] = {0};

deferred_token enqueue_deferred_exec(uint32_t delay_ms, deferred_exec_callback callback, void *cb_arg) {
// Ignore queueing if it's a zero-time delay
// Ignore queueing if it's a zero-time delay, or invalid callback
if (delay_ms == 0 || !callback) {
return INVALID_DEFERRED_TOKEN;
}
Expand Down Expand Up @@ -49,6 +49,11 @@ deferred_token enqueue_deferred_exec(uint32_t delay_ms, deferred_exec_callback c
}

bool extend_deferred_exec(deferred_token token, uint32_t delay_ms) {
// Ignore queueing if it's a zero-time delay
if (delay_ms == 0) {
return false;
}

for (int i = 0; i < MAX_DEFERRED_EXECUTORS; ++i) {
deferred_executor_t *entry = &executors[i];
if (entry->token == (uint16_t)token) {
Expand Down

0 comments on commit 0c7601b

Please sign in to comment.