diff options
-rw-r--r-- | cmd/zdb/zdb.c | 72 | ||||
-rw-r--r-- | include/os/freebsd/spl/sys/debug.h | 1 | ||||
-rw-r--r-- | include/os/linux/kernel/linux/mod_compat.h | 15 | ||||
-rw-r--r-- | include/os/linux/spl/sys/debug.h | 7 | ||||
-rw-r--r-- | include/sys/arc_impl.h | 13 | ||||
-rw-r--r-- | include/sys/vdev_impl.h | 4 | ||||
-rw-r--r-- | lib/libspl/include/assert.h | 8 | ||||
-rw-r--r-- | module/os/freebsd/zfs/zfs_ctldir.c | 3 | ||||
-rw-r--r-- | module/os/freebsd/zfs/zfs_vfsops.c | 6 | ||||
-rw-r--r-- | module/os/freebsd/zfs/zfs_vnops_os.c | 6 | ||||
-rw-r--r-- | module/zfs/edonr_zfs.c | 3 |
11 files changed, 72 insertions, 66 deletions
diff --git a/cmd/zdb/zdb.c b/cmd/zdb/zdb.c index c0b1a62a3..ce6454f5e 100644 --- a/cmd/zdb/zdb.c +++ b/cmd/zdb/zdb.c @@ -1228,9 +1228,9 @@ dump_bpobj(objset_t *os, uint64_t object, void *data, size_t size) char bytes[32], comp[32], uncomp[32]; /* make sure the output won't get truncated */ - CTASSERT(sizeof (bytes) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (comp) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (uncomp) >= NN_NUMBUF_SZ); + _Static_assert(sizeof (bytes) >= NN_NUMBUF_SZ, "bytes truncated"); + _Static_assert(sizeof (comp) >= NN_NUMBUF_SZ, "comp truncated"); + _Static_assert(sizeof (uncomp) >= NN_NUMBUF_SZ, "uncomp truncated"); if (bpop == NULL) return; @@ -1655,7 +1655,7 @@ dump_metaslab_stats(metaslab_t *msp) int free_pct = range_tree_space(rt) * 100 / msp->ms_size; /* max sure nicenum has enough space */ - CTASSERT(sizeof (maxbuf) >= NN_NUMBUF_SZ); + _Static_assert(sizeof (maxbuf) >= NN_NUMBUF_SZ, "maxbuf truncated"); zdb_nicenum(metaslab_largest_allocatable(msp), maxbuf, sizeof (maxbuf)); @@ -2490,7 +2490,7 @@ dump_dsl_dir(objset_t *os, uint64_t object, void *data, size_t size) char nice[32]; /* make sure nicenum has enough space */ - CTASSERT(sizeof (nice) >= NN_NUMBUF_SZ); + _Static_assert(sizeof (nice) >= NN_NUMBUF_SZ, "nice truncated"); if (dd == NULL) return; @@ -2548,10 +2548,12 @@ dump_dsl_dataset(objset_t *os, uint64_t object, void *data, size_t size) char blkbuf[BP_SPRINTF_LEN]; /* make sure nicenum has enough space */ - CTASSERT(sizeof (used) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (compressed) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (uncompressed) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (unique) >= NN_NUMBUF_SZ); + _Static_assert(sizeof (used) >= NN_NUMBUF_SZ, "used truncated"); + _Static_assert(sizeof (compressed) >= NN_NUMBUF_SZ, + "compressed truncated"); + _Static_assert(sizeof (uncompressed) >= NN_NUMBUF_SZ, + "uncompressed truncated"); + _Static_assert(sizeof (unique) >= NN_NUMBUF_SZ, "unique truncated"); if (ds == NULL) return; @@ -2622,7 +2624,7 @@ dump_bptree(objset_t *os, uint64_t obj, const char *name) dmu_buf_t *db; /* make sure nicenum has enough space */ - CTASSERT(sizeof (bytes) >= NN_NUMBUF_SZ); + _Static_assert(sizeof (bytes) >= NN_NUMBUF_SZ, "bytes truncated"); if (dump_opt['d'] < 3) return; @@ -2663,9 +2665,9 @@ dump_full_bpobj(bpobj_t *bpo, const char *name, int indent) uint64_t i; /* make sure nicenum has enough space */ - CTASSERT(sizeof (bytes) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (comp) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (uncomp) >= NN_NUMBUF_SZ); + _Static_assert(sizeof (bytes) >= NN_NUMBUF_SZ, "bytes truncated"); + _Static_assert(sizeof (comp) >= NN_NUMBUF_SZ, "comp truncated"); + _Static_assert(sizeof (uncomp) >= NN_NUMBUF_SZ, "uncomp truncated"); if (dump_opt['d'] < 3) return; @@ -2941,10 +2943,10 @@ dump_blkptr_list(dsl_deadlist_t *dl, char *name) } /* make sure nicenum has enough space */ - CTASSERT(sizeof (bytes) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (comp) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (uncomp) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (entries) >= NN_NUMBUF_SZ); + _Static_assert(sizeof (bytes) >= NN_NUMBUF_SZ, "bytes truncated"); + _Static_assert(sizeof (comp) >= NN_NUMBUF_SZ, "comp truncated"); + _Static_assert(sizeof (uncomp) >= NN_NUMBUF_SZ, "uncomp truncated"); + _Static_assert(sizeof (entries) >= NN_NUMBUF_SZ, "entries truncated"); if (dump_opt['d'] < 3) return; @@ -3428,11 +3430,12 @@ dump_object(objset_t *os, uint64_t object, int verbosity, int error; /* make sure nicenum has enough space */ - CTASSERT(sizeof (iblk) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (dblk) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (lsize) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (asize) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (bonus_size) >= NN_NUMBUF_SZ); + _Static_assert(sizeof (iblk) >= NN_NUMBUF_SZ, "iblk truncated"); + _Static_assert(sizeof (dblk) >= NN_NUMBUF_SZ, "dblk truncated"); + _Static_assert(sizeof (lsize) >= NN_NUMBUF_SZ, "lsize truncated"); + _Static_assert(sizeof (asize) >= NN_NUMBUF_SZ, "asize truncated"); + _Static_assert(sizeof (bonus_size) >= NN_NUMBUF_SZ, + "bonus_size truncated"); if (*print_header) { (void) printf("\n%10s %3s %5s %5s %5s %6s %5s %6s %s\n", @@ -3581,7 +3584,8 @@ dump_object(objset_t *os, uint64_t object, int verbosity, for (;;) { char segsize[32]; /* make sure nicenum has enough space */ - CTASSERT(sizeof (segsize) >= NN_NUMBUF_SZ); + _Static_assert(sizeof (segsize) >= NN_NUMBUF_SZ, + "segsize truncated"); error = dnode_next_offset(dn, 0, &start, minlvl, blkfill, 0); if (error) @@ -3770,7 +3774,7 @@ dump_objset(objset_t *os) uint64_t flags; /* make sure nicenum has enough space */ - CTASSERT(sizeof (numbuf) >= NN_NUMBUF_SZ); + _Static_assert(sizeof (numbuf) >= NN_NUMBUF_SZ, "numbuf truncated"); dsl_pool_config_enter(dmu_objset_pool(os), FTAG); dmu_objset_fast_stat(os, &dds); @@ -5542,7 +5546,7 @@ zdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, (zcb->zcb_totalasize - bytes) / 1024 / kb_per_sec; /* make sure nicenum has enough space */ - CTASSERT(sizeof (buf) >= NN_NUMBUF_SZ); + _Static_assert(sizeof (buf) >= NN_NUMBUF_SZ, "buf truncated"); zfs_nicebytes(bytes, buf, sizeof (buf)); (void) fprintf(stderr, @@ -6651,12 +6655,18 @@ dump_block_stats(spa_t *spa) const char *typename; /* make sure nicenum has enough space */ - CTASSERT(sizeof (csize) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (lsize) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (psize) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (asize) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (avg) >= NN_NUMBUF_SZ); - CTASSERT(sizeof (gang) >= NN_NUMBUF_SZ); + _Static_assert(sizeof (csize) >= NN_NUMBUF_SZ, + "csize truncated"); + _Static_assert(sizeof (lsize) >= NN_NUMBUF_SZ, + "lsize truncated"); + _Static_assert(sizeof (psize) >= NN_NUMBUF_SZ, + "psize truncated"); + _Static_assert(sizeof (asize) >= NN_NUMBUF_SZ, + "asize truncated"); + _Static_assert(sizeof (avg) >= NN_NUMBUF_SZ, + "avg truncated"); + _Static_assert(sizeof (gang) >= NN_NUMBUF_SZ, + "gang truncated"); if (t < DMU_OT_NUMTYPES) typename = dmu_ot[t].ot_name; diff --git a/include/os/freebsd/spl/sys/debug.h b/include/os/freebsd/spl/sys/debug.h index 6b440ed31..86fad18e1 100644 --- a/include/os/freebsd/spl/sys/debug.h +++ b/include/os/freebsd/spl/sys/debug.h @@ -125,7 +125,6 @@ void spl_dumpstack(void); "failed (0 == %lld)\n", \ (long long) (_verify3_right)); \ } while (0) -#define CTASSERT_GLOBAL(x) CTASSERT(x) /* * Debugging disabled (--disable-debug) diff --git a/include/os/linux/kernel/linux/mod_compat.h b/include/os/linux/kernel/linux/mod_compat.h index 57d03e2f5..a90bdf7cf 100644 --- a/include/os/linux/kernel/linux/mod_compat.h +++ b/include/os/linux/kernel/linux/mod_compat.h @@ -109,8 +109,9 @@ enum scope_prefix_types { * dmu_prefetch_max */ #define ZFS_MODULE_PARAM(scope_prefix, name_prefix, name, type, perm, desc) \ - CTASSERT_GLOBAL( \ - sizeof (scope_prefix) == sizeof (enum scope_prefix_types)); \ + _Static_assert( \ + sizeof (scope_prefix) == sizeof (enum scope_prefix_types), \ + "" #scope_prefix " size mismatch with enum scope_prefix_types"); \ module_param(name_prefix ## name, type, perm); \ MODULE_PARM_DESC(name_prefix ## name, desc) @@ -138,8 +139,9 @@ enum scope_prefix_types { */ #define ZFS_MODULE_PARAM_CALL( \ scope_prefix, name_prefix, name, setfunc, getfunc, perm, desc) \ - CTASSERT_GLOBAL( \ - sizeof (scope_prefix) == sizeof (enum scope_prefix_types)); \ + _Static_assert( \ + sizeof (scope_prefix) == sizeof (enum scope_prefix_types), \ + "" #scope_prefix " size mismatch with enum scope_prefix_types"); \ module_param_call(name_prefix ## name, setfunc, getfunc, \ &name_prefix ## name, perm); \ MODULE_PARM_DESC(name_prefix ## name, desc) @@ -150,8 +152,9 @@ enum scope_prefix_types { */ #define ZFS_MODULE_VIRTUAL_PARAM_CALL( \ scope_prefix, name_prefix, name, setfunc, getfunc, perm, desc) \ - CTASSERT_GLOBAL(\ - sizeof (scope_prefix) == sizeof (enum scope_prefix_types)); \ + _Static_assert( \ + sizeof (scope_prefix) == sizeof (enum scope_prefix_types), \ + "" #scope_prefix " size mismatch with enum scope_prefix_types"); \ module_param_call(name_prefix ## name, setfunc, getfunc, NULL, perm); \ MODULE_PARM_DESC(name_prefix ## name, desc) diff --git a/include/os/linux/spl/sys/debug.h b/include/os/linux/spl/sys/debug.h index 15d94135f..9c013370c 100644 --- a/include/os/linux/spl/sys/debug.h +++ b/include/os/linux/spl/sys/debug.h @@ -120,13 +120,6 @@ void spl_dumpstack(void); (long long) (_verify3_right)); \ } while (0) -#define CTASSERT_GLOBAL(x) _CTASSERT(x, __LINE__) -#define CTASSERT(x) { _CTASSERT(x, __LINE__); } -#define _CTASSERT(x, y) __CTASSERT(x, y) -#define __CTASSERT(x, y) \ - typedef char __attribute__((unused)) \ - __compile_time_assertion__ ## y[(x) ? 1 : -1] - /* * Debugging disabled (--disable-debug) */ diff --git a/include/sys/arc_impl.h b/include/sys/arc_impl.h index 3c5af9d86..755e87fe6 100644 --- a/include/sys/arc_impl.h +++ b/include/sys/arc_impl.h @@ -250,7 +250,8 @@ typedef struct l2arc_dev_hdr_phys { const uint64_t dh_pad[30]; /* pad to 512 bytes */ zio_eck_t dh_tail; } l2arc_dev_hdr_phys_t; -CTASSERT_GLOBAL(sizeof (l2arc_dev_hdr_phys_t) == SPA_MINBLOCKSIZE); +_Static_assert(sizeof (l2arc_dev_hdr_phys_t) == SPA_MINBLOCKSIZE, + "l2arc_dev_hdr_phys_t wrong size"); /* * A single ARC buffer header entry in a l2arc_log_blk_phys_t. @@ -307,10 +308,12 @@ typedef struct l2arc_log_blk_phys { * The size of l2arc_log_blk_phys_t has to be power-of-2 aligned with * SPA_MINBLOCKSHIFT because of L2BLK_SET_*SIZE macros. */ -CTASSERT_GLOBAL(IS_P2ALIGNED(sizeof (l2arc_log_blk_phys_t), - 1ULL << SPA_MINBLOCKSHIFT)); -CTASSERT_GLOBAL(sizeof (l2arc_log_blk_phys_t) >= SPA_MINBLOCKSIZE); -CTASSERT_GLOBAL(sizeof (l2arc_log_blk_phys_t) <= SPA_MAXBLOCKSIZE); +_Static_assert(IS_P2ALIGNED(sizeof (l2arc_log_blk_phys_t), + 1ULL << SPA_MINBLOCKSHIFT), "l2arc_log_blk_phys_t misaligned"); +_Static_assert(sizeof (l2arc_log_blk_phys_t) >= SPA_MINBLOCKSIZE, + "l2arc_log_blk_phys_t too small"); +_Static_assert(sizeof (l2arc_log_blk_phys_t) <= SPA_MAXBLOCKSIZE, + "l2arc_log_blk_phys_t too big"); /* * These structures hold in-flight abd buffers for log blocks as they're being diff --git a/include/sys/vdev_impl.h b/include/sys/vdev_impl.h index 1567182a7..db8fbdeb0 100644 --- a/include/sys/vdev_impl.h +++ b/include/sys/vdev_impl.h @@ -521,8 +521,8 @@ typedef struct vdev_boot_envblock { sizeof (zio_eck_t)]; zio_eck_t vbe_zbt; } vdev_boot_envblock_t; - -CTASSERT_GLOBAL(sizeof (vdev_boot_envblock_t) == VDEV_PAD_SIZE); +_Static_assert(sizeof (vdev_boot_envblock_t) == VDEV_PAD_SIZE, + "vdev_boot_envblock_t wrong size"); typedef struct vdev_label { char vl_pad1[VDEV_PAD_SIZE]; /* 8K */ diff --git a/lib/libspl/include/assert.h b/lib/libspl/include/assert.h index e129ef7df..fb964042b 100644 --- a/lib/libspl/include/assert.h +++ b/lib/libspl/include/assert.h @@ -111,14 +111,6 @@ do { \ #undef assert #endif -/* Compile time assert */ -#define CTASSERT_GLOBAL(x) _CTASSERT(x, __LINE__) -#define CTASSERT(x) { _CTASSERT(x, __LINE__); } -#define _CTASSERT(x, y) __CTASSERT(x, y) -#define __CTASSERT(x, y) \ - typedef char __attribute__((unused)) \ - __compile_time_assertion__ ## y[(x) ? 1 : -1] - #ifdef NDEBUG #define ASSERT3B(x, y, z) \ ((void) sizeof ((uintptr_t)(x)), (void) sizeof ((uintptr_t)(z))) diff --git a/module/os/freebsd/zfs/zfs_ctldir.c b/module/os/freebsd/zfs/zfs_ctldir.c index 206f65b08..10e7bc64b 100644 --- a/module/os/freebsd/zfs/zfs_ctldir.c +++ b/module/os/freebsd/zfs/zfs_ctldir.c @@ -685,7 +685,8 @@ zfsctl_root_readdir(struct vop_readdir_args *ap) if (zfs_uio_offset(&uio) != dots_offset) return (SET_ERROR(EINVAL)); - CTASSERT(sizeof (node->snapdir->sn_name) <= sizeof (entry.d_name)); + _Static_assert(sizeof (node->snapdir->sn_name) <= sizeof (entry.d_name), + "node->snapdir->sn_name too big for entry.d_name"); entry.d_fileno = node->snapdir->sn_id; entry.d_type = DT_DIR; strcpy(entry.d_name, node->snapdir->sn_name); diff --git a/module/os/freebsd/zfs/zfs_vfsops.c b/module/os/freebsd/zfs/zfs_vfsops.c index 2c03f27bf..0dff872b8 100644 --- a/module/os/freebsd/zfs/zfs_vfsops.c +++ b/module/os/freebsd/zfs/zfs_vfsops.c @@ -1777,8 +1777,10 @@ zfs_checkexp(vfs_t *vfsp, struct sockaddr *nam, int *extflagsp, credanonp, numsecflavors, secflavors)); } -CTASSERT(SHORT_FID_LEN <= sizeof (struct fid)); -CTASSERT(LONG_FID_LEN <= sizeof (struct fid)); +_Static_assert(sizeof (struct fid) >= SHORT_FID_LEN, + "struct fid bigger than SHORT_FID_LEN"); +_Static_assert(sizeof (struct fid) >= LONG_FID_LEN, + "struct fid bigger than LONG_FID_LEN"); static int zfs_fhtovp(vfs_t *vfsp, fid_t *fidp, int flags, vnode_t **vpp) diff --git a/module/os/freebsd/zfs/zfs_vnops_os.c b/module/os/freebsd/zfs/zfs_vnops_os.c index 3db117525..90314f7df 100644 --- a/module/os/freebsd/zfs/zfs_vnops_os.c +++ b/module/os/freebsd/zfs/zfs_vnops_os.c @@ -3937,8 +3937,10 @@ zfs_inactive(vnode_t *vp, cred_t *cr, caller_context_t *ct) } -CTASSERT(sizeof (struct zfid_short) <= sizeof (struct fid)); -CTASSERT(sizeof (struct zfid_long) <= sizeof (struct fid)); +_Static_assert(sizeof (struct zfid_short) <= sizeof (struct fid), + "struct zfid_short bigger than struct fid"); +_Static_assert(sizeof (struct zfid_long) <= sizeof (struct fid), + "struct zfid_long bigger than struct fid"); /*ARGSUSED*/ static int diff --git a/module/zfs/edonr_zfs.c b/module/zfs/edonr_zfs.c index aa00e1c94..938d684ec 100644 --- a/module/zfs/edonr_zfs.c +++ b/module/zfs/edonr_zfs.c @@ -89,7 +89,8 @@ abd_checksum_edonr_tmpl_init(const zio_cksum_salt_t *salt) * size by double-hashing it (the new salt block will be composed of * H(salt) || H(H(salt))). */ - CTASSERT(EDONR_BLOCK_SIZE == 2 * (EDONR_MODE / 8)); + _Static_assert(EDONR_BLOCK_SIZE == 2 * (EDONR_MODE / 8), + "Edon-R block size mismatch"); EdonRHash(EDONR_MODE, salt->zcs_bytes, sizeof (salt->zcs_bytes) * 8, salt_block); EdonRHash(EDONR_MODE, salt_block, EDONR_MODE, salt_block + |