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>
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
#define PERFSTATUS PERFCOUNTER
#define PERFSTATUS_ARRAY PERFCOUNTER_ARRAY
-enum perfcounter {
+enum {
#include <xen/perfc_defn.h>
NUM_PERFCOUNTERS
};