From 73cca6386bb9a184e2092ef50a60e010e617866e Mon Sep 17 00:00:00 2001 From: Tomohiro Kusumi Date: Wed, 12 Apr 2017 18:58:52 +0300 Subject: [PATCH] sbin/hammer: Add /* not reached */ (missing ones in 052fd72b) Some comments for errx(3) were missing in 052fd72b which was intended to do this for all err(3)/errx(3) in sbin/hammer/*.c. --- sbin/hammer/blockmap.c | 4 +++- sbin/hammer/cmd_dedup.c | 6 +++++- sbin/hammer/cmd_remote.c | 12 +++++++++--- sbin/hammer/cmd_strip.c | 4 +++- sbin/hammer/hammer.c | 18 ++++++++++++++---- 5 files changed, 34 insertions(+), 10 deletions(-) diff --git a/sbin/hammer/blockmap.c b/sbin/hammer/blockmap.c index 09d2393caa..5383e80035 100644 --- a/sbin/hammer/blockmap.c +++ b/sbin/hammer/blockmap.c @@ -164,8 +164,10 @@ again: HAMMER_BLOCKMAP_LAYER2_OFFSET(blockmap->next_offset); layer2 = get_buffer_data(layer2_offset, &buffer2, 0); - if (layer2->zone == HAMMER_ZONE_UNAVAIL_INDEX) + if (layer2->zone == HAMMER_ZONE_UNAVAIL_INDEX) { errx(1, "alloc_blockmap: layer2 ran out of space!"); + /* not reached */ + } /* * If we are entering a new big-block assign ownership to our diff --git a/sbin/hammer/cmd_dedup.c b/sbin/hammer/cmd_dedup.c index 1833c8517a..e1b3a64d51 100644 --- a/sbin/hammer/cmd_dedup.c +++ b/sbin/hammer/cmd_dedup.c @@ -650,6 +650,7 @@ process_btree_elm(hammer_btree_leaf_elm_t scan_leaf, int flags) case DEDUP_VERS_FAILURE: errx(1, "HAMMER filesystem must be at least " "version 5 to dedup"); + /* not reached */ default: fprintf(stderr, "Unknown error\n"); goto terminate_early; @@ -691,6 +692,7 @@ sha256_failure: case DEDUP_VERS_FAILURE: errx(1, "HAMMER filesystem must be at least " "version 5 to dedup"); + /* not reached */ default: fprintf(stderr, "Unknown error\n"); goto terminate_early; @@ -922,8 +924,10 @@ scan_pfs(char *filesystem, scan_pfs_cb_t func, const char *id) while (offset < mirror.count) { mrec = (void *)((char *)buf + offset); bytes = HAMMER_HEAD_DOALIGN(mrec->head.rec_size); - if (offset + bytes > mirror.count) + if (offset + bytes > mirror.count) { errx(1, "Misaligned record"); + /* not reached */ + } assert((mrec->head.type & HAMMER_MRECF_TYPE_MASK) == HAMMER_MREC_TYPE_REC); diff --git a/sbin/hammer/cmd_remote.c b/sbin/hammer/cmd_remote.c index a73b790648..b5a2784731 100644 --- a/sbin/hammer/cmd_remote.c +++ b/sbin/hammer/cmd_remote.c @@ -46,8 +46,10 @@ hammer_cmd_sshremote(const char *cmd, const char *target) const char *av[REMOTE_MAXARGS + 1]; int ac; - if ((env = getenv("SSH_ORIGINAL_COMMAND")) == NULL) + if ((env = getenv("SSH_ORIGINAL_COMMAND")) == NULL) { errx(1, "SSH_ORIGINAL_COMMAND env missing"); + /* not reached */ + } dup = env = strdup(env); av[0] = "hammer"; @@ -58,11 +60,15 @@ hammer_cmd_sshremote(const char *cmd, const char *target) ac = 5; str = strsep(&env, " \t\r\n"); - if (str == NULL) + if (str == NULL) { errx(1, "hammer-remote: null command"); + /* not reached */ + } - if (strstr(str, "hammer") == NULL) + if (strstr(str, "hammer") == NULL) { errx(1, "hammer-remote: Command not 'hammer'"); + /* not reached */ + } while (ac < REMOTE_MAXARGS) { av[ac] = strsep(&env, " \t\r\n"); diff --git a/sbin/hammer/cmd_strip.c b/sbin/hammer/cmd_strip.c index 040e12c939..c9f56c4da1 100644 --- a/sbin/hammer/cmd_strip.c +++ b/sbin/hammer/cmd_strip.c @@ -160,8 +160,10 @@ hammer_ask_yn(void) printf("Do you really want to do this? [y/n] "); fflush(stdout); - if (getyn() == 0) + if (getyn() == 0) { errx(1, "No action taken"); + /* not reached */ + } printf("Stripping HAMMER filesystem (%s)", volume->ondisk->vol_label); diff --git a/sbin/hammer/hammer.c b/sbin/hammer/hammer.c index 7e0ed452f4..4dff7d211d 100644 --- a/sbin/hammer/hammer.c +++ b/sbin/hammer/hammer.c @@ -245,9 +245,11 @@ main(int ac, char **av) if (strcmp(av[0], elm) == 0) break; } - if (elm == NULL) + if (elm == NULL) { errx(1, "hammer-remote: request does not match " "restricted command"); + /* not reached */ + } free(dup); } @@ -258,6 +260,7 @@ main(int ac, char **av) if (status != uuid_s_ok) { errx(1, "uuids file does not have the DragonFly " "HAMMER filesystem type"); + /* not reached */ } /* @@ -522,8 +525,10 @@ main(int ac, char **av) int indent = 0; hammer_parsedevs(blkdevs, O_RDONLY); - if (ac > 3) + if (ac > 3) { errx(1, "Too many options specified"); + /* not reached */ + } if (ac > 1) arg = av[1]; if (ac > 2) { @@ -594,6 +599,7 @@ __hammer_parsedevs(const char *blkdevs, int oflags, int verify) if (blkdevs == NULL) { errx(1, "A -f blkdevs specification is required " "for this command"); + /* not reached */ } copy = strdup(blkdevs); @@ -616,12 +622,16 @@ __hammer_parsedevs(const char *blkdevs, int oflags, int verify) * All volumes have the same vol_count. */ assert(volume); - if (volnum != volume->ondisk->vol_count) + if (volnum != volume->ondisk->vol_count) { errx(1, "Volume header says %d volumes, but %d specified.", volume->ondisk->vol_count, volnum); + /* not reached */ + } - if (get_root_volume() == NULL) + if (get_root_volume() == NULL) { errx(1, "No root volume found"); + /* not reached */ + } } static __inline -- 2.11.4.GIT