From 93f2021912c45bf88b598bfa5806cb40cf108754 Mon Sep 17 00:00:00 2001 From: Augustin Cavalier Date: Thu, 7 Jul 2022 14:44:29 -0400 Subject: [PATCH] openbsd_network: Fix return values of timeout functions. As far as I can tell, nothing checks these, so this should not actually make any kind of difference. The timeout_set change is also not a functional one, either, as callout_init with mpsafe=0 uses &Giant also. --- src/libs/compat/openbsd_network/compat/sys/timeout.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/libs/compat/openbsd_network/compat/sys/timeout.h b/src/libs/compat/openbsd_network/compat/sys/timeout.h index 3813bf8771..a62bf2cf36 100644 --- a/src/libs/compat/openbsd_network/compat/sys/timeout.h +++ b/src/libs/compat/openbsd_network/compat/sys/timeout.h @@ -17,7 +17,7 @@ struct timeout { static inline void timeout_set(struct timeout *to, void (*fn)(void *), void *arg) { - callout_init(&to->c, 0); + callout_init_mtx(&to->c, &Giant, 0); callout_reset(&to->c, -1, fn, arg); } @@ -32,7 +32,7 @@ timeout_pending(struct timeout *to) static inline int timeout_add_usec(struct timeout *to, int usec) { - return callout_schedule(&to->c, USEC_2_TICKS(usec)); + return (callout_schedule(&to->c, USEC_2_TICKS(usec)) ? 0 : 1); } @@ -53,7 +53,7 @@ timeout_add_sec(struct timeout *to, int sec) static inline int timeout_del(struct timeout *to) { - return callout_stop(&to->c); + return ((callout_stop(&to->c) == 1) ? 1 : 0); }