[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Qemu-devel] Hacks for building on gcc 7 / Fedora 26
From: |
Eric Blake |
Subject: |
Re: [Qemu-devel] Hacks for building on gcc 7 / Fedora 26 |
Date: |
Tue, 18 Jul 2017 19:34:51 -0500 |
User-agent: |
Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1 |
On 07/18/2017 06:59 PM, Richard Henderson wrote:
>> +++ w/hw/usb/bus.c
>> @@ -407,8 +407,9 @@ void usb_register_companion(const char *masterbus,
>> USBPort *ports[],
>> void usb_port_location(USBPort *downstream, USBPort *upstream, int
>> portnr)
>> {
>> if (upstream) {
>> - snprintf(downstream->path, sizeof(downstream->path), "%s.%d",
>> - upstream->path, portnr);
>> + int l = snprintf(downstream->path, sizeof(downstream->path),
>> "%s.%d",
>> + upstream->path, portnr);
>> + assert(l < sizeof(downstream->path));
>
> Do you really need an assert there, or will
>
> (void)l; /* "used" */
>
> work as well? You didn't mention what the reported error is, so I'm
> guessing.
The original error is that gcc 7 complains that snprintf is prone to
buffer overflow if the input is unbounded. Adding the assert that we
KNOW the input is not unbounded is enough to shut up gcc, on Linux.
What was then drawn into question is whether assert still has that
property on mingw (since assert on mingw lacks the noreturn marking that
it has on Linux).
At this point, unless someone posts an actual failure of gcc 7 compiling
this code for mingw, I don't see why we have to change it; shutting up
the warning on Linux is good enough for the purpose of this patch.
--
Eric Blake, Principal Software Engineer
Red Hat, Inc. +1-919-301-3266
Virtualization: qemu.org | libvirt.org
signature.asc
Description: OpenPGP digital signature
- Re: [Qemu-devel] Hacks for building on gcc 7 / Fedora 26, (continued)
- Re: [Qemu-devel] Hacks for building on gcc 7 / Fedora 26, Philippe Mathieu-Daudé, 2017/07/18
- Re: [Qemu-devel] Hacks for building on gcc 7 / Fedora 26, Eric Blake, 2017/07/18
- Re: [Qemu-devel] Hacks for building on gcc 7 / Fedora 26, Thomas Huth, 2017/07/19
- Re: [Qemu-devel] Hacks for building on gcc 7 / Fedora 26, Dr. David Alan Gilbert, 2017/07/17
- Re: [Qemu-devel] Hacks for building on gcc 7 / Fedora 26, Daniel P. Berrange, 2017/07/18
- Re: [Qemu-devel] Hacks for building on gcc 7 / Fedora 26, Eric Blake, 2017/07/18
- Re: [Qemu-devel] Hacks for building on gcc 7 / Fedora 26, Daniel P. Berrange, 2017/07/18
- Re: [Qemu-devel] Hacks for building on gcc 7 / Fedora 26, Richard Henderson, 2017/07/18
- Re: [Qemu-devel] Hacks for building on gcc 7 / Fedora 26,
Eric Blake <=
Re: [Qemu-devel] Hacks for building on gcc 7 / Fedora 26, Daniel P. Berrange, 2017/07/20