From f008f6a33bea9aaafdd03a4cbd34c7fe6acc54d5 Mon Sep 17 00:00:00 2001 From: Eric Engestrom Date: Thu, 18 Apr 2024 12:18:46 +0200 Subject: [PATCH] util/futex: replace double-cast check with a simple sign check We want to know whether the signed int can be represented by an unsigned int of the same size (no down-cast); for that, all we need is for it to be `>= 0`, so let's check that. Part-of: --- src/util/futex.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/util/futex.c b/src/util/futex.c index 54a80beb160d5..df3e949de3ddb 100644 --- a/src/util/futex.c +++ b/src/util/futex.c @@ -66,7 +66,7 @@ int futex_wait(uint32_t *addr, int32_t value, const struct timespec *timeout) int futex_wake(uint32_t *addr, int32_t count) { - assert(count == (int32_t)(uint32_t)count); /* Check that bits weren't discarded */ + assert(count >= 0); return _umtx_op(addr, UMTX_OP_WAKE, (uint32_t)count, NULL, NULL) == -1 ? errno : 0; }