Skip to content

Commit

Permalink
Remove NOTE(CONSTCOND) and note.h
Browse files Browse the repository at this point in the history
These were mostly used to annotate do {} while(0)s

Reviewed-by: Brian Behlendorf <behlendorf1@llnl.gov>
Signed-off-by: Ahelenia Ziemiańska <nabijaczleweli@nabijaczleweli.xyz>
Issue #12201
  • Loading branch information
nabijaczleweli authored and behlendorf committed Jul 26, 2021
1 parent 2c69ba6 commit 037af3e
Show file tree
Hide file tree
Showing 21 changed files with 23 additions and 110 deletions.
1 change: 0 additions & 1 deletion include/sys/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@ COMMON_H = \
mntent.h \
mod.h \
multilist.h \
note.h \
nvpair.h \
nvpair_impl.h \
objlist.h \
Expand Down
4 changes: 2 additions & 2 deletions include/sys/arc.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,12 @@ extern "C" {
#define HDR_SET_LSIZE(hdr, x) do { \
ASSERT(IS_P2ALIGNED(x, 1U << SPA_MINBLOCKSHIFT)); \
(hdr)->b_lsize = ((x) >> SPA_MINBLOCKSHIFT); \
_NOTE(CONSTCOND) } while (0)
} while (0)

#define HDR_SET_PSIZE(hdr, x) do { \
ASSERT(IS_P2ALIGNED((x), 1U << SPA_MINBLOCKSHIFT)); \
(hdr)->b_psize = ((x) >> SPA_MINBLOCKSHIFT); \
_NOTE(CONSTCOND) } while (0)
} while (0)

#define HDR_GET_LSIZE(hdr) ((hdr)->b_lsize << SPA_MINBLOCKSHIFT)
#define HDR_GET_PSIZE(hdr) ((hdr)->b_psize << SPA_MINBLOCKSHIFT)
Expand Down
1 change: 0 additions & 1 deletion include/sys/arc_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,6 @@ typedef struct l2arc_lb_ptr_buf {
void *tmp = (x);\
x = y; \
y = tmp; \
_NOTE(CONSTCOND)\
} while (0)

#define L2ARC_DEV_HDR_MAGIC 0x5a46534341434845LLU /* ASCII: "ZFSCACHE" */
Expand Down
11 changes: 5 additions & 6 deletions include/sys/bitops.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,13 +53,13 @@ extern "C" {
ASSERT3U(val, <, 1U << (len)); \
ASSERT3U(low + len, <=, 32); \
(x) ^= BF32_ENCODE((x >> low) ^ (val), low, len); \
_NOTE(CONSTCOND) } while (0)
} while (0)

#define BF64_SET(x, low, len, val) do { \
ASSERT3U(val, <, 1ULL << (len)); \
ASSERT3U(low + len, <=, 64); \
((x) ^= BF64_ENCODE((x >> low) ^ (val), low, len)); \
_NOTE(CONSTCOND) } while (0)
} while (0)

#define BF32_GET_SB(x, low, len, shift, bias) \
((BF32_GET(x, low, len) + (bias)) << (shift))
Expand All @@ -69,19 +69,18 @@ _NOTE(CONSTCOND) } while (0)
/*
* We use ASSERT3U instead of ASSERT in these macros to prevent a lint error in
* the case where val is a constant. We can't fix ASSERT because it's used as
* an expression in several places in the kernel; as a result, changing it to
* the do{} while() syntax to allow us to _NOTE the CONSTCOND is not an option.
* an expression in several places in the kernel.
*/
#define BF32_SET_SB(x, low, len, shift, bias, val) do { \
ASSERT3U(IS_P2ALIGNED(val, 1U << shift), !=, B_FALSE); \
ASSERT3S((val) >> (shift), >=, bias); \
BF32_SET(x, low, len, ((val) >> (shift)) - (bias)); \
_NOTE(CONSTCOND) } while (0)
} while (0)
#define BF64_SET_SB(x, low, len, shift, bias, val) do { \
ASSERT3U(IS_P2ALIGNED(val, 1ULL << shift), !=, B_FALSE); \
ASSERT3S((val) >> (shift), >=, bias); \
BF64_SET(x, low, len, ((val) >> (shift)) - (bias)); \
_NOTE(CONSTCOND) } while (0)
} while (0)

#ifdef __cplusplus
}
Expand Down
4 changes: 2 additions & 2 deletions include/sys/dbuf.h
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,7 @@ dbuf_find_dirty_eq(dmu_buf_impl_t *db, uint64_t txg)
__db_buf, (dbuf)->db_level, \
(u_longlong_t)(dbuf)->db_blkid, __VA_ARGS__); \
} \
_NOTE(CONSTCOND) } while (0)
} while (0)

#define dprintf_dbuf_bp(db, bp, fmt, ...) do { \
if (zfs_flags & ZFS_DEBUG_DPRINTF) { \
Expand All @@ -483,7 +483,7 @@ _NOTE(CONSTCOND) } while (0)
dprintf_dbuf(db, fmt " %s\n", __VA_ARGS__, __blkbuf); \
kmem_free(__blkbuf, BP_SPRINTF_LEN); \
} \
_NOTE(CONSTCOND) } while (0)
} while (0)

#define DBUF_VERIFY(db) dbuf_verify(db)

Expand Down
2 changes: 1 addition & 1 deletion include/sys/dnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -607,7 +607,7 @@ extern dnode_stats_t dnode_stats;
dprintf_ds((dn)->dn_objset->os_dsl_dataset, "obj=%s " fmt, \
__db_buf, __VA_ARGS__); \
} \
_NOTE(CONSTCOND) } while (0)
} while (0)

#define DNODE_VERIFY(dn) dnode_verify(dn)
#define FREE_VERIFY(db, start, end, tx) free_verify(db, start, end, tx)
Expand Down
2 changes: 1 addition & 1 deletion include/sys/dsl_dataset.h
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ void dsl_dataset_activate_redaction(dsl_dataset_t *ds, uint64_t *redact_snaps,
dprintf("ds=%s " fmt, __ds_name, __VA_ARGS__); \
kmem_free(__ds_name, ZFS_MAX_DATASET_NAME_LEN); \
} \
_NOTE(CONSTCOND) } while (0)
} while (0)
#else
#define dprintf_ds(dd, fmt, ...)
#endif
Expand Down
2 changes: 1 addition & 1 deletion include/sys/dsl_dir.h
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ void dsl_dir_cancel_waiters(dsl_dir_t *dd);
dprintf("dd=%s " fmt, __ds_name, __VA_ARGS__); \
kmem_free(__ds_name, ZFS_MAX_DATASET_NAME_LEN); \
} \
_NOTE(CONSTCOND) } while (0)
} while (0)
#else
#define dprintf_dd(dd, fmt, ...)
#endif
Expand Down
56 changes: 0 additions & 56 deletions include/sys/note.h

This file was deleted.

14 changes: 7 additions & 7 deletions include/sys/spa.h
Original file line number Diff line number Diff line change
Expand Up @@ -328,23 +328,23 @@ typedef struct zio_cksum_salt {
#define BPE_SET_ETYPE(bp, t) do { \
ASSERT(BP_IS_EMBEDDED(bp)); \
BF64_SET((bp)->blk_prop, 40, 8, t); \
_NOTE(CONSTCOND) } while (0)
} while (0)

#define BPE_GET_LSIZE(bp) \
(ASSERT(BP_IS_EMBEDDED(bp)), \
BF64_GET_SB((bp)->blk_prop, 0, 25, 0, 1))
#define BPE_SET_LSIZE(bp, x) do { \
ASSERT(BP_IS_EMBEDDED(bp)); \
BF64_SET_SB((bp)->blk_prop, 0, 25, 0, 1, x); \
_NOTE(CONSTCOND) } while (0)
} while (0)

#define BPE_GET_PSIZE(bp) \
(ASSERT(BP_IS_EMBEDDED(bp)), \
BF64_GET_SB((bp)->blk_prop, 25, 7, 0, 1))
#define BPE_SET_PSIZE(bp, x) do { \
ASSERT(BP_IS_EMBEDDED(bp)); \
BF64_SET_SB((bp)->blk_prop, 25, 7, 0, 1, x); \
_NOTE(CONSTCOND) } while (0)
} while (0)

typedef enum bp_embedded_type {
BP_EMBEDDED_TYPE_DATA,
Expand Down Expand Up @@ -419,7 +419,7 @@ typedef struct blkptr {
ASSERT(!BP_IS_EMBEDDED(bp)); \
BF64_SET_SB((bp)->blk_prop, \
0, SPA_LSIZEBITS, SPA_MINBLOCKSHIFT, 1, x); \
_NOTE(CONSTCOND) } while (0)
} while (0)

#define BP_GET_PSIZE(bp) \
(BP_IS_EMBEDDED(bp) ? 0 : \
Expand All @@ -428,7 +428,7 @@ _NOTE(CONSTCOND) } while (0)
ASSERT(!BP_IS_EMBEDDED(bp)); \
BF64_SET_SB((bp)->blk_prop, \
16, SPA_PSIZEBITS, SPA_MINBLOCKSHIFT, 1, x); \
_NOTE(CONSTCOND) } while (0)
} while (0)

#define BP_GET_COMPRESS(bp) \
BF64_GET((bp)->blk_prop, 32, SPA_COMPRESSBITS)
Expand All @@ -444,7 +444,7 @@ _NOTE(CONSTCOND) } while (0)
#define BP_SET_CHECKSUM(bp, x) do { \
ASSERT(!BP_IS_EMBEDDED(bp)); \
BF64_SET((bp)->blk_prop, 40, 8, x); \
_NOTE(CONSTCOND) } while (0)
} while (0)

#define BP_GET_TYPE(bp) BF64_GET((bp)->blk_prop, 48, 8)
#define BP_SET_TYPE(bp, x) BF64_SET((bp)->blk_prop, 48, 8, x)
Expand Down Expand Up @@ -1193,7 +1193,7 @@ int param_set_deadman_failmode(ZFS_MODULE_PARAM_ARGS);
dprintf(fmt " %s\n", __VA_ARGS__, __blkbuf); \
kmem_free(__blkbuf, BP_SPRINTF_LEN); \
} \
_NOTE(CONSTCOND) } while (0)
} while (0)
#else
#define dprintf_bp(bp, fmt, ...)
#endif
Expand Down
2 changes: 0 additions & 2 deletions include/sys/zfs_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ extern "C" {
* similar environment.
*/
#if defined(__KERNEL__) || defined(_STANDALONE)
#include <sys/note.h>
#include <sys/types.h>
#include <sys/atomic.h>
#include <sys/sysmacros.h>
Expand Down Expand Up @@ -104,7 +103,6 @@ extern "C" {
#include <ctype.h>
#include <signal.h>
#include <sys/mman.h>
#include <sys/note.h>
#include <sys/types.h>
#include <sys/cred.h>
#include <sys/sysmacros.h>
Expand Down
9 changes: 4 additions & 5 deletions lib/libnvpair/libnvpair.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@
#include <libintl.h>
#include <sys/types.h>
#include <sys/inttypes.h>
#include <sys/note.h>
#include <stdarg.h>
#include "libnvpair.h"

Expand Down Expand Up @@ -191,9 +190,9 @@ static int \
nvprint_##type_and_variant(nvlist_prtctl_t pctl, void *private, \
nvlist_t *nvl, const char *name, vtype value) \
{ \
(void) private; \
(void) nvl; \
FILE *fp = pctl->nvprt_fp; \
NOTE(ARGUNUSED(private)) \
NOTE(ARGUNUSED(nvl)) \
indent(pctl, 1); \
(void) fprintf(fp, pctl->nvprt_nmfmt, name); \
(void) fprintf(fp, vfmt, (ptype)value); \
Expand Down Expand Up @@ -224,10 +223,10 @@ static int \
nvaprint_##type_and_variant(nvlist_prtctl_t pctl, void *private, \
nvlist_t *nvl, const char *name, vtype *valuep, uint_t count) \
{ \
(void) private; \
(void) nvl; \
FILE *fp = pctl->nvprt_fp; \
uint_t i; \
NOTE(ARGUNUSED(private)) \
NOTE(ARGUNUSED(nvl)) \
for (i = 0; i < count; i++) { \
if (i == 0 || pctl->nvprt_btwnarrfmt_nl) { \
indent(pctl, 1); \
Expand Down
2 changes: 0 additions & 2 deletions lib/libspl/include/os/linux/sys/sysmacros.h
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,4 @@
#define offsetof(s, m) ((size_t)(&(((s *)0)->m)))
#endif

#define _NOTE(x)

#endif /* _LIBSPL_SYS_SYSMACROS_H */
8 changes: 0 additions & 8 deletions module/icp/algs/skein/skein_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@

#include <sys/skein.h>
#include <sys/strings.h>
#include <sys/note.h>
#include "skein_impl.h"
#include "skein_port.h"

Expand Down Expand Up @@ -139,7 +138,6 @@
#define Skein_Set_Tweak(ctxPtr, TWK_NUM, tVal) \
do { \
(ctxPtr)->h.T[TWK_NUM] = (tVal); \
_NOTE(CONSTCOND) \
} while (0)

#define Skein_Get_T0(ctxPtr) Skein_Get_Tweak(ctxPtr, 0)
Expand All @@ -152,7 +150,6 @@
do { \
Skein_Set_T0(ctxPtr, (T0)); \
Skein_Set_T1(ctxPtr, (T1)); \
_NOTE(CONSTCOND) \
} while (0)

#define Skein_Set_Type(ctxPtr, BLK_TYPE) \
Expand All @@ -166,24 +163,20 @@
Skein_Set_T0_T1(ctxPtr, 0, SKEIN_T1_FLAG_FIRST | \
SKEIN_T1_BLK_TYPE_ ## BLK_TYPE); \
(ctxPtr)->h.bCnt = 0; \
_NOTE(CONSTCOND) \
} while (0)

#define Skein_Clear_First_Flag(hdr) \
do { \
(hdr).T[1] &= ~SKEIN_T1_FLAG_FIRST; \
_NOTE(CONSTCOND) \
} while (0)
#define Skein_Set_Bit_Pad_Flag(hdr) \
do { \
(hdr).T[1] |= SKEIN_T1_FLAG_BIT_PAD; \
_NOTE(CONSTCOND) \
} while (0)

#define Skein_Set_Tree_Level(hdr, height) \
do { \
(hdr).T[1] |= SKEIN_T1_TREE_LEVEL(height); \
_NOTE(CONSTCOND) \
} while (0)

/*
Expand Down Expand Up @@ -212,7 +205,6 @@
do { \
if (!(x)) \
return (retCode); \
_NOTE(CONSTCOND) \
} while (0)
/* internal error */
#define Skein_assert(x) ASSERT(x)
Expand Down
1 change: 0 additions & 1 deletion module/icp/io/skein_mod.c
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ typedef struct skein_ctx {
(void) Skein1024_ ## _op(&sc->sc_1024, __VA_ARGS__);\
break; \
} \
_NOTE(CONSTCOND) \
} while (0)

static int
Expand Down
2 changes: 0 additions & 2 deletions module/os/freebsd/zfs/zio_crypt.c
Original file line number Diff line number Diff line change
Expand Up @@ -1060,7 +1060,6 @@ zio_crypt_do_objset_hmacs(zio_crypt_key_t *key, void *data, uint_t datalen,
if (should_bswap)
intval = BSWAP_64(intval);
intval &= OBJSET_CRYPT_PORTABLE_FLAGS_MASK;
/* CONSTCOND */
if (!ZFS_HOST_BYTEORDER)
intval = BSWAP_64(intval);

Expand Down Expand Up @@ -1100,7 +1099,6 @@ zio_crypt_do_objset_hmacs(zio_crypt_key_t *key, void *data, uint_t datalen,
if (should_bswap)
intval = BSWAP_64(intval);
intval &= ~OBJSET_CRYPT_PORTABLE_FLAGS_MASK;
/* CONSTCOND */
if (!ZFS_HOST_BYTEORDER)
intval = BSWAP_64(intval);

Expand Down
2 changes: 0 additions & 2 deletions module/zfs/arc.c
Original file line number Diff line number Diff line change
Expand Up @@ -644,7 +644,6 @@ arc_sums_t arc_sums;
x = x - x / ARCSTAT_F_AVG_FACTOR + \
(value) / ARCSTAT_F_AVG_FACTOR; \
ARCSTAT(stat) = x; \
_NOTE(CONSTCOND) \
} while (0)

kstat_t *arc_ksp;
Expand Down Expand Up @@ -10738,7 +10737,6 @@ l2arc_log_blk_commit(l2arc_dev_t *dev, zio_t *pio, l2arc_write_callback_t *cb)
dev->l2ad_log_blk_payload_asize;
l2dhdr->dh_start_lbps[0].lbp_payload_start =
dev->l2ad_log_blk_payload_start;
_NOTE(CONSTCOND)
L2BLK_SET_LSIZE(
(&l2dhdr->dh_start_lbps[0])->lbp_prop, sizeof (*lb));
L2BLK_SET_PSIZE(
Expand Down
1 change: 0 additions & 1 deletion module/zfs/ddt.c
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,6 @@ ddt_compress(void *src, uchar_t *dst, size_t s_len, size_t d_len)
}

*version = cpfunc;
/* CONSTCOND */
if (ZFS_HOST_BYTEORDER)
*version |= DDT_COMPRESS_BYTEORDER_MASK;

Expand Down
Loading

0 comments on commit 037af3e

Please sign in to comment.