|
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [xen master] Eclair: deviate BUILD_ERROR() wrt rule 2.1 and introduce variants
commit 13d1c89e045dcf55316b64d73384f49f67b1d367
Author: Jan Beulich <jbeulich@xxxxxxxx>
AuthorDate: Tue Sep 1 10:00:34 2026 +0200
Commit: Jan Beulich <jbeulich@xxxxxxxx>
CommitDate: Tue Sep 1 10:00:34 2026 +0200
Eclair: deviate BUILD_ERROR() wrt rule 2.1 and introduce variants
BUILD_ERROR() is even stronger a guard than assertions in general, and
ASSERT_UNREACHABLE() (or BUG()) in particular. Deviate it just like those
to allow use for marking unreachable portions of code.
In some cases code being unreachable is dependent upon configuration.
Introduce two variants, as constructs like
if ( IS_ENABLED(CONFIG_...) )
BUILD_ERROR("...");
results in the if() still being reported as unreachable. Sadly these two
new macros introduce a new 20.12 violation each, which hence also needs
deviating.
Signed-off-by: Jan Beulich <jbeulich@xxxxxxxx>
Reviewed-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
---
automation/eclair_analysis/ECLAIR/deviations.ecl | 2 ++
xen/include/xen/macros.h | 15 +++++++++++++++
2 files changed, 17 insertions(+)
diff --git a/automation/eclair_analysis/ECLAIR/deviations.ecl
b/automation/eclair_analysis/ECLAIR/deviations.ecl
index 7d4b6f2948..c087032293 100644
--- a/automation/eclair_analysis/ECLAIR/deviations.ecl
+++ b/automation/eclair_analysis/ECLAIR/deviations.ecl
@@ -19,6 +19,7 @@ Constant expressions and unreachable branches of if and
switch statements are ex
-doc_begin="Unreachability inside an ASSERT_UNREACHABLE() and analogous macro
calls is deliberate and safe."
-config=MC3A2.R2.1,reports+={deliberate,
"any_area(any_loc(any_exp(macro(name(ASSERT_UNREACHABLE||PARSE_ERR_RET||PARSE_ERR||FAIL_MSR||FAIL_CPUID)))))"}
+-config=MC3A2.R2.1,reports+={deliberate,
"any_area(any_loc(any_exp(macro(^BUILD_ERROR(|_IF(|_NOT))$))))"}
-doc_end
-doc_begin="The asm-offset files are not linked deliberately, since they are
used to generate definitions for asm modules."
@@ -667,6 +668,7 @@ deliberate."
to the # or ## operators within the following macros are deliberate, to provide
useful diagnostic messages to the user."
-config=MC3A2.R20.12,macros+={deliberate,
"name(ASSERT||BUILD_BUG_ON||BUILD_BUG_ON_ZERO||RUNTIME_CHECK)"}
+-config=MC3A2.R20.12,macros+={deliberate, "^BUILD_ERROR(|_IF(|_NOT))$"}
-doc_end
-doc_begin="The helper macro GENERATE_CASE may use a macro parameter for
ordinary
diff --git a/xen/include/xen/macros.h b/xen/include/xen/macros.h
index e29cff791e..b07bd5f530 100644
--- a/xen/include/xen/macros.h
+++ b/xen/include/xen/macros.h
@@ -64,6 +64,21 @@
*/
#define BUILD_ERROR(msg) asm ( ".error \"" msg "\"" )
+/*
+ * Like above, but conditional upon @cfg (not) being enabled. @cfg must be
+ * suitable to pass to IS_ENABLED().
+ */
+#define BUILD_ERROR_IF(cfg) \
+ (IS_ENABLED(cfg) \
+ ? ({ BUILD_ERROR( #cfg " unexpectedly enabled"); }) \
+ : (void)0)
+
+#define BUILD_ERROR_IF_NOT(cfg) \
+ (!IS_ENABLED(cfg) \
+ ? ({ BUILD_ERROR( #cfg " unexpectedly disabled"); }) \
+ : (void)0)
+
+
/* Hide a value from the optimiser. */
#define HIDE(x) \
({ \
--
generated by git-patchbot for /home/xen/git/xen.git#master
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |