[Qemu-devel] [PATCH] Fix 32-bit compilation with gcc 5.5

Andrew Randrianasulu posted 1 patch 5 years ago
Test docker-mingw@fedora passed
Test docker-clang@ubuntu failed
Test checkpatch failed
Test asan failed
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/qemu tags/patchew/20190329064853.22886-1-randrianasulu@gmail.com
Maintainers: Gerd Hoffmann <kraxel@redhat.com>
ui/curses.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
[Qemu-devel] [PATCH] Fix 32-bit compilation with gcc 5.5
Posted by Andrew Randrianasulu 5 years ago
---
 ui/curses.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ui/curses.c b/ui/curses.c
index cc6d6da684..b25814f3fb 100644
--- a/ui/curses.c
+++ b/ui/curses.c
@@ -453,7 +453,7 @@ static uint16_t get_ucs(wchar_t wch, iconv_t conv)
     swch = sizeof(wch);
 
     if (iconv(conv, &pwch, &swch, &pch, &sch) == (size_t) -1) {
-        fprintf(stderr, "Could not convert 0x%02x from WCHAR_T to UCS-2: %s\n",
+        fprintf(stderr, "Could not convert 0x%02lx from WCHAR_T to UCS-2: %s\n",
                         wch, strerror(errno));
         return 0xFFFD;
     }
-- 
2.14.4


Re: [Qemu-devel] [PATCH] Fix 32-bit compilation with gcc 5.5
Posted by no-reply@patchew.org 5 years ago
Patchew URL: https://patchew.org/QEMU/20190329064853.22886-1-randrianasulu@gmail.com/



Hi,

This series seems to have some coding style problems. See output below for
more information:

Message-id: 20190329064853.22886-1-randrianasulu@gmail.com
Subject: [Qemu-devel] [PATCH] Fix 32-bit compilation with gcc 5.5
Type: series

=== TEST SCRIPT BEGIN ===
#!/bin/bash
git rev-parse base > /dev/null || exit 0
git config --local diff.renamelimit 0
git config --local diff.renames True
git config --local diff.algorithm histogram
./scripts/checkpatch.pl --mailback base..
=== TEST SCRIPT END ===

Updating 3c8cf5a9c21ff8782164d1def7f44bd888713384
From https://github.com/patchew-project/qemu
 * [new tag]               patchew/20190329064853.22886-1-randrianasulu@gmail.com -> patchew/20190329064853.22886-1-randrianasulu@gmail.com
Switched to a new branch 'test'
c585ddd722 Fix 32-bit compilation with gcc 5.5

=== OUTPUT BEGIN ===
ERROR: Missing Signed-off-by: line(s)

total: 1 errors, 0 warnings, 8 lines checked

Commit c585ddd7222a (Fix 32-bit compilation with gcc 5.5) has style problems, please review.  If any of these errors
are false positives report them to the maintainer, see
CHECKPATCH in MAINTAINERS.
=== OUTPUT END ===

Test command exited with code: 1


The full log is available at
http://patchew.org/logs/20190329064853.22886-1-randrianasulu@gmail.com/testing.checkpatch/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Re: [Qemu-devel] [PATCH] Fix 32-bit compilation with gcc 5.5
Posted by no-reply@patchew.org 5 years ago
Patchew URL: https://patchew.org/QEMU/20190329064853.22886-1-randrianasulu@gmail.com/



Hi,

This series failed the asan build test. Please find the testing commands and
their output below. If you have Docker installed, you can probably reproduce it
locally.

=== TEST SCRIPT BEGIN ===
#!/bin/bash
time make docker-test-debug@fedora TARGET_LIST=x86_64-softmmu J=14 NETWORK=1
=== TEST SCRIPT END ===

  LINK    qemu-nbd
  BUILD   optionrom/kvmvapic.img
  BUILD   optionrom/kvmvapic.raw
/tmp/qemu-test/src/ui/curses.c:457:25: error: format specifies type 'unsigned long' but the argument has type 'wchar_t' (aka 'int') [-Werror,-Wformat]
                        wch, strerror(errno));
                        ^~~
1 error generated.


The full log is available at
http://patchew.org/logs/20190329064853.22886-1-randrianasulu@gmail.com/testing.asan/?type=message.
---
Email generated automatically by Patchew [https://patchew.org/].
Please send your feedback to patchew-devel@redhat.com
Re: [Qemu-devel] [PATCH] Fix 32-bit compilation with gcc 5.5
Posted by Alex Bennée 5 years ago
Andrew Randrianasulu <randrianasulu@gmail.com> writes:

> ---
>  ui/curses.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/ui/curses.c b/ui/curses.c
> index cc6d6da684..b25814f3fb 100644
> --- a/ui/curses.c
> +++ b/ui/curses.c
> @@ -453,7 +453,7 @@ static uint16_t get_ucs(wchar_t wch, iconv_t conv)
>      swch = sizeof(wch);
>
>      if (iconv(conv, &pwch, &swch, &pch, &sch) == (size_t) -1) {
> -        fprintf(stderr, "Could not convert 0x%02x from WCHAR_T to UCS-2: %s\n",
> +        fprintf(stderr, "Could not convert 0x%02lx from WCHAR_T to UCS-2: %s\n",
>                          wch, strerror(errno));

This will break 64 bit compiles:

  ui/curses.c: In function ‘get_ucs’:
  ui/curses.c:456:50: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘wchar_t’ {aka ‘int’} [-Werror=format=]

Annoyingly it seems wchar_t can be various sizes on various platforms.
Maybe the simplest solution would be to upcast to a known size?

        fprintf(stderr, "Could not convert %" PRIx32 " from WCHAR_T to UCS-2: %s\n",
                (uint32_t) wch, strerror(errno));

>          return 0xFFFD;
>      }


--
Alex Bennée

Re: [Qemu-devel] [PATCH] Fix 32-bit compilation with gcc 5.5
Posted by Andrew Randrianasulu 5 years ago
В сообщении от Friday 29 March 2019 11:40:42 Alex Bennée написал(а):
> 
> Andrew Randrianasulu <randrianasulu@gmail.com> writes:
> 
> > ---
> >  ui/curses.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/ui/curses.c b/ui/curses.c
> > index cc6d6da684..b25814f3fb 100644
> > --- a/ui/curses.c
> > +++ b/ui/curses.c
> > @@ -453,7 +453,7 @@ static uint16_t get_ucs(wchar_t wch, iconv_t conv)
> >      swch = sizeof(wch);
> >
> >      if (iconv(conv, &pwch, &swch, &pch, &sch) == (size_t) -1) {
> > -        fprintf(stderr, "Could not convert 0x%02x from WCHAR_T to UCS-2: %s\n",
> > +        fprintf(stderr, "Could not convert 0x%02lx from WCHAR_T to UCS-2: %s\n",
> >                          wch, strerror(errno));
> 
> This will break 64 bit compiles:
> 
>   ui/curses.c: In function ‘get_ucs’:
>   ui/curses.c:456:50: error: format ‘%lx’ expects argument of type ‘long unsigned int’, but argument 3 has type ‘wchar_t’ {aka ‘int’} [-Werror=format=]
> 
> Annoyingly it seems wchar_t can be various sizes on various platforms.
> Maybe the simplest solution would be to upcast to a known size?
> 
>         fprintf(stderr, "Could not convert %" PRIx32 " from WCHAR_T to UCS-2: %s\n",
>                 (uint32_t) wch, strerror(errno));
> 
> >          return 0xFFFD;
> >      }
> 


This worked for me with 32-bit gcc. Thanks!

> 
> --
> Alex Bennée
> 



Re: [Qemu-devel] [PATCH] Fix 32-bit compilation with gcc 5.5
Posted by Philippe Mathieu-Daudé 5 years ago
Le ven. 29 mars 2019 13:53, Andrew Randrianasulu <randrianasulu@gmail.com>
a écrit :

> В сообщении от Friday 29 March 2019 11:40:42 Alex Bennée написал(а):
> >
> > Andrew Randrianasulu <randrianasulu@gmail.com> writes:
> >
> > > ---
> > >  ui/curses.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/ui/curses.c b/ui/curses.c
> > > index cc6d6da684..b25814f3fb 100644
> > > --- a/ui/curses.c
> > > +++ b/ui/curses.c
> > > @@ -453,7 +453,7 @@ static uint16_t get_ucs(wchar_t wch, iconv_t conv)
> > >      swch = sizeof(wch);
> > >
> > >      if (iconv(conv, &pwch, &swch, &pch, &sch) == (size_t) -1) {
> > > -        fprintf(stderr, "Could not convert 0x%02x from WCHAR_T to
> UCS-2: %s\n",
> > > +        fprintf(stderr, "Could not convert 0x%02lx from WCHAR_T to
> UCS-2: %s\n",
> > >                          wch, strerror(errno));
> >
> > This will break 64 bit compiles:
> >
> >   ui/curses.c: In function ‘get_ucs’:
> >   ui/curses.c:456:50: error: format ‘%lx’ expects argument of type ‘long
> unsigned int’, but argument 3 has type ‘wchar_t’ {aka ‘int’}
> [-Werror=format=]
> >
> > Annoyingly it seems wchar_t can be various sizes on various platforms.
> > Maybe the simplest solution would be to upcast to a known size?
> >
> >         fprintf(stderr, "Could not convert %" PRIx32 " from WCHAR_T to
> UCS-2: %s\n",
> >                 (uint32_t) wch, strerror(errno));
>

Can you simply use uint16_t instead?  UCS-2 chars fit in 16bit.

>
> > >          return 0xFFFD;
> > >      }
> >
>
>
> This worked for me with 32-bit gcc. Thanks!
>
> >
> > --
> > Alex Bennée
> >
>
>
>
>
Re: [Qemu-devel] [PATCH] Fix 32-bit compilation with gcc 5.5
Posted by Peter Maydell 5 years ago
On Fri, 29 Mar 2019 at 17:23, Philippe Mathieu-Daudé <f4bug@amsat.org> wrote:
>
> Le ven. 29 mars 2019 13:53, Andrew Randrianasulu <randrianasulu@gmail.com>
> a écrit :
>
> > В сообщении от Friday 29 March 2019 11:40:42 Alex Bennée написал(а):
> > > This will break 64 bit compiles:
> > >
> > >   ui/curses.c: In function ‘get_ucs’:
> > >   ui/curses.c:456:50: error: format ‘%lx’ expects argument of type ‘long
> > unsigned int’, but argument 3 has type ‘wchar_t’ {aka ‘int’}
> > [-Werror=format=]
> > >
> > > Annoyingly it seems wchar_t can be various sizes on various platforms.
> > > Maybe the simplest solution would be to upcast to a known size?
> > >
> > >         fprintf(stderr, "Could not convert %" PRIx32 " from WCHAR_T to
> > UCS-2: %s\n",
> > >                 (uint32_t) wch, strerror(errno));
> >
>
> Can you simply use uint16_t instead?  UCS-2 chars fit in 16bit.

We're not printing a UCS-2 character, though, we're printing
a wchar_t, which isn't necessarily 16 bits.

thanks
-- PMM

Re: [Qemu-devel] [PATCH] Fix 32-bit compilation with gcc 5.5
Posted by Philippe Mathieu-Daudé 5 years ago
Le ven. 29 mars 2019 18:41, Peter Maydell <peter.maydell@linaro.org> a
écrit :

> On Fri, 29 Mar 2019 at 17:23, Philippe Mathieu-Daudé <f4bug@amsat.org>
> wrote:
> >
> > Le ven. 29 mars 2019 13:53, Andrew Randrianasulu <
> randrianasulu@gmail.com>
> > a écrit :
> >
> > > В сообщении от Friday 29 March 2019 11:40:42 Alex Bennée написал(а):
> > > > This will break 64 bit compiles:
> > > >
> > > >   ui/curses.c: In function ‘get_ucs’:
> > > >   ui/curses.c:456:50: error: format ‘%lx’ expects argument of type
> ‘long
> > > unsigned int’, but argument 3 has type ‘wchar_t’ {aka ‘int’}
> > > [-Werror=format=]
> > > >
> > > > Annoyingly it seems wchar_t can be various sizes on various
> platforms.
> > > > Maybe the simplest solution would be to upcast to a known size?
> > > >
> > > >         fprintf(stderr, "Could not convert %" PRIx32 " from WCHAR_T
> to
> > > UCS-2: %s\n",
> > > >                 (uint32_t) wch, strerror(errno));
> > >
> >
> > Can you simply use uint16_t instead?  UCS-2 chars fit in 16bit.
>
> We're not printing a UCS-2 character, though, we're printing
> a wchar_t, which isn't necessarily 16 bits.
>

Oops I missed that. The uint32_t is correct then, thanks!


> thanks
> -- PMM
>
>