Skip to content

Commit

Permalink
block/snapshot: Fix compiler warning with -Wshadow=local
Browse files Browse the repository at this point in the history
No need to declare a new variable in the the inner code block
here, we can re-use the "ret" variable that has been declared
at the beginning of the function. With this change, the code
can now be successfully compiled with -Wshadow=local again.

Signed-off-by: Thomas Huth <thuth@redhat.com>
Message-ID: <20231023175038.111607-1-thuth@redhat.com>
Reviewed-by: Markus Armbruster <armbru@redhat.com>
[Commit message tweaked]
Signed-off-by: Markus Armbruster <armbru@redhat.com>
  • Loading branch information
huth authored and Markus Armbruster committed Nov 13, 2023
1 parent 6968074 commit 6ab4f1c
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions block/snapshot.c
Original file line number Diff line number Diff line change
Expand Up @@ -629,17 +629,15 @@ int bdrv_all_goto_snapshot(const char *name,
while (iterbdrvs) {
BlockDriverState *bs = iterbdrvs->data;
AioContext *ctx = bdrv_get_aio_context(bs);
int ret = 0;
bool all_snapshots_includes_bs;

aio_context_acquire(ctx);
bdrv_graph_rdlock_main_loop();
all_snapshots_includes_bs = bdrv_all_snapshots_includes_bs(bs);
bdrv_graph_rdunlock_main_loop();

if (devices || all_snapshots_includes_bs) {
ret = bdrv_snapshot_goto(bs, name, errp);
}
ret = (devices || all_snapshots_includes_bs) ?
bdrv_snapshot_goto(bs, name, errp) : 0;
aio_context_release(ctx);
if (ret < 0) {
bdrv_graph_rdlock_main_loop();
Expand Down

0 comments on commit 6ab4f1c

Please sign in to comment.