sbin/hammer: Add /* not reached */ for usage() variants
authorTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Tue, 11 Apr 2017 20:51:35 +0000 (23:51 +0300)
committerTomohiro Kusumi <kusumi.tomohiro@gmail.com>
Tue, 11 Apr 2017 21:11:36 +0000 (00:11 +0300)
that were originally missing.
Recommended by dillon@.
No diff in sbin/hammer binary when assert(3) is disabled.

sbin/hammer/cmd_dedup.c
sbin/hammer/cmd_mirror.c
sbin/hammer/cmd_pfs.c
sbin/hammer/cmd_rebalance.c
sbin/hammer/cmd_reblock.c
sbin/hammer/cmd_softprune.c
sbin/hammer/cmd_synctid.c
sbin/hammer/hammer.c

index 39785a8..1833c85 100644 (file)
@@ -200,8 +200,10 @@ hammer_cmd_dedup_simulate(char **av, int ac)
 {
        struct sim_dedup_entry *sim_de;
 
-       if (ac != 1)
+       if (ac != 1) {
                dedup_usage(1);
+               /* not reached */
+       }
 
        glob_fd = getpfs(&glob_pfs, av[0]);
 
@@ -263,8 +265,10 @@ hammer_cmd_dedup(char **av, int ac)
        if (TimeoutOpt > 0)
                alarm(TimeoutOpt);
 
-       if (ac != 1)
+       if (ac != 1) {
                dedup_usage(1);
+               /* not reached */
+       }
 
        STAILQ_INIT(&pass2_dedup_queue);
 
index 56a61a9..88f1a09 100644 (file)
@@ -110,8 +110,10 @@ hammer_cmd_mirror_read(char **av, int ac, int streaming)
        uint64_t bwcount;
        uint64_t estbytes;
 
-       if (ac == 0 || ac > 2)
+       if (ac == 0 || ac > 2) {
                mirror_usage(1);
+               /* not reached */
+       }
        filesystem = av[0];
        hammer_check_restrict(filesystem);
 
@@ -770,8 +772,10 @@ hammer_cmd_mirror_write(char **av, int ac)
        int fd;
        int n;
 
-       if (ac != 1)
+       if (ac != 1) {
                mirror_usage(1);
+               /* not reached */
+       }
        filesystem = av[0];
        hammer_check_restrict(filesystem);
 
@@ -955,10 +959,12 @@ hammer_cmd_mirror_dump(char **av, int ac)
        int bytes;
        int header_only = 0;
 
-       if (ac == 1 && strcmp(*av, "header") == 0)
+       if (ac == 1 && strcmp(*av, "header") == 0) {
                header_only = 1;
-       else if (ac != 0)
+       } else if (ac != 0) {
                mirror_usage(1);
+               /* not reached */
+       }
 
        /*
         * Read and process the PFS header
@@ -1083,8 +1089,10 @@ hammer_cmd_mirror_copy(char **av, int ac, int streaming)
        char *sh, *user, *host, *rfs;
        int xac;
 
-       if (ac != 2)
+       if (ac != 2) {
                mirror_usage(1);
+               /* not reached */
+       }
 
        TwoWayPipeOpt = 1;
        signal(SIGPIPE, SIG_IGN);
index 9bd301e..65fc347 100644 (file)
@@ -252,8 +252,10 @@ hammer_cmd_pseudofs_create(char **av, int ac, int is_slave)
        int pfs_id;
        int fd;
 
-       if (ac == 0)
+       if (ac == 0) {
                pseudofs_usage(1);
+               /* not reached */
+       }
        path = av[0];
        if (lstat(path, &st) == 0) {
                errx(1, "Cannot create %s, file exists!", path);
@@ -343,8 +345,10 @@ hammer_cmd_pseudofs_destroy(char **av, int ac)
        int fd;
        int i;
 
-       if (ac == 0)
+       if (ac == 0) {
                pseudofs_usage(1);
+               /* not reached */
+       }
        fd = getpfs(&pfs, av[0]);
 
        if (pfs.pfs_id == HAMMER_ROOT_PFSID) {
@@ -411,8 +415,10 @@ hammer_cmd_pseudofs_upgrade(char **av, int ac)
        struct hammer_ioc_pseudofs_rw pfs;
        int fd;
 
-       if (ac == 0)
+       if (ac == 0) {
                pseudofs_usage(1);
+               /* not reached */
+       }
        fd = getpfs(&pfs, av[0]);
 
        if (pfs.pfs_id == HAMMER_ROOT_PFSID) {
@@ -442,8 +448,10 @@ hammer_cmd_pseudofs_downgrade(char **av, int ac)
        struct hammer_ioc_pseudofs_rw pfs;
        int fd;
 
-       if (ac == 0)
+       if (ac == 0) {
                pseudofs_usage(1);
+               /* not reached */
+       }
        fd = getpfs(&pfs, av[0]);
 
        if (pfs.pfs_id == HAMMER_ROOT_PFSID) {
@@ -471,8 +479,10 @@ hammer_cmd_pseudofs_update(char **av, int ac)
        struct hammer_ioc_pseudofs_rw pfs;
        int fd;
 
-       if (ac == 0)
+       if (ac == 0) {
                pseudofs_usage(1);
+               /* not reached */
+       }
        fd = getpfs(&pfs, av[0]);
 
        printf("%s\n", av[0]);
index 0d66156..bb3da79 100644 (file)
@@ -60,15 +60,19 @@ hammer_cmd_rebalance(char **av, int ac)
        rebal.key_end.obj_id = HAMMER_MAX_OBJID;
        rebal.allpfs = AllPFS;
 
-       if (ac == 0)
+       if (ac == 0) {
                rebalance_usage(1);
+               /* not reached */
+       }
        filesystem = av[0];
        if (ac == 1) {
                perc = 85;
        } else {
                perc = strtol(av[1], NULL, 0);
-               if (perc < 50 || perc > 100)
+               if (perc < 50 || perc > 100) {
                        rebalance_usage(1);
+                       /* not reached */
+               }
        }
        rebal.saturation = HAMMER_BTREE_INT_ELMS * perc / 100;
 
index cb54a44..e5573ea 100644 (file)
@@ -85,15 +85,19 @@ hammer_cmd_reblock(char **av, int ac, int flags)
                break;
        }
 
-       if (ac == 0)
+       if (ac == 0) {
                reblock_usage(1);
+               /* not reached */
+       }
        filesystem = av[0];
        if (ac == 1) {
                perc = 100;
        } else {
                perc = strtol(av[1], NULL, 0);
-               if (perc < 0 || perc > 100)
+               if (perc < 0 || perc > 100) {
                        reblock_usage(1);
+                       /* not reached */
+               }
        }
        reblock.free_level = (int)((int64_t)perc *
                                   HAMMER_BIGBLOCK_SIZE / 100);
index 11e4917..3ccd9cc 100644 (file)
@@ -99,8 +99,10 @@ hammer_cmd_softprune(char **av, int ac, int everything_opt)
        /*
         * For now just allow one directory
         */
-       if (ac == 0 || ac > 1)
+       if (ac == 0 || ac > 1) {
                softprune_usage(1);
+               /* not reached */
+       }
 
        /*
         * Scan the softlink directory.
@@ -110,8 +112,10 @@ hammer_cmd_softprune(char **av, int ac, int everything_opt)
                scan = hammer_softprune_addentry(&base, &template,
                                                 *av, NULL, NULL,
                                                 dummylink, dummylink);
-               if (scan == NULL)
+               if (scan == NULL) {
                        softprune_usage(1);
+                       /* not reached */
+               }
                scan->prune.nelms = 0;
                scan->prune.head.flags |= HAMMER_IOC_PRUNE_ALL;
        } else {
@@ -121,8 +125,10 @@ hammer_cmd_softprune(char **av, int ac, int everything_opt)
                        scan = hammer_softprune_addentry(&base, &template,
                                                         *av, NULL, NULL,
                                                         dummylink, dummylink);
-                       if (scan == NULL)
+                       if (scan == NULL) {
                                softprune_usage(1);
+                               /* not reached */
+                       }
                        scan->prune.nelms = 0;
                }
                ++av;
index ba5835a..e9c433a 100644 (file)
@@ -51,14 +51,18 @@ hammer_cmd_synctid(char **av, int ac)
        bzero(&synctid, sizeof(synctid));
        synctid.op = HAMMER_SYNCTID_SYNC2;
 
-       if (ac == 0 || ac > 2)
+       if (ac == 0 || ac > 2) {
                synctid_usage(1);
+               /* not reached */
+       }
        filesystem = av[0];
        if (ac == 2) {
-               if (strcmp(av[1], "quick") == 0)
+               if (strcmp(av[1], "quick") == 0) {
                        synctid.op = HAMMER_SYNCTID_SYNC1;
-               else
+               } else {
                        synctid_usage(1);
+                       /* not reached */
+               }
        }
        fd = open(filesystem, O_RDONLY);
        if (fd < 0) {
index d825a21..7e0ed45 100644 (file)
@@ -99,6 +99,7 @@ main(int ac, char **av)
                                break;
                        default:
                                usage(1);
+                               /* not reached */
                        }
                        break;
                case 'S':
@@ -122,6 +123,7 @@ main(int ac, char **av)
                                break;
                        default:
                                usage(1);
+                               /* not reached */
                        }
                        break;
                case 'c':
@@ -197,8 +199,10 @@ main(int ac, char **av)
                        BulkOpt = 1;
                        break;
                case 'C':
-                       if (hammer_parse_cache_size(optarg) == -1)
+                       if (hammer_parse_cache_size(optarg) == -1) {
                                usage(1);
+                               /* not reached */
+                       }
                        break;
                case 'F':
                        ForceOpt = 1;
@@ -269,8 +273,10 @@ main(int ac, char **av)
                int len;
                const char *aname = av[1];
 
-               if (aname == NULL)
+               if (aname == NULL) {
                        usage(1);
+                       /* not reached */
+               }
                len = strlen(aname);
                key = (uint32_t)crc32(aname, len) & 0xFFFFFFFEU;
 
@@ -305,8 +311,10 @@ main(int ac, char **av)
        if (strcmp(av[0], "namekey1") == 0) {
                int64_t key;
 
-               if (av[1] == NULL)
+               if (av[1] == NULL) {
                        usage(1);
+                       /* not reached */
+               }
                key = (int64_t)(crc32(av[1], strlen(av[1])) & 0x7FFFFFFF) << 32;
                if (key == 0)
                        key |= 0x100000000LL;
@@ -316,8 +324,10 @@ main(int ac, char **av)
        if (strcmp(av[0], "namekey32") == 0) {
                int32_t key;
 
-               if (av[1] == NULL)
+               if (av[1] == NULL) {
                        usage(1);
+                       /* not reached */
+               }
                key = crc32(av[1], strlen(av[1])) & 0x7FFFFFFF;
                if (key == 0)
                        ++key;
@@ -381,8 +391,10 @@ main(int ac, char **av)
                exit(0);
        }
        if (strcmp(av[0], "ssh-remote") == 0) {
-               if (ac != 3)
+               if (ac != 3) {
                        usage(1);
+                       /* not reached */
+               }
                hammer_cmd_sshremote(av[1], av[2]);
                exit(0);
        }
@@ -444,8 +456,10 @@ main(int ac, char **av)
                        hammer_cmd_reblock(av + 1, ac - 1, HAMMER_IOC_DO_DIRS);
                else if (strcmp(av[0], "reblock-data") == 0)
                        hammer_cmd_reblock(av + 1, ac - 1, HAMMER_IOC_DO_DATA);
-               else
+               else {
                        usage(1);
+                       /* not reached */
+               }
                exit(0);
        }
        if (strncmp(av[0], "mirror", 6) == 0) {
@@ -461,8 +475,10 @@ main(int ac, char **av)
                        hammer_cmd_mirror_copy(av + 1, ac - 1, 1);
                else if (strcmp(av[0], "mirror-dump") == 0)
                        hammer_cmd_mirror_dump(av + 1, ac - 1);
-               else
+               else {
                        usage(1);
+                       /* not reached */
+               }
                exit(0);
        }
        if (strcmp(av[0], "dedup-simulate") == 0) {