Skip to content

Commit a3ed94f

Browse files
author
Ryan Moeller
committed
FreeBSD: Clean up ASSERT/VERIFY use in module
Signed-off-by: Ryan Moeller <[email protected]>
1 parent 056a658 commit a3ed94f

23 files changed

+233
-238
lines changed

module/os/freebsd/spl/acl_common.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,6 @@
4343
#include <grp.h>
4444
#include <pwd.h>
4545
#include <acl_common.h>
46-
#define ASSERT assert
4746
#endif
4847

4948
#define ACE_POSIX_SUPPORTED_BITS (ACE_READ_DATA | \
@@ -170,8 +169,9 @@ ksort(caddr_t v, int n, int s, int (*f)(void *, void *))
170169
return;
171170

172171
/* Sanity check on arguments */
173-
ASSERT(((uintptr_t)v & 0x3) == 0 && (s & 0x3) == 0);
174-
ASSERT(s > 0);
172+
ASSERT3U(((uintptr_t)v & 0x3), ==, 0);
173+
ASSERT3S((s & 0x3), ==, 0);
174+
ASSERT3S(s, >, 0);
175175
for (g = n / 2; g > 0; g /= 2) {
176176
for (i = g; i < n; i++) {
177177
for (j = i - g; j >= 0 &&

module/os/freebsd/spl/callb.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ typedef struct callb {
7575
typedef struct callb_table {
7676
kmutex_t ct_lock; /* protect all callb states */
7777
callb_t *ct_freelist; /* free callb structures */
78-
int ct_busy; /* != 0 prevents additions */
78+
boolean_t ct_busy; /* B_TRUE prevents additions */
7979
kcondvar_t ct_busy_cv; /* to wait for not busy */
8080
int ct_ncallb; /* num of callbs allocated */
8181
callb_t *ct_first_cb[NCBCLASS]; /* ptr to 1st callb in a class */
@@ -98,7 +98,7 @@ callb_cpr_t callb_cprinfo_safe = {
9898
static void
9999
callb_init(void *dummy __unused)
100100
{
101-
callb_table.ct_busy = 0; /* mark table open for additions */
101+
callb_table.ct_busy = B_FALSE; /* mark table open for additions */
102102
mutex_init(&callb_safe_mutex, NULL, MUTEX_DEFAULT, NULL);
103103
mutex_init(&callb_table.ct_lock, NULL, MUTEX_DEFAULT, NULL);
104104
}
@@ -139,7 +139,7 @@ callb_add_common(boolean_t (*func)(void *arg, int code),
139139
{
140140
callb_t *cp;
141141

142-
ASSERT(class < NCBCLASS);
142+
ASSERT3S(class, <, NCBCLASS);
143143

144144
mutex_enter(&ct->ct_lock);
145145
while (ct->ct_busy)
@@ -259,7 +259,7 @@ callb_execute_class(int class, int code)
259259
callb_t *cp;
260260
void *ret = NULL;
261261

262-
ASSERT(class < NCBCLASS);
262+
ASSERT3S(class, <, NCBCLASS);
263263

264264
mutex_enter(&ct->ct_lock);
265265

@@ -351,8 +351,8 @@ void
351351
callb_lock_table(void)
352352
{
353353
mutex_enter(&ct->ct_lock);
354-
ASSERT(ct->ct_busy == 0);
355-
ct->ct_busy = 1;
354+
ASSERT(!ct->ct_busy);
355+
ct->ct_busy = B_TRUE;
356356
mutex_exit(&ct->ct_lock);
357357
}
358358

@@ -363,8 +363,8 @@ void
363363
callb_unlock_table(void)
364364
{
365365
mutex_enter(&ct->ct_lock);
366-
ASSERT(ct->ct_busy != 0);
367-
ct->ct_busy = 0;
366+
ASSERT(ct->ct_busy);
367+
ct->ct_busy = B_FALSE;
368368
cv_broadcast(&ct->ct_busy_cv);
369369
mutex_exit(&ct->ct_lock);
370370
}

module/os/freebsd/spl/list.c

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,8 @@
6161
void
6262
list_create(list_t *list, size_t size, size_t offset)
6363
{
64-
ASSERT(list);
65-
ASSERT(size > 0);
66-
ASSERT(size >= offset + sizeof (list_node_t));
64+
ASSERT3P(list, !=, NULL);
65+
ASSERT3U(size, >=, offset + sizeof (list_node_t));
6766

6867
list->list_size = size;
6968
list->list_offset = offset;
@@ -76,9 +75,9 @@ list_destroy(list_t *list)
7675
{
7776
list_node_t *node = &list->list_head;
7877

79-
ASSERT(list);
80-
ASSERT(list->list_head.list_next == node);
81-
ASSERT(list->list_head.list_prev == node);
78+
ASSERT3P(list, !=, NULL);
79+
ASSERT3P(list->list_head.list_next, ==, node);
80+
ASSERT3P(list->list_head.list_prev, ==, node);
8281

8382
node->list_next = node->list_prev = NULL;
8483
}
@@ -124,7 +123,7 @@ list_remove(list_t *list, void *object)
124123
{
125124
list_node_t *lold = list_d2l(list, object);
126125
ASSERT(!list_empty(list));
127-
ASSERT(lold->list_next != NULL);
126+
ASSERT3P(lold->list_next, !=, NULL);
128127
list_remove_node(lold);
129128
}
130129

@@ -195,8 +194,8 @@ list_move_tail(list_t *dst, list_t *src)
195194
list_node_t *dstnode = &dst->list_head;
196195
list_node_t *srcnode = &src->list_head;
197196

198-
ASSERT(dst->list_size == src->list_size);
199-
ASSERT(dst->list_offset == src->list_offset);
197+
ASSERT3U(dst->list_size, ==, src->list_size);
198+
ASSERT3U(dst->list_offset, ==, src->list_offset);
200199

201200
if (list_empty(src))
202201
return;

module/os/freebsd/spl/spl_kmem.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,7 @@ zfs_kmem_free(void *buf, size_t size __unused)
112112
if (i == buf)
113113
break;
114114
}
115-
ASSERT(i != NULL);
115+
ASSERT3P(i, !=, NULL);
116116
LIST_REMOVE(i, next);
117117
mtx_unlock(&kmem_items_mtx);
118118
memset(buf, 0xDC, MAX(size, 16));
@@ -162,7 +162,7 @@ kmem_cache_create(char *name, size_t bufsize, size_t align,
162162
{
163163
kmem_cache_t *cache;
164164

165-
ASSERT(vmp == NULL);
165+
ASSERT3P(vmp, ==, NULL);
166166

167167
cache = kmem_alloc(sizeof (*cache), KM_SLEEP);
168168
strlcpy(cache->kc_name, name, sizeof (cache->kc_name));
@@ -324,7 +324,7 @@ void
324324
spl_kmem_cache_set_move(kmem_cache_t *skc,
325325
kmem_cbrc_t (move)(void *, void *, size_t, void *))
326326
{
327-
ASSERT(move != NULL);
327+
ASSERT3P(move, !=, NULL);
328328
}
329329

330330
#ifdef KMEM_DEBUG

module/os/freebsd/spl/spl_kstat.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ __kstat_set_seq_raw_ops(kstat_t *ksp,
6969
static int
7070
kstat_default_update(kstat_t *ksp, int rw)
7171
{
72-
ASSERT(ksp != NULL);
72+
ASSERT3P(ksp, !=, NULL);
7373

7474
if (rw == KSTAT_WRITE)
7575
return (EACCES);
@@ -223,7 +223,7 @@ kstat_sysctl_raw(SYSCTL_HANDLER_ARGS)
223223
sbuf_printf(sb, "%s", ksp->ks_raw_buf);
224224

225225
} else {
226-
ASSERT(ksp->ks_ndata == 1);
226+
ASSERT3U(ksp->ks_ndata, ==, 1);
227227
sbuf_hexdump(sb, ksp->ks_data,
228228
ksp->ks_data_size, NULL, 0);
229229
}
@@ -250,7 +250,7 @@ __kstat_create(const char *module, int instance, const char *name,
250250

251251
KASSERT(instance == 0, ("instance=%d", instance));
252252
if ((ks_type == KSTAT_TYPE_INTR) || (ks_type == KSTAT_TYPE_IO))
253-
ASSERT(ks_ndata == 1);
253+
ASSERT3U(ks_ndata, ==, 1);
254254

255255
if (class == NULL)
256256
class = "misc";
@@ -461,7 +461,7 @@ kstat_install(kstat_t *ksp)
461461
struct sysctl_oid *root;
462462

463463
if (ksp->ks_ndata == UINT32_MAX)
464-
VERIFY(ksp->ks_type == KSTAT_TYPE_RAW);
464+
VERIFY3U(ksp->ks_type, ==, KSTAT_TYPE_RAW);
465465

466466
switch (ksp->ks_type) {
467467
case KSTAT_TYPE_NAMED:
@@ -493,7 +493,7 @@ kstat_install(kstat_t *ksp)
493493
default:
494494
panic("unsupported kstat type %d\n", ksp->ks_type);
495495
}
496-
VERIFY(root != NULL);
496+
VERIFY3P(root, !=, NULL);
497497
ksp->ks_sysctl_root = root;
498498
}
499499

@@ -535,7 +535,7 @@ kstat_waitq_exit(kstat_io_t *kiop)
535535
delta = new - kiop->wlastupdate;
536536
kiop->wlastupdate = new;
537537
wcnt = kiop->wcnt--;
538-
ASSERT((int)wcnt > 0);
538+
ASSERT3S(wcnt, >, 0);
539539
kiop->wlentime += delta * wcnt;
540540
kiop->wtime += delta;
541541
}
@@ -566,7 +566,7 @@ kstat_runq_exit(kstat_io_t *kiop)
566566
delta = new - kiop->rlastupdate;
567567
kiop->rlastupdate = new;
568568
rcnt = kiop->rcnt--;
569-
ASSERT((int)rcnt > 0);
569+
ASSERT3S(rcnt, >, 0);
570570
kiop->rlentime += delta * rcnt;
571571
kiop->rtime += delta;
572572
}

module/os/freebsd/spl/spl_string.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,6 @@ kmem_asprintf(const char *fmt, ...)
102102
void
103103
kmem_strfree(char *str)
104104
{
105-
ASSERT(str != NULL);
105+
ASSERT3P(str, !=, NULL);
106106
kmem_free(str, strlen(str) + 1);
107107
}

module/os/freebsd/spl/spl_sysevent.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -245,7 +245,7 @@ sysevent_worker(void *arg __unused)
245245
if (error == ESHUTDOWN)
246246
break;
247247
} else {
248-
VERIFY(event != NULL);
248+
VERIFY3P(event, !=, NULL);
249249
log_sysevent(event);
250250
nvlist_free(event);
251251
}

module/os/freebsd/spl/spl_uio.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
int
4949
zfs_uiomove(void *cp, size_t n, zfs_uio_rw_t dir, zfs_uio_t *uio)
5050
{
51-
ASSERT(zfs_uio_rw(uio) == dir);
51+
ASSERT3U(zfs_uio_rw(uio), ==, dir);
5252
return (uiomove(cp, (int)n, GET_UIO_STRUCT(uio)));
5353
}
5454

@@ -102,6 +102,6 @@ zfs_uioskip(zfs_uio_t *uio, size_t n)
102102
int
103103
zfs_uio_fault_move(void *p, size_t n, zfs_uio_rw_t dir, zfs_uio_t *uio)
104104
{
105-
ASSERT(zfs_uio_rw(uio) == dir);
105+
ASSERT3U(zfs_uio_rw(uio), ==, dir);
106106
return (vn_io_fault_uiomove(p, n, GET_UIO_STRUCT(uio)));
107107
}

module/os/freebsd/spl/spl_vfs.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -275,13 +275,13 @@ mount_snapshot(kthread_t *td, vnode_t **vpp, const char *fstype, char *fspath,
275275
void
276276
vn_rele_async(vnode_t *vp, taskq_t *taskq)
277277
{
278-
VERIFY(vp->v_count > 0);
278+
VERIFY3U(vp->v_count, >, 0);
279279
if (refcount_release_if_not_last(&vp->v_usecount)) {
280280
#if __FreeBSD_version < 1300045
281281
vdrop(vp);
282282
#endif
283283
return;
284284
}
285-
VERIFY(taskq_dispatch((taskq_t *)taskq,
286-
(task_func_t *)vrele, vp, TQ_SLEEP) != 0);
285+
VERIFY3U(taskq_dispatch((taskq_t *)taskq,
286+
(task_func_t *)vrele, vp, TQ_SLEEP), !=, 0);
287287
}

module/os/freebsd/zfs/abd_os.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,8 +168,7 @@ abd_verify_scatter(abd_t *abd)
168168
* if an error if the ABD has been marked as a linear page.
169169
*/
170170
ASSERT(!abd_is_linear_page(abd));
171-
ASSERT3U(ABD_SCATTER(abd).abd_offset, <,
172-
zfs_abd_chunk_size);
171+
ASSERT3U(ABD_SCATTER(abd).abd_offset, <, zfs_abd_chunk_size);
173172
n = abd_scatter_chunkcnt(abd);
174173
for (i = 0; i < n; i++) {
175174
ASSERT3P(ABD_SCATTER(abd).abd_chunks[i], !=, NULL);

0 commit comments

Comments
 (0)