x86/cpuid: Change cpuid() from a macro to a static inline
PATCH 1/1 x86/cpuid: Change cpuid() from a macro to a static inline
Fixes MISRA XXX
No functional change.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Wei Liu <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: Julien Grall <[email protected]>
CC: Volodymyr Babchuk <[email protected]>
CC: Bertrand Marquis <[email protected]>
CC: Michal Orzel <[email protected]>
CC: Roberto Bagnara <[email protected]>
CC: Federico Serafini <[email protected]>
CC: [email protected] <[email protected]>
Can someone please remind me which MISRA rule is the one about macros aliasing identifiers?
--- xen/arch/x86/include/asm/processor.h | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-)
xen/arch/x86/include/asm/processor.h +15 -8
@@ -126,14 +126,6 @@ static inline int cpu_nr_siblings(unsigned int cpu)return cpu_data[cpu].x86_num_siblings; } -/* -* Generic CPUID function -* clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx -* resulting in stale register contents being returned. -*/ -#define cpuid (leaf, eax, ebx, ecx, edx) \ - cpuid_count(leaf, 0, eax, ebx, ecx, edx) -/* Some CPUID calls want 'count' to be placed in ecx */ static inline void cpuid_count( unsigned int op,
@@ -148,6 +140,21 @@ static inline void cpuid_count( : "0" (op), "c" (count) ); } +/* +* Generic CPUID function +* clear %ecx since some cpus (Cyrix MII) do not set or clear %ecx +* resulting in stale register contents being returned. +*/ +static inline void cpuid ( +unsigned int leaf, +unsigned int *eax, +unsigned int *ebx, +unsigned int *ecx, +unsigned int *edx) +{ +cpuid_count (leaf,0 , eax, ebx, ecx, edx); +} +/* * CPUID functions returning a single datum */
base-commit: f3f6c500e2dbd23af77c207e2cf4b496fffa1b0d
Signature · 1 line
2.30.2
Quoted 1 line · Andrew Cooper
Fixes MISRA XXX
Rule 5.5 if I'm not mistaken; had to look it up for the patch sent earlier in the day. As to "fixes" - when it's not an actual bug, I had (successfully) asked the bugseng guys to avoid that term, and instead use "addresses" or "eliminates a ... violation" or some such.
Quoted 3 lines
No functional change.
Signed-off-by Andrew Cooper <[email protected]>
Jan
Quoted 6 lines · Jan Beulich
Quoted 1 line · Andrew Cooper
Fixes MISRA XXX
Rule 5.5 if I'm not mistaken; had to look it up for the patch sent earlier in the day. As to "fixes" - when it's not an actual bug, I had (successfully) asked the bugseng guys to avoid that term, and instead use "addresses" or "eliminates a ... violation" or some such.
Ok.
Quoted 5 lines
Quoted 4 lines
No functional change.
Signed-off-by Andrew Cooper <[email protected]>Reviewed-by Jan Beulich <[email protected]>
Thanks.
~Andrew
Quoted 8 lines · Jan Beulich
Quoted 1 line · Andrew Cooper
Fixes MISRA XXX
Rule 5.5 if I'm not mistaken; had to look it up for the patch sent earlier in the day. As to "fixes" - when it's not an actual bug, I had (successfully) asked the bugseng guys to avoid that term, and instead use "addresses" or "eliminates a ... violation" or some such.
Quoted 7 lines
Quoted 3 lines
No functional change.
Signed-off-by Andrew Cooper <[email protected]>Reviewed-by Jan Beulich <[email protected]>Jan
I confirm that it is Rule 5.5.
I would like to point out that although the patch fixes violations of
Rule 5.5, it introduces new violations of Rule 5.3 "An identifier declared in an inner scope shall not hide an identifier declared in an outer scope": cpuid is used also as an identifier for some formal arguments (the pipeline does not fail because Rule 5.3 is not tagged as "clean" and the introduction of new violations does not cause
a failure).
A solution could be to rename the function adding a prefix or a suffix
to its name.
Signature · 3 lines
Federico Serafini, M.Sc. Software Engineer, BUGSENG (http://bugseng.com)