diff options
author | Christophe Fergeau <cfergeau@redhat.com> | 2013-10-18 14:50:29 +0200 |
---|---|---|
committer | Christophe Fergeau <cfergeau@redhat.com> | 2013-10-28 11:12:20 +0100 |
commit | 1b6ced7ddafd1bc6e490af091427327b05c96b3f (patch) | |
tree | 47e11d88e44137e9383f743df39b1c6932ccff9c | |
parent | 56e7876d8f935f573db5fa44d7a15bc345310917 (diff) | |
download | spice-1b6ced7ddafd1bc6e490af091427327b05c96b3f.tar.gz spice-1b6ced7ddafd1bc6e490af091427327b05c96b3f.tar.xz spice-1b6ced7ddafd1bc6e490af091427327b05c96b3f.zip |
Silence gcc false positive with -Wuninitialized
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.
-rw-r--r-- | server/red_channel.c | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/server/red_channel.c b/server/red_channel.c index 2cef2be2..24a8b647 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,6 +2369,8 @@ int red_channel_client_wait_pipe_item_sent(RedChannelClient *rcc, if (timeout != -1) { end_time = red_now() + timeout; + } else { + end_time = UINT64_MAX; } rcc->channel->channel_cbs.hold_item(rcc, item); @@ -2404,6 +2408,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); |