xen: address violations of MISRA C Rule 13.6
cover xen: address violations of MISRA C Rule 13.6
Address remaining violations of Rule 13.6 and tag it as clean.
Federico Serafini (3):
EFI: address violations of MISRA C Rule 13.6 xen/gnttab: address violations of MISRA C Rule 13.6 automation/eclair: tag Rule 13.6 as clean
automation/eclair_analysis/ECLAIR/tagging.ecl | 1 + xen/common/compat/grant_table.c | 15 +++++++++------ xen/common/efi/runtime.c | 12 ++++++++++-- 3 files changed, 20 insertions(+), 8 deletions(-)
Signature · 1 line
2.34.1
PATCH 1/3 EFI: address violations of MISRA C Rule 13.6
Refactor the code to improve readability and address violations of MISRA C:2012 Rule 13.6 ("The operand of the `sizeof' operator shall not contain any expression which has potential side effect").
No functional change.
--- xen/common/efi/runtime.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-)
xen/common/efi/runtime.c +10 -2
@@ -250,14 +250,20 @@ int efi_get_info(uint32_t idx, union xenpf_efi_info *info) info->cfg.addr =__pa (efi_ct); info->cfg.nent = efi_num_ct;break ; +case XEN_FW_EFI_VENDOR : + { +XEN_GUEST_HANDLE_PARAM (CHAR16) vendor_name = +guest_handle_cast (info->vendor.name,CHAR16 ); +if ( !efi_fw_vendor )return -EOPNOTSUPP ; + info->vendor.revision = efi_fw_revision; n = info->vendor.bufsz /sizeof (*efi_fw_vendor); -if ( !guest_handle_okay (guest_handle_cast (info->vendor.name, -CHAR16 ), n) ) +if ( !guest_handle_okay (vendor_name, n) )return -EFAULT ; +for ( i =0 ; i < n; ++i ) { if ( __copy_to_guest_offset(info->vendor.name, i,
@@ -267,6 +273,8 @@ int efi_get_info(uint32_t idx, union xenpf_efi_info *info)break ; }break ; + } +case XEN_FW_EFI_MEM_INFO :for ( i =0 ; i < efi_memmap_size; i += efi_mdesc_size ) {
Signature · 1 line
2.34.1
Re: [XEN PATCH 1/3] EFI: address violations of MISRA C Rule 13.6
Quoted 1 line · Federico Serafini
Refactor the code to improve readability
I question this aspect. I'm not the maintainer of this code anymore, so my view probably doesn't matter much here.
Quoted 3 lines
and address violations of
MISRA C:2012 Rule 13.6 ("The operand of the `sizeof' operator shall not contain any expression which has potential side effect").
Where's the potential side effect? Since you move ...
xen/common/efi/runtime.c int efi_get_info(uint32_t idx, union xenpf_efi_info *info) · line 257
Quoted 11 lines
xen/common/efi/runtime.c +4
-0@@ -250,14 +250,20 @@ int efi_get_info(uint32_t idx, union xenpf_efi_info *info) info->cfg.addr =__pa (efi_ct); info->cfg.nent = efi_num_ct;break ; +case XEN_FW_EFI_VENDOR : + { +XEN_GUEST_HANDLE_PARAM (CHAR16) vendor_name = +guest_handle_cast (info->vendor.name,CHAR16 );
.. this out, it must be the one. I've looked at it, yet I can't spot anything:
#define guest_handle_cast(hnd, type) ({ \
type *_x = (hnd).p; \
(XEN_GUEST_HANDLE_PARAM(type)) { _x }; \})
As a rule of thumb, when things aren't obvious, please call out the specific aspect / property in descriptions of such patches.
Jan
Re: [XEN PATCH 1/3] EFI: address violations of MISRA C Rule 13.6
Quoted 27 lines · Jan Beulich
Quoted 1 line · Federico Serafini
Refactor the code to improve readability
I question this aspect. I'm not the maintainer of this code anymore, so my view probably doesn't matter much here.
Quoted 3 lines
and address violations of
MISRA C:2012 Rule 13.6 ("The operand of the `sizeof' operator shall not contain any expression which has potential side effect").Where's the potential side effect? Since you move ...
xen/common/efi/runtime.c int efi_get_info(uint32_t idx, union xenpf_efi_info *info) · line 257
Quoted 11 lines
xen/common/efi/runtime.c +4
-0@@ -250,14 +250,20 @@ int efi_get_info(uint32_t idx, union xenpf_efi_info *info) info->cfg.addr =__pa (efi_ct); info->cfg.nent = efi_num_ct;break ; +case XEN_FW_EFI_VENDOR : + { +XEN_GUEST_HANDLE_PARAM (CHAR16) vendor_name = +guest_handle_cast (info->vendor.name,CHAR16 );.. this out, it must be the one. I've looked at it, yet I can't spot anything:
Quoted 7 lines
#define guest_handle_cast(hnd, type) ({ \ type *_x = (hnd).p; \ (XEN_GUEST_HANDLE_PARAM(type)) { _x }; \})
As a rule of thumb, when things aren't obvious, please call out the specific aspect / property in descriptions of such patches.
I guess it's because guest_handle_cast() is a macro, yet it's lowercase so looks like a function? Wasn't there some other MISRA rule about lowercase/uppercase for macro names?
And yes, I don't really see why this would violate the side effect rule either.
Signature · 3 lines
Best Regards, Marek Marczykowski-Górecki Invisible Things Lab
Re: [XEN PATCH 1/3] EFI: address violations of MISRA C Rule 13.6
Quoted 33 lines · Marek Marczykowski-Górecki
Quoted 32 lines · Jan Beulich
Quoted 1 line · Federico Serafini
Refactor the code to improve readability
I question this aspect. I'm not the maintainer of this code anymore, so my view probably doesn't matter much here.
Quoted 3 lines
and address violations of
MISRA C:2012 Rule 13.6 ("The operand of the `sizeof' operator shall not contain any expression which has potential side effect").Where's the potential side effect? Since you move ...
xen/common/efi/runtime.c int efi_get_info(uint32_t idx, union xenpf_efi_info *info) · line 257
Quoted 11 lines
xen/common/efi/runtime.c +4
-0@@ -250,14 +250,20 @@ int efi_get_info(uint32_t idx, union xenpf_efi_info *info) info->cfg.addr =__pa (efi_ct); info->cfg.nent = efi_num_ct;break ; +case XEN_FW_EFI_VENDOR : + { +XEN_GUEST_HANDLE_PARAM (CHAR16) vendor_name = +guest_handle_cast (info->vendor.name,CHAR16 );.. this out, it must be the one. I've looked at it, yet I can't spot anything:
#define guest_handle_cast(hnd, type) ({ \ type *_x = (hnd).p; \ (XEN_GUEST_HANDLE_PARAM(type)) { _x }; \})
Quoted 5 lines
Quoted 2 lines
As a rule of thumb, when things aren't obvious, please call out the specific aspect / property in descriptions of such patches.
I guess it's because
guest_handle_cast()is a macro, yet it's lowercase so looks like a function?
If Eclair didn't look at the macro-expanded code, it wouldn't even see the sizeof(). Hence I don't expect the thing to be mistaken for a function call.
Quoted 1 line
Wasn't there some other MISRA rule about lowercase/uppercase for macro names?
I can't recall having run into one, but I also haven't memorized them all.
Jan
Re: [XEN PATCH 1/3] EFI: address violations of MISRA C Rule 13.6
Quoted 31 lines · Jan Beulich
Quoted 30 lines · Marek Marczykowski-Górecki
Quoted 29 lines · Jan Beulich
Quoted 1 line · Federico Serafini
Refactor the code to improve readability
I question this aspect. I'm not the maintainer of this code anymore, so my view probably doesn't matter much here.
Quoted 3 lines
and address violations of
MISRA C:2012 Rule 13.6 ("The operand of the `sizeof' operator shall not contain any expression which has potential side effect").Where's the potential side effect? Since you move ...
xen/common/efi/runtime.c int efi_get_info(uint32_t idx, union xenpf_efi_info *info) · line 257
Quoted 11 lines
xen/common/efi/runtime.c +4
-0@@ -250,14 +250,20 @@ int efi_get_info(uint32_t idx, union xenpf_efi_info *info) info->cfg.addr =__pa (efi_ct); info->cfg.nent = efi_num_ct;break ; +case XEN_FW_EFI_VENDOR : + { +XEN_GUEST_HANDLE_PARAM (CHAR16) vendor_name = +guest_handle_cast (info->vendor.name,CHAR16 );.. this out, it must be the one. I've looked at it, yet I can't spot anything:
#define guest_handle_cast(hnd, type) ({ \ type *_x = (hnd).p; \ (XEN_GUEST_HANDLE_PARAM(type)) { _x }; \})
Quoted 7 lines
Quoted 4 lines
Quoted 2 lines
As a rule of thumb, when things aren't obvious, please call out the specific aspect / property in descriptions of such patches.
I guess it's because
guest_handle_cast()is a macro, yet it's lowercase so looks like a function?If Eclair didn't look at the macro-expanded code, it wouldn't even see the
sizeof(). Hence I don't expect the thing to be mistaken for a function call.
The complaint is a sizeof in guest_handle_okay() being given ({ ... }) to interpret.
({}) can have arbitrary side effects in it, hence the violation.
~Andrew
Re: [XEN PATCH 1/3] EFI: address violations of MISRA C Rule 13.6
Quoted 36 lines · Andrew Cooper
Quoted 35 lines · Jan Beulich
Quoted 34 lines · Marek Marczykowski-Górecki
Quoted 24 lines · Jan Beulich
Quoted 1 line · Federico Serafini
Refactor the code to improve readability
I question this aspect. I'm not the maintainer of this code anymore, so my view probably doesn't matter much here.
Quoted 3 lines
and address violations of
MISRA C:2012 Rule 13.6 ("The operand of the `sizeof' operator shall not contain any expression which has potential side effect").Where's the potential side effect? Since you move ...
xen/common/efi/runtime.c int efi_get_info(uint32_t idx, union xenpf_efi_info *info) · line 257
Quoted 11 lines
xen/common/efi/runtime.c +4
-0@@ -250,14 +250,20 @@ int efi_get_info(uint32_t idx, union xenpf_efi_info *info) info->cfg.addr =__pa (efi_ct); info->cfg.nent = efi_num_ct;break ; +case XEN_FW_EFI_VENDOR : + { +XEN_GUEST_HANDLE_PARAM (CHAR16) vendor_name = +guest_handle_cast (info->vendor.name,CHAR16 );.. this out, it must be the one. I've looked at it, yet I can't spot anything:
Quoted 7 lines
#define guest_handle_cast(hnd, type) ({ \ type *_x = (hnd).p; \ (XEN_GUEST_HANDLE_PARAM(type)) { _x }; \})
As a rule of thumb, when things aren't obvious, please call out the specific aspect / property in descriptions of such patches.
I guess it's because
guest_handle_cast()is a macro, yet it's lowercase so looks like a function?
Quoted 8 lines
Quoted 3 lines
If Eclair didn't look at the macro-expanded code, it wouldn't even see the
sizeof(). Hence I don't expect the thing to be mistaken for a function call.The complaint is a sizeof in
guest_handle_okay()being given ({ ... }) to interpret.({}) can have arbitrary side effects in it, hence the violation.
I sincerely hope the tool actually looks inside the ({}).
Jan
Re: [XEN PATCH 1/3] EFI: address violations of MISRA C Rule 13.6
In reply to Jan BeulichQuoted 38 lines · Jan Beulich
Quoted 37 lines · Marek Marczykowski-Górecki
Quoted 35 lines · Jan Beulich
Quoted 1 line · Federico Serafini
Refactor the code to improve readability
I question this aspect. I'm not the maintainer of this code anymore, so my view probably doesn't matter much here.
Quoted 3 lines
and address violations of
MISRA C:2012 Rule 13.6 ("The operand of the `sizeof' operator shall not contain any expression which has potential side effect").Where's the potential side effect? Since you move ...
xen/common/efi/runtime.c int efi_get_info(uint32_t idx, union · line 258
Quoted 12 lines
xen/common/efi/runtime.c +4
-0@@ -250,14 +250,20 @@ int efi_get_info(uint32_t idx, union xenpf_efi_info *info) info->cfg.addr = __pa(efi_ct); info->cfg.nent = efi_num_ct;break ; +case XEN_FW_EFI_VENDOR : + { +XEN_GUEST_HANDLE_PARAM (CHAR16) vendor_name = +guest_handle_cast (info->vendor.name,CHAR16 );.. this out, it must be the one. I've looked at it, yet I can't spot anything:
#define guest_handle_cast(hnd, type) ({ \ type *_x = (hnd).p; \ (XEN_GUEST_HANDLE_PARAM(type)) { _x }; \})
As a rule of thumb, when things aren't obvious, please call out the specific aspect / property in descriptions of such patches.
Quoted 7 lines
Quoted 2 lines
I guess it's because
guest_handle_cast()is a macro, yet it's lowercase so looks like a function?If Eclair didn't look at the macro-expanded code, it wouldn't even see the
sizeof(). Hence I don't expect the thing to be mistaken for a function call.
Looking at the fully preprocessed code [1], there is an assignment to CHAR *_x inside a sizeof(), therefore compat_handle_cast is triggering the violation when used in such a way to be inside the sizeof().
if ( !((!!((((get_cpu_info()->current_vcpu))->domain)->arch.paging.mode & ((1 << 4) << 10))) || ( __builtin_expect(!!(((n)) < (~0U / (sizeof(**(({ CHAR16 *_x = (__typeof__(**(info->vendor.name)._) *)(full_ptr_t)(info-> vendor.name).c; (__compat_handle_CHAR16) { (full_ptr_t)_x }; }))._)))),1) && ((unsigned long)((unsigned long)((void *)( full_ptr_t)(({ CHAR16 *_x = (__typeof__(**(info->vendor.name)._) *)(full_ptr_t)(info->vendor.name).c; ( __compat_handle_CHAR16) { (full_ptr_t)_x }; })).c) + ((0 + ((n)) * (sizeof(**(({ CHAR16 *_x = (__typeof__(**(info-> vendor.name)._) *)(full_ptr_t)(info->vendor.name).c; (__compat_handle_CHAR16) { (full_ptr_t)_x }; }))._))) ? (0 + ((n))
* (sizeof(**(({ CHAR16 *_x = (__typeof__(**(info->vendor.name)._) *)(full_ptr_t)(info->vendor.name).c; ( __compat_handle_CHAR16) { (full_ptr_t)_x }; }))._))) - 1 : 0)) < ((void)(((get_cpu_info()->current_vcpu))->domain), 0))) ) )
[1] https://saas.eclairit.com:3787/fs/var/local/eclair/XEN.ecdf/ECLAIR_normal/staging/X86_64-BUGSENG/latest/PROJECT.ecd;/by_service/MC3R1.R13.6.html#{"select":true,"selection":{"hiddenAreaKinds":[],"hiddenSubareaKinds":[],"show":false,"selector":{"enabled":true,"negated":true,"kind":0,"domain":"message","inputs":[{"enabled":true,"text":"^.*xen/common/efi/runtime\\.c:258\\.15-258\\.31: `sizeof' expression trait"}]}}}
Quoted 2 lines
Quoted 1 line
Wasn't there some other MISRA rule about lowercase/uppercase for macro names?
There isn't one imposing this restriction (at least in MISRA C:2012, I haven't checked earlier editions).
Quoted 3 lines
I can't recall having run into one, but I also haven't memorized them all.
Jan
Signature · 2 lines
Nicola Vetrini, BSc Software Engineer, BUGSENG srl (https://bugseng.com)
Re: [XEN PATCH 1/3] EFI: address violations of MISRA C Rule 13.6
Quoted 50 lines · Nicola Vetrini
Quoted 39 lines · Jan Beulich
Quoted 38 lines · Marek Marczykowski-Górecki
Quoted 36 lines · Jan Beulich
Quoted 1 line · Federico Serafini
Refactor the code to improve readability
I question this aspect. I'm not the maintainer of this code anymore, so
my view probably doesn't matter much here.Quoted 3 lines
and address violations of
MISRA C:2012 Rule 13.6 ("The operand of the `sizeof' operator shall not contain any expression which has potential side effect").Where's the potential side effect? Since you move ...
xen/common/efi/runtime.c int efi_get_info(uint32_t idx, union · line 258
Quoted 12 lines
xen/common/efi/runtime.c +4
-0@@ -250,14 +250,20 @@ int efi_get_info(uint32_t idx, union xenpf_efi_info *info) info->cfg.addr = __pa(efi_ct); info->cfg.nent = efi_num_ct;break ; +case XEN_FW_EFI_VENDOR : + { +XEN_GUEST_HANDLE_PARAM (CHAR16) vendor_name = +guest_handle_cast (info->vendor.name,CHAR16 );.. this out, it must be the one. I've looked at it, yet I can't spot anything:
#define guest_handle_cast(hnd, type) ({ \ type *_x = (hnd).p; \ (XEN_GUEST_HANDLE_PARAM(type)) { _x }; \})
As a rule of thumb, when things aren't obvious, please call out the specific aspect / property in descriptions of such patches.
Quoted 9 lines
Quoted 3 lines
I guess it's because
guest_handle_cast()is a macro, yet it's lowercase
so looks like a function?If Eclair didn't look at the macro-expanded code, it wouldn't even see the
sizeof(). Hence I don't expect the thing to be mistaken for a function
call.
Quoted 3 lines
Looking at the fully preprocessed code [1], there is an assignment to CHAR *_x inside a
sizeof(), thereforecompat_handle_castis triggering the violation when used in such a way to be inside thesizeof().
I can see a number of initializers, but no assignment.
Jan
Quoted 17 lines
if ( !((!!((((get_cpu_info()->current_vcpu))->domain)->arch.paging.mode & ((1 << 4) << 10))) || (
__builtin_expect(!!(((n)) < (~0U / (sizeof(**(({ CHAR16 *_x = (__typeof__(**(info->vendor.name)._) *)(full_ptr_t)(info-> vendor.name).c; (__compat_handle_CHAR16) { (full_ptr_t)_x }; }))._)))),1) && ((unsigned long)((unsigned long)((void *)( full_ptr_t)(({ CHAR16 *_x = (__typeof__(**(info->vendor.name)._) *)(full_ptr_t)(info->vendor.name).c; (__compat_handle_CHAR16) { (full_ptr_t)_x }; })).c) + ((0 + ((n)) * (sizeof(**(({ CHAR16 *_x = (__typeof__(**(info-> vendor.name)._)*)(full_ptr_t)(info->vendor.name).c; (__compat_handle_CHAR16) { (full_ptr_t)_x }; }))._))) ? (0 + ((n))
* (sizeof(**(({ CHAR16 *_x = (__typeof__(**(info->vendor.name)._) *)(full_ptr_t)(info->vendor.name).c; (__compat_handle_CHAR16) { (full_ptr_t)_x }; }))._))) - 1 : 0)) < ((void)(((get_cpu_info()->current_vcpu))->domain), 0)))
) )
Re: [XEN PATCH 1/3] EFI: address violations of MISRA C Rule 13.6
Quoted 51 lines · Jan Beulich
Quoted 50 lines · Nicola Vetrini
Quoted 48 lines · Jan Beulich
Quoted 35 lines · Marek Marczykowski-Górecki
Quoted 34 lines · Jan Beulich
Quoted 1 line · Federico Serafini
Refactor the code to improve readability
I question this aspect. I'm not the maintainer of this code anymore, so
my view probably doesn't matter much here.Quoted 3 lines
and address violations of
MISRA C:2012 Rule 13.6 ("The operand of the `sizeof' operator shall not contain any expression which has potential side effect").Where's the potential side effect? Since you move ...
xen/common/efi/runtime.c int efi_get_info(uint32_t idx, union · line 258
Quoted 12 lines
xen/common/efi/runtime.c +4
-0@@ -250,14 +250,20 @@ int efi_get_info(uint32_t idx, union xenpf_efi_info *info) info->cfg.addr = __pa(efi_ct); info->cfg.nent = efi_num_ct;break ; +case XEN_FW_EFI_VENDOR : + { +XEN_GUEST_HANDLE_PARAM (CHAR16) vendor_name = +guest_handle_cast (info->vendor.name,CHAR16 );.. this out, it must be the one. I've looked at it, yet I can't spot anything:
#define guest_handle_cast(hnd, type) ({ \ type *_x = (hnd).p; \ (XEN_GUEST_HANDLE_PARAM(type)) { _x }; \ })Quoted 6 lines
Quoted 2 lines
As a rule of thumb, when things aren't obvious, please call out the specific aspect / property in descriptions of such patches.
I guess it's because
guest_handle_cast()is a macro, yet it's lowercase
so looks like a function?If Eclair didn't look at the macro-expanded code, it wouldn't even see the
sizeof(). Hence I don't expect the thing to be mistaken for a function
call.
Quoted 5 lines
Quoted 3 lines
Looking at the fully preprocessed code [1], there is an assignment to CHAR *_x inside a
sizeof(), thereforecompat_handle_castis triggering the violation when used in such a way to be inside thesizeof().I can see a number of initializers, but no assignment.
+ Stefano in CC.
MISRA considers the initialization (even of a local variable) a side effect. This is the reason of the violations.
I will send a V2 with a better description.
Quoted 19 lines
Quoted 18 lines
if ( !((!!((((get_cpu_info()->current_vcpu))->domain)->arch.paging.mode & ((1 << 4) << 10))) || (
__builtin_expect(!!(((n)) < (~0U / (sizeof(**(({ CHAR16 *_x = (__typeof__(**(info->vendor.name)._) *)(full_ptr_t)(info-> vendor.name).c; (__compat_handle_CHAR16) { (full_ptr_t)_x }; }))._)))),1) && ((unsigned long)((unsigned long)((void *)( full_ptr_t)(({ CHAR16 *_x = (__typeof__(**(info->vendor.name)._) *)(full_ptr_t)(info->vendor.name).c; (__compat_handle_CHAR16) { (full_ptr_t)_x }; })).c) + ((0 + ((n)) * (sizeof(**(({ CHAR16 *_x = (__typeof__(**(info-> vendor.name)._)*)(full_ptr_t)(info->vendor.name).c; (__compat_handle_CHAR16) { (full_ptr_t)_x }; }))._))) ? (0 + ((n))
* (sizeof(**(({ CHAR16 *_x = (__typeof__(**(info->vendor.name)._) *)(full_ptr_t)(info->vendor.name).c; (__compat_handle_CHAR16) { (full_ptr_t)_x }; }))._))) - 1 : 0)) < ((void)(((get_cpu_info()->current_vcpu))->domain), 0)))
) )
Signature · 3 lines
Federico Serafini, M.Sc. Software Engineer, BUGSENG (http://bugseng.com)
PATCH 2/3 xen/gnttab: address violations of MISRA C Rule 13.6
In reply to Federico SerafiniRefactor the code to improve readability and address violations of MISRA C:2012 Rule 13.6 ("The operand of the `sizeof' operator shall not contain any expression which has potential side effect").
No functional change.
--- xen/common/compat/grant_table.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-)
xen/common/compat/grant_table.c +9 -6
@@ -78,12 +78,15 @@ int compat_grant_table_op( cmd_op = cmd;switch ( cmd_op ) { -#define CASE (name) \ - case GNTTABOP_##name: \ - if ( unlikely(!guest_handle_okay(guest_handle_cast(uop, \ - gnttab_##name##_compat_t), \ - count)) ) \ - rc = -EFAULT; \ +#define CASE (name) \ + case GNTTABOP_ ## name: \ + { \ + XEN_GUEST_HANDLE_PARAM(gnttab_ ## name ## _compat_t) h = \ + guest_handle_cast(uop, gnttab_ ## name ## _compat_t); \ + \ + if ( unlikely(!guest_handle_okay(h, count)) ) \ + rc = -EFAULT; \ + } \ break#ifndef CHECK_gnttab_map_grant_ref
Signature · 1 line
2.34.1
Re: [XEN PATCH 2/3] xen/gnttab: address violations of MISRA C Rule 13.6
Quoted 4 lines · Federico Serafini
xen/common/compat/grant_table.c +0
-0@@ -78,12 +78,15 @@ int compat_grant_table_op( cmd_op = cmd;
xen/common/compat/grant_table.c int compat_grant_table_op( · line 82
Quoted 10 lines
xen/common/compat/grant_table.c +2
-6switch ( cmd_op ) { -#define CASE (name) \ - case GNTTABOP_##name: \ - if ( unlikely(!guest_handle_okay(guest_handle_cast(uop, \ - gnttab_##name##_compat_t), \ - count)) ) \ - rc = -EFAULT; \ +#define CASE (name) \ + case GNTTABOP_ ## name: \
Why the re-indentation? The earlier way was pretty intentional, to match what a non-macroized case label would look like in this switch.
xen/common/compat/grant_table.c int compat_grant_table_op( · line 88
Quoted 6 lines
xen/common/compat/grant_table.c +6
-0+ { \ + XEN_GUEST_HANDLE_PARAM(gnttab_ ## name ## _compat_t) h = \ + guest_handle_cast(uop, gnttab_ ## name ## _compat_t); \ + \ + if ( unlikely(!guest_handle_okay(h, count)) ) \ + rc = -EFAULT; \
Same question as for the earlier patch - where's the potential side effect?
Jan
Re: [XEN PATCH 2/3] xen/gnttab: address violations of MISRA C Rule 13.6
Quoted 26 lines · Jan Beulich
Quoted 4 lines · Federico Serafini
xen/common/compat/grant_table.c +0
-0@@ -78,12 +78,15 @@ int compat_grant_table_op( cmd_op = cmd;xen/common/compat/grant_table.c int compat_grant_table_op( · line 82
Quoted 10 lines
xen/common/compat/grant_table.c +2
-6switch ( cmd_op ) { -#define CASE (name) \ - case GNTTABOP_##name: \ - if ( unlikely(!guest_handle_okay(guest_handle_cast(uop, \ - gnttab_##name##_compat_t), \ - count)) ) \ - rc = -EFAULT; \ +#define CASE (name) \ + case GNTTABOP_ ## name: \Why the re-indentation? The earlier way was pretty intentional, to match what a non-macroized case label would look like in this switch.
xen/common/compat/grant_table.c int compat_grant_table_op( · line 88
Quoted 6 lines
xen/common/compat/grant_table.c +6
-0+ { \ + XEN_GUEST_HANDLE_PARAM(gnttab_ ## name ## _compat_t) h = \ + guest_handle_cast(uop, gnttab_ ## name ## _compat_t); \ + \ + if ( unlikely(!guest_handle_okay(h, count)) ) \ + rc = -EFAULT; \
Quoted 2 lines
Same question as for the earlier patch - where's the potential side effect?
Leaving aside the re-indentation / readability changes, I think the fix is to move the call to guest_handle_cast out of guest_handle_okay.
Since guest_handle_okay is implemented by calling sizeof on *h.p, I am guessing that passing guest_handle_cast() as h causes problems. I am not sure if there is a side effect, I cannot spot one, but I can see that the nested macros could cause issues to a static analyzer.
PATCH 3/3 automation/eclair: tag Rule 13.6 as clean
In reply to Federico SerafiniUpdate ECLAIR configuration to consider Rule 13.6 as clean:
introducing violations of this rule will cause a failure of the CI pipeline.
--- automation/eclair_analysis/ECLAIR/tagging.ecl | 1 + 1 file changed, 1 insertion(+)
automation/eclair_analysis/ECLAIR/tagging.ecl +1 -0
@@ -60,6 +60,7 @@ MC3R1.R11.6|| MC3R1.R11.7|| MC3R1.R11.9|| MC3R1.R12.5|| +MC3R1.R13.6|| MC3R1.R14.1|| MC3R1.R14.3|| MC3R1.R14.4||
Signature · 1 line
2.34.1
Re: [XEN PATCH 3/3] automation/eclair: tag Rule 13.6 as clean
Quoted 4 lines · Federico Serafini
Update ECLAIR configuration to consider Rule 13.6 as clean:
introducing violations of this rule will cause a failure of the CI pipeline.Signed-off-by Federico Serafini <[email protected]>
With of course the understanding that this patch can only be committed after the last two 13.6 fixes are committed:
Quoted 19 lines
--- automation/eclair_analysis/ECLAIR/tagging.ecl | 1 + 1 file changed, 1 insertion(+)automation/eclair_analysis/ECLAIR/tagging.ecl +1
-0@@ -60,6 +60,7 @@ MC3R1.R11.6|| MC3R1.R11.7|| MC3R1.R11.9|| MC3R1.R12.5|| +MC3R1.R13.6|| MC3R1.R14.1|| MC3R1.R14.3|| MC3R1.R14.4||Signature · 1 line
2.34.1