aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMateusz Guzik <mjg@FreeBSD.org>2021-07-15 14:01:02 +0000
committerMateusz Guzik <mjg@FreeBSD.org>2021-07-21 16:59:58 +0000
commitbc28e9596c59b58fbbdbd9f97e42a0e0fbedb855 (patch)
treed5dbe33922d0f83491579680ad41149f70974a06
parent6af8350df68206be18bc1ebee5e461ca20fb523e (diff)
downloadsrc-bc28e9596c59b58fbbdbd9f97e42a0e0fbedb855.tar.gz
src-bc28e9596c59b58fbbdbd9f97e42a0e0fbedb855.zip
Add __diagused
This can be used for variables which are only used with either INVARIANTS or WITNESS. Without any annotation they run into dead store warnings from cc --analyze and always annotating with __unused may hide bad vars when it should not. Reviewed by: kib, markj Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D31185 (cherry picked from commit b9296725cf99696b48926270a553044522d6e344)
-rw-r--r--sys/sys/systm.h7
1 files changed, 7 insertions, 0 deletions
diff --git a/sys/sys/systm.h b/sys/sys/systm.h
index d13379b0a12f..36d48fbf080d 100644
--- a/sys/sys/systm.h
+++ b/sys/sys/systm.h
@@ -625,6 +625,13 @@ void _gone_in_dev(device_t dev, int major, const char *msg);
#endif
#define gone_in(major, msg) __gone_ok(major, msg) _gone_in(major, msg)
#define gone_in_dev(dev, major, msg) __gone_ok(major, msg) _gone_in_dev(dev, major, msg)
+
+#if defined(INVARIANTS) || defined(WITNESS)
+#define __diagused
+#else
+#define __diagused __unused
+#endif
+
#endif /* _KERNEL */
__NULLABILITY_PRAGMA_POP