OSDN Git Service

Prevent compiler warning on block.c
authorMiroslav Rezanina <mrezanin@redhat.com>
Wed, 5 May 2021 07:59:03 +0000 (03:59 -0400)
committerKevin Wolf <kwolf@redhat.com>
Tue, 29 Jun 2021 14:51:00 +0000 (16:51 +0200)
commit2d369d6e6e890a0204183e853604f8077329c4bc
tree5e3a9ca887affcdf552be9c40f55481e9fe26b5c
parent13d5f87cc3b94bfccc501142df4a7b12fee3a6e7
Prevent compiler warning on block.c

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 may treat these 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.

The warning was observed with GCC 8.4.1 and 11.0.1.

To prevent this warning, initialize the variable with NULL.

Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
Message-Id: <1162368493.17178530.1620201543649.JavaMail.zimbra@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block.c