summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorbluhm <bluhm@openbsd.org>2020-01-13 16:51:04 +0000
committerbluhm <bluhm@openbsd.org>2020-01-13 16:51:04 +0000
commitfa07df457f3952a155c61842549efde687e94760 (patch)
tree4c3df06d708afa00b9f808c3448d4e143386262b
parentEnsure XHCI_SCTX_DCI() always contains a valid number, i.e. the DCI of (diff)
downloadwireguard-openbsd-fa07df457f3952a155c61842549efde687e94760.tar.xz
wireguard-openbsd-fa07df457f3952a155c61842549efde687e94760.zip
Fix printf compiler warnings in wfp regress. Convert wchar to a
printable error message when failing.
-rw-r--r--regress/lib/libc/wprintf/wfp.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/regress/lib/libc/wprintf/wfp.c b/regress/lib/libc/wprintf/wfp.c
index fc3120b53c1..fa9bc07166d 100644
--- a/regress/lib/libc/wprintf/wfp.c
+++ b/regress/lib/libc/wprintf/wfp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: wfp.c,v 1.1 2011/04/24 08:00:22 stsp Exp $ */
+/* $OpenBSD: wfp.c,v 1.2 2020/01/13 16:51:04 bluhm Exp $ */
/*-
* Copyright (c) 2002, 2005 David Schultz <das@FreeBSD.org>
* All rights reserved.
@@ -201,18 +201,27 @@ smash_stack(void)
}
void
-_testfmt(const wchar_t *result, int line, const char *argstr, const wchar_t *fmt,...)
+_testfmt(const wchar_t *result, int line, const char *argstr,
+ const wchar_t *fmt, ...)
{
- wchar_t s[100];
+ wchar_t ws[100];
va_list ap;
va_start(ap, fmt);
smash_stack();
- vswprintf(s, sizeof(s), fmt, ap);
- if (wcscmp(result, s) != 0) {
- fprintf(stderr,
- "%d: printf(\"%s\", %s) ==> [%s], expected [%s]\n",
- line, (char*)fmt, argstr, s, result);
- abort();
+ vswprintf(ws, sizeof(ws)/sizeof(ws[0]), fmt, ap);
+ if (wcscmp(result, ws) != 0) {
+ const wchar_t *p = ws;
+ char f[100], s[100], r[100];
+
+ memset(f, 0, sizeof(f));
+ memset(s, 0, sizeof(s));
+ memset(r, 0, sizeof(r));
+ wcsrtombs(f, &fmt, sizeof(f) - 1, NULL);
+ wcsrtombs(s, &p, sizeof(s) - 1, NULL);
+ wcsrtombs(r, &result, sizeof(r) - 1, NULL);
+
+ errx(1, "line %d: printf(\"%s\", %s) ==> [%s], expected [%s]",
+ line, f, argstr, s, r);
}
}