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

Re: [PATCH v2] xen: address violations of MISRA C:2012 Rule 11.8.



On 01/12/23 14:03, Jan Beulich wrote:
On 01.12.2023 12:48, Julien Grall wrote:
On 01/12/2023 11:37, Simone Ballarin wrote:
--- a/xen/arch/arm/include/asm/regs.h
+++ b/xen/arch/arm/include/asm/regs.h
@@ -48,7 +48,7 @@ static inline bool regs_mode_is_32bit(const struct 
cpu_user_regs *regs)
static inline bool guest_mode(const struct cpu_user_regs *r)
   {
-    unsigned long diff = (char *)guest_cpu_user_regs() - (char *)(r);
+    unsigned long diff = (const uintptr_t)guest_cpu_user_regs() - (const 
uintptr_t)(r);

NIT: The const should not be necessary here. Am I correct?

--- a/xen/arch/x86/include/asm/regs.h
+++ b/xen/arch/x86/include/asm/regs.h
@@ -6,7 +6,8 @@
#define guest_mode(r) \
   ({                                                                           
 \
-    unsigned long diff = (char *)guest_cpu_user_regs() - (char *)(r);         \
+    unsigned long diff = (const uintptr_t)guest_cpu_user_regs() -             \
+                                                        (const uintptr_t(r)); \

Was this compiled on x86? Shouldn't the last one be (const uintptr_t)(r))?

And again with the stray const-s dropped and with indentation adjusted.


I will remove the const in the first parameter and fix the indentation
in the following way:

unsigned long diff = (uintptr_t)guest_cpu_user_regs() -                \
                     (const uintptr_t)(r);                             \

Jan


--
Simone Ballarin, M.Sc.

Field Application Engineer, BUGSENG (https://bugseng.com)




 


Rackspace

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