From ea083911b1dc609506dd715b82f75759f7807c31 Mon Sep 17 00:00:00 2001 From: Nicola Vetrini Date: Wed, 11 Oct 2023 15:03:49 +0200 Subject: [PATCH] xen/include: make enum perfcounter anonymous Using enumerators declared in a named enum, such as the one modified, as operands to arithmetic operators is not allowed by MISRA C:2012 Rule 10.1. The enumerators of an anonymous enum can be used instead. Signed-off-by: Nicola Vetrini Reviewed-by: Stefano Stabellini --- docs/misra/rules.rst | 3 +++ xen/include/xen/perfc.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/misra/rules.rst b/docs/misra/rules.rst index 6efe66195d..aa65eb4dd0 100644 --- a/docs/misra/rules.rst +++ b/docs/misra/rules.rst @@ -341,6 +341,9 @@ maintainers if you want to suggest a change. compilers' extensions) - Implicit conversions to boolean for conditionals (?: if while for) and logical operators (! || &&) + - The essential type model allows the constants defined by anonymous + enums (e.g., enum { A, B, C }) to be used as operands to arithmetic + operators, as they have a signed essential type. * - `Rule 10.2 `_ - Required diff --git a/xen/include/xen/perfc.h b/xen/include/xen/perfc.h index 7c5ce537bd..96022c0748 100644 --- a/xen/include/xen/perfc.h +++ b/xen/include/xen/perfc.h @@ -39,7 +39,7 @@ #define PERFSTATUS PERFCOUNTER #define PERFSTATUS_ARRAY PERFCOUNTER_ARRAY -enum perfcounter { +enum { #include NUM_PERFCOUNTERS };