Fix gcc uninitialized variable warnings
[zfs.git] / cmd / zdb / zdb.c
index 891cb9c..459445b 100644 (file)
@@ -87,7 +87,7 @@ libzfs_handle_t *g_zfs;
  * debugging facilities.
  */
 const char *
-_umem_debug_init()
+_umem_debug_init(void)
 {
        return ("default,verbose"); /* $UMEM_DEBUG setting */
 }
@@ -1221,7 +1221,7 @@ static boolean_t sa_loaded;
 sa_attr_type_t *sa_attr_table;
 
 static void
-fuid_table_destroy()
+fuid_table_destroy(void)
 {
        if (fuid_table_loaded) {
                zfs_fuid_table_destroy(&idx_tree, &domain_tree);
@@ -1668,7 +1668,7 @@ dump_uberblock(uberblock_t *ub, const char *header, const char *footer)
 {
        time_t timestamp = ub->ub_timestamp;
 
-       (void) printf(header ? header : "");
+       (void) printf("%s", header ? header : "");
        (void) printf("\tmagic = %016llx\n", (u_longlong_t)ub->ub_magic);
        (void) printf("\tversion = %llu\n", (u_longlong_t)ub->ub_version);
        (void) printf("\ttxg = %llu\n", (u_longlong_t)ub->ub_txg);
@@ -1680,7 +1680,7 @@ dump_uberblock(uberblock_t *ub, const char *header, const char *footer)
                sprintf_blkptr(blkbuf, &ub->ub_rootbp);
                (void) printf("\trootbp = %s\n", blkbuf);
        }
-       (void) printf(footer ? footer : "");
+       (void) printf("%s", footer ? footer : "");
 }
 
 static void
@@ -2179,7 +2179,7 @@ count_block_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
 static int
 dump_block_stats(spa_t *spa)
 {
-       zdb_cb_t zcb = { 0 };
+       zdb_cb_t zcb;
        zdb_blkstats_t *zb, *tzb;
        uint64_t norm_alloc, norm_space, total_alloc, total_found;
        int flags = TRAVERSE_PRE | TRAVERSE_PREFETCH_METADATA | TRAVERSE_HARD;
@@ -2201,6 +2201,7 @@ dump_block_stats(spa_t *spa)
         * it's not part of any space map) is a double allocation,
         * reference to a freed block, or an unclaimed log block.
         */
+       bzero(&zcb, sizeof(zdb_cb_t));
        zdb_leak_init(spa, &zcb);
 
        /*
@@ -2413,8 +2414,11 @@ dump_simulated_ddt(spa_t *spa)
        avl_tree_t t;
        void *cookie = NULL;
        zdb_ddt_entry_t *zdde;
-       ddt_histogram_t ddh_total = { 0 };
-       ddt_stat_t dds_total = { 0 };
+       ddt_histogram_t ddh_total;
+       ddt_stat_t dds_total;
+
+       bzero(&ddh_total, sizeof (ddt_histogram_t));
+       bzero(&dds_total, sizeof (ddt_stat_t));
 
        avl_create(&t, ddt_entry_compare,
            sizeof (zdb_ddt_entry_t), offsetof(zdb_ddt_entry_t, zdde_node));
@@ -2554,7 +2558,7 @@ zdb_dump_block_raw(void *buf, uint64_t size, int flags)
 {
        if (flags & ZDB_FLAG_BSWAP)
                byteswap_uint64_array(buf, size);
-       (void) write(1, buf, size);
+       VERIFY(write(fileno(stdout), buf, size) == size);
 }
 
 static void
@@ -2884,7 +2888,7 @@ find_zpool(char **target, nvlist_t **configp, int dirc, char **dirv)
        nvlist_t *match = NULL;
        char *name = NULL;
        char *sepp = NULL;
-       char sep;
+       char sep = 0;
        int count = 0;
        importargs_t args = { 0 };