[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 01/24] Prevent compiler warning on block.c
From: |
Kevin Wolf |
Subject: |
[PULL 01/24] Prevent compiler warning on block.c |
Date: |
Wed, 30 Jun 2021 18:01:43 +0200 |
From: Miroslav Rezanina <mrezanin@redhat.com>
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 | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/block.c b/block.c
index 1d37f133a8..3e277855e7 100644
--- a/block.c
+++ b/block.c
@@ -4866,7 +4866,7 @@ static int bdrv_replace_node_common(BlockDriverState
*from,
Transaction *tran = tran_new();
g_autoptr(GHashTable) found = NULL;
g_autoptr(GSList) refresh_list = NULL;
- BlockDriverState *to_cow_parent;
+ BlockDriverState *to_cow_parent = NULL;
int ret;
if (detach_subchain) {
--
2.31.1
- [PULL 00/24] Block layer patches, Kevin Wolf, 2021/06/30
- [PULL 01/24] Prevent compiler warning on block.c,
Kevin Wolf <=
- [PULL 03/24] block: BDRV_O_NO_IO for backing file on creation, Kevin Wolf, 2021/06/30
- [PULL 02/24] block: Move read-only check during truncation earlier, Kevin Wolf, 2021/06/30
- [PULL 06/24] block: introduce bdrv_remove_file_or_backing_child(), Kevin Wolf, 2021/06/30
- [PULL 08/24] block: bdrv_reopen_parse_backing(): don't check aio context, Kevin Wolf, 2021/06/30
- [PULL 07/24] block: introduce bdrv_set_file_or_backing_noperm(), Kevin Wolf, 2021/06/30
- [PULL 12/24] block: BDRVReopenState: drop replace_backing_bs field, Kevin Wolf, 2021/06/30
- [PULL 09/24] block: bdrv_reopen_parse_backing(): don't check frozen child, Kevin Wolf, 2021/06/30
- [PULL 10/24] block: bdrv_reopen_parse_backing(): simplify handling implicit filters, Kevin Wolf, 2021/06/30
- [PULL 11/24] block: move supports_backing check to bdrv_set_file_or_backing_noperm(), Kevin Wolf, 2021/06/30
- [PULL 13/24] block: Allow changing bs->file on reopen, Kevin Wolf, 2021/06/30