Update cmd line arg parsing
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 22 Feb 2013 20:11:06 +0000 (15:11 -0500)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fri, 22 Feb 2013 20:11:06 +0000 (15:11 -0500)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
test-ssd-write.c

index 2bce0fc8f65b3e68046e3194b008f13d040cd498..49a4238f28fec84a44c78e08c07854954e874070 100644 (file)
@@ -71,7 +71,7 @@
 #include <string.h>
 
 enum write_mode {
-       WRITE_RANDOM,
+       WRITE_RANDOM = 0,
        WRITE_ZEROES,
 };
 
@@ -236,17 +236,6 @@ int main(int argc, char **argv)
        printf("Creating file %s of length %zu, random seed %u\n", argv[1], len,
                seed);
 
-       if (strcmp(argv[4], "-r") == 0) {
-               printf("Generating random data\n");
-               write_mode = WRITE_RANDOM;
-       } else if (strcmp(argv[4], "-z") == 0) {
-               printf("Filling with zeroes (compressible pattern)\n");
-               write_mode = WRITE_ZEROES;
-       } else {
-               printf("Invalid argument %s\n", argv[4]);
-               exit(EXIT_FAILURE);
-       }
-
        for (i = 4; i < argc; i++) {
                if (strcmp(argv[i], "-z") == 0) {
                        write_mode = WRITE_ZEROES;
@@ -255,19 +244,22 @@ int main(int argc, char **argv)
                }
        }
 
-       if (verify_mode) {
-               printf("Verification mode activated.\n");
-       }
-
        switch (write_mode) {
        case WRITE_RANDOM:
+               printf("Generating random data\n");
+               break;
        case WRITE_ZEROES:
+               printf("Filling with zeroes (compressible pattern)\n");
                break;
        default:
                printf("Unsupported write-mode\n");
                exit(EXIT_FAILURE);
        }
 
+       if (verify_mode) {
+               printf("Verification mode activated.\n");
+       }
+
        /* Grow file */
        pos = lseek(fd, len - 1, SEEK_SET);
        if (pos < 0) {
This page took 0.033696 seconds and 4 git commands to generate.