Skip to content

Commit 5bdc1b5

Browse files
tests/unit/test_xasprintf.c: Fix sign-mismatch diagnostic
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 <[email protected]> Signed-off-by: Alejandro Colomar <[email protected]>
1 parent 73c99d4 commit 5bdc1b5

File tree

1 file changed

+4
-5
lines changed

1 file changed

+4
-5
lines changed

tests/unit/test_xasprintf.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
1-
/*
2-
* SPDX-FileCopyrightText: 2023, Alejandro Colomar <[email protected]>
3-
* SPDX-License-Identifier: BSD-3-Clause
4-
*/
1+
// SPDX-FileCopyrightText: 2023-2025, Alejandro Colomar <[email protected]>
2+
// SPDX-License-Identifier: BSD-3-Clause
53

64

75
#include <setjmp.h>
@@ -19,6 +17,7 @@
1917
#include "string/sprintf/xasprintf.h"
2018

2119

20+
#define smock() _Generic(mock(), uintmax_t: (intmax_t) mock())
2221
#define assert_unreachable() assert_true(0)
2322

2423
#define XASPRINTF_CALLED (-36)
@@ -56,7 +55,7 @@ main(void)
5655
int
5756
__wrap_vasprintf(char **restrict p, const char *restrict fmt, va_list ap)
5857
{
59-
return mock() == -1 ? -1 : __real_vasprintf(p, fmt, ap);
58+
return smock() == -1 ? -1 : __real_vasprintf(p, fmt, ap);
6059
}
6160

6261

0 commit comments

Comments
 (0)