From 037af3e0d403e3850c5d4b0bc4854911013a6a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=BD=D0=B0=D0=B1?= Date: Sat, 5 Jun 2021 16:02:41 +0200 Subject: [PATCH] Remove NOTE(CONSTCOND) and note.h MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit These were mostly used to annotate do {} while(0)s Reviewed-by: Brian Behlendorf Signed-off-by: Ahelenia ZiemiaƄska Issue #12201 --- include/sys/Makefile.am | 1 - include/sys/arc.h | 4 +- include/sys/arc_impl.h | 1 - include/sys/bitops.h | 11 ++-- include/sys/dbuf.h | 4 +- include/sys/dnode.h | 2 +- include/sys/dsl_dataset.h | 2 +- include/sys/dsl_dir.h | 2 +- include/sys/note.h | 56 ------------------- include/sys/spa.h | 14 ++--- include/sys/zfs_context.h | 2 - lib/libnvpair/libnvpair.c | 9 ++- lib/libspl/include/os/linux/sys/sysmacros.h | 2 - module/icp/algs/skein/skein_impl.h | 8 --- module/icp/io/skein_mod.c | 1 - module/os/freebsd/zfs/zio_crypt.c | 2 - module/zfs/arc.c | 2 - module/zfs/ddt.c | 1 - .../tests/functional/checksum/edonr_test.c | 3 - .../tests/functional/checksum/sha2_test.c | 3 - .../tests/functional/checksum/skein_test.c | 3 - 21 files changed, 23 insertions(+), 110 deletions(-) delete mode 100644 include/sys/note.h diff --git a/include/sys/Makefile.am b/include/sys/Makefile.am index 385c82c92..54573fbe1 100644 --- a/include/sys/Makefile.am +++ b/include/sys/Makefile.am @@ -50,7 +50,6 @@ COMMON_H = \ mntent.h \ mod.h \ multilist.h \ - note.h \ nvpair.h \ nvpair_impl.h \ objlist.h \ diff --git a/include/sys/arc.h b/include/sys/arc.h index ef07a657f..20fa47bd9 100644 --- a/include/sys/arc.h +++ b/include/sys/arc.h @@ -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) diff --git a/include/sys/arc_impl.h b/include/sys/arc_impl.h index 747100a22..f99d2911b 100644 --- a/include/sys/arc_impl.h +++ b/include/sys/arc_impl.h @@ -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" */ diff --git a/include/sys/bitops.h b/include/sys/bitops.h index 56d52073b..69d07d765 100644 --- a/include/sys/bitops.h +++ b/include/sys/bitops.h @@ -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 } diff --git a/include/sys/dbuf.h b/include/sys/dbuf.h index d2c175af6..89422659d 100644 --- a/include/sys/dbuf.h +++ b/include/sys/dbuf.h @@ -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) diff --git a/include/sys/dnode.h b/include/sys/dnode.h index 2cdc5b879..e7cccd044 100644 --- a/include/sys/dnode.h +++ b/include/sys/dnode.h @@ -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) diff --git a/include/sys/dsl_dataset.h b/include/sys/dsl_dataset.h index ed934f969..3c9199b86 100644 --- a/include/sys/dsl_dataset.h +++ b/include/sys/dsl_dataset.h @@ -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 diff --git a/include/sys/dsl_dir.h b/include/sys/dsl_dir.h index d635b3140..993e44354 100644 --- a/include/sys/dsl_dir.h +++ b/include/sys/dsl_dir.h @@ -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 diff --git a/include/sys/note.h b/include/sys/note.h deleted file mode 100644 index 33b547668..000000000 --- a/include/sys/note.h +++ /dev/null @@ -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 */ diff --git a/include/sys/spa.h b/include/sys/spa.h index 05b31004b..f811d6f5a 100644 --- a/include/sys/spa.h +++ b/include/sys/spa.h @@ -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 diff --git a/include/sys/zfs_context.h b/include/sys/zfs_context.h index 4d67e652a..80931f98e 100644 --- a/include/sys/zfs_context.h +++ b/include/sys/zfs_context.h @@ -41,7 +41,6 @@ extern "C" { * similar environment. */ #if defined(__KERNEL__) || defined(_STANDALONE) -#include #include #include #include @@ -104,7 +103,6 @@ extern "C" { #include #include #include -#include #include #include #include diff --git a/lib/libnvpair/libnvpair.c b/lib/libnvpair/libnvpair.c index 2e9ea1c17..fd43a44c1 100644 --- a/lib/libnvpair/libnvpair.c +++ b/lib/libnvpair/libnvpair.c @@ -28,7 +28,6 @@ #include #include #include -#include #include #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); \ diff --git a/lib/libspl/include/os/linux/sys/sysmacros.h b/lib/libspl/include/os/linux/sys/sysmacros.h index 22fcb04b9..31f347c6f 100644 --- a/lib/libspl/include/os/linux/sys/sysmacros.h +++ b/lib/libspl/include/os/linux/sys/sysmacros.h @@ -98,6 +98,4 @@ #define offsetof(s, m) ((size_t)(&(((s *)0)->m))) #endif -#define _NOTE(x) - #endif /* _LIBSPL_SYS_SYSMACROS_H */ diff --git a/module/icp/algs/skein/skein_impl.h b/module/icp/algs/skein/skein_impl.h index 205a517d6..2f6307fa7 100644 --- a/module/icp/algs/skein/skein_impl.h +++ b/module/icp/algs/skein/skein_impl.h @@ -26,7 +26,6 @@ #include #include -#include #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) diff --git a/module/icp/io/skein_mod.c b/module/icp/io/skein_mod.c index 5ee36af12..ac7d201eb 100644 --- a/module/icp/io/skein_mod.c +++ b/module/icp/io/skein_mod.c @@ -179,7 +179,6 @@ typedef struct skein_ctx { (void) Skein1024_ ## _op(&sc->sc_1024, __VA_ARGS__);\ break; \ } \ - _NOTE(CONSTCOND) \ } while (0) static int diff --git a/module/os/freebsd/zfs/zio_crypt.c b/module/os/freebsd/zfs/zio_crypt.c index aeb42b304..832378a92 100644 --- a/module/os/freebsd/zfs/zio_crypt.c +++ b/module/os/freebsd/zfs/zio_crypt.c @@ -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); diff --git a/module/zfs/arc.c b/module/zfs/arc.c index 75b1dcc82..69783afcd 100644 --- a/module/zfs/arc.c +++ b/module/zfs/arc.c @@ -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( diff --git a/module/zfs/ddt.c b/module/zfs/ddt.c index 479e5a3ad..fe5a188f4 100644 --- a/module/zfs/ddt.c +++ b/module/zfs/ddt.c @@ -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; diff --git a/tests/zfs-tests/tests/functional/checksum/edonr_test.c b/tests/zfs-tests/tests/functional/checksum/edonr_test.c index a88756091..d8585ea4c 100644 --- a/tests/zfs-tests/tests/functional/checksum/edonr_test.c +++ b/tests/zfs-tests/tests/functional/checksum/edonr_test.c @@ -36,7 +36,6 @@ #include #include #include -#include #include #include @@ -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"); diff --git a/tests/zfs-tests/tests/functional/checksum/sha2_test.c b/tests/zfs-tests/tests/functional/checksum/sha2_test.c index 5800002a6..c7561b54f 100644 --- a/tests/zfs-tests/tests/functional/checksum/sha2_test.c +++ b/tests/zfs-tests/tests/functional/checksum/sha2_test.c @@ -40,7 +40,6 @@ #define _SHA2_IMPL #include #include -#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"); diff --git a/tests/zfs-tests/tests/functional/checksum/skein_test.c b/tests/zfs-tests/tests/functional/checksum/skein_test.c index 55df9075c..484fad844 100644 --- a/tests/zfs-tests/tests/functional/checksum/skein_test.c +++ b/tests/zfs-tests/tests/functional/checksum/skein_test.c @@ -38,7 +38,6 @@ #include #include #include -#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");