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

19 files changed:
sbin/hammer/cmd_cleanup.c
sbin/hammer/cmd_config.c
sbin/hammer/cmd_dedup.c
sbin/hammer/cmd_history.c
sbin/hammer/cmd_info.c
sbin/hammer/cmd_mirror.c
sbin/hammer/cmd_pfs.c
sbin/hammer/cmd_rebalance.c
sbin/hammer/cmd_reblock.c
sbin/hammer/cmd_recover.c
sbin/hammer/cmd_remote.c
sbin/hammer/cmd_show.c
sbin/hammer/cmd_snapshot.c
sbin/hammer/cmd_softprune.c
sbin/hammer/cmd_synctid.c
sbin/hammer/cmd_version.c
sbin/hammer/cmd_volume.c
sbin/hammer/misc.c
sbin/hammer/ondisk.c

index 5b76680..dab6b0c 100644 (file)
@@ -721,6 +721,7 @@ strtosecs(char *ptr)
                break;
        default:
                errx(1, "illegal suffix converting %s", ptr);
+               /* not reached */
                break;
        }
        return(val);
index c1e308b..178e798 100644 (file)
@@ -150,11 +150,15 @@ hammer_cmd_viconfig(char **av, int ac)
        atexit(config_remove_path);
 
        fd = open(path, O_RDWR|O_CREAT|O_TRUNC, 0600);
-       if (fd < 0)
+       if (fd < 0) {
                err(2, "hammer viconfig: creating temporary file %s", path);
+               /* not reached */
+       }
        write(fd, config.config.text, strlen(config.config.text));
-       if (fstat(fd, &st) < 0)
+       if (fstat(fd, &st) < 0) {
                err(2, "hammer viconfig");
+               /* not reached */
+       }
        times[0].tv_sec = st.st_mtime - 1;
        times[0].tv_usec = 0;
        times[1] = times[0];
@@ -170,20 +174,26 @@ hammer_cmd_viconfig(char **av, int ac)
        asprintf(&runcmd, "%s %s", editor, path);
        system(runcmd);
 
-       if (stat(path, &st) < 0)
+       if (stat(path, &st) < 0) {
                err(2, "hammer viconfig: unable to stat file after vi");
+               /* not reached */
+       }
        if (times[0].tv_sec == st.st_mtime) {
                printf("hammer viconfig: no changes were made\n");
                remove(path);
                return;
        }
        fd = open(path, O_RDONLY);
-       if (fd < 0)
+       if (fd < 0) {
                err(2, "hammer viconfig: unable to read %s", path);
+               /* not reached */
+       }
        remove(path);
        n = read(fd, config.config.text, sizeof(config.config.text) - 1);
-       if (n < 0)
+       if (n < 0) {
                err(2, "hammer viconfig: unable to read %s", path);
+               /* not reached */
+       }
        if (n == sizeof(config.config.text) - 1) {
                err(2, "hammer config: config file too big, limit %zu bytes",
                    sizeof(config.config.text) - 1);
@@ -202,13 +212,19 @@ config_get(const char *dirpath, struct hammer_ioc_config *config)
        int fd;
 
        bzero(&version, sizeof(version));
-       if ((fd = open(dirpath, O_RDONLY)) < 0)
+       if ((fd = open(dirpath, O_RDONLY)) < 0) {
                err(2, "hammer config: unable to open directory %s", dirpath);
-       if (ioctl(fd, HAMMERIOC_GET_VERSION, &version) < 0)
+               /* not reached */
+       }
+       if (ioctl(fd, HAMMERIOC_GET_VERSION, &version) < 0) {
                errx(2, "hammer config: not a HAMMER filesystem!");
+               /* not reached */
+       }
        HammerVersion = version.cur_version;
-       if (ioctl(fd, HAMMERIOC_GET_CONFIG, config) < 0)
+       if (ioctl(fd, HAMMERIOC_GET_CONFIG, config) < 0) {
                errx(2, "hammer config: config_get");
+               /* not reached */
+       }
        close(fd);
 }
 
@@ -219,13 +235,19 @@ config_set(const char *dirpath, struct hammer_ioc_config *config)
        int fd;
 
        bzero(&version, sizeof(version));
-       if ((fd = open(dirpath, O_RDONLY)) < 0)
+       if ((fd = open(dirpath, O_RDONLY)) < 0) {
                errx(2, "hammer config: unable to open directory %s", dirpath);
-       if (ioctl(fd, HAMMERIOC_GET_VERSION, &version) < 0)
+               /* not reached */
+       }
+       if (ioctl(fd, HAMMERIOC_GET_VERSION, &version) < 0) {
                errx(2, "hammer config: not a HAMMER filesystem!");
+               /* not reached */
+       }
        HammerVersion = version.cur_version;
-       if (ioctl(fd, HAMMERIOC_SET_CONFIG, config) < 0)
+       if (ioctl(fd, HAMMERIOC_SET_CONFIG, config) < 0) {
                err(2, "hammer config");
+               /* not reached */
+       }
        close(fd);
 }
 
index c18ac38..39785a8 100644 (file)
@@ -904,11 +904,15 @@ scan_pfs(char *filesystem, scan_pfs_cb_t func, const char *id)
                mirror.count = 0;
                mirror.pfs_id = glob_pfs.pfs_id;
                mirror.shared_uuid = glob_pfs.ondisk->shared_uuid;
-               if (ioctl(glob_fd, HAMMERIOC_MIRROR_READ, &mirror) < 0)
+               if (ioctl(glob_fd, HAMMERIOC_MIRROR_READ, &mirror) < 0) {
                        err(1, "Mirror-read %s failed", filesystem);
-               if (mirror.head.flags & HAMMER_IOC_HEAD_ERROR)
+                       /* not reached */
+               }
+               if (mirror.head.flags & HAMMER_IOC_HEAD_ERROR) {
                        errx(1, "Mirror-read %s fatal error %d",
                                filesystem, mirror.head.error);
+                       /* not reached */
+               }
                if (mirror.count) {
                        offset = 0;
                        while (offset < mirror.count) {
index 289e3fa..a5efa71 100644 (file)
@@ -161,14 +161,17 @@ parse_attr(const char *s, cmd_attr_t *ca)
        if (test_strtoll(errno, offset)) {
                *rptr = '\0';  /* side effect */
                err(1, "%s", s);
+               /* not reached */
        }
        ca->offset = offset;
 
        if (*rptr == ',') {
                errno = 0;  /* clear */
                length = strtol(rptr + 1, NULL, 0);
-               if (test_strtol(errno, length))
+               if (test_strtol(errno, length)) {
                        err(1, "%s", rptr);
+                       /* not reached */
+               }
                if (length >= 0)
                        ca->length = length;
        }
index b6b62de..48a089d 100644 (file)
@@ -91,15 +91,19 @@ __test_if_hammer_or_abort(const char *path)
        int fd;
 
        fd = open(path, O_RDONLY);
-       if (fd < 0)
+       if (fd < 0) {
                err(1, "Failed to open %s", path);
+               /* not reached */
+       }
 
        /*
         * This ioctl never fails as long as fd is for HAMMER filesystem,
         * thus we can assume path isn't in HAMMER if this fails.
         */
-       if (ioctl(fd, HAMMERIOC_GET_INFO, &info) < 0)
+       if (ioctl(fd, HAMMERIOC_GET_INFO, &info) < 0) {
                err(1, "%s is probably not a HAMMER filesystem", path);
+               /* not reached */
+       }
 
        close(fd);
 }
@@ -127,19 +131,25 @@ show_info(char *path)
        __test_if_hammer_or_abort(path);
 
        fip = libhammer_get_fsinfo(path);
-       if (fip == NULL)
+       if (fip == NULL) {
                errx(1, "Failed to get filesystem info");
+               /* not reached */
+       }
 
        /* Find out the UUID strings */
        uuid_to_string(&fip->vol_fsid, &fsid, NULL);
 
        /* Get the volume paths */
-       if (hammer_fs_to_vol(path, &ioc) == -1)
+       if (hammer_fs_to_vol(path, &ioc) == -1) {
                errx(1, "Failed to get volume paths");
+               /* not reached */
+       }
 
        /* Get the root volume path */
-       if (hammer_fs_to_rootvol(path, rootvol, sizeof(rootvol)) == -1)
+       if (hammer_fs_to_rootvol(path, rootvol, sizeof(rootvol)) == -1) {
                errx(1, "Failed to get root volume path");
+               /* not reached */
+       }
 
        /* Volume information */
        printf("Volume identification\n");
index ec74f1e..56a61a9 100644 (file)
@@ -290,12 +290,14 @@ again:
                        score_printf(LINE3, "Mirror-read %s failed: %s",
                                     filesystem, strerror(errno));
                        err(1, "Mirror-read %s failed", filesystem);
+                       /* not reached */
                }
                if (mirror.head.flags & HAMMER_IOC_HEAD_ERROR) {
                        score_printf(LINE3, "Mirror-read %s fatal error %d",
                                     filesystem, mirror.head.error);
                        errx(1, "Mirror-read %s fatal error %d",
                                filesystem, mirror.head.error);
+                       /* not reached */
                }
                if (mirror.count) {
                        if (BandwidthOpt) {
@@ -311,6 +313,7 @@ again:
                                             filesystem);
                                errx(1, "Mirror-read %s failed: short write",
                                        filesystem);
+                               /* not reached */
                        }
                }
                total_bytes += mirror.count;
@@ -385,6 +388,7 @@ done:
                    mrec->head.rec_size != sizeof(mrec->update)) {
                        errx(1, "mirror_read: Did not get final "
                                "acknowledgement packet from target");
+                       /* not reached */
                }
                if (interrupted) {
                        if (CyclePath) {
@@ -549,11 +553,15 @@ generate_histogram(int fd, const char *filesystem,
        chunkno = 0;
        for (;;) {
                mirror.count = 0;
-               if (ioctl(fd, HAMMERIOC_MIRROR_READ, &mirror) < 0)
+               if (ioctl(fd, HAMMERIOC_MIRROR_READ, &mirror) < 0) {
                        err(1, "Mirror-read %s failed", filesystem);
-               if (mirror.head.flags & HAMMER_IOC_HEAD_ERROR)
+                       /* not reached */
+               }
+               if (mirror.head.flags & HAMMER_IOC_HEAD_ERROR) {
                        errx(1, "Mirror-read %s fatal error %d",
                                filesystem, mirror.head.error);
+                       /* not reached */
+               }
                for (off = 0;
                     off < mirror.count;
                     off += HAMMER_HEAD_DOALIGN(mrec->head.rec_size)) {
@@ -697,8 +705,10 @@ create_pfs(const char *filesystem, uuid_t *s_uuid)
                        "Do you want to create a new slave PFS? [y/n] ",
                        filesystem);
                fflush(stderr);
-               if (getyntty() != 1)
+               if (getyntty() != 1) {
                        errx(1, "Aborting operation");
+                       /* not reached */
+               }
        }
 
        uint32_t status;
@@ -710,8 +720,10 @@ create_pfs(const char *filesystem, uuid_t *s_uuid)
                 filesystem, shared_uuid);
        free(shared_uuid);
 
-       if (cmd == NULL)
+       if (cmd == NULL) {
                errx(1, "Failed to alloc memory");
+               /* not reached */
+       }
        if (system(cmd) != 0)
                fprintf(stderr, "Failed to create PFS\n");
        free(cmd);
@@ -777,8 +789,10 @@ again:
         */
        mrec = read_mrecord(0, &error, &pickup);
        if (mrec == NULL) {
-               if (error == 0)
+               if (error == 0) {
                        errx(1, "validate_mrec_header: short read");
+                       /* not reached */
+               }
                exit(1);
        }
        /*
@@ -788,11 +802,15 @@ again:
                free(buf);
                return;
        }
-       if (mrec->head.type != HAMMER_MREC_TYPE_PFSD)
+       if (mrec->head.type != HAMMER_MREC_TYPE_PFSD) {
                errx(1, "validate_mrec_header: did not get expected "
                        "PFSD record type");
-       if (mrec->head.rec_size != sizeof(mrec->pfs))
+               /* not reached */
+       }
+       if (mrec->head.rec_size != sizeof(mrec->pfs)) {
                errx(1, "validate_mrec_header: unexpected payload size");
+               /* not reached */
+       }
 
        /*
         * Create slave PFS if it doesn't yet exist
@@ -847,17 +865,22 @@ again:
                mirror.size = read_mrecords(0, buf, SERIALBUF_SIZE, &pickup);
                if (mirror.size <= 0)
                        break;
-               if (ioctl(fd, HAMMERIOC_MIRROR_WRITE, &mirror) < 0)
+               if (ioctl(fd, HAMMERIOC_MIRROR_WRITE, &mirror) < 0) {
                        err(1, "Mirror-write %s failed", filesystem);
-               if (mirror.head.flags & HAMMER_IOC_HEAD_ERROR)
+                       /* not reached */
+               }
+               if (mirror.head.flags & HAMMER_IOC_HEAD_ERROR) {
                        errx(1, "Mirror-write %s fatal error %d",
                                filesystem, mirror.head.error);
+                       /* not reached */
+               }
 #if 0
                if (mirror.head.flags & HAMMER_IOC_HEAD_INTR) {
                        errx(1, "Mirror-write %s interrupted by timer at"
                                " %016llx",
                                filesystem,
                                mirror.key_cur.obj_id);
+                       /* not reached */
                }
 #endif
        }
@@ -882,6 +905,7 @@ again:
                errx(1, "Mirror-write %s: Did not get termination "
                        "sync record, or rec_size is wrong rt=%d",
                        filesystem, (mrec ? (int)mrec->head.type : -1));
+               /* not reached */
        }
 
        /*
@@ -969,8 +993,10 @@ again:
                while (offset < size) {
                        mrec = (void *)((char *)buf + offset);
                        bytes = HAMMER_HEAD_DOALIGN(mrec->head.rec_size);
-                       if (offset + bytes > size)
+                       if (offset + bytes > size) {
                                errx(1, "Misaligned record");
+                               /* not reached */
+                       }
 
                        switch(mrec->head.type & HAMMER_MRECF_TYPE_MASK) {
                        case HAMMER_MREC_TYPE_REC_BADCRC:
@@ -1064,8 +1090,10 @@ hammer_cmd_mirror_copy(char **av, int ac, int streaming)
        signal(SIGPIPE, SIG_IGN);
 
 again:
-       if (pipe(fds) < 0)
+       if (pipe(fds) < 0) {
                err(1, "pipe");
+               /* not reached */
+       }
 
        /*
         * Source
@@ -1264,16 +1292,22 @@ read_mrecords(int fd, char *buf, u_int size, hammer_ioc_mrecord_head_t pickup)
                        }
                        if (n == 0)
                                break;
-                       if (n != HAMMER_MREC_HEADSIZE)
+                       if (n != HAMMER_MREC_HEADSIZE) {
                                errx(1, "read_mrecords: short read on pipe");
-                       if (pickup->signature != HAMMER_IOC_MIRROR_SIGNATURE)
+                               /* not reached */
+                       }
+                       if (pickup->signature != HAMMER_IOC_MIRROR_SIGNATURE) {
                                errx(1, "read_mrecords: malformed record on pipe, "
                                        "bad signature");
+                               /* not reached */
+                       }
                }
                if (pickup->rec_size < HAMMER_MREC_HEADSIZE ||
-                   pickup->rec_size > sizeof(*mrec) + HAMMER_XBUFSIZE)
+                   pickup->rec_size > sizeof(*mrec) + HAMMER_XBUFSIZE) {
                        errx(1, "read_mrecords: malformed record on pipe, "
                                "illegal rec_size");
+                       /* not reached */
+               }
 
                /*
                 * Stop if we have insufficient space for the record and data.
@@ -1305,8 +1339,10 @@ read_mrecords(int fd, char *buf, u_int size, hammer_ioc_mrecord_head_t pickup)
                        if (i <= 0)
                                break;
                }
-               if (n != bytes)
+               if (n != bytes) {
                        errx(1, "read_mrecords: short read on pipe");
+                       /* not reached */
+               }
 
                bcopy(pickup, buf + count, HAMMER_MREC_HEADSIZE);
                pickup->signature = 0;
@@ -1316,8 +1352,10 @@ read_mrecords(int fd, char *buf, u_int size, hammer_ioc_mrecord_head_t pickup)
                /*
                 * Validate the completed record
                 */
-               if (!hammer_crc_test_mrec_head(&mrec->head, mrec->head.rec_size))
+               if (!hammer_crc_test_mrec_head(&mrec->head, mrec->head.rec_size)) {
                        errx(1, "read_mrecords: malformed record on pipe, bad crc");
+                       /* not reached */
+               }
 
                /*
                 * If its a B-Tree record validate the data crc.
@@ -1332,6 +1370,7 @@ read_mrecords(int fd, char *buf, u_int size, hammer_ioc_mrecord_head_t pickup)
                            sizeof(mrec->rec) + mrec->rec.leaf.data_len) {
                                errx(1, "read_mrecords: malformed record on "
                                        "pipe, illegal element data_len");
+                               /* not reached */
                        }
                        if (mrec->rec.leaf.data_len &&
                            mrec->rec.leaf.data_offset &&
@@ -1433,12 +1472,16 @@ write_mrecord(int fdout, uint32_t type, hammer_ioc_mrecord_any_t mrec,
        mrec->head.type = type;
        mrec->head.rec_size = bytes;
        hammer_crc_set_mrec_head(&mrec->head, bytes);
-       if (write(fdout, mrec, bytes) != bytes)
+       if (write(fdout, mrec, bytes) != bytes) {
                err(1, "write_mrecord");
+               /* not reached */
+       }
        if (pad) {
                bzero(zbuf, pad);
-               if (write(fdout, zbuf, pad) != pad)
+               if (write(fdout, zbuf, pad) != pad) {
                        err(1, "write_mrecord");
+                       /* not reached */
+               }
        }
 }
 
@@ -1455,10 +1498,14 @@ generate_mrec_header(int fd, int pfs_id,
        bzero(mrec_tmp, sizeof(*mrec_tmp));
        clrpfs(&pfs, &mrec_tmp->pfs.pfsd, pfs_id);
 
-       if (ioctl(fd, HAMMERIOC_GET_PSEUDOFS, &pfs) != 0)
+       if (ioctl(fd, HAMMERIOC_GET_PSEUDOFS, &pfs) != 0) {
                err(1, "Mirror-read: not a HAMMER fs/pseudofs!");
-       if (pfs.version != HAMMER_IOC_PSEUDOFS_VERSION)
+               /* not reached */
+       }
+       if (pfs.version != HAMMER_IOC_PSEUDOFS_VERSION) {
                errx(1, "Mirror-read: HAMMER PFS version mismatch!");
+               /* not reached */
+       }
        mrec_tmp->pfs.version = pfs.version;
 }
 
@@ -1482,15 +1529,21 @@ validate_mrec_header(int fd, int fdin, int is_target, int pfs_id,
         * Get the PFSD info from the target filesystem.
         */
        clrpfs(&pfs, &pfsd, pfs_id);
-       if (ioctl(fd, HAMMERIOC_GET_PSEUDOFS, &pfs) != 0)
+       if (ioctl(fd, HAMMERIOC_GET_PSEUDOFS, &pfs) != 0) {
                err(1, "mirror-write: not a HAMMER fs/pseudofs!");
-       if (pfs.version != HAMMER_IOC_PSEUDOFS_VERSION)
+               /* not reached */
+       }
+       if (pfs.version != HAMMER_IOC_PSEUDOFS_VERSION) {
                errx(1, "mirror-write: HAMMER PFS version mismatch!");
+               /* not reached */
+       }
 
        mrec = read_mrecord(fdin, &error, pickup);
        if (mrec == NULL) {
-               if (error == 0)
+               if (error == 0) {
                        errx(1, "validate_mrec_header: short read");
+                       /* not reached */
+               }
                exit(1);
        }
        if (mrec->head.type == HAMMER_MREC_TYPE_TERM) {
@@ -1498,23 +1551,33 @@ validate_mrec_header(int fd, int fdin, int is_target, int pfs_id,
                return(-1);
        }
 
-       if (mrec->head.type != HAMMER_MREC_TYPE_PFSD)
+       if (mrec->head.type != HAMMER_MREC_TYPE_PFSD) {
                errx(1, "validate_mrec_header: did not get expected "
                        "PFSD record type");
-       if (mrec->head.rec_size != sizeof(mrec->pfs))
+               /* not reached */
+       }
+       if (mrec->head.rec_size != sizeof(mrec->pfs)) {
                errx(1, "validate_mrec_header: unexpected payload size");
-       if (mrec->pfs.version != pfs.version)
+               /* not reached */
+       }
+       if (mrec->pfs.version != pfs.version) {
                errx(1, "validate_mrec_header: Version mismatch");
+               /* not reached */
+       }
 
        /*
         * Whew.  Ok, is the read PFS info compatible with the target?
         */
        if (bcmp(&mrec->pfs.pfsd.shared_uuid, &pfsd.shared_uuid,
-               sizeof(pfsd.shared_uuid)) != 0)
+               sizeof(pfsd.shared_uuid)) != 0) {
                errx(1, "mirror-write: source and target have "
                        "different shared-uuid's!");
-       if (is_target && hammer_is_pfs_master(&pfsd))
+               /* not reached */
+       }
+       if (is_target && hammer_is_pfs_master(&pfsd)) {
                errx(1, "mirror-write: target must be in slave mode");
+               /* not reached */
+       }
        if (tid_begp)
                *tid_begp = mrec->pfs.pfsd.sync_beg_tid;
        if (tid_endp)
@@ -1530,13 +1593,17 @@ update_pfs_snapshot(int fd, hammer_tid_t snapshot_tid, int pfs_id)
        struct hammer_pseudofs_data pfsd;
 
        clrpfs(&pfs, &pfsd, pfs_id);
-       if (ioctl(fd, HAMMERIOC_GET_PSEUDOFS, &pfs) != 0)
+       if (ioctl(fd, HAMMERIOC_GET_PSEUDOFS, &pfs) != 0) {
                err(1, "update_pfs_snapshot (read)");
+               /* not reached */
+       }
 
        if (pfsd.sync_end_tid != snapshot_tid) {
                pfsd.sync_end_tid = snapshot_tid;
-               if (ioctl(fd, HAMMERIOC_SET_PSEUDOFS, &pfs) != 0)
+               if (ioctl(fd, HAMMERIOC_SET_PSEUDOFS, &pfs) != 0) {
                        err(1, "update_pfs_snapshot (rewrite)");
+                       /* not reached */
+               }
                if (VerboseOpt >= 2) {
                        fprintf(stderr,
                                "Mirror-write: Completed, updated snapshot "
@@ -1669,8 +1736,10 @@ hammer_check_restrict(const char *filesystem)
        if (RestrictTarget == NULL)
                return;
        rlen = strlen(RestrictTarget);
-       if (strncmp(filesystem, RestrictTarget, rlen) != 0)
+       if (strncmp(filesystem, RestrictTarget, rlen) != 0) {
                errx(1, "hammer-remote: restricted target");
+               /* not reached */
+       }
 
        atslash = 1;
        while (filesystem[rlen]) {
@@ -1678,6 +1747,7 @@ hammer_check_restrict(const char *filesystem)
                    filesystem[rlen] == '.' &&
                    filesystem[rlen+1] == '.') {
                        errx(1, "hammer-remote: '..' not allowed");
+                       /* not reached */
                }
                if (filesystem[rlen] == '/')
                        atslash = 1;
index bd97043..9bd301e 100644 (file)
@@ -113,16 +113,20 @@ getpfs(struct hammer_ioc_pseudofs_rw *pfs, const char *path)
         * commands can take a regular file/directory (e.g. pfs-status).
         */
        fd = open(path, O_RDONLY);
-       if (fd < 0)
+       if (fd < 0) {
                err(1, "Failed to open %s", path);
+               /* not reached */
+       }
 
        /*
         * If pfs.pfs_id has been set to non -1, the file descriptor fd
         * could be any fd of HAMMER inodes since HAMMERIOC_GET_PSEUDOFS
         * doesn't depend on inode attributes if it's set to a valid id.
         */
-       if (ioctl(fd, HAMMERIOC_GET_PSEUDOFS, pfs) < 0)
+       if (ioctl(fd, HAMMERIOC_GET_PSEUDOFS, pfs) < 0) {
                err(1, "Cannot access %s", path);
+               /* not reached */
+       }
 
        return(fd);
 }
@@ -169,8 +173,10 @@ scanpfsid(struct hammer_ioc_pseudofs_rw *pfs, const char *path)
         */
        if (strchr(path, '/')) {
                path = basename(path); /* strips trailing / first if any */
-               if (path == NULL)
+               if (path == NULL) {
                        err(1, "basename");
+                       /* not reached */
+               }
        }
 
        /*
@@ -249,10 +255,13 @@ hammer_cmd_pseudofs_create(char **av, int ac, int is_slave)
        if (ac == 0)
                pseudofs_usage(1);
        path = av[0];
-       if (lstat(path, &st) == 0)
+       if (lstat(path, &st) == 0) {
                errx(1, "Cannot create %s, file exists!", path);
-       else if (path[strlen(path) - 1] == '/')
+               /* not reached */
+       } else if (path[strlen(path) - 1] == '/') {
                errx(1, "Invalid PFS path %s with trailing /", path);
+               /* not reached */
+       }
 
        /*
         * Figure out the directory prefix, taking care of degenerate
@@ -260,8 +269,10 @@ hammer_cmd_pseudofs_create(char **av, int ac, int is_slave)
         */
        dirpath = dirname(path);
        fd = open(dirpath, O_RDONLY);
-       if (fd < 0)
+       if (fd < 0) {
                err(1, "Cannot open directory %s", dirpath);
+               /* not reached */
+       }
 
        /*
         * Avoid foot-shooting.  Don't let the user create a PFS
@@ -285,15 +296,20 @@ hammer_cmd_pseudofs_create(char **av, int ac, int is_slave)
        for (pfs_id = 0; pfs_id < HAMMER_MAX_PFS; ++pfs_id) {
                clrpfs(&pfs, &pfsd, pfs_id);
                if (ioctl(fd, HAMMERIOC_GET_PSEUDOFS, &pfs) < 0) {
-                       if (errno != ENOENT)
+                       if (errno != ENOENT) {
                                err(1, "Cannot create %s", path);
+                               /* not reached */
+                       }
                        break;
                }
        }
-       if (pfs_id == HAMMER_MAX_PFS)
+       if (pfs_id == HAMMER_MAX_PFS) {
                errx(1, "Cannot create %s, all PFSs in use", path);
-       else if (pfs_id == HAMMER_ROOT_PFSID)
+               /* not reached */
+       } else if (pfs_id == HAMMER_ROOT_PFSID) {
                errx(1, "Fatal error: PFS#%d must exist", HAMMER_ROOT_PFSID);
+               /* not reached */
+       }
 
        /*
         * Create the new PFS
@@ -331,23 +347,29 @@ hammer_cmd_pseudofs_destroy(char **av, int ac)
                pseudofs_usage(1);
        fd = getpfs(&pfs, av[0]);
 
-       if (pfs.pfs_id == HAMMER_ROOT_PFSID)
+       if (pfs.pfs_id == HAMMER_ROOT_PFSID) {
                errx(1, "You cannot destroy PFS#%d", HAMMER_ROOT_PFSID);
+               /* not reached */
+       }
 
        printf("You have requested that PFS#%d (%s) be destroyed\n",
                pfs.pfs_id, pfs.ondisk->label);
        printf("This will irrevocably destroy all data on this PFS!!!!!\n");
        printf("Do you really want to do this? [y/n] ");
        fflush(stdout);
-       if (getyn() == 0)
+       if (getyn() == 0) {
                errx(1, "No action taken on PFS#%d", pfs.pfs_id);
+               /* not reached */
+       }
 
        if (hammer_is_pfs_master(pfs.ondisk)) {
                printf("This PFS is currently setup as a MASTER!\n");
                printf("Are you absolutely sure you want to destroy it? [y/n] ");
                fflush(stdout);
-               if (getyn() == 0)
+               if (getyn() == 0) {
                        errx(1, "No action taken on PFS#%d", pfs.pfs_id);
+                       /* not reached */
+               }
        }
 
        printf("Destroying PFS#%d (%s)", pfs.pfs_id, pfs.ondisk->label);
@@ -370,8 +392,10 @@ hammer_cmd_pseudofs_destroy(char **av, int ac)
                printf("pfs-destroy of PFS#%d succeeded!\n", pfs.pfs_id);
                linkpath = getlink(av[0]);
                if (linkpath) {
-                       if (remove(linkpath) < 0)
+                       if (remove(linkpath) < 0) {
                                err(1, "Unable to remove softlink %s", linkpath);
+                               /* not reached */
+                       }
                        free(linkpath);
                }
        } else {
@@ -395,8 +419,10 @@ hammer_cmd_pseudofs_upgrade(char **av, int ac)
                errx(1, "You cannot upgrade PFS#%d"
                        " (It should already be a master)",
                        HAMMER_ROOT_PFSID);
+               /* not reached */
        } else if (hammer_is_pfs_master(pfs.ondisk)) {
                errx(1, "It is already a master");
+               /* not reached */
        }
 
        if (ioctl(fd, HAMMERIOC_UPG_PSEUDOFS, &pfs) == 0) {
@@ -405,6 +431,7 @@ hammer_cmd_pseudofs_upgrade(char **av, int ac)
        } else {
                err(1, "pfs-upgrade of PFS#%d (%s) failed",
                        pfs.pfs_id, pfs.ondisk->label);
+               /* not reached */
        }
        relpfs(fd, &pfs);
 }
@@ -419,10 +446,13 @@ hammer_cmd_pseudofs_downgrade(char **av, int ac)
                pseudofs_usage(1);
        fd = getpfs(&pfs, av[0]);
 
-       if (pfs.pfs_id == HAMMER_ROOT_PFSID)
+       if (pfs.pfs_id == HAMMER_ROOT_PFSID) {
                errx(1, "You cannot downgrade PFS#%d", HAMMER_ROOT_PFSID);
-       else if (hammer_is_pfs_slave(pfs.ondisk))
+               /* not reached */
+       } else if (hammer_is_pfs_slave(pfs.ondisk)) {
                errx(1, "It is already a slave");
+               /* not reached */
+       }
 
        if (ioctl(fd, HAMMERIOC_DGD_PSEUDOFS, &pfs) == 0) {
                printf("pfs-downgrade of PFS#%d (%s) succeeded\n",
@@ -430,6 +460,7 @@ hammer_cmd_pseudofs_downgrade(char **av, int ac)
        } else {
                err(1, "pfs-downgrade of PFS#%d (%s) failed",
                        pfs.pfs_id, pfs.ondisk->label);
+               /* not reached */
        }
        relpfs(fd, &pfs);
 }
@@ -454,6 +485,7 @@ hammer_cmd_pseudofs_update(char **av, int ac)
                        errx(1, "The real mount point cannot be made a PFS "
                               "slave, only PFS sub-directories can be made "
                               "slaves");
+                       /* not reached */
                }
                pfs.bytes = sizeof(*pfs.ondisk);
                if (ioctl(fd, HAMMERIOC_SET_PSEUDOFS, &pfs) == 0) {
@@ -462,9 +494,11 @@ hammer_cmd_pseudofs_update(char **av, int ac)
                        } else {
                                err(1, "Unable to retrieve PFS configuration "
                                        "after successful update");
+                               /* not reached */
                        }
                } else {
                        err(1, "Unable to adjust PFS configuration");
+                       /* not reached */
                }
        }
        relpfs(fd, &pfs);
@@ -566,8 +600,10 @@ parse_pfsd_options(char **av, int ac, hammer_pseudofs_data_t pfsd)
                /*
                 * Basic assignment value test
                 */
-               if (ptr == NULL)
+               if (ptr == NULL) {
                        errx(1, "option %s requires an assignment", cmd);
+                       /* not reached */
+               }
 
                status = uuid_s_ok;
                if (strcmp(cmd, "sync-beg-tid") == 0) {
@@ -585,6 +621,7 @@ parse_pfsd_options(char **av, int ac, hammer_pseudofs_data_t pfsd)
                                ++ptr;
                        } else if (ptr[0] == '"') {
                                errx(1, "option %s: malformed string", cmd);
+                               /* not reached */
                        }
                        snprintf(pfsd->label, sizeof(pfsd->label), "%s", ptr);
                } else if (strcmp(cmd, "snapshots") == 0) {
@@ -603,6 +640,7 @@ parse_pfsd_options(char **av, int ac, hammer_pseudofs_data_t pfsd)
                        if (len >= (int)sizeof(pfsd->snapshots)) {
                                errx(1, "option %s: path too long, %d "
                                        "character limit", cmd, len);
+                               /* not reached */
                        }
                        snprintf(pfsd->snapshots, sizeof(pfsd->snapshots),
                                 "%s", ptr);
@@ -613,12 +651,16 @@ parse_pfsd_options(char **av, int ac, hammer_pseudofs_data_t pfsd)
                        if (pfsd->prune_min < 0) {
                                errx(1, "option %s: illegal time spec, "
                                        "use Nd or [Nd/]hh[:mm[:ss]]", ptr);
+                               /* not reached */
                        }
                } else {
                        errx(1, "invalid option: %s", cmd);
+                       /* not reached */
                }
-               if (status != uuid_s_ok)
+               if (status != uuid_s_ok) {
                        errx(1, "option %s: error parsing uuid %s", cmd, ptr);
+                       /* not reached */
+               }
                --ac;
                ++av;
        }
index 327a230..0d66156 100644 (file)
@@ -77,8 +77,10 @@ hammer_cmd_rebalance(char **av, int ac)
                rebal.key_beg.localization);
 
        fd = open(filesystem, O_RDONLY);
-       if (fd < 0)
+       if (fd < 0) {
                err(1, "Unable to open %s", filesystem);
+               /* not reached */
+       }
        RunningIoctl = 1;
        if (ioctl(fd, HAMMERIOC_REBALANCE, &rebal) < 0) {
                printf("Rebalance %s failed: %s\n",
index 78ed812..cb54a44 100644 (file)
@@ -107,8 +107,10 @@ hammer_cmd_reblock(char **av, int ac, int flags)
                HAMMER_BIGBLOCK_SIZE);
 
        fd = open(filesystem, O_RDONLY);
-       if (fd < 0)
+       if (fd < 0) {
                err(1, "Unable to open %s", filesystem);
+               /* not reached */
+       }
        RunningIoctl = 1;
        if (ioctl(fd, HAMMERIOC_REBLOCK, &reblock) < 0) {
                printf("Reblock %s failed: %s\n", filesystem, strerror(errno));
index fb724d7..585b060 100644 (file)
@@ -135,8 +135,10 @@ hammer_cmd_recover(char **av, int ac)
        int full = 0;
        int quick = 0;
 
-       if (ac < 1)
+       if (ac < 1) {
                errx(1, "hammer recover <target_dir> [full|quick]");
+               /* not reached */
+       }
 
        TargetDir = av[0];
        if (ac > 1) {
@@ -148,8 +150,10 @@ hammer_cmd_recover(char **av, int ac)
        assert(!full || !quick);
 
        if (mkdir(TargetDir, 0777) == -1) {
-               if (errno != EEXIST)
+               if (errno != EEXIST) {
                        err(1, "mkdir");
+                       /* not reached */
+               }
        }
 
        printf("Running %sraw scan of HAMMER image, recovering to %s\n",
index 1ef5a55..a73b790 100644 (file)
@@ -73,4 +73,5 @@ hammer_cmd_sshremote(const char *cmd, const char *target)
        free(dup);
        execv("/sbin/hammer", (void *)av);
        err(1, "hammer-remote: execv failed");
+       /* not reached */
 }
index f6d05f5..3a9a3c9 100644 (file)
@@ -890,8 +890,10 @@ _strtoul(const char *p, int base)
 
        errno = 0;  /* clear */
        retval = strtoul(p, NULL, base);
-       if (errno == ERANGE && retval == ULONG_MAX)
+       if (errno == ERANGE && retval == ULONG_MAX) {
                err(1, "strtoul");
+               /* not reached */
+       }
        return retval;
 }
 
@@ -903,8 +905,10 @@ _strtoull(const char *p, int base)
 
        errno = 0;  /* clear */
        retval = strtoull(p, NULL, base);
-       if (errno == ERANGE && retval == ULLONG_MAX)
+       if (errno == ERANGE && retval == ULLONG_MAX) {
                err(1, "strtoull");
+               /* not reached */
+       }
        return retval;
 }
 
index 9b8ab6e..93419c9 100644 (file)
@@ -130,6 +130,7 @@ hammer_cmd_snap(char **av, int ac, int tostdout, int fsbase)
        if (ioctl(fsfd, HAMMERIOC_SYNCTID, &synctid) < 0) {
                err(2, "hammer snap: Synctid %s failed",
                    dirpath);
+               /* not reached */
        }
        if (tostdout) {
                if (strcmp(dirpath, ".") == 0 || strcmp(dirpath, "..") == 0) {
@@ -152,6 +153,7 @@ hammer_cmd_snap(char **av, int ac, int tostdout, int fsbase)
                if (statfs(dirpath, &buf) < 0) {
                        err(2, "hammer snap: Cannot determine mount for %s",
                            dirpath);
+                       /* not reached */
                }
                asprintf(&fsym, "%s/@@0x%016jx",
                         buf.f_mntonname, (uintmax_t)synctid.tid);
@@ -338,21 +340,26 @@ hammer_cmd_snapshot(char **av, int ac)
        }
 
        if (stat(softlink_dir, &st) == 0) {
-               if (!S_ISDIR(st.st_mode))
+               if (!S_ISDIR(st.st_mode)) {
                        err(2, "File %s already exists", softlink_dir);
+                       /* not reached */
+               }
 
                if (filesystem == NULL) {
                        if (statfs(softlink_dir, &buf) != 0) {
                                err(2, "Unable to determine filesystem of %s",
                                    softlink_dir);
+                               /* not reached */
                        }
                        filesystem = buf.f_mntonname;
                }
 
                softlink_fmt = malloc(strlen(softlink_dir) + 1 + 1 +
                                      sizeof(DEFAULT_SNAPSHOT_NAME));
-               if (softlink_fmt == NULL)
+               if (softlink_fmt == NULL) {
                        err(2, "Failed to allocate string");
+                       /* not reached */
+               }
 
                strcpy(softlink_fmt, softlink_dir);
                if (softlink_fmt[strlen(softlink_fmt)-1] != '/')
@@ -375,10 +382,12 @@ hammer_cmd_snapshot(char **av, int ac)
                            !S_ISDIR(st.st_mode)) {
                                err(2, "Unable to determine softlink dir %s",
                                    softlink_fmt);
+                               /* not reached */
                        }
                        if (statfs(softlink_fmt, &buf) != 0) {
                                err(2, "Unable to determine filesystem of %s",
                                    softlink_fmt);
+                               /* not reached */
                        }
                        filesystem = buf.f_mntonname;
 
@@ -395,23 +404,33 @@ hammer_cmd_snapshot(char **av, int ac)
        synctid.op = HAMMER_SYNCTID_SYNC2;
 
        int fd = open(filesystem, O_RDONLY);
-       if (fd < 0)
+       if (fd < 0) {
                err(2, "Unable to open %s", filesystem);
-       if (ioctl(fd, HAMMERIOC_SYNCTID, &synctid) < 0)
+               /* not reached */
+       }
+       if (ioctl(fd, HAMMERIOC_SYNCTID, &synctid) < 0) {
                err(2, "Synctid %s failed", filesystem);
+               /* not reached */
+       }
 
        asprintf(&from, "%s/@@0x%016jx", filesystem, (uintmax_t)synctid.tid);
-       if (from == NULL)
+       if (from == NULL) {
                err(2, "Couldn't generate string");
+               /* not reached */
+       }
 
        int sz = strlen(softlink_fmt) + 50;
        to = malloc(sz);
-       if (to == NULL)
+       if (to == NULL) {
                err(2, "Failed to allocate string");
+               /* not reached */
+       }
 
        time_t t = time(NULL);
-       if (strftime(to, sz, softlink_fmt, localtime(&t)) == 0)
+       if (strftime(to, sz, softlink_fmt, localtime(&t)) == 0) {
                err(2, "String buffer too small");
+               /* not reached */
+       }
 
        asprintf(&from, "%s/@@0x%016jx", filesystem, (uintmax_t)synctid.tid);
 
@@ -454,10 +473,12 @@ snapshot_add(int fd, const char *fsym, const char *tsym, const char *label,
                }
                if (ioctl(fd, HAMMERIOC_ADD_SNAPSHOT, &snapshot) < 0) {
                        err(2, "Unable to create snapshot");
+                       /* not reached */
                } else if (snapshot.head.error &&
                           snapshot.head.error != EEXIST) {
                        errx(2, "Unable to create snapshot: %s",
                                strerror(snapshot.head.error));
+                       /* not reached */
                }
         }
 
@@ -469,6 +490,7 @@ snapshot_add(int fd, const char *fsym, const char *tsym, const char *label,
                remove(tsym);
                if (symlink(fsym, tsym) < 0) {
                        err(2, "Unable to create symlink %s", tsym);
+                       /* not reached */
                }
        }
 }
@@ -541,11 +563,13 @@ snapshot_del(int fsfd, hammer_tid_t tid)
 
         if (ioctl(fsfd, HAMMERIOC_GET_VERSION, &version) < 0) {
                err(2, "hammer snaprm 0x%016jx", (uintmax_t)tid);
+               /* not reached */
        }
        HammerVersion = version.cur_version;
        if (version.cur_version < 3) {
                errx(2, "hammer snaprm 0x%016jx: You must upgrade to version "
                        " 3 to use this directive", (uintmax_t)tid);
+               /* not reached */
        }
 
        bzero(&snapshot, sizeof(snapshot));
@@ -558,6 +582,7 @@ snapshot_del(int fsfd, hammer_tid_t tid)
        if (ioctl(fsfd, HAMMERIOC_DEL_SNAPSHOT, &snapshot) < 0) {
                err(2, "hammer snaprm 0x%016jx",
                      (uintmax_t)tid);
+               /* not reached */
        } else if (snapshot.head.error == ENOENT) {
                fprintf(stderr, "Warning: hammer snaprm 0x%016jx: "
                                "meta-data not found\n",
index 1e005a9..11e4917 100644 (file)
@@ -132,9 +132,11 @@ hammer_cmd_softprune(char **av, int ac, int everything_opt)
        /*
         * XXX future (need to store separate cycles for each filesystem)
         */
-       if (base->next)
+       if (base->next) {
                errx(1, "Currently only one HAMMER filesystem may "
                        "be specified in the softlink scan");
+               /* not reached */
+       }
 
        /*
         * Issue the prunes
@@ -260,8 +262,10 @@ hammer_softprune_scandir(struct softprune **basep,
        path = NULL;
        linkbuf = malloc(MAXPATHLEN);
 
-       if ((dir = opendir(dirname)) == NULL)
+       if ((dir = opendir(dirname)) == NULL) {
                err(1, "Cannot open directory %s", dirname);
+               /* not reached */
+       }
        while ((den = readdir(dir)) != NULL) {
                if (strcmp(den->d_name, ".") == 0)
                        continue;
index 39997dd..ba5835a 100644 (file)
@@ -61,12 +61,16 @@ hammer_cmd_synctid(char **av, int ac)
                        synctid_usage(1);
        }
        fd = open(filesystem, O_RDONLY);
-       if (fd < 0)
+       if (fd < 0) {
                err(1, "Unable to open %s", filesystem);
-       if (ioctl(fd, HAMMERIOC_SYNCTID, &synctid) < 0)
+               /* not reached */
+       }
+       if (ioctl(fd, HAMMERIOC_SYNCTID, &synctid) < 0) {
                err(1, "Synctid %s failed", filesystem);
-       else
+               /* not reached */
+       } else {
                printf("0x%016jx\n", (uintmax_t)synctid.tid);
+       }
        close(fd);
 }
 
index 6879d5e..1d10c10 100644 (file)
@@ -49,19 +49,25 @@ hammer_cmd_get_version(char **av, int ac)
        char wip[16];
        int fd;
 
-       if (ac != 1)
+       if (ac != 1) {
                errx(1, "hammer version - expected a single <fs> path arg");
+               /* not reached */
+       }
         fd = open(av[0], O_RDONLY);
-       if (fd < 0)
+       if (fd < 0) {
                err(1, "hammer version: unable to access %s", av[0]);
+               /* not reached */
+       }
 
        /*
         * version.cur_version must be set to 0 to retrieve current version
         * info.
         */
        bzero(&version, sizeof(version));
-       if (ioctl(fd, HAMMERIOC_GET_VERSION, &version) < 0)
+       if (ioctl(fd, HAMMERIOC_GET_VERSION, &version) < 0) {
                err(1, "hammer version ioctl");
+               /* not reached */
+       }
        HammerVersion = version.cur_version;
 
        snprintf(wip, 16, "%d", version.wip_version);
@@ -102,33 +108,47 @@ hammer_cmd_set_version(char **av, int ac)
        int overs;
        int nvers;
 
-       if (ac < 2 || ac > 3 || (ac == 3 && strcmp(av[2], "force") != 0))
+       if (ac < 2 || ac > 3 || (ac == 3 && strcmp(av[2], "force") != 0)) {
                errx(1, "hammer version-upgrade: expected <fs> vers# [force]");
+               /* not reached */
+       }
 
         fd = open(av[0], O_RDONLY);
-       if (fd < 0)
+       if (fd < 0) {
                err(1, "hammer version-upgrade: unable to access %s", av[0]);
+               /* not reached */
+       }
 
        bzero(&version, sizeof(version));
-       if (ioctl(fd, HAMMERIOC_GET_VERSION, &version) < 0)
+       if (ioctl(fd, HAMMERIOC_GET_VERSION, &version) < 0) {
                err(1, "hammer ioctl");
+               /* not reached */
+       }
        HammerVersion = version.cur_version;
        overs = version.cur_version;
 
        version.cur_version = strtol(av[1], NULL, 0);
        nvers = version.cur_version;
 
-       if (ioctl(fd, HAMMERIOC_GET_VERSION, &version) < 0)
+       if (ioctl(fd, HAMMERIOC_GET_VERSION, &version) < 0) {
                err(1, "hammer ioctl");
+               /* not reached */
+       }
        HammerVersion = version.cur_version;
-       if (version.cur_version >= version.wip_version && ac != 3)
+       if (version.cur_version >= version.wip_version && ac != 3) {
                errx(1, "The requested version is a work-in-progress"
                        " and requires the 'force' directive");
+               /* not reached */
+       }
 
-       if (ioctl(fd, HAMMERIOC_SET_VERSION, &version) < 0)
+       if (ioctl(fd, HAMMERIOC_SET_VERSION, &version) < 0) {
                err(1, "hammer version-upgrade ioctl");
-       if (version.head.error)
+               /* not reached */
+       }
+       if (version.head.error) {
                errx(1, "hammer version-upgrade ioctl");
+               /* not reached */
+       }
 
        printf("hammer version-upgrade: succeeded\n");
        if (overs < 3 && nvers >= 3) {
index 8f1d383..f88bc29 100644 (file)
@@ -56,23 +56,29 @@ hammer_cmd_volume_add(char **av, int ac)
        int fd;
        const char *device, *filesystem;
 
-       if (ac != 2)
+       if (ac != 2) {
                errx(1, "hammer volume-add <device> <filesystem>");
+               /* not reached */
+       }
 
        device = av[0];
        filesystem = av[1];
 
         fd = open(filesystem, O_RDONLY);
-       if (fd < 0)
+       if (fd < 0) {
                err(1, "hammer volume-add: unable to access %s", filesystem);
+               /* not reached */
+       }
 
        /*
         * Initialize and check the device
         */
        volume = init_volume(device, O_RDONLY, -1);
        assert(volume->vol_no == -1);
-       if (is_regfile(volume))
+       if (is_regfile(volume)) {
                errx(1, "Not a block device: %s", device);
+               /* not reached */
+       }
        close(volume->fd);
 
        /*
@@ -84,8 +90,10 @@ hammer_cmd_volume_add(char **av, int ac)
        ioc.boot_area_size = init_boot_area_size(0, ioc.vol_size);
        ioc.memory_log_size = init_memory_log_size(0, ioc.vol_size);
 
-       if (ioctl(fd, HAMMERIOC_ADD_VOLUME, &ioc) < 0)
+       if (ioctl(fd, HAMMERIOC_ADD_VOLUME, &ioc) < 0) {
                err(1, "hammer volume-add ioctl");
+               /* not reached */
+       }
 
        close(fd);
        hammer_cmd_volume_list(av + 1, ac - 1);
@@ -101,15 +109,19 @@ hammer_cmd_volume_del(char **av, int ac)
        int fd, retried = 0;
        const char *device, *filesystem;
 
-       if (ac != 2)
+       if (ac != 2) {
                errx(1, "hammer volume-del <device> <filesystem>");
+               /* not reached */
+       }
 
        device = av[0];
        filesystem = av[1];
 
         fd = open(filesystem, O_RDONLY);
-       if (fd < 0)
+       if (fd < 0) {
                err(1, "hammer volume-del: unable to access %s", filesystem);
+               /* not reached */
+       }
 
        /*
         * volume-del ioctl
@@ -130,6 +142,7 @@ retry:
                        }
                }
                err(1, "hammer volume-del ioctl");
+               /* not reached */
        }
 
        close(fd);
@@ -146,11 +159,15 @@ hammer_cmd_volume_list(char **av, int ac)
        char *device_name;
        int vol_no, i;
 
-       if (ac < 1)
+       if (ac < 1) {
                errx(1, "hammer volume-list <filesystem>");
+               /* not reached */
+       }
 
-       if (hammer_fs_to_vol(av[0], &ioc) == -1)
+       if (hammer_fs_to_vol(av[0], &ioc) == -1) {
                errx(1, "hammer volume-list: failed");
+               /* not reached */
+       }
 
        for (i = 0; i < ioc.nvols; i++) {
                device_name = ioc.vols[i].device_name;
@@ -176,11 +193,15 @@ hammer_cmd_volume_blkdevs(char **av, int ac)
        struct hammer_ioc_volume_list ioc;
        int i;
 
-       if (ac < 1)
+       if (ac < 1) {
                errx(1, "hammer volume-blkdevs <filesystem>");
+               /* not reached */
+       }
 
-       if (hammer_fs_to_vol(av[0], &ioc) == -1)
+       if (hammer_fs_to_vol(av[0], &ioc) == -1) {
                errx(1, "hammer volume-list: failed");
+               /* not reached */
+       }
 
        for (i = 0; i < ioc.nvols; i++) {
                printf("%s", ioc.vols[i].device_name);
index 81a4bc5..252bddf 100644 (file)
@@ -203,8 +203,10 @@ hammer_extend_layer1_bits(int vol, int newsiz, int oldsiz)
                p = malloc(HAMMER_LAYER1_BYTES * newsiz);
        else
                p = realloc(p, HAMMER_LAYER1_BYTES * newsiz);
-       if (p == NULL)
+       if (p == NULL) {
                err(1, "alloc");
+               /* not reached */
+       }
        l1_bits[vol] = p;
 
        p += HAMMER_LAYER1_UINT64 * oldsiz;
@@ -223,12 +225,16 @@ hammer_init_zone_stat_bits(void)
        int i;
 
        l1_max = calloc(HAMMER_MAX_VOLUMES, sizeof(int));
-       if (l1_max == NULL)
+       if (l1_max == NULL) {
                err(1, "calloc");
+               /* not reached */
+       }
 
        l1_bits = calloc(HAMMER_MAX_VOLUMES, sizeof(uint64_t*));
-       if (l1_bits == NULL)
+       if (l1_bits == NULL) {
                err(1, "calloc");
+               /* not reached */
+       }
 
        for (i = 0; i < HAMMER_MAX_VOLUMES; i++) {
                l1_max[i] = -1;  /* +1 needs to be 0 */
index aa5ef14..885143f 100644 (file)
@@ -94,8 +94,10 @@ __alloc_volume(const char *volname, int oflags)
        volume->rdonly = (oflags == O_RDONLY);
        volume->name = strdup(volname);
        volume->fd = open(volume->name, oflags);
-       if (volume->fd < 0)
+       if (volume->fd < 0) {
                err(1, "alloc_volume: Failed to open %s", volume->name);
+               /* not reached */
+       }
        check_volume(volume);
 
        volume->ondisk = calloc(1, HAMMER_BUFSIZE);
@@ -112,22 +114,27 @@ __add_volume(struct volume_info *volume)
        struct volume_info *scan;
        struct stat st1, st2;
 
-       if (fstat(volume->fd, &st1) != 0)
+       if (fstat(volume->fd, &st1) != 0) {
                errx(1, "add_volume: %s: Failed to stat", volume->name);
+               /* not reached */
+       }
 
        TAILQ_FOREACH(scan, &VolList, entry) {
                if (scan->vol_no == volume->vol_no) {
                        errx(1, "add_volume: %s: Duplicate volume number %d "
                                "against %s",
                                volume->name, volume->vol_no, scan->name);
+                       /* not reached */
                }
                if (fstat(scan->fd, &st2) != 0) {
                        errx(1, "add_volume: %s: Failed to stat %s",
                                volume->name, scan->name);
+                       /* not reached */
                }
                if ((st1.st_ino == st2.st_ino) && (st1.st_dev == st2.st_dev)) {
                        errx(1, "add_volume: %s: Specified more than once",
                                volume->name);
+                       /* not reached */
                }
        }
 
@@ -142,18 +149,22 @@ __verify_volume(struct volume_info *volume)
        if (ondisk->vol_signature != HAMMER_FSBUF_VOLUME) {
                errx(1, "verify_volume: Invalid volume signature %016jx",
                        ondisk->vol_signature);
+               /* not reached */
        }
        if (ondisk->vol_rootvol != HAMMER_ROOT_VOLNO) {
                errx(1, "verify_volume: Invalid root volume# %d",
                        ondisk->vol_rootvol);
+               /* not reached */
        }
        if (bcmp(&Hammer_FSType, &ondisk->vol_fstype, sizeof(Hammer_FSType))) {
                errx(1, "verify_volume: %s: Header does not indicate "
                        "that this is a HAMMER volume", volume->name);
+               /* not reached */
        }
        if (bcmp(&Hammer_FSId, &ondisk->vol_fsid, sizeof(Hammer_FSId))) {
                errx(1, "verify_volume: %s: FSId does not match other volumes!",
                        volume->name);
+               /* not reached */
        }
 }
 
@@ -188,6 +199,7 @@ load_volume(const char *filename, int oflags, int verify)
        if (n == -1) {
                err(1, "load_volume: %s: Read failed at offset 0",
                    volume->name);
+               /* not reached */
        }
        volume->vol_no = volume->ondisk->vol_no;
        HammerVersion = volume->ondisk->vol_version;
@@ -215,8 +227,10 @@ check_volume(struct volume_info *volume)
         * Allow the formatting of block devices or regular files
         */
        if (ioctl(volume->fd, DIOCGPART, &pinfo) < 0) {
-               if (fstat(volume->fd, &st) < 0)
+               if (fstat(volume->fd, &st) < 0) {
                        err(1, "Unable to stat %s", volume->name);
+                       /* not reached */
+               }
                if (S_ISREG(st.st_mode)) {
                        volume->size = st.st_size;
                        volume->type = "REGFILE";
@@ -233,11 +247,13 @@ check_volume(struct volume_info *volume)
                if (pinfo.reserved_blocks) {
                        errx(1, "HAMMER cannot be placed in a partition "
                                "which overlaps the disklabel or MBR");
+                       /* not reached */
                }
                if (pinfo.media_blksize > HAMMER_BUFSIZE ||
                    HAMMER_BUFSIZE % pinfo.media_blksize) {
                        errx(1, "A media sector size of %d is not supported",
                             pinfo.media_blksize);
+                       /* not reached */
                }
 
                volume->size = pinfo.media_size;
@@ -257,8 +273,10 @@ assert_volume_offset(struct volume_info *volume)
 {
        assert(hammer_is_zone_raw_buffer(volume->vol_free_off));
        assert(hammer_is_zone_raw_buffer(volume->vol_free_end));
-       if (volume->vol_free_off >= volume->vol_free_end)
+       if (volume->vol_free_off >= volume->vol_free_end) {
                errx(1, "Ran out of room, filesystem too small");
+               /* not reached */
+       }
 }
 
 struct volume_info *
@@ -320,6 +338,7 @@ __alloc_buffer(hammer_off_t zone2_offset, int isnew)
                            volume->name,
                            (intmax_t)buffer->zone2_offset,
                            (intmax_t)buffer->raw_offset);
+                       /* not reached */
                }
        }
 
@@ -870,8 +889,10 @@ flush_volume(struct volume_info *volume)
                TAILQ_FOREACH(buffer, &volume->buffer_lists[i], entry)
                        flush_buffer(buffer);
        }
-       if (writehammervol(volume) == -1)
+       if (writehammervol(volume) == -1) {
                err(1, "Write volume %d (%s)", volume->vol_no, volume->name);
+               /* not reached */
+       }
 }
 
 void
@@ -880,8 +901,10 @@ flush_buffer(struct buffer_info *buffer)
        struct volume_info *volume;
 
        volume = buffer->volume;
-       if (writehammerbuf(buffer) == -1)
+       if (writehammerbuf(buffer) == -1) {
                err(1, "Write volume %d (%s)", volume->vol_no, volume->name);
+               /* not reached */
+       }
        buffer->cache.modified = 0;
 }