[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[xen master] xen/include: make enum perfcounter anonymous



commit ea083911b1dc609506dd715b82f75759f7807c31
Author:     Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx>
AuthorDate: Wed Oct 11 15:03:49 2023 +0200
Commit:     Stefano Stabellini <stefano.stabellini@xxxxxxx>
CommitDate: Thu Nov 2 14:58:56 2023 -0700

    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 <nicola.vetrini@xxxxxxxxxxx>
    Reviewed-by: Stefano Stabellini <sstabellini@xxxxxxxxxx>
---
 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 
<https://gitlab.com/MISRA/MISRA-C/MISRA-C-2012/Example-Suite/-/blob/master/R_10_02.c>`_
      - 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 <xen/perfc_defn.h>
        NUM_PERFCOUNTERS
 };
--
generated by git-patchbot for /home/xen/git/xen.git#master



 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.