xen: address violations of MISRA C:2012 Rule 11.8
v2 cover xen: address violations of MISRA C:2012 Rule 11.8
From: Maria Celeste Cesario <[email protected]>
The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states:
"A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer".
This patch amends or drops casts that unnecessarily drop const qualifiers.
Example:
int device_tree_for_each_node(const void *fdt);
size_t __init boot_fdt_info(const void *fdt)
{
int ret = device_tree_for_each_node((void *)fdt); /* Non-compliant */
int ret = device_tree_for_each_node(fdt); /* Compliant, proposed change */
}
In this example, the const qualifier is unnecessarily cast away from the original object, therefore making it non-compliant.
Deviate the following violations:
- removal of const qualifier to comply with function signatures A single function could either read or write through a passed in pointer, depending on how it is called. It is deemed safe to cast away a const qualifier when passing a pointer to such a function, when the other parameters guarantee read-only operation.
A SAF-3-safe comment was added to deviate these violations.
- violations in macro container_of
Violations caused by this macro are due to pointer arithmetic operations with the provided offset. The resulting pointer is then immediately cast back to its original type, which preserves the qualifier. This use is deemed safe.
Changes in v2:
- reword SAF-3-safe text;
- merge comments on __hvm_copy;
- add SAF-3-safe comment in x86/hvm.c:3433;
- add SAF-3-safe comment on arm/guestcopy.c raw_copy_to_guest and raw_copy_to_guest_flush_dcache;
- remove deviation for function ERR_CAST;
- remove function ERR_CAST;
- move common/version.c to patch xen/common;
- change cast type from const void* to uintptr_t in common/version.c;
- drop redundant cast on fdt.
Maria Celeste Cesario (6):
xen/arm: address violations of MISRA C:2012 Rule 11.8 xen/ppc: address violations of MISRA C:2012 Rule 11.8.
xen: add deviations for Rule 11.8
xen: add SAF deviation for safe cast removal
xen: remove unused function ERR_CAST xen/common: address violations of MISRA C:2012 Rule 11.8
automation/eclair_analysis/ECLAIR/deviations.ecl | 7 +++++++ docs/misra/deviations.rst | 7 +++++++ docs/misra/safe.json | 8 ++++++++ xen/arch/arm/bootfdt.c | 6 +++--- xen/arch/arm/guestcopy.c | 2 ++ xen/arch/arm/include/asm/alternative.h | 2 +- xen/arch/ppc/include/asm/atomic.h | 2 +- xen/arch/x86/hvm/hvm.c | 6 ++++-- xen/common/version.c | 2 +- xen/include/xen/err.h | 13 ------------- 10 files changed, 34 insertions(+), 21 deletions(-)
Signature · 1 line
2.40.0
PATCH v2 1/6 xen/arm: address violations of MISRA C:2012 Rule 11.8
From: Maria Celeste Cesario <[email protected]>
The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states:
"A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer".
Add missing const qualifiers in casts.
The variables are originally const-qualified.
There's no reason to drop the qualifiers.
Drop redundant cast to preserve const qualifier.
No functional change.
---
Changes in v2:
- drop redundant cast on fdt
--- xen/arch/arm/bootfdt.c | 6 +++--- xen/arch/arm/include/asm/alternative.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-)
xen/arch/arm/bootfdt.c +3 -3
@@ -377,7 +377,7 @@ static int __init process_chosen_node(const void *fdt, int node,printk ("linux,initrd-start property has invalid length %d\n" , len);return -EINVAL ; } - start =dt_read_paddr ((void *)&prop->data,dt_size_to_cells (len)); + start =dt_read_paddr ((const void *)&prop->data,dt_size_to_cells (len)); prop =fdt_get_property (fdt, node,"linux,initrd-end" , &len);if ( !prop )
@@ -390,7 +390,7 @@ static int __init process_chosen_node(const void *fdt, int node,printk ("linux,initrd-end property has invalid length %d\n" , len);return -EINVAL ; } - end =dt_read_paddr ((void *)&prop->data,dt_size_to_cells (len)); + end =dt_read_paddr ((const void *)&prop->data,dt_size_to_cells (len));if ( start >= end ) {
@@ -541,7 +541,7 @@ size_t __init boot_fdt_info(const void *fdt, paddr_t paddr)add_boot_module (BOOTMOD_FDT , paddr,fdt_totalsize (fdt), false); - ret =device_tree_for_each_node ((void *)fdt,0 , early_scan_node,NULL ); + ret =device_tree_for_each_node (fdt,0 , early_scan_node,NULL );if ( ret )panic ("Early FDT parsing failed (%d)\n" , ret);
xen/arch/arm/include/asm/alternative.h +1 -1
@@ -20,7 +20,7 @@ struct alt_instr { };/* Xen: helpers used by common code. */ -#define __ALT_PTR (a,f) ((void *)&(a)->f + (a)->f) +#define __ALT_PTR (a,f) ((const void *)&(a)->f + (a)->f)#define ALT_ORIG_PTR (a) __ALT_PTR(a, orig_offset)#define ALT_REPL_PTR (a) __ALT_PTR(a, repl_offset)
Signature · 1 line
2.40.0
Re: [PATCH v2 1/6] xen/arm: address violations of MISRA C:2012 Rule 11.8
Quoted 11 lines · Simone Ballarin
From: Maria Celeste Cesario <[email protected]>
The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states:
"A conversion shall not remove any const, volatile or_Atomicqualification from the type pointed to by a pointer".Add missing const qualifiers in casts.
The variables are originally const-qualified.
There's no reason to drop the qualifiers.
Quoted 6 lines
Drop redundant cast to preserve const qualifier.
No functional change.
Signed-off-by Maria Celeste Cesario <[email protected]>Signed-off-by Simone Ballarin <[email protected]>
PATCH v2 2/6 xen/ppc: address violations of MISRA C:2012 Rule 11.8.
In reply to Simone BallarinFrom: Maria Celeste Cesario <[email protected]>
The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states:
"A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer".
Fix violation by adding missing const qualifier in cast.
---
Adaptation requested by the community to make the code more consistent.
--- xen/arch/ppc/include/asm/atomic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/arch/ppc/include/asm/atomic.h +1 -1
@@ -16,7 +16,7 @@static inline int atomic_read (const atomic_t *v) { -return *(volatile int *)&v->counter; +return *(const volatile int *)&v->counter; }static inline int _atomic_read (atomic_t v)
Signature · 1 line
2.40.0
Re: [PATCH v2 2/6] xen/ppc: address violations of MISRA C:2012 Rule 11.8.
Shawn,
I am thinking of committing this, if you disagree please say something in the next couple of days
Quoted 34 lines · Simone Ballarin
From: Maria Celeste Cesario <[email protected]>
The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states:
"A conversion shall not remove any const, volatile or_Atomicqualification from the type pointed to by a pointer".Fix violation by adding missing const qualifier in cast.
Signed-off-by Maria Celeste Cesario <[email protected]>Signed-off-by Simone Ballarin <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>---
Adaptation requested by the community to make the code more consistent.--- xen/arch/ppc/include/asm/atomic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/ppc/include/asm/atomic.h +1
-1@@ -16,7 +16,7 @@static inline int atomic_read (const atomic_t *v) { -return *(volatile int *)&v->counter; +return *(const volatile int *)&v->counter; }static inline int _atomic_read (atomic_t v)Signature · 1 line
2.40.0
Shawn Anastasio
Acked-byRe: [PATCH v2 2/6] xen/ppc: address violations of MISRA C:2012 Rule 11.8.
Hi Stefano,
Sorry for the delay on this.
Best,
Shawn
Quoted 41 lines · Stefano Stabellini
Shawn,
I am thinking of committing this, if you disagree please say something in the next couple of days
Quoted 34 lines · Simone Ballarin
From: Maria Celeste Cesario <[email protected]>
The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states:
"A conversion shall not remove any const, volatile or_Atomicqualification from the type pointed to by a pointer".Fix violation by adding missing const qualifier in cast.
Signed-off-by Maria Celeste Cesario <[email protected]>Signed-off-by Simone Ballarin <[email protected]>Reviewed-by Stefano Stabellini <[email protected]>---
Adaptation requested by the community to make the code more consistent.--- xen/arch/ppc/include/asm/atomic.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)xen/arch/ppc/include/asm/atomic.h +1
-1@@ -16,7 +16,7 @@static inline int atomic_read (const atomic_t *v) { -return *(volatile int *)&v->counter; +return *(const volatile int *)&v->counter; }static inline int _atomic_read (atomic_t v)Signature · 1 line
2.40.0
PATCH v2 3/6 xen: add deviations for Rule 11.8
In reply to Simone BallarinFrom: Maria Celeste Cesario <[email protected]>
The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states:
"A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer".
The macro 'container_of' violates the Rule because it casts away any qualifier to do pointer arithmetic, but making the macro definition compliant would add additional complexity, therefore a deviation is introduced.
---
Changes in v2:
- remove deviation for function ERR_CAST;
container_of: Fixing this violation would require the declaration of a new
macro taking advantage of the return value of the ternary operator ?: :
its return value preserves qualifiers present on both expression, hence returning void* or qualified void* depending on pointer type, like in this macro:
'#define same_constness_void_ptr(ptr) ((typeof((false ? (void*) 1 : (ptr)))) (ptr))' The result could then be used with a Generic to avoid the cast.
--- automation/eclair_analysis/ECLAIR/deviations.ecl | 7 +++++++ docs/misra/deviations.rst | 7 +++++++ 2 files changed, 14 insertions(+)
automation/eclair_analysis/ECLAIR/deviations.ecl +7 -0
@@ -292,6 +292,13 @@ constant expressions are required.\"" # Series 11 # +-doc_begin="Violations caused by container_of are due to pointer arithmetic operations +with the provided offset. The resulting pointer is then immediately cast back to its +original type, which preserves the qualifier. This use is deemed safe. +Fixing this violation would require to increase code complexity and lower readability." +-config=MC3R1.R11.8,reports+={safe,"any_area(any_loc(any_exp(macro(^container_of$))))"} +-doc_end + -doc_begin="This construct is used to check if the type is scalar, and for this purpose the use of 0 as a null pointer constant is deliberate." -config=MC3R1.R11.9,reports+={deliberate, "any_area(any_loc(any_exp(macro(^__ACCESS_ONCE$))))" }
docs/misra/deviations.rst +7 -0
@@ -248,6 +248,13 @@ Deviations related to MISRA C:2012 Rules: If no bits are set, 0 is returned. - Tagged as `safe` for ECLAIR. + * - R11.8 + - Violations caused by container_of are due to pointer arithmetic operations + with the provided offset. The resulting pointer is then immediately cast back to its + original type, which preserves the qualifier. This use is deemed safe. + Fixing this violation would require to increase code complexity and lower readability. + - Tagged as `safe` for ECLAIR. + * - R11.9 - __ACCESS_ONCE uses an integer, which happens to be zero, as a compile time check. The typecheck uses a cast. The usage of zero or other
Signature · 1 line
2.40.0
Re: [PATCH v2 3/6] xen: add deviations for Rule 11.8
Quoted 7 lines · Simone Ballarin
From: Maria Celeste Cesario <[email protected]>
The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states:
"A conversion shall not remove any const, volatile or_Atomicqualification from the type pointed to by a pointer".
Quoted 6 lines
The macro '
container_of' violates the Rule because it casts away any qualifier to do pointer arithmetic, but making the macro definition compliant would add additional complexity, therefore a deviation is introduced.Signed-off-by Maria Celeste Cesario <[email protected]>Signed-off-by Simone Ballarin <[email protected]>
Re: [PATCH v2 3/6] xen: add deviations for Rule 11.8
In reply to Simone Ballarindocs/misra/deviations.rst Deviations related to MISRA C:2012 Rules: · line 257
Quoted 13 lines · Simone Ballarin
docs/misra/deviations.rst +7
-0@@ -248,6 +248,13 @@ Deviations related to MISRA C:2012 Rules: If no bits are set, 0 is returned. - Tagged as `safe` for ECLAIR. + * - R11.8 + - Violations caused by container_of are due to pointer arithmetic operations + with the provided offset. The resulting pointer is then immediately cast back to its + original type, which preserves the qualifier. This use is deemed safe. + Fixing this violation would require to increase code complexity and lower readability. + - Tagged as `safe` for ECLAIR. +
Going forward can you please avoid adding trailing whitespace. "git am" doesn't really like that, and hence it requires extra steps to clean up.
Jan
Re: [PATCH v2 3/6] xen: add deviations for Rule 11.8
Quoted 22 lines · Jan Beulich
Quoted 15 lines · Simone Ballarin
docs/misra/deviations.rst +2
-0@@ -248,6 +248,13 @@ Deviations related to MISRA C:2012 Rules: If no bits are set, 0 is returned. - Tagged as `safe` for ECLAIR. + * - R11.8 + - Violations caused by container_of are due to pointerarithmetic operations
+ with the provided offset. The resulting pointer is then
immediately cast back to its
+ original type, which preserves the qualifier. This use is
deemed safe.
+ Fixing this violation would require to increase code
complexity and lower readability.docs/misra/deviations.rst Deviations related to MISRA C:2012 Rules: · line 257
Quoted 2 lines
docs/misra/deviations.rst +2
-0+ - Tagged as `safe` for ECLAIR. +Going forward can you please avoid adding trailing whitespace. "git am" doesn't really like that, and hence it requires extra steps to clean up.
Quoted 1 line
Jan
Noted, sorry for the inconvenience.
Signature · 2 lines
Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)
PATCH v2 4/6 xen: add SAF deviation for safe cast removal
In reply to Simone BallarinFrom: Maria Celeste Cesario <[email protected]>
The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states:
"A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer".
Add SAF-3-safe deviation: removal of const qualifier to comply with function signature.
---
Changes in v2:
- reword SAF-3-safe text;
- merge comments on __hvm_copy;
- add SAF-3-safe comment in x86/hvm.c:3433;
- add SAF-3-safe comment on arm/guestcopy.c raw_copy_to_guest and raw_copy_to_guest_flush_dcache.
--- docs/misra/safe.json | 8 ++++++++ xen/arch/arm/guestcopy.c | 2 ++ xen/arch/x86/hvm/hvm.c | 6 ++++-- 3 files changed, 14 insertions(+), 2 deletions(-)
docs/misra/safe.json +8 -0
@@ -28,6 +28,14 @@ }, { "id": "SAF-3-safe", + "analyser": { + "eclair": "MC3R1.R11.8" + }, + "name": "MC3R1.R11.8: removal of const qualifier to comply with function signature", + "text": "A single function could either read or write through a passed in pointer, depending on how it is called. It is deemed safe to cast away a const qualifier when passing a pointer to such a function, when the other parameters guarantee read-only operation." + }, + { + "id": "SAF-4-safe", "analyser": {}, "name": "Sentinel", "text": "Next ID to be used"
xen/arch/arm/guestcopy.c +2 -0
@@ -109,6 +109,7 @@ static unsigned long copy_guest(void *buf, uint64_t addr, unsigned int len,unsigned long raw_copy_to_guest (void *to,const void *from,unsigned int len) { +/* SAF-3-safe COPY_to_guest doesn't modify from */ return copy_guest ((void *)from, (vaddr_t )to, len,GVA_INFO (current), COPY_to_guest | COPY_linear); }
@@ -116,6 +117,7 @@ unsigned long raw_copy_to_guest(void *to, const void *from, unsigned int len)unsigned long raw_copy_to_guest_flush_dcache (void *to,const void *from,unsigned int len) { +/* SAF-3-safe COPY_to_guest doesn't modify from */ return copy_guest ((void *)from, (vaddr_t )to, len,GVA_INFO (current), COPY_to_guest | COPY_flush_dcache | COPY_linear); }
xen/arch/x86/hvm/hvm.c +4 -2
@@ -3413,7 +3413,8 @@ static enum hvm_translation_result __hvm_copy(enum hvm_translation_result hvm_copy_to_guest_phys (paddr_t paddr,const void *buf,unsigned int size,struct vcpu *v) { -return __hvm_copy ((void *)buf/* HVMCOPY_to_guest doesn't modify */ , +/* SAF-3-safe HVMCOPY_to_guest doesn't modify buf */ +return __hvm_copy ((void *)buf, paddr, size, v, HVMCOPY_to_guest | HVMCOPY_phys,0 ,NULL ); }
@@ -3429,7 +3430,8 @@ enum hvm_translation_result hvm_copy_to_guest_linear( unsigned long addr, const void *buf, unsigned int size, uint32_t pfec, pagefault_info_t *pfinfo) { - return __hvm_copy((void *)buf /* HVMCOPY_to_guest doesn't modify */, + /* SAF-3-safe HVMCOPY_to_guest doesn't modify buf */ + return __hvm_copy((void *)buf, addr, size, current, HVMCOPY_to_guest | HVMCOPY_linear, PFEC_page_present | PFEC_write_access | pfec, pfinfo); }
Signature · 1 line
2.40.0
Re: [PATCH v2 4/6] xen: add SAF deviation for safe cast removal
Quoted 11 lines · Simone Ballarin
xen/arch/arm/guestcopy.c +1
-0@@ -109,6 +109,7 @@ static unsigned long copy_guest(void *buf, uint64_t addr, unsigned int len,unsigned long raw_copy_to_guest (void *to,const void *from,unsigned int len) { +/* SAF-3-safe COPY_to_guest doesn't modify from */ return copy_guest ((void *)from, (vaddr_t )to, len,GVA_INFO (current), COPY_to_guest | COPY_linear); }
xen/arch/arm/guestcopy.c unsigned long raw_copy_to_guest(void *to, const void *from, unsigned int len) · line 123
Quoted 7 lines
xen/arch/arm/guestcopy.c +1
-0@@ -116,6 +117,7 @@ unsigned long raw_copy_to_guest(void *to, const void *from, unsigned int len)unsigned long raw_copy_to_guest_flush_dcache (void *to,const void *from,unsigned int len) { +/* SAF-3-safe COPY_to_guest doesn't modify from */ return copy_guest ((void *)from, (vaddr_t )to, len,GVA_INFO (current), COPY_to_guest | COPY_flush_dcache | COPY_linear); }
Unlike below for x86, here in both cases the comment cover more than just the one function argument they are intended to cover. I think we want to limit the scope of such comments as much as possible (and hence have as little as possible on the immediately following line).
Jan
Quoted 22 lines
xen/arch/x86/hvm/hvm.c +4
-2@@ -3413,7 +3413,8 @@ static enum hvm_translation_result __hvm_copy(enum hvm_translation_result hvm_copy_to_guest_phys (paddr_t paddr,const void *buf,unsigned int size,struct vcpu *v) { -return __hvm_copy ((void *)buf/* HVMCOPY_to_guest doesn't modify */ , +/* SAF-3-safe HVMCOPY_to_guest doesn't modify buf */ +return __hvm_copy ((void *)buf, paddr, size, v, HVMCOPY_to_guest | HVMCOPY_phys,0 ,NULL ); }@@ -3429,7 +3430,8 @@ enum hvm_translation_result hvm_copy_to_guest_linear( unsigned long addr, const void *buf, unsigned int size, uint32_t pfec, pagefault_info_t *pfinfo) { - return __hvm_copy((void *)buf /* HVMCOPY_to_guest doesn't modify */, + /* SAF-3-safe HVMCOPY_to_guest doesn't modify buf */ + return __hvm_copy((void *)buf, addr, size, current, HVMCOPY_to_guest | HVMCOPY_linear, PFEC_page_present | PFEC_write_access | pfec, pfinfo); }
Re: [PATCH v2 4/6] xen: add SAF deviation for safe cast removal
Quoted 32 lines · Jan Beulich
Quoted 21 lines · Simone Ballarin
xen/arch/arm/guestcopy.c +1
-0@@ -109,6 +109,7 @@ static unsigned long copy_guest(void *buf, uint64_t addr, unsigned int len, unsigned long raw_copy_to_guest(void *to, const void *from, unsigned int len) { + /* SAF-3-safe COPY_to_guest doesn't modify from */ return copy_guest((void *)from, (vaddr_t)to, len,
GVA_INFO(current),COPY_to_guest|COPY_linear);
}xen/arch/arm/guestcopy.c +1
-0@@ -116,6 +117,7 @@ unsigned long raw_copy_to_guest(void *to, const void *from, unsigned int len) unsigned long raw_copy_to_guest_flush_dcache(void *to, const void *from, unsigned int len) { + /* SAF-3-safe COPY_to_guest doesn't modify from */ return copy_guest((void *)from, (vaddr_t)to, len,Quoted 4 lines
GVA_INFO(current),
COPY_to_guest|COPY_flush_dcache|COPY_linear);
}Unlike below for x86, here in both cases the comment cover more than just the one function argument they are intended to cover. I think we want to limit the scope of such comments as much as possible (and hence have as little as possible on the immediately following line).
Quoted 1 line
Jan
Ok, noted for v3.
Signature · 2 lines
Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)
PATCH v2 5/6 xen: remove unused function ERR_CAST
In reply to Simone BallarinFrom: Maria Celeste Cesario <[email protected]>
Function ERR_CAST contains a violation of MISRA C:2012 Rule 11.8, whose headline states:
"A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer".
Since the function has no users, it is appropriate to remove it.
---
Commit introduced in v2.
--- xen/include/xen/err.h | 13 ------------- 1 file changed, 13 deletions(-)
xen/include/xen/err.h +0 -13
@@ -36,19 +36,6 @@ static inline long __must_check IS_ERR_OR_NULL(const void *ptr)return !ptr ||IS_ERR_VALUE ((unsigned long )ptr); } -/** -* ERR_CAST - Explicitly cast an error-valued pointer to another pointer type -* @ptr: The pointer to cast. -* -* Explicitly cast an error-valued pointer to another pointer type in such a -* way as to make it clear that's what's going on. -*/ -static inline void *__must_check ERR_CAST (const void *ptr) -{ -/* cast away the const */ -return (void *)ptr; -} -static inline int __must_check PTR_RET (const void *ptr) {return IS_ERR (ptr) ?PTR_ERR (ptr) :0 ;
Signature · 1 line
2.40.0
Re: [PATCH v2 5/6] xen: remove unused function ERR_CAST
Quoted 11 lines · Simone Ballarin
From: Maria Celeste Cesario <[email protected]>
Function
ERR_CASTcontains a violation of MISRA C:2012 Rule 11.8, whose headline states:
"A conversion shall not remove any const, volatile or_Atomicqualification from the type pointed to by a pointer".Since the function has no users, it is appropriate to remove it.
Signed-off-by Maria Celeste Cesario <[email protected]>Signed-off-by Simone Ballarin <[email protected]>
Re: [PATCH v2 5/6] xen: remove unused function ERR_CAST
In reply to Simone BallarinQuoted 11 lines · Simone Ballarin
From: Maria Celeste Cesario <[email protected]>
Function
ERR_CASTcontains a violation of MISRA C:2012 Rule 11.8, whose headline states:
"A conversion shall not remove any const, volatile or_Atomicqualification from the type pointed to by a pointer".Since the function has no users, it is appropriate to remove it.
Signed-off-by Maria Celeste Cesario <[email protected]>Signed-off-by Simone Ballarin <[email protected]>
PATCH v2 6/6 xen/common: address violations of MISRA C:2012 Rule 11.8
In reply to Simone BallarinFrom: Maria Celeste Cesario <[email protected]>
The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states:
"A conversion shall not remove any const, volatile or _Atomic qualification from the type pointed to by a pointer".
Change cast type from void* to uintptr_t.
void* type cast resulted in violation of the Rule, a cast to type uintptr_t is more appropriate type-wise.
---
Commit introduced in v2
--- xen/common/version.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
xen/common/version.c +1 -1
@@ -178,7 +178,7 @@ void __init xen_build_init(void)if ( &n[1 ] >= __note_gnu_build_id_end )return ; - sz = (void *)__note_gnu_build_id_end - (void *)n; + sz = (uintptr_t )__note_gnu_build_id_end - (uintptr_t )n; rc =xen_build_id_check (n, sz, &build_id_p, &build_id_len);
Signature · 1 line
2.40.0
Re: [PATCH v2 6/6] xen/common: address violations of MISRA C:2012 Rule 11.8
Quoted 7 lines · Simone Ballarin
From: Maria Celeste Cesario <[email protected]>
The xen sources contain violations of MISRA C:2012 Rule 11.8 whose headline states:
"A conversion shall not remove any const, volatile or_Atomicqualification from the type pointed to by a pointer".
Quoted 6 lines
Change cast type from void* to
uintptr_t.
void* type cast resulted in violation of the Rule, a cast to typeuintptr_tis more appropriate type-wise.Signed-off-by Maria Celeste Cesario <[email protected]>Signed-off-by Simone Ballarin <[email protected]>