Skip to content
Snippets Groups Projects
Commit dc3c871a authored by Hanna Reitz's avatar Hanna Reitz Committed by Gerd Hoffmann
Browse files

ui/curses: Fix build with -m32


wchar_t may resolve to be an unsigned long on 32-bit architectures.
Using the %x conversion specifier will then give a compiler warning:

ui/curses.c: In function ‘get_ucs’:
ui/curses.c:492:49: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘wchar_t’ {aka ‘long int’} [-Werror=format=]
  492 |         fprintf(stderr, "Could not convert 0x%04x "
      |                                              ~~~^
      |                                                 |
      |                                                 unsigned int
      |                                              %04lx
  493 |                         "from wchar_t to a multibyte character: %s\n",
  494 |                         wch, strerror(errno));
      |                         ~~~
      |                         |
      |                         wchar_t {aka long int}
ui/curses.c:504:49: error: format ‘%x’ expects argument of type ‘unsigned int’, but argument 3 has type ‘wchar_t’ {aka ‘long int’} [-Werror=format=]
  504 |         fprintf(stderr, "Could not convert 0x%04x "
      |                                              ~~~^
      |                                                 |
      |                                                 unsigned int
      |                                              %04lx
  505 |                         "from a multibyte character to UCS-2 : %s\n",
  506 |                         wch, strerror(errno));
      |                         ~~~
      |                         |
      |                         wchar_t {aka long int}

Fix this by casting the wchar_t value to an unsigned long and using %lx
as the conversion specifier.

Fixes: b7b664a4
Signed-off-by: default avatarMax Reitz <mreitz@redhat.com>
Reviewed-by: default avatarSamuel Thibault <samuel.thibault@ens-lyon.org>
Message-id: 20190527142540.23255-1-mreitz@redhat.com
Signed-off-by: default avatarGerd Hoffmann <kraxel@redhat.com>
parent 0d74f3b4
No related branches found
No related tags found
No related merge requests found
......@@ -489,9 +489,9 @@ static uint16_t get_ucs(wchar_t wch, iconv_t conv)
memset(&ps, 0, sizeof(ps));
ret = wcrtomb(mbch, wch, &ps);
if (ret == -1) {
fprintf(stderr, "Could not convert 0x%04x "
fprintf(stderr, "Could not convert 0x%04lx "
"from wchar_t to a multibyte character: %s\n",
wch, strerror(errno));
(unsigned long)wch, strerror(errno));
return 0xFFFD;
}
......@@ -501,9 +501,9 @@ static uint16_t get_ucs(wchar_t wch, iconv_t conv)
such = sizeof(uch);
if (iconv(conv, &pmbch, &smbch, &puch, &such) == (size_t) -1) {
fprintf(stderr, "Could not convert 0x%04x "
fprintf(stderr, "Could not convert 0x%04lx "
"from a multibyte character to UCS-2 : %s\n",
wch, strerror(errno));
(unsigned long)wch, strerror(errno));
return 0xFFFD;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment