On Mon, Jul 27, 2026 at 12:44:02AM +0400, Marc-André Lureau wrote:
> Under some optimization, gcc produces a false-positive:
>     ../block/blkio.c: In function ‘blkio_co_getlength’:
>     ../block/blkio.c:943:8: error: ‘ret’ may be used uninitialized 
> [-Werror=maybe-uninitialized]
>       943 |     if (ret < 0) {
>           |        ^
> 
> Replace WITH_QEMU_LOCK_GUARD with the simpler QEMU_LOCK_GUARD.
> 
> Suggested-by: Akihiko Odaki <[email protected]>
> Signed-off-by: Marc-André Lureau <[email protected]>


or we can disable erroring out on these warnings with these "some optimization" 
options.
the warning in question already questionable at best.

> ---
>  block/blkio.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
> 
> diff --git a/block/blkio.c b/block/blkio.c
> index 52a8be220d1c..4801339f98b2 100644
> --- a/block/blkio.c
> +++ b/block/blkio.c
> @@ -937,9 +937,8 @@ static int64_t coroutine_fn 
> blkio_co_getlength(BlockDriverState *bs)
>      uint64_t capacity;
>      int ret;
>  
> -    WITH_QEMU_LOCK_GUARD(&s->blkio_lock) {
> -        ret = blkio_get_uint64(s->blkio, "capacity", &capacity);
> -    }
> +    QEMU_LOCK_GUARD(&s->blkio_lock);
> +    ret = blkio_get_uint64(s->blkio, "capacity", &capacity);
>      if (ret < 0) {
>          return ret;
>      }
> 
> -- 
> 2.55.0


Reply via email to