Re: [PATCH] Silence gcc false positive with -Wuninitialized

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On 10/25/2013 11:19 AM, Christophe Fergeau wrote:
> Ping ?
> 
> On Fri, Oct 18, 2013 at 02:53:08PM +0200, Christophe Fergeau
> wrote:
>> Some versions of gcc warn about: red_channel.c: In function
>> 'red_channel_client_wait_outgoing_item': red_channel.c:2331:
>> error: 'end_time' may be used uninitialized in this function
>> [-Wuninitialized] red_channel.c: In function
>> 'red_channel_client_wait_pipe_item_sent': red_channel.c:2363:
>> error: 'end_time' may be used uninitialized in this function
>> [-Wuninitialized] red_channel.c: In function
>> 'red_channel_wait_all_sent': red_channel.c:2401: error:
>> 'end_time' may be used uninitialized in this function
>> [-Wuninitialized]
>> 
>> This is a false positive as end_time is unitialized when timeout
>> is -1, and we will only try to use end_time if timeout is not
>> -1.
>> 
>> This commit initializes end_time to UINT64_MAX to avoid that
>> warning. As the test involving end_time will never be reached, we
>> ensure it's always TRUE so that it would be a noop even if it was
>> reached. --- server/red_channel.c | 7 +++++++ 1 file changed, 7
>> insertions(+)
>> 
>> diff --git a/server/red_channel.c b/server/red_channel.c index
>> 2cef2be..f2d1cca 100644 --- a/server/red_channel.c +++
>> b/server/red_channel.c @@ -2336,6 +2336,8 @@ int
>> red_channel_client_wait_outgoing_item(RedChannelClient *rcc, } if
>> (timeout != -1) { end_time = red_now() + timeout; +    } else { +
>> end_time = UINT64_MAX; } spice_info("blocked");
>> 
>> @@ -2367,8 +2369,11 @@ int
>> red_channel_client_wait_pipe_item_sent(RedChannelClient *rcc,
>> 
>> if (timeout != -1) { end_time = red_now() + timeout; +    } else
>> { +        end_time = UINT64_MAX; }
>> 
>> +

ACK with dropped whitespace change.

>> rcc->channel->channel_cbs.hold_item(rcc, item);
>> 
>> if (red_channel_client_blocked(rcc)) { @@ -2404,6 +2409,8 @@ int
>> red_channel_wait_all_sent(RedChannel *channel,
>> 
>> if (timeout != -1) { end_time = red_now() + timeout; +    } else
>> { +        end_time = UINT64_MAX; }
>> 
>> red_channel_push(channel); -- 1.8.3.1
>> 
>> _______________________________________________ Spice-devel
>> mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx 
>> http://lists.freedesktop.org/mailman/listinfo/spice-devel
>> 
>> 
>> _______________________________________________ Spice-devel
>> mailing list Spice-devel@xxxxxxxxxxxxxxxxxxxxx 
>> http://lists.freedesktop.org/mailman/listinfo/spice-devel

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.15 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/

iQEcBAEBAgAGBQJSbQi+AAoJEGSFt2Lm6PXuNmMH/iXe7+RVnceeMxatEOHGUGrG
JtlNFlrh2Nrn5sqkybcDXOwBx7Q8vhxAYQVrljlPgxFgGwVZEn+3FoGOt6qUaj5A
/5n5xXQusonDdqmyzibl5B5tTraEfaBuhkrA15ClZ3AJcKNrIV+vQdmQjDXEBP/i
HpYP7rDphmWSdgbwTDIHtVsvYFq1F7N1Dqmc3tW35keS3s/qjRAfVh8SmIVXQ3UJ
xfM/UqcSUTHCja3RFpEpF8CgJidpeN8K1eUNbAGtG4w7OVvBQi3kflkj/REMmJdD
RYP2ro+XpepG8dmL7pIEp2Khoo36dQONk2ZMnf/Mx4ZJNr4VYMd+35cin2rH+zM=
=H06m
-----END PGP SIGNATURE-----
_______________________________________________
Spice-devel mailing list
Spice-devel@xxxxxxxxxxxxxxxxxxxxx
http://lists.freedesktop.org/mailman/listinfo/spice-devel




[Index of Archives]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Asterisk Internet PBX]     [Linux API]     [Monitors]