From fb9316def952d2b2c3a576e5ebedfe7e65d70d82 Mon Sep 17 00:00:00 2001 From: Bo Date: Sun, 2 Feb 2025 08:41:26 +0200 Subject: [PATCH] guards (unnecessary, but why not) --- fio-stl.h | 7 +++++-- fio-stl/102 queue.h | 7 +++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/fio-stl.h b/fio-stl.h index 8426b12..4a872e1 100644 --- a/fio-stl.h +++ b/fio-stl.h @@ -17538,6 +17538,8 @@ FIO_IFUNC fio___timer_event_s *fio___timer_event_new( FIO_IFUNC void fio___timer_event_free(fio_timer_queue_s *tq, fio___timer_event_s *t) { + if (!t) + return; if (tq && (t->repetitions < 0 || fio_atomic_sub_fetch(&t->repetitions, 1))) { FIO___LOCK_LOCK(tq->lock); fio___timer_insert(&tq->next, t); @@ -17614,7 +17616,9 @@ SFUNC void fio_timer_schedule FIO_NOOP(fio_timer_queue_s *timer, * they repeat). */ SFUNC void fio_timer_destroy(fio_timer_queue_s *tq) { - fio___timer_event_s *next; + if (!tq) + return; + fio___timer_event_s *next = NULL; FIO___LOCK_LOCK(tq->lock); next = tq->next; tq->next = NULL; @@ -17622,7 +17626,6 @@ SFUNC void fio_timer_destroy(fio_timer_queue_s *tq) { FIO___LOCK_DESTROY(tq->lock); while (next) { fio___timer_event_s *tmp = next; - next = next->next; fio___timer_event_free(NULL, tmp); } diff --git a/fio-stl/102 queue.h b/fio-stl/102 queue.h index be847a0..7fa42ca 100644 --- a/fio-stl/102 queue.h +++ b/fio-stl/102 queue.h @@ -663,6 +663,8 @@ FIO_IFUNC fio___timer_event_s *fio___timer_event_new( FIO_IFUNC void fio___timer_event_free(fio_timer_queue_s *tq, fio___timer_event_s *t) { + if (!t) + return; if (tq && (t->repetitions < 0 || fio_atomic_sub_fetch(&t->repetitions, 1))) { FIO___LOCK_LOCK(tq->lock); fio___timer_insert(&tq->next, t); @@ -739,7 +741,9 @@ SFUNC void fio_timer_schedule FIO_NOOP(fio_timer_queue_s *timer, * they repeat). */ SFUNC void fio_timer_destroy(fio_timer_queue_s *tq) { - fio___timer_event_s *next; + if (!tq) + return; + fio___timer_event_s *next = NULL; FIO___LOCK_LOCK(tq->lock); next = tq->next; tq->next = NULL; @@ -747,7 +751,6 @@ SFUNC void fio_timer_destroy(fio_timer_queue_s *tq) { FIO___LOCK_DESTROY(tq->lock); while (next) { fio___timer_event_s *tmp = next; - next = next->next; fio___timer_event_free(NULL, tmp); }