From 635de63a8afac4c5cf64265be6a4604e13033cf6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Mon, 8 Oct 2018 17:51:26 +0200 Subject: [PATCH] Fix pointer assignment errors Without this patch, the following error is emitted when compiling with the latest LLVM/Clang 8.x: ```text src/stdio/vfwscanf.c:218:9: error: assigning to 'const wchar_t *' (aka 'const unsigned int *') from 'int [1]' converts between pointers to integer types with different sign [-Werror,-Wpointer-sign] set = L""; ^ ~~~ 1 error generated. ``` --- src/stdio/vfwscanf.c | 3 ++- src/stdlib/wcstod.c | 3 ++- src/stdlib/wcstol.c | 3 ++- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/stdio/vfwscanf.c b/src/stdio/vfwscanf.c index a7cd0923..af66379a 100644 --- a/src/stdio/vfwscanf.c +++ b/src/stdio/vfwscanf.c @@ -215,7 +215,8 @@ int vfwscanf(FILE *restrict f, const wchar_t *restrict fmt, va_list ap) if (t == 'c') { if (width<1) width = 1; invert = 1; - set = L""; + static const wchar_t empty[] = { 0 }; + set = empty; } else if (t == 's') { invert = 1; static const wchar_t spaces[] = { diff --git a/src/stdlib/wcstod.c b/src/stdlib/wcstod.c index 26fe9af8..bd1ef040 100644 --- a/src/stdlib/wcstod.c +++ b/src/stdlib/wcstod.c @@ -12,8 +12,9 @@ static size_t do_read(FILE *f, unsigned char *buf, size_t len) { size_t i; const wchar_t *wcs = f->cookie; + static const wchar_t strudel[] = { '@', 0 }; - if (!wcs[0]) wcs=L"@"; + if (!wcs[0]) wcs=strudel; for (i=0; ibuf_size && wcs[i]; i++) f->buf[i] = wcs[i] < 128 ? wcs[i] : '@'; f->rpos = f->buf; diff --git a/src/stdlib/wcstol.c b/src/stdlib/wcstol.c index 4443f577..4744910e 100644 --- a/src/stdlib/wcstol.c +++ b/src/stdlib/wcstol.c @@ -14,8 +14,9 @@ static size_t do_read(FILE *f, unsigned char *buf, size_t len) { size_t i; const wchar_t *wcs = f->cookie; + static const wchar_t strudel[] = { '@', 0 }; - if (!wcs[0]) wcs=L"@"; + if (!wcs[0]) wcs=strudel; for (i=0; ibuf_size && wcs[i]; i++) f->buf[i] = wcs[i] < 128 ? wcs[i] : '@'; f->rpos = f->buf;