Remove NOTE(CONSTCOND) and note.h

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
This commit is contained in:
наб 2021-06-05 16:02:41 +02:00 committed by Brian Behlendorf
parent 2c69ba6444
commit 037af3e0d4
21 changed files with 23 additions and 110 deletions

View File

@ -50,7 +50,6 @@ COMMON_H = \
mntent.h \
mod.h \
multilist.h \
note.h \
nvpair.h \
nvpair_impl.h \
objlist.h \

View File

@ -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)

View File

@ -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" */

View File

@ -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))
@ -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
}

View File

@ -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) { \
@ -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)

View File

@ -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)

View File

@ -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

View File

@ -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

View File

@ -1,56 +0,0 @@
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* or http://www.opensolaris.org/os/licensing.
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1994 by Sun Microsystems, Inc.
*/
/*
* sys/note.h: interface for annotating source with info for tools
*
* This is the underlying interface; NOTE (/usr/include/note.h) is the
* preferred interface, but all exported header files should include this
* file directly and use _NOTE so as not to take "NOTE" from the user's
* namespace. For consistency, *all* kernel source should use _NOTE.
*
* By default, annotations expand to nothing. This file implements
* that. Tools using annotations will interpose a different version
* of this file that will expand annotations as needed.
*/
#ifndef _SYS_NOTE_H
#define _SYS_NOTE_H
#ifdef __cplusplus
extern "C" {
#endif
#ifndef _NOTE
#define _NOTE(s)
#endif
#define NOTE(s) _NOTE(s)
#ifdef __cplusplus
}
#endif
#endif /* _SYS_NOTE_H */

View File

@ -328,7 +328,7 @@ 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)), \
@ -336,7 +336,7 @@ _NOTE(CONSTCOND) } while (0)
#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)), \
@ -344,7 +344,7 @@ _NOTE(CONSTCOND) } while (0)
#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,
@ -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 : \
@ -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)
@ -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)
@ -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

View File

@ -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>
@ -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>

View File

@ -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"
@ -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); \
@ -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); \

View File

@ -98,6 +98,4 @@
#define offsetof(s, m) ((size_t)(&(((s *)0)->m)))
#endif
#define _NOTE(x)
#endif /* _LIBSPL_SYS_SYSMACROS_H */

View File

@ -26,7 +26,6 @@
#include <sys/skein.h>
#include <sys/strings.h>
#include <sys/note.h>
#include "skein_impl.h"
#include "skein_port.h"
@ -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)
@ -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) \
@ -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)
/*
@ -212,7 +205,6 @@
do { \
if (!(x)) \
return (retCode); \
_NOTE(CONSTCOND) \
} while (0)
/* internal error */
#define Skein_assert(x) ASSERT(x)

View File

@ -179,7 +179,6 @@ typedef struct skein_ctx {
(void) Skein1024_ ## _op(&sc->sc_1024, __VA_ARGS__);\
break; \
} \
_NOTE(CONSTCOND) \
} while (0)
static int

View File

@ -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);
@ -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);

View File

@ -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;
@ -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(

View File

@ -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;

View File

@ -36,7 +36,6 @@
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <sys/note.h>
#include <sys/time.h>
#include <sys/stdtypes.h>
@ -167,7 +166,6 @@ main(int argc, char *argv[])
(void) printf("FAILED!\n"); \
failed = B_TRUE; \
} \
NOTE(CONSTCOND) \
} while (0)
#define EDONR_PERF_TEST(mode) \
@ -194,7 +192,6 @@ main(int argc, char *argv[])
} \
(void) printf("Edon-R-%-6s%llu us (%.02f CPB)\n", #mode,\
(u_longlong_t)delta, cpb); \
NOTE(CONSTCOND) \
} while (0)
(void) printf("Running algorithm correctness tests:\n");

View File

@ -40,7 +40,6 @@
#define _SHA2_IMPL
#include <sys/sha2.h>
#include <sys/stdtypes.h>
#define NOTE(x)
/*
@ -196,7 +195,6 @@ main(int argc, char *argv[])
(void) printf("FAILED!\n"); \
failed = B_TRUE; \
} \
NOTE(CONSTCOND) \
} while (0)
#define SHA2_PERF_TEST(mode, diglen) \
@ -223,7 +221,6 @@ main(int argc, char *argv[])
} \
(void) printf("SHA%-9s%llu us (%.02f CPB)\n", #mode, \
(u_longlong_t)delta, cpb); \
NOTE(CONSTCOND) \
} while (0)
(void) printf("Running algorithm correctness tests:\n");

View File

@ -38,7 +38,6 @@
#include <stdio.h>
#include <sys/time.h>
#include <sys/stdtypes.h>
#define NOTE(x)
/*
* Skein test suite using values from the Skein V1.3 specification found at:
@ -285,7 +284,6 @@ main(int argc, char *argv[])
(void) printf("FAILED!\n"); \
failed = B_TRUE; \
} \
NOTE(CONSTCOND) \
} while (0)
#define SKEIN_PERF_TEST(mode, diglen) \
@ -314,7 +312,6 @@ main(int argc, char *argv[])
} \
(void) printf("Skein" #mode "/" #diglen "\t%llu us " \
"(%.02f CPB)\n", (u_longlong_t)delta, cpb); \
NOTE(CONSTCOND) \
} while (0)
(void) printf("Running algorithm correctness tests:\n");