qemu-devel
[Top][All Lists]
Advanced

[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: Mon, 17 Jul 2017 10:04:59 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.2.1

On 07/17/2017 09:16 AM, Gerd Hoffmann wrote:
>   Hi,
> 
>> FWIW, most of these have been fixed in the meantime; the only
>> remaining
>> hack I had to add was:
>>
>> diff --git i/hw/usb/bus.c w/hw/usb/bus.c
>> index 5939b273b9..bce011058b 100644
>> --- i/hw/usb/bus.c
>> +++ 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));
> 
> Approach looks ok to me.
> 
> Maximum hub chain length is 5, number of ports hubs is limited too,
> you'll never need more that two digits for port numbers.  So 2*5 plus 4
> connecting dots => 14 chars is the max strlen.  path size is 16, so it
> will fit, including the terminating \0.

Cool! With that text in the commit message and/or code comment, we can
turn this from a hack into an actual patch, with no change in code.
I'll go ahead and spin this as a formal patch.

> 
> Trying things like "assert(portnr <= 99)" have no effect on the
> possible string length calculated by gcc7.

Perhaps a limitation that ought to be reported to the gcc folks.

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org

Attachment: signature.asc
Description: OpenPGP digital signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]