Skip to content

Commit 9df86d9

Browse files
robnlundman
authored andcommitted
Prefer VERIFY0(n) over VERIFY(n == 0)
Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov> Reviewed-by: Alexander Motin <alexander.motin@TrueNAS.com> Signed-off-by: Rob Norris <robn@despairlabs.com> Sponsored-by: https://despairlabs.com/sponsor/ Closes openzfs#17591
1 parent 7c7a7cc commit 9df86d9

64 files changed

Lines changed: 332 additions & 349 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

cmd/zdb/zdb.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -893,9 +893,9 @@ dump_packed_nvlist(objset_t *os, uint64_t object, void *data, size_t size)
893893
size_t nvsize = *(uint64_t *)data;
894894
char *packed = umem_alloc(nvsize, UMEM_NOFAIL);
895895

896-
VERIFY(0 == dmu_read(os, object, 0, nvsize, packed, DMU_READ_PREFETCH));
896+
VERIFY0(dmu_read(os, object, 0, nvsize, packed, DMU_READ_PREFETCH));
897897

898-
VERIFY(nvlist_unpack(packed, nvsize, &nv, 0) == 0);
898+
VERIFY0(nvlist_unpack(packed, nvsize, &nv, 0));
899899

900900
umem_free(packed, nvsize);
901901

@@ -2044,10 +2044,10 @@ dump_ddt_object(ddt_t *ddt, ddt_type_t type, ddt_class_t class)
20442044

20452045
if (error == ENOENT)
20462046
return;
2047-
ASSERT(error == 0);
2047+
ASSERT0(error);
20482048

20492049
error = ddt_object_count(ddt, type, class, &count);
2050-
ASSERT(error == 0);
2050+
ASSERT0(error);
20512051
if (count == 0)
20522052
return;
20532053

@@ -3521,8 +3521,8 @@ dump_uidgid(objset_t *os, uint64_t uid, uint64_t gid)
35213521
uint64_t fuid_obj;
35223522

35233523
/* first find the fuid object. It lives in the master node */
3524-
VERIFY(zap_lookup(os, MASTER_NODE_OBJ, ZFS_FUID_TABLES,
3525-
8, 1, &fuid_obj) == 0);
3524+
VERIFY0(zap_lookup(os, MASTER_NODE_OBJ, ZFS_FUID_TABLES,
3525+
8, 1, &fuid_obj));
35263526
zfs_fuid_avl_tree_create(&idx_tree, &domain_tree);
35273527
(void) zfs_fuid_table_load(os, fuid_obj,
35283528
&idx_tree, &domain_tree);

cmd/zhack.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -162,9 +162,9 @@ zhack_import(char *target, boolean_t readonly)
162162

163163
props = NULL;
164164
if (readonly) {
165-
VERIFY(nvlist_alloc(&props, NV_UNIQUE_NAME, 0) == 0);
166-
VERIFY(nvlist_add_uint64(props,
167-
zpool_prop_to_name(ZPOOL_PROP_READONLY), 1) == 0);
165+
VERIFY0(nvlist_alloc(&props, NV_UNIQUE_NAME, 0));
166+
VERIFY0(nvlist_add_uint64(props,
167+
zpool_prop_to_name(ZPOOL_PROP_READONLY), 1));
168168
}
169169

170170
zfeature_checks_disable = B_TRUE;
@@ -218,8 +218,8 @@ dump_obj(objset_t *os, uint64_t obj, const char *name)
218218
} else {
219219
ASSERT(za->za_integer_length == 1);
220220
char val[1024];
221-
VERIFY(zap_lookup(os, obj, za->za_name,
222-
1, sizeof (val), val) == 0);
221+
VERIFY0(zap_lookup(os, obj, za->za_name,
222+
1, sizeof (val), val));
223223
(void) printf("\t%s = %s\n", za->za_name, val);
224224
}
225225
}

cmd/zpool/zpool_main.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12377,7 +12377,7 @@ zpool_do_events_next(ev_opts_t *opts)
1237712377
nvlist_free(nvl);
1237812378
}
1237912379

12380-
VERIFY(0 == close(zevent_fd));
12380+
VERIFY0(close(zevent_fd));
1238112381

1238212382
return (ret);
1238312383
}

cmd/ztest.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2277,8 +2277,8 @@ ztest_replay_write(void *arg1, void *arg2, boolean_t byteswap)
22772277

22782278
ztest_block_tag_t rbt;
22792279

2280-
VERIFY(dmu_read(os, lr->lr_foid, offset,
2281-
sizeof (rbt), &rbt, flags) == 0);
2280+
VERIFY0(dmu_read(os, lr->lr_foid, offset,
2281+
sizeof (rbt), &rbt, flags));
22822282
if (rbt.bt_magic == BT_MAGIC) {
22832283
ztest_bt_verify(&rbt, os, lr->lr_foid, 0,
22842284
offset, gen, txg, crtxg);
@@ -5536,8 +5536,8 @@ ztest_dmu_read_write_zcopy(ztest_ds_t *zd, uint64_t id)
55365536
}
55375537

55385538
if (i == 1) {
5539-
VERIFY(dmu_buf_hold(os, bigobj, off,
5540-
FTAG, &dbt, DMU_READ_NO_PREFETCH) == 0);
5539+
VERIFY0(dmu_buf_hold(os, bigobj, off,
5540+
FTAG, &dbt, DMU_READ_NO_PREFETCH));
55415541
}
55425542
if (i != 5 || chunksize < (SPA_MINBLOCKSIZE * 2)) {
55435543
VERIFY0(dmu_assign_arcbuf_by_dbuf(bonus_db,

include/os/freebsd/spl/sys/proc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ do_thread_create(caddr_t stk, size_t stksize, void (*proc)(void *), void *arg,
7878
* Be sure there are no surprises.
7979
*/
8080
ASSERT(stk == NULL);
81-
ASSERT(len == 0);
81+
ASSERT0(len);
8282
ASSERT(state == TS_RUN);
8383

8484
if (pp == &p0)

include/sys/zfs_znode.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ extern "C" {
7373
pflags |= attr; \
7474
else \
7575
pflags &= ~attr; \
76-
VERIFY(0 == sa_update(zp->z_sa_hdl, SA_ZPL_FLAGS(ZTOZSB(zp)), \
76+
VERIFY0(sa_update(zp->z_sa_hdl, SA_ZPL_FLAGS(ZTOZSB(zp)), \
7777
&pflags, sizeof (pflags), tx)); \
7878
}
7979

lib/libzfs/libzfs_diff.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ get_stats_for_obj(differ_info_t *di, const char *dsname, uint64_t obj,
8181
/* we can get stats even if we failed to get a path */
8282
(void) memcpy(sb, &zc.zc_stat, sizeof (zfs_stat_t));
8383
if (error == 0) {
84-
ASSERT(di->zerr == 0);
84+
ASSERT0(di->zerr);
8585
(void) strlcpy(pn, zc.zc_value, maxlen);
8686
return (0);
8787
}
@@ -404,7 +404,7 @@ write_free_diffs(FILE *fp, differ_info_t *di, dmu_diff_record_t *dr)
404404
(void) strlcpy(zc.zc_name, di->fromsnap, sizeof (zc.zc_name));
405405
zc.zc_obj = dr->ddr_first - 1;
406406

407-
ASSERT(di->zerr == 0);
407+
ASSERT0(di->zerr);
408408

409409
while (zc.zc_obj < dr->ddr_last) {
410410
int err;

lib/libzfs/libzfs_import.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ const pool_config_ops_t libzfs_config_ops = {
122122
static uint64_t
123123
label_offset(uint64_t size, int l)
124124
{
125-
ASSERT(P2PHASE_TYPED(size, sizeof (vdev_label_t), uint64_t) == 0);
125+
ASSERT0(P2PHASE_TYPED(size, sizeof (vdev_label_t), uint64_t));
126126
return (l * sizeof (vdev_label_t) + (l < VDEV_LABELS / 2 ?
127127
0 : size - VDEV_LABELS * sizeof (vdev_label_t)));
128128
}

lib/libzfs/libzfs_mount.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -517,7 +517,7 @@ zfs_mount_at(zfs_handle_t *zhp, const char *options, int flags,
517517
} else if (rc == ENOTSUP) {
518518
int spa_version;
519519

520-
VERIFY(zfs_spa_version(zhp, &spa_version) == 0);
520+
VERIFY0(zfs_spa_version(zhp, &spa_version));
521521
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
522522
"Can't mount a version %llu "
523523
"file system on a version %d pool. Pool must be"

lib/libzfs/libzfs_sendrecv.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2505,7 +2505,7 @@ zfs_send_cb_impl(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
25052505
err = ENOENT;
25062506

25072507
if (sdd.cleanup_fd != -1) {
2508-
VERIFY(0 == close(sdd.cleanup_fd));
2508+
VERIFY0(close(sdd.cleanup_fd));
25092509
sdd.cleanup_fd = -1;
25102510
}
25112511

@@ -2531,7 +2531,7 @@ zfs_send_cb_impl(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
25312531
fnvlist_free(sdd.snapholds);
25322532

25332533
if (sdd.cleanup_fd != -1)
2534-
VERIFY(0 == close(sdd.cleanup_fd));
2534+
VERIFY0(close(sdd.cleanup_fd));
25352535
return (err);
25362536
}
25372537

@@ -5108,7 +5108,7 @@ zfs_receive_one(libzfs_handle_t *hdl, int infd, const char *tosnap,
51085108
nvlist_t *holds, *errors = NULL;
51095109
int cleanup_fd = -1;
51105110

5111-
VERIFY(0 == nvlist_alloc(&holds, 0, KM_SLEEP));
5111+
VERIFY0(nvlist_alloc(&holds, 0, KM_SLEEP));
51125112
for (pair = nvlist_next_nvpair(snapholds_nvlist, NULL);
51135113
pair != NULL;
51145114
pair = nvlist_next_nvpair(snapholds_nvlist, pair)) {

0 commit comments

Comments
 (0)