From b1c05b06211be42f97b506beacc7b347cd600e23 Mon Sep 17 00:00:00 2001 From: guping Date: Mon, 25 Aug 2025 10:20:30 +0000 Subject: [PATCH] block/stream: fix -Werror=maybe-uninitialized false-positives cherry-pick from ce2a0ef65c3bb857985cd4b9c1f2145c81f2cdec MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../block/stream.c:193:19: error: ‘unfiltered_bs’ may be used uninitialized [-Werror=maybe-uninitialized] ../block/stream.c:176:5: error: ‘len’ may be used uninitialized [-Werror=maybe-uninitialized] trace/trace-block.h:906:9: error: ‘ret’ may be used uninitialized [-Werror=maybe-uninitialized] Signed-off-by: Marc-André Lureau Acked-by: Vladimir Sementsov-Ogievskiy Reviewed-by: Manos Pitsidianakis Signed-off-by: guping --- block/stream.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/block/stream.c b/block/stream.c index 01fe7c0f16..421ef5c729 100644 --- a/block/stream.c +++ b/block/stream.c @@ -149,8 +149,8 @@ static void stream_clean(Job *job) static int coroutine_fn stream_run(Job *job, Error **errp) { StreamBlockJob *s = container_of(job, StreamBlockJob, common.job); - BlockDriverState *unfiltered_bs; - int64_t len; + BlockDriverState *unfiltered_bs = NULL; + int64_t len = -1; int64_t offset = 0; int error = 0; int64_t n = 0; /* bytes */ @@ -171,7 +171,7 @@ static int coroutine_fn stream_run(Job *job, Error **errp) for ( ; offset < len; offset += n) { bool copy; - int ret; + int ret = -1; /* Note that even when no rate limit is applied we need to yield * with no pending I/O here so that bdrv_drain_all() returns. -- Gitee