[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [XEN PATCH 5/9] x86/cpu-policy: address violations of MISRA C Rule 10.1
The COUNT_LEAVES macro is introduced to avoid using an essentially boolean value in a subtraction. No functional change. Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx> --- xen/include/xen/lib/x86/cpu-policy.h | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/xen/include/xen/lib/x86/cpu-policy.h b/xen/include/xen/lib/x86/cpu-policy.h index bab3eecda6c1..700993cc67e8 100644 --- a/xen/include/xen/lib/x86/cpu-policy.h +++ b/xen/include/xen/lib/x86/cpu-policy.h @@ -95,17 +95,18 @@ const char *x86_cpuid_vendor_to_str(unsigned int vendor); #define CPUID_GUEST_NR_EXTD MAX(CPUID_GUEST_NR_EXTD_INTEL, \ CPUID_GUEST_NR_EXTD_AMD) +#define COUNT_LEAVES(X) ((X) - ((X) ? 1 : 0)) /* * Maximum number of leaves a struct cpu_policy turns into when serialised for * interaction with the toolstack. (Sum of all leaves in each union, less the * entries in basic which sub-unions hang off of.) */ -#define CPUID_MAX_SERIALISED_LEAVES \ - (CPUID_GUEST_NR_BASIC + \ - CPUID_GUEST_NR_FEAT - !!CPUID_GUEST_NR_FEAT + \ - CPUID_GUEST_NR_CACHE - !!CPUID_GUEST_NR_CACHE + \ - CPUID_GUEST_NR_TOPO - !!CPUID_GUEST_NR_TOPO + \ - CPUID_GUEST_NR_XSTATE - !!CPUID_GUEST_NR_XSTATE + \ +#define CPUID_MAX_SERIALISED_LEAVES \ + (CPUID_GUEST_NR_BASIC + \ + COUNT_LEAVES(CPUID_GUEST_NR_FEAT) + \ + COUNT_LEAVES(CPUID_GUEST_NR_CACHE) + \ + COUNT_LEAVES(CPUID_GUEST_NR_TOPO) + \ + COUNT_LEAVES(CPUID_GUEST_NR_XSTATE) + \ CPUID_GUEST_NR_EXTD + 2 /* hv_limit and hv2_limit */ ) /* Maximum number of MSRs written when serialising a cpu_policy. */ -- 2.34.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |