Skip to content

Commit

Permalink
block: Fix compiler warning (-Werror=uninitialized)
Browse files Browse the repository at this point in the history
The patch fixes a warning from gcc (Debian 4.6.3-14+rpi1) 4.6.3:

block/stream.c:141:22: error:
‘copy’ may be used uninitialized in this function [-Werror=uninitialized]

This is not a real bug - a better compiler would not complain.

Now 'copy' has always a defined value, so the check for ret >= 0
can be removed.

Signed-off-by: Stefan Weil <sw@weilnetz.de>
Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
stweil authored and kevmw committed Sep 25, 2013
1 parent 030be32 commit c3e4f43
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions block/stream.c
Expand Up @@ -119,11 +119,12 @@ static void coroutine_fn stream_run(void *opaque)
break;
}

copy = false;

ret = bdrv_is_allocated(bs, sector_num,
STREAM_BUFFER_SIZE / BDRV_SECTOR_SIZE, &n);
if (ret == 1) {
/* Allocated in the top, no need to copy. */
copy = false;
} else if (ret >= 0) {
/* Copy if allocated in the intermediate images. Limit to the
* known-unallocated area [sector_num, sector_num+n). */
Expand All @@ -138,7 +139,7 @@ static void coroutine_fn stream_run(void *opaque)
copy = (ret == 1);
}
trace_stream_one_iteration(s, sector_num, n, ret);
if (ret >= 0 && copy) {
if (copy) {
if (s->common.speed) {
delay_ns = ratelimit_calculate_delay(&s->limit, n);
if (delay_ns > 0) {
Expand Down

0 comments on commit c3e4f43

Please sign in to comment.