diff options
Diffstat (limited to 'cmd/zdb/zdb.c')
-rw-r--r-- | cmd/zdb/zdb.c | 48 |
1 files changed, 24 insertions, 24 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index ce95759dc..d3a68171a 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -102,7 +102,7 @@ #define ZDB_MAP_OBJECT_ID(obj) (obj) #endif -static char * +static const char * zdb_ot_name(dmu_object_type_t type) { if (type < DMU_OT_NUMTYPES) @@ -2922,7 +2922,7 @@ dsl_deadlist_entry_dump(void *arg, dsl_deadlist_entry_t *dle) } static void -dump_blkptr_list(dsl_deadlist_t *dl, char *name) +dump_blkptr_list(dsl_deadlist_t *dl, const char *name) { char bytes[32]; char comp[32]; @@ -2963,7 +2963,7 @@ dump_blkptr_list(dsl_deadlist_t *dl, char *name) if (dump_opt['d'] < 4) return; - (void) printf("\n"); + (void) putchar('\n'); dsl_deadlist_iterate(dl, dsl_deadlist_entry_dump, NULL); } @@ -3098,9 +3098,8 @@ static void print_idstr(uint64_t id, const char *id_type) { if (FUID_INDEX(id)) { - char *domain; - - domain = zfs_fuid_idx_domain(&idx_tree, FUID_INDEX(id)); + const char *domain = + zfs_fuid_idx_domain(&idx_tree, FUID_INDEX(id)); (void) printf("\t%s %llx [%s-%d]\n", id_type, (u_longlong_t)id, domain, (int)FUID_RID(id)); } else { @@ -3643,7 +3642,7 @@ count_ds_mos_objects(dsl_dataset_t *ds) } } -static const char *objset_types[DMU_OST_NUMTYPES] = { +static const char *const objset_types[DMU_OST_NUMTYPES] = { "NONE", "META", "ZPL", "ZVOL", "OTHER", "ANY" }; /* @@ -3653,7 +3652,7 @@ static const char *objset_types[DMU_OST_NUMTYPES] = { * pointer to point to a descriptive error message. */ static int -parse_object_range(char *range, zopt_object_range_t *zor, char **msg) +parse_object_range(char *range, zopt_object_range_t *zor, const char **msg) { uint64_t flags = 0; char *p, *s, *dup, *flagstr, *tmp = NULL; @@ -4236,13 +4235,13 @@ first_label(cksum_record_t *rec) } static void -print_label_numbers(char *prefix, cksum_record_t *rec) +print_label_numbers(const char *prefix, const cksum_record_t *rec) { - printf("%s", prefix); + fputs(prefix, stdout); for (int i = 0; i < VDEV_LABELS; i++) if (rec->labels[i] == B_TRUE) printf("%d ", i); - printf("\n"); + putchar('\n'); } #define MAX_UBERBLOCK_COUNT (VDEV_UBERBLOCK_RING >> UBERBLOCK_SHIFT) @@ -5126,7 +5125,7 @@ same_metaslab(spa_t *spa, uint64_t vdev, uint64_t off1, uint64_t off2) * Used to simplify reporting of the histogram data. */ typedef struct one_histo { - char *name; + const char *name; uint64_t *count; uint64_t *len; uint64_t cumulative; @@ -8093,32 +8092,33 @@ zdb_read_block(char *thing, spa_t *spa) vdev_t *vd; abd_t *pabd; void *lbuf, *buf; - char *s, *p, *dup, *vdev, *flagstr, *sizes, *tmp = NULL; + char *s, *p, *dup, *flagstr, *sizes, *tmp = NULL; + const char *vdev, *errmsg = NULL; int i, error; boolean_t borrowed = B_FALSE, found = B_FALSE; dup = strdup(thing); s = strtok_r(dup, ":", &tmp); - vdev = s ? s : ""; + vdev = s ?: ""; s = strtok_r(NULL, ":", &tmp); offset = strtoull(s ? s : "", NULL, 16); sizes = strtok_r(NULL, ":", &tmp); s = strtok_r(NULL, ":", &tmp); - flagstr = strdup(s ? s : ""); + flagstr = strdup(s ?: ""); - s = NULL; - tmp = NULL; if (!zdb_parse_block_sizes(sizes, &lsize, &psize)) - s = "invalid size(s)"; + errmsg = "invalid size(s)"; if (!IS_P2ALIGNED(psize, DEV_BSIZE) || !IS_P2ALIGNED(lsize, DEV_BSIZE)) - s = "size must be a multiple of sector size"; + errmsg = "size must be a multiple of sector size"; if (!IS_P2ALIGNED(offset, DEV_BSIZE)) - s = "offset must be a multiple of sector size"; - if (s) { - (void) printf("Invalid block specifier: %s - %s\n", thing, s); + errmsg = "offset must be a multiple of sector size"; + if (errmsg) { + (void) printf("Invalid block specifier: %s - %s\n", + thing, errmsg); goto done; } + tmp = NULL; for (s = strtok_r(flagstr, ":", &tmp); s != NULL; s = strtok_r(NULL, ":", &tmp)) { @@ -8930,13 +8930,13 @@ retry_lookup: sizeof (zopt_object_range_t)); for (unsigned i = 0; i < zopt_object_args; i++) { int err; - char *msg = NULL; + const char *msg = NULL; err = parse_object_range(argv[i], &zopt_object_ranges[i], &msg); if (err != 0) fatal("Bad object or range: '%s': %s\n", - argv[i], msg ? msg : ""); + argv[i], msg ?: ""); } } else if (argc > 0 && dump_opt['m']) { zopt_metaslab_args = argc; |