]> sourceware.org Git - lvm2.git/commitdiff
Refactor vgcreate/vgextend validation of vgname/pvname(s).
authorDave Wysochanski <dwysocha@redhat.com>
Mon, 5 Oct 2009 20:03:37 +0000 (20:03 +0000)
committerDave Wysochanski <dwysocha@redhat.com>
Mon, 5 Oct 2009 20:03:37 +0000 (20:03 +0000)
Decrement argc and increment argv in a consistent way to allow for later
code-sharing.  Should be no functional change.

tools/vgcreate.c
tools/vgextend.c

index d171026bd3d8919925ce6795802a306dc1ceb202..3d4b1b7cef509183f0b96423af52cdb0488505e0 100644 (file)
@@ -22,6 +22,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
        struct volume_group *vg;
        const char *tag;
        const char *clustered_message = "";
+       char *vg_name;
 
        if (!argc) {
                log_error("Please provide volume group name and "
@@ -29,7 +30,11 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
                return EINVALID_CMD_LINE;
        }
 
-       if (argc == 1) {
+       vg_name = argv[0];
+       argc--;
+       argv++;
+
+       if (argc == 0) {
                log_error("Please enter physical volume name(s)");
                return EINVALID_CMD_LINE;
        }
@@ -40,7 +45,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
        vp_def.max_lv = DEFAULT_MAX_LV;
        vp_def.alloc = DEFAULT_ALLOC_POLICY;
        vp_def.clustered = DEFAULT_CLUSTERED;
-       if (fill_vg_create_params(cmd, argv[0], &vp_new, &vp_def))
+       if (fill_vg_create_params(cmd, vg_name, &vp_new, &vp_def))
                return EINVALID_CMD_LINE;
 
        if (validate_vg_create_params(cmd, &vp_new))
@@ -63,7 +68,7 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
        }
 
        /* attach the pv's */
-       if (!vg_extend(vg, argc - 1, argv + 1, NULL))
+       if (!vg_extend(vg, argc, argv, NULL))
                goto_bad;
 
        if (vp_new.max_lv != vg->max_lv)
index 9fa7d31773d22a2fe07725be7e2657b05e8fe9f1..c97b3bb3535e30dd6f24bdc5b9bd7bb9192db178 100644 (file)
@@ -27,15 +27,15 @@ int vgextend(struct cmd_context *cmd, int argc, char **argv)
                return EINVALID_CMD_LINE;
        }
 
-       if (argc == 1) {
-               log_error("Please enter physical volume(s)");
-               return EINVALID_CMD_LINE;
-       }
-
        vg_name = skip_dev_dir(cmd, argv[0], NULL);
        argc--;
        argv++;
 
+       if (argc == 0) {
+               log_error("Please enter physical volume(s)");
+               return EINVALID_CMD_LINE;
+       }
+
        log_verbose("Checking for volume group \"%s\"", vg_name);
        vg = vg_read_for_update(cmd, vg_name, NULL, 0);
        if (vg_read_error(vg)) {
This page took 0.041317 seconds and 5 git commands to generate.