]> git.ipfire.org Git - thirdparty/shadow.git/commitdiff
tests/unit/test_xasprintf.c: Fix sign-mismatch diagnostic
authorAlejandro Colomar <alx@kernel.org>
Sun, 9 Feb 2025 13:10:55 +0000 (14:10 +0100)
committerAlejandro Colomar <alx@kernel.org>
Mon, 3 Mar 2025 23:08:15 +0000 (00:08 +0100)
Add a signed wrapper around mock() which returns a signed integer.
This makes it possible to compare the return value with literal -1.

Acked-by: Serge Hallyn <serge@hallyn.com>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
tests/unit/test_xasprintf.c

index 3f3566898010893bfdccb46096a605032060f788..b28470f62fcc70116a5db803a5d14bae108209a4 100644 (file)
@@ -1,7 +1,5 @@
-/*
- * SPDX-FileCopyrightText: 2023, Alejandro Colomar <alx@kernel.org>
- * SPDX-License-Identifier: BSD-3-Clause
- */
+// SPDX-FileCopyrightText: 2023-2025, Alejandro Colomar <alx@kernel.org>
+// SPDX-License-Identifier: BSD-3-Clause
 
 
 #include <setjmp.h>
@@ -19,6 +17,7 @@
 #include "string/sprintf/xasprintf.h"
 
 
+#define smock()               _Generic(mock(), uintmax_t: (intmax_t) mock())
 #define assert_unreachable()  assert_true(0)
 
 #define XASPRINTF_CALLED  (-36)
@@ -56,7 +55,7 @@ main(void)
 int
 __wrap_vasprintf(char **restrict p, const char *restrict fmt, va_list ap)
 {
-       return mock() == -1 ? -1 : __real_vasprintf(p, fmt, ap);
+       return smock() == -1 ? -1 : __real_vasprintf(p, fmt, ap);
 }