Print this page
3006 VERIFY[S,U,P] and ASSERT[S,U,P] frequently check if first argument is zero

@@ -970,11 +970,11 @@
 
         if (error == ENOSPC) {
                 ztest_record_enospc(FTAG);
                 return (error);
         }
-        ASSERT3U(error, ==, 0);
+        ASSERT0(error);
 
         VERIFY3U(dsl_prop_get(osname, propname, sizeof (curval),
             1, &curval, setpoint), ==, 0);
 
         if (ztest_opts.zo_verbose >= 6) {

@@ -1002,11 +1002,11 @@
 
         if (error == ENOSPC) {
                 ztest_record_enospc(FTAG);
                 return (error);
         }
-        ASSERT3U(error, ==, 0);
+        ASSERT0(error);
 
         return (error);
 }
 
 static void

@@ -1410,20 +1410,20 @@
         }
 
         ASSERT(lr->lr_foid != 0);
 
         if (lr->lrz_type != DMU_OT_ZAP_OTHER)
-                VERIFY3U(0, ==, dmu_object_set_blocksize(os, lr->lr_foid,
+                VERIFY0(dmu_object_set_blocksize(os, lr->lr_foid,
                     lr->lrz_blocksize, lr->lrz_ibshift, tx));
 
-        VERIFY3U(0, ==, dmu_bonus_hold(os, lr->lr_foid, FTAG, &db));
+        VERIFY0(dmu_bonus_hold(os, lr->lr_foid, FTAG, &db));
         bbt = ztest_bt_bonus(db);
         dmu_buf_will_dirty(db, tx);
         ztest_bt_generate(bbt, os, lr->lr_foid, -1ULL, lr->lr_gen, txg, txg);
         dmu_buf_rele(db, FTAG);
 
-        VERIFY3U(0, ==, zap_add(os, lr->lr_doid, name, sizeof (uint64_t), 1,
+        VERIFY0(zap_add(os, lr->lr_doid, name, sizeof (uint64_t), 1,
             &lr->lr_foid, tx));
 
         (void) ztest_log_create(zd, tx, lr);
 
         dmu_tx_commit(tx);

@@ -1444,17 +1444,17 @@
                 byteswap_uint64_array(lr, sizeof (*lr));
 
         ASSERT(lr->lr_doid == ZTEST_DIROBJ);
         ASSERT(name[0] != '\0');
 
-        VERIFY3U(0, ==,
+        VERIFY0(
             zap_lookup(os, lr->lr_doid, name, sizeof (object), 1, &object));
         ASSERT(object != 0);
 
         ztest_object_lock(zd, object, RL_WRITER);
 
-        VERIFY3U(0, ==, dmu_object_info(os, object, &doi));
+        VERIFY0(dmu_object_info(os, object, &doi));
 
         tx = dmu_tx_create(os);
 
         dmu_tx_hold_zap(tx, lr->lr_doid, B_FALSE, name);
         dmu_tx_hold_free(tx, object, 0, DMU_OBJECT_END);

@@ -1464,16 +1464,16 @@
                 ztest_object_unlock(zd, object);
                 return (ENOSPC);
         }
 
         if (doi.doi_type == DMU_OT_ZAP_OTHER) {
-                VERIFY3U(0, ==, zap_destroy(os, object, tx));
+                VERIFY0(zap_destroy(os, object, tx));
         } else {
-                VERIFY3U(0, ==, dmu_object_free(os, object, tx));
+                VERIFY0(dmu_object_free(os, object, tx));
         }
 
-        VERIFY3U(0, ==, zap_remove(os, lr->lr_doid, name, tx));
+        VERIFY0(zap_remove(os, lr->lr_doid, name, tx));
 
         (void) ztest_log_remove(zd, tx, lr, object);
 
         dmu_tx_commit(tx);
 

@@ -1519,11 +1519,11 @@
                 bt = NULL;
 
         ztest_object_lock(zd, lr->lr_foid, RL_READER);
         rl = ztest_range_lock(zd, lr->lr_foid, offset, length, RL_WRITER);
 
-        VERIFY3U(0, ==, dmu_bonus_hold(os, lr->lr_foid, FTAG, &db));
+        VERIFY0(dmu_bonus_hold(os, lr->lr_foid, FTAG, &db));
 
         dmu_object_info_from_db(db, &doi);
 
         bbt = ztest_bt_bonus(db);
         ASSERT3U(bbt->bt_magic, ==, BT_MAGIC);

@@ -1658,11 +1658,11 @@
         if (byteswap)
                 byteswap_uint64_array(lr, sizeof (*lr));
 
         ztest_object_lock(zd, lr->lr_foid, RL_WRITER);
 
-        VERIFY3U(0, ==, dmu_bonus_hold(os, lr->lr_foid, FTAG, &db));
+        VERIFY0(dmu_bonus_hold(os, lr->lr_foid, FTAG, &db));
 
         tx = dmu_tx_create(os);
         dmu_tx_hold_bonus(tx, lr->lr_foid);
 
         txg = ztest_tx_assign(tx, TXG_WAIT, FTAG);

@@ -1699,11 +1699,11 @@
 
         dmu_buf_will_dirty(db, tx);
 
         ASSERT3U(lr->lr_size, >=, sizeof (*bbt));
         ASSERT3U(lr->lr_size, <=, db->db_size);
-        VERIFY3U(dmu_set_bonus(db, lr->lr_size, tx), ==, 0);
+        VERIFY0(dmu_set_bonus(db, lr->lr_size, tx));
         bbt = ztest_bt_bonus(db);
 
         ztest_bt_generate(bbt, os, lr->lr_foid, -1ULL, lr->lr_mode, txg, crtxg);
 
         dmu_buf_rele(db, FTAG);

@@ -1891,11 +1891,11 @@
 
                         ASSERT(od->od_object != 0);
                         ASSERT(missing == 0);   /* there should be no gaps */
 
                         ztest_object_lock(zd, od->od_object, RL_READER);
-                        VERIFY3U(0, ==, dmu_bonus_hold(zd->zd_os,
+                        VERIFY0(dmu_bonus_hold(zd->zd_os,
                             od->od_object, FTAG, &db));
                         dmu_object_info_from_db(db, &doi);
                         bbt = ztest_bt_bonus(db);
                         ASSERT3U(bbt->bt_magic, ==, BT_MAGIC);
                         od->od_type = doi.doi_type;

@@ -2269,11 +2269,11 @@
          */
         (void) rw_rdlock(&ztest_name_lock);
         nvroot = make_vdev_root("/dev/bogus", NULL, 0, 0, 0, 0, 0, 1);
         VERIFY3U(EEXIST, ==, spa_create(zo->zo_pool, nvroot, NULL, NULL));
         nvlist_free(nvroot);
-        VERIFY3U(0, ==, spa_open(zo->zo_pool, &spa, FTAG));
+        VERIFY0(spa_open(zo->zo_pool, &spa, FTAG));
         VERIFY3U(EBUSY, ==, spa_destroy(zo->zo_pool));
         spa_close(spa, FTAG);
 
         (void) rw_unlock(&ztest_name_lock);
 }

@@ -3028,24 +3028,24 @@
         int error;
 
         /*
          * Verify that the dataset contains a directory object.
          */
-        VERIFY3U(0, ==, dmu_objset_hold(name, FTAG, &os));
+        VERIFY0(dmu_objset_hold(name, FTAG, &os));
         error = dmu_object_info(os, ZTEST_DIROBJ, &doi);
         if (error != ENOENT) {
                 /* We could have crashed in the middle of destroying it */
-                ASSERT3U(error, ==, 0);
+                ASSERT0(error);
                 ASSERT3U(doi.doi_type, ==, DMU_OT_ZAP_OTHER);
                 ASSERT3S(doi.doi_physical_blocks_512, >=, 0);
         }
         dmu_objset_rele(os, FTAG);
 
         /*
          * Destroy the dataset.
          */
-        VERIFY3U(0, ==, dmu_objset_destroy(name, B_FALSE));
+        VERIFY0(dmu_objset_destroy(name, B_FALSE));
         return (0);
 }
 
 static boolean_t
 ztest_snapshot_create(char *osname, uint64_t id)

@@ -3134,12 +3134,11 @@
                         return;
                 }
                 fatal(0, "dmu_objset_create(%s) = %d", name, error);
         }
 
-        VERIFY3U(0, ==,
-            dmu_objset_own(name, DMU_OST_OTHER, B_FALSE, FTAG, &os));
+        VERIFY0(dmu_objset_own(name, DMU_OST_OTHER, B_FALSE, FTAG, &os));
 
         ztest_zd_init(&zdtmp, NULL, os);
 
         /*
          * Open the intent log for it.

@@ -3164,11 +3163,11 @@
             dmu_objset_create(name, DMU_OST_OTHER, 0, NULL, NULL));
 
         /*
          * Verify that we can hold an objset that is also owned.
          */
-        VERIFY3U(0, ==, dmu_objset_hold(name, FTAG, &os2));
+        VERIFY0(dmu_objset_hold(name, FTAG, &os2));
         dmu_objset_rele(os2, FTAG);
 
         /*
          * Verify that we cannot own an objset that is already owned.
          */

@@ -3441,14 +3440,14 @@
         /*
          * Read the current contents of our objects.
          */
         error = dmu_read(os, packobj, packoff, packsize, packbuf,
             DMU_READ_PREFETCH);
-        ASSERT3U(error, ==, 0);
+        ASSERT0(error);
         error = dmu_read(os, bigobj, bigoff, bigsize, bigbuf,
             DMU_READ_PREFETCH);
-        ASSERT3U(error, ==, 0);
+        ASSERT0(error);
 
         /*
          * Get a tx for the mods to both packobj and bigobj.
          */
         tx = dmu_tx_create(os);

@@ -3684,11 +3683,11 @@
         bigsize = s * chunksize;
 
         packbuf = umem_zalloc(packsize, UMEM_NOFAIL);
         bigbuf = umem_zalloc(bigsize, UMEM_NOFAIL);
 
-        VERIFY3U(0, ==, dmu_bonus_hold(os, bigobj, FTAG, &bonus_db));
+        VERIFY0(dmu_bonus_hold(os, bigobj, FTAG, &bonus_db));
 
         bigbuf_arcbufs = umem_zalloc(2 * s * sizeof (arc_buf_t *), UMEM_NOFAIL);
 
         /*
          * Iteration 0 test zcopy for DB_UNCACHED dbufs.

@@ -3754,14 +3753,14 @@
                  * existing dbufs for the specified offsets.
                  */
                 if (i != 0 || ztest_random(2) != 0) {
                         error = dmu_read(os, packobj, packoff,
                             packsize, packbuf, DMU_READ_PREFETCH);
-                        ASSERT3U(error, ==, 0);
+                        ASSERT0(error);
                         error = dmu_read(os, bigobj, bigoff, bigsize,
                             bigbuf, DMU_READ_PREFETCH);
-                        ASSERT3U(error, ==, 0);
+                        ASSERT0(error);
                 }
                 compare_and_update_pbbufs(s, packbuf, bigbuf, bigsize,
                     n, chunksize, txg);
 
                 /*

@@ -3936,23 +3935,22 @@
         txg = ztest_tx_assign(tx, TXG_MIGHTWAIT, FTAG);
         if (txg == 0)
                 return;
         for (i = 0; i < 2; i++) {
                 value[i] = i;
-                VERIFY3U(0, ==, zap_add(os, object, hc[i], sizeof (uint64_t),
+                VERIFY0(zap_add(os, object, hc[i], sizeof (uint64_t),
                     1, &value[i], tx));
         }
         for (i = 0; i < 2; i++) {
                 VERIFY3U(EEXIST, ==, zap_add(os, object, hc[i],
                     sizeof (uint64_t), 1, &value[i], tx));
-                VERIFY3U(0, ==,
-                    zap_length(os, object, hc[i], &zl_intsize, &zl_ints));
+                VERIFY0(zap_length(os, object, hc[i], &zl_intsize, &zl_ints));
                 ASSERT3U(zl_intsize, ==, sizeof (uint64_t));
                 ASSERT3U(zl_ints, ==, 1);
         }
         for (i = 0; i < 2; i++) {
-                VERIFY3U(0, ==, zap_remove(os, object, hc[i], tx));
+                VERIFY0(zap_remove(os, object, hc[i], tx));
         }
         dmu_tx_commit(tx);
 
         /*
          * Generate a buch of random entries.

@@ -4009,13 +4007,13 @@
                 fatal(0, "zap future leak: old %llu new %llu", last_txg, txg);
 
         for (i = 0; i < ints; i++)
                 value[i] = txg + object + i;
 
-        VERIFY3U(0, ==, zap_update(os, object, txgname, sizeof (uint64_t),
+        VERIFY0(zap_update(os, object, txgname, sizeof (uint64_t),
             1, &txg, tx));
-        VERIFY3U(0, ==, zap_update(os, object, propname, sizeof (uint64_t),
+        VERIFY0(zap_update(os, object, propname, sizeof (uint64_t),
             ints, value, tx));
 
         dmu_tx_commit(tx);
 
         /*

@@ -4028,19 +4026,19 @@
         error = zap_length(os, object, txgname, &zl_intsize, &zl_ints);
 
         if (error == ENOENT)
                 return;
 
-        ASSERT3U(error, ==, 0);
+        ASSERT0(error);
 
         tx = dmu_tx_create(os);
         dmu_tx_hold_zap(tx, object, B_TRUE, NULL);
         txg = ztest_tx_assign(tx, TXG_MIGHTWAIT, FTAG);
         if (txg == 0)
                 return;
-        VERIFY3U(0, ==, zap_remove(os, object, txgname, tx));
-        VERIFY3U(0, ==, zap_remove(os, object, propname, tx));
+        VERIFY0(zap_remove(os, object, txgname, tx));
+        VERIFY0(zap_remove(os, object, propname, tx));
         dmu_tx_commit(tx);
 }
 
 /*
  * Testcase to test the upgrading of a microzap to fatzap.

@@ -4224,11 +4222,11 @@
                     synced_txg);
 
         data->zcd_called = B_TRUE;
 
         if (error == ECANCELED) {
-                ASSERT3U(data->zcd_txg, ==, 0);
+                ASSERT0(data->zcd_txg);
                 ASSERT(!data->zcd_added);
 
                 /*
                  * The private callback data should be destroyed here, but
                  * since we are going to check the zcd_called field after

@@ -4429,11 +4427,11 @@
         (void) rw_rdlock(&ztest_name_lock);
 
         (void) ztest_spa_prop_set_uint64(ZPOOL_PROP_DEDUPDITTO,
             ZIO_DEDUPDITTO_MIN + ztest_random(ZIO_DEDUPDITTO_MIN));
 
-        VERIFY3U(spa_prop_get(ztest_spa, &props), ==, 0);
+        VERIFY0(spa_prop_get(ztest_spa, &props));
 
         if (ztest_opts.zo_verbose >= 6)
                 dump_nvlist(props, 4);
 
         nvlist_free(props);

@@ -4885,34 +4883,34 @@
         (void) strcat(newname, "_tmp");
 
         /*
          * Do the rename
          */
-        VERIFY3U(0, ==, spa_rename(oldname, newname));
+        VERIFY0(spa_rename(oldname, newname));
 
         /*
          * Try to open it under the old name, which shouldn't exist
          */
         VERIFY3U(ENOENT, ==, spa_open(oldname, &spa, FTAG));
 
         /*
          * Open it under the new name and make sure it's still the same spa_t.
          */
-        VERIFY3U(0, ==, spa_open(newname, &spa, FTAG));
+        VERIFY0(spa_open(newname, &spa, FTAG));
 
         ASSERT(spa == ztest_spa);
         spa_close(spa, FTAG);
 
         /*
          * Rename it back to the original
          */
-        VERIFY3U(0, ==, spa_rename(newname, oldname));
+        VERIFY0(spa_rename(newname, oldname));
 
         /*
          * Make sure it can still be opened
          */
-        VERIFY3U(0, ==, spa_open(oldname, &spa, FTAG));
+        VERIFY0(spa_open(oldname, &spa, FTAG));
 
         ASSERT(spa == ztest_spa);
         spa_close(spa, FTAG);
 
         umem_free(newname, strlen(newname) + 1);

@@ -5008,11 +5006,11 @@
         (void) spa_destroy(newname);
 
         /*
          * Get the pool's configuration and guid.
          */
-        VERIFY3U(0, ==, spa_open(oldname, &spa, FTAG));
+        VERIFY0(spa_open(oldname, &spa, FTAG));
 
         /*
          * Kick off a scrub to tickle scrub/export races.
          */
         if (ztest_random(2) == 0)

@@ -5024,11 +5022,11 @@
         ztest_walk_pool_directory("pools before export");
 
         /*
          * Export it.
          */
-        VERIFY3U(0, ==, spa_export(oldname, &config, B_FALSE, B_FALSE));
+        VERIFY0(spa_export(oldname, &config, B_FALSE, B_FALSE));
 
         ztest_walk_pool_directory("pools after export");
 
         /*
          * Try to import it.

@@ -5038,11 +5036,11 @@
         nvlist_free(newconfig);
 
         /*
          * Import it under the new name.
          */
-        VERIFY3U(0, ==, spa_import(newname, config, NULL, 0));
+        VERIFY0(spa_import(newname, config, NULL, 0));
 
         ztest_walk_pool_directory("pools after import");
 
         /*
          * Try to import it again -- should fail with EEXIST.

@@ -5060,11 +5058,11 @@
         VERIFY3U(ENOENT, ==, spa_open(oldname, &spa, FTAG));
 
         /*
          * Verify that we can open and close the pool using the new name.
          */
-        VERIFY3U(0, ==, spa_open(newname, &spa, FTAG));
+        VERIFY0(spa_open(newname, &spa, FTAG));
         ASSERT(pool_guid == spa_guid(spa));
         spa_close(spa, FTAG);
 
         nvlist_free(config);
 }

@@ -5218,11 +5216,11 @@
          * Note that we can only check this in ztest_dataset_open(),
          * when the open-context and syncing-context values agree.
          * That's because zap_count() returns the open-context value,
          * while dmu_objset_space() returns the rootbp fill count.
          */
-        VERIFY3U(0, ==, zap_count(zd->zd_os, ZTEST_DIROBJ, &dirobjs));
+        VERIFY0(zap_count(zd->zd_os, ZTEST_DIROBJ, &dirobjs));
         dmu_objset_space(zd->zd_os, &scratch, &scratch, &usedobjs, &scratch);
         ASSERT3U(dirobjs + 1, ==, usedobjs);
 }
 
 static int

@@ -5245,11 +5243,11 @@
                 ztest_record_enospc(FTAG);
                 return (error);
         }
         ASSERT(error == 0 || error == EEXIST);
 
-        VERIFY3U(dmu_objset_hold(name, zd, &os), ==, 0);
+        VERIFY0(dmu_objset_hold(name, zd, &os));
         (void) rw_unlock(&ztest_name_lock);
 
         ztest_zd_init(zd, ZTEST_GET_SHARED_DS(d), os);
 
         zilog = zd->zd_zilog;

@@ -5334,11 +5332,11 @@
         kernel_init(FREAD | FWRITE);
         VERIFY(spa_open(ztest_opts.zo_pool, &spa, FTAG) == 0);
         spa->spa_debug = B_TRUE;
         ztest_spa = spa;
 
-        VERIFY3U(0, ==, dmu_objset_hold(ztest_opts.zo_pool, FTAG, &os));
+        VERIFY0(dmu_objset_hold(ztest_opts.zo_pool, FTAG, &os));
         zs->zs_guid = dmu_objset_fsid_guid(os);
         dmu_objset_rele(os, FTAG);
 
         spa->spa_dedup_ditto = 2 * ZIO_DEDUPDITTO_MIN;
 

@@ -5476,12 +5474,12 @@
 
         if (ztest_opts.zo_verbose >= 3)
                 (void) printf("testing spa_freeze()...\n");
 
         kernel_init(FREAD | FWRITE);
-        VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG));
-        VERIFY3U(0, ==, ztest_dataset_open(0));
+        VERIFY0(spa_open(ztest_opts.zo_pool, &spa, FTAG));
+        VERIFY0(ztest_dataset_open(0));
 
         /*
          * Force the first log block to be transactionally allocated.
          * We have to do this before we freeze the pool -- otherwise
          * the log chain won't be anchored.

@@ -5528,12 +5526,12 @@
 
         /*
          * Open and close the pool and dataset to induce log replay.
          */
         kernel_init(FREAD | FWRITE);
-        VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG));
-        VERIFY3U(0, ==, ztest_dataset_open(0));
+        VERIFY0(spa_open(ztest_opts.zo_pool, &spa, FTAG));
+        VERIFY0(ztest_dataset_open(0));
         ztest_dataset_close(0);
         spa_close(spa, FTAG);
         kernel_fini();
 }
 

@@ -5602,16 +5600,16 @@
         props = make_random_props();
         for (int i = 0; i < SPA_FEATURES; i++) {
                 char buf[1024];
                 (void) snprintf(buf, sizeof (buf), "feature@%s",
                     spa_feature_table[i].fi_uname);
-                VERIFY3U(0, ==, nvlist_add_uint64(props, buf, 0));
+                VERIFY0(nvlist_add_uint64(props, buf, 0));
         }
-        VERIFY3U(0, ==, spa_create(ztest_opts.zo_pool, nvroot, props, NULL));
+        VERIFY0(spa_create(ztest_opts.zo_pool, nvroot, props, NULL));
         nvlist_free(nvroot);
 
-        VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG));
+        VERIFY0(spa_open(ztest_opts.zo_pool, &spa, FTAG));
         zs->zs_metaslab_sz =
             1ULL << spa->spa_root_vdev->vdev_child[0]->vdev_ms_shift;
 
         spa_close(spa, FTAG);
 

@@ -5664,11 +5662,11 @@
 
         hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()),
             PROT_READ | PROT_WRITE, MAP_SHARED, ZTEST_FD_DATA, 0);
         ASSERT(hdr != MAP_FAILED);
 
-        VERIFY3U(0, ==, ftruncate(ZTEST_FD_DATA, sizeof (ztest_shared_hdr_t)));
+        VERIFY0(ftruncate(ZTEST_FD_DATA, sizeof (ztest_shared_hdr_t)));
 
         hdr->zh_hdr_size = sizeof (ztest_shared_hdr_t);
         hdr->zh_opts_size = sizeof (ztest_shared_opts_t);
         hdr->zh_size = sizeof (ztest_shared_t);
         hdr->zh_stats_size = sizeof (ztest_shared_callstate_t);

@@ -5675,11 +5673,11 @@
         hdr->zh_stats_count = ZTEST_FUNCS;
         hdr->zh_ds_size = sizeof (ztest_shared_ds_t);
         hdr->zh_ds_count = ztest_opts.zo_datasets;
 
         size = shared_data_size(hdr);
-        VERIFY3U(0, ==, ftruncate(ZTEST_FD_DATA, size));
+        VERIFY0(ftruncate(ZTEST_FD_DATA, size));
 
         (void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize()));
 }
 
 static void