Skip to content

Commit

Permalink
blockdev: Consistently use snapshot_node_name in external_snapshot_pr…
Browse files Browse the repository at this point in the history
…epare()

In the function external_snapshot_prepare() we have a
BlockdevSnapshotSync struct, which has the usual combination
of has_snapshot_node_name and snapshot_node_name fields for an
optional field. We set up a local variable
        const char *snapshot_node_name =
            s->has_snapshot_node_name ? s->snapshot_node_name : NULL;

and then mostly use "if (!snapshot_node_name)" for checking
whether we have a snapshot node name. The exception is that in
one place we check s->has_snapshot_node_name instead. This
confuses Coverity (CID 1396473), which thinks it might be
possible to get here with s->has_snapshot_node_name true but
snapshot_node_name NULL, and warns that the call to
qdict_put_str() will segfault in that case.

Make the code consistent and unconfuse Coverity by using
the same check for this conditional that we do in the rest
of the surrounding code.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
Reviewed-by: Alberto Garcia <berto@igalia.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
  • Loading branch information
pm215 authored and kevmw committed Nov 12, 2018
1 parent 63d5341 commit d52e1a0
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion blockdev.c
Expand Up @@ -1640,7 +1640,7 @@ static void external_snapshot_prepare(BlkActionState *common,
}

options = qdict_new();
if (s->has_snapshot_node_name) {
if (snapshot_node_name) {
qdict_put_str(options, "node-name", snapshot_node_name);
}
qdict_put_str(options, "driver", format);
Expand Down

0 comments on commit d52e1a0

Please sign in to comment.