]> sourceware.org Git - lvm2.git/commitdiff
clang: ensure vg is defined
authorZdenek Kabelac <zkabelac@redhat.com>
Thu, 22 Apr 2021 20:42:54 +0000 (22:42 +0200)
committerZdenek Kabelac <zkabelac@redhat.com>
Fri, 23 Apr 2021 21:00:55 +0000 (23:00 +0200)
tools/pvchange.c

index b0bc83ed5a37dc41e80c9c17684a9c55b0fd9f10..d6e35d66f9cc3368bb36575b5c62597ce5ef888b 100644 (file)
@@ -54,7 +54,7 @@ static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg,
        }
 
        /* If in a VG, must change using volume group. */
-       if (!is_orphan(pv)) {
+       if (vg && !is_orphan(pv)) {
                if (tagargs && !(vg->fid->fmt->features & FMT_TAGS)) {
                        log_error("Volume group containing %s does not "
                                  "support tags", pv_name);
@@ -134,7 +134,7 @@ static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg,
        }
 
        if (arg_is_set(cmd, metadataignore_ARG)) {
-               if ((vg_mda_copies(vg) != VGMETADATACOPIES_UNMANAGED) &&
+               if (vg && (vg_mda_copies(vg) != VGMETADATACOPIES_UNMANAGED) &&
                    (arg_count(cmd, force_ARG) == PROMPT) &&
                    yes_no_prompt("Override preferred number of copies "
                                  "of VG %s metadata? [y/n]: ",
@@ -175,7 +175,7 @@ static int _pvchange_single(struct cmd_context *cmd, struct volume_group *vg,
        }
 
        log_verbose("Updating physical volume \"%s\"", pv_name);
-       if (!is_orphan(pv)) {
+       if (vg && !is_orphan(pv)) {
                if (!vg_write(vg) || !vg_commit(vg)) {
                        log_error("Failed to store physical volume \"%s\" in "
                                  "volume group \"%s\"", pv_name, vg->name);
This page took 0.041141 seconds and 5 git commands to generate.