x86/emul: Adjust get_stub() to avoid shadowing an outer variable
PATCH 1/1 x86/emul: Adjust get_stub() to avoid shadowing an outer variable
Eclair reports a violation of MISRA Rule 5.3.
get_stub() has a local ptr variable which genuinely shadows x86_emul_rmw()'s parameter of the same name. The logic is correct, so the easiest fix is to rename one of variables.
With this addressed, Rule 5.3 is clean, so mark it as such.
---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Stefano Stabellini <[email protected]>
CC: [email protected] <[email protected]>
https://gitlab.com/xen-project/people/andyhhp/xen/-/pipelines/1545385154
--- automation/eclair_analysis/ECLAIR/tagging.ecl | 1 + xen/arch/x86/x86_emulate/private.h | 10 +++++----- 2 files changed, 6 insertions(+), 5 deletions(-)
automation/eclair_analysis/ECLAIR/tagging.ecl +1 -0
@@ -35,6 +35,7 @@ MC3R1.R4.1|| MC3R1.R4.2|| MC3R1.R5.1|| MC3R1.R5.2|| +MC3R1.R5.3|| MC3R1.R5.4|| MC3R1.R5.6|| MC3R1.R6.1||
xen/arch/x86/x86_emulate/private.h +5 -5
@@ -672,19 +672,19 @@ amd_like(const struct x86_emulate_ctxt *ctxt)# include <asm/uaccess.h> # define get_stub (stb) ({ \ - void *ptr; \ + void *_ptr; \ BUILD_BUG_ON(STUB_BUF_SIZE / 2 < MAX_INST_LEN + 1); \ ASSERT(!(stb).ptr); \ (stb).addr = this_cpu(stubs.addr) + STUB_BUF_SIZE / 2; \ (stb).ptr = map_domain_page(_mfn(this_cpu(stubs.mfn))) + \ ((stb).addr & ~PAGE_MASK); \ - ptr = memset((stb).ptr, 0xcc, STUB_BUF_SIZE / 2); \ + _ptr = memset((stb).ptr, 0xcc, STUB_BUF_SIZE / 2); \ if ( cpu_has_xen_ibt ) \ { \ - place_endbr64(ptr); \ - ptr += 4; \ + place_endbr64(_ptr); \ + _ptr += 4; \ } \ - ptr; \ + _ptr; \ })# define put_stub (stb) ({ \
base-commit: d2bbb0d4554aa08649985d790317ba78f0db22ff
Signature · 1 line
2.39.5
Quoted 9 lines · Andrew Cooper
Eclair reports a violation of MISRA Rule 5.3.
get_stub()has a local ptr variable which genuinely shadows x86_emul_rmw()'s parameter of the same name. The logic is correct, so the easiest fix is to rename one of variables.With this addressed, Rule 5.3 is clean, so mark it as such.
Signed-off-by Andrew Cooper <[email protected]>
Albeit you certainly know ...
xen/arch/x86/x86_emulate/private.h amd_like(const struct x86_emulate_ctxt *ctxt) · line 675
Quoted 8 lines
xen/arch/x86/x86_emulate/private.h +1
-1@@ -672,19 +672,19 @@ amd_like(const struct x86_emulate_ctxt *ctxt)# include <asm/uaccess.h> # define get_stub (stb) ({ \ - void *ptr; \ + void *_ptr; \
... what I think of non-file-scope variable names starting with an underscore.
Jan