[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Prevent compiler warning on block.c
From: |
Peter Maydell |
Subject: |
Re: Prevent compiler warning on block.c |
Date: |
Wed, 5 May 2021 11:43:44 +0100 |
On Wed, 5 May 2021 at 09:06, Miroslav Rezanina <mrezanin@redhat.com> wrote:
>
> Commit 3108a15cf (block: introduce bdrv_drop_filter()) introduced
> uninitialized
> variable to_cow_parent in bdrv_replace_node_common function that is used only
> when
> detach_subchain is true. It is used in two places. First if block properly
> initialize
> the variable and second block use it.
>
> However, compiler treats this two blocks as two independent cases so it
> thinks first
> block can fail test and second one pass (although both use same condition).
> This cause
> warning that variable can be uninitialized in second block.
>
> To prevent this warning, initialize the variable with NULL.
If fixing compiler warnings, please quote the compiler name/version
in the commit message. (This helps with understanding whether the issue
is because of an older and not-smart-enough compiler or a new bleeding-edge
compiler with extra checking.)
thanks
-- PMM