Skip to contentSkip to conversation

x86/MCE: adjust ID2COOKIE() for Misra C:2012 rule 11.2

PATCH In review Jan Beulich 2 participants 3 messages May 18

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 x86/MCE: adjust ID2COOKIE() for Misra C:2012 rule 11.2

... ("Conversions shall not be performed between a pointer to an incomplete type and any other type"): Add an intermediate cast to unsigned long.

---
v2: Add comment.

xen/arch/x86/cpu/mcheck/mce.c +2 -1
@@ -1264,7 +1264,8 @@ static void cf_check __maybe_unused x86_
 
 #if BITS_PER_LONG == 64
 
-#define ID2COOKIE(id) ((mctelem_cookie_t)(id))
+/* Two layers of casting to cover Misra C:2012 rule 11.2. */
+#define ID2COOKIE(id) ((mctelem_cookie_t)(void *)(id))
 #define COOKIE2ID(c) ((uint64_t)(c))
 
 #elif defined(BITS_PER_LONG)
Reviewed-by on v2 1/1
#1 lore raw
Quoted 4 lines · Jan Beulich

... ("Conversions shall not be performed between a pointer to an incomplete type and any other type"): Add an intermediate cast to unsigned long.

Stale comment I presume.

Quoted 1 line
Quoted 15 lines

---
v2: Add comment.

xen/arch/x86/cpu/mcheck/mce.c +2 -1
@@ -1264,7 +1264,8 @@ static void cf_check __maybe_unused x86_
 
 #if BITS_PER_LONG == 64
 
-#define ID2COOKIE(id) ((mctelem_cookie_t)(id))
+/* Two layers of casting to cover Misra C:2012 rule 11.2. */
+#define ID2COOKIE(id) ((mctelem_cookie_t)(void *)(id))
 #define COOKIE2ID(c) ((uint64_t)(c))
 
 #elif defined(BITS_PER_LONG)
Signature · 4 lines
Nicola Vetrini, B.Sc.
Software Engineer
BUGSENG (https://bugseng.com)
LinkedIn: https://www.linkedin.com/in/nicola-vetrini-a42471253
#2 lore raw
Quoted 6 lines · Nicola Vetrini
Quoted 3 lines · Jan Beulich

... ("Conversions shall not be performed between a pointer to an incomplete type and any other type"): Add an intermediate cast to unsigned long.

Stale comment I presume.

Indeed, forgot to edit it again after the failed attempt.

Quoted 2 lines
Quoted 1 line

Thanks.

Jan