]> xenbits.xensource.com Git - xen.git/commitdiff
xen/include: make enum perfcounter anonymous
authorNicola Vetrini <nicola.vetrini@bugseng.com>
Wed, 11 Oct 2023 13:03:49 +0000 (15:03 +0200)
committerStefano Stabellini <stefano.stabellini@amd.com>
Thu, 2 Nov 2023 21:58:56 +0000 (14:58 -0700)
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 <nicola.vetrini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
docs/misra/rules.rst
xen/include/xen/perfc.h

index 6efe66195de3a05e172d4247d5b928f6cf849360..aa65eb4dd0b896f9d873bf76f1b0043498174851 100644 (file)
@@ -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 <https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_10_02.c>`_
      - Required
index 7c5ce537bd0221e302079eb8f7dfd6e78435ecb9..96022c07481ee67e4f24c8bc77bf240e46c00261 100644 (file)
@@ -39,7 +39,7 @@
 #define PERFSTATUS       PERFCOUNTER
 #define PERFSTATUS_ARRAY PERFCOUNTER_ARRAY
 
-enum perfcounter {
+enum {
 #include <xen/perfc_defn.h>
        NUM_PERFCOUNTERS
 };