diff mbox series

x86/emul: Adjust get_stub() to avoid shadowing an outer variable

Message ID 20241115132742.2155370-1-andrew.cooper3@citrix.com (mailing list archive)
State New
Headers show
Series x86/emul: Adjust get_stub() to avoid shadowing an outer variable | expand

Commit Message

Andrew Cooper Nov. 15, 2024, 1:27 p.m. UTC
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 <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Stefano Stabellini <sstabellini@kernel.org>
CC: consulting@bugseng.com <consulting@bugseng.com>

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(-)


base-commit: d2bbb0d4554aa08649985d790317ba78f0db22ff

Comments

Jan Beulich Nov. 15, 2024, 1:44 p.m. UTC | #1
On 15.11.2024 14:27, Andrew Cooper wrote:
> 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 <andrew.cooper3@citrix.com>

Reviewed-by: Jan Beulich <jbeulich@suse.com> # x86

Albeit you certainly know ...

> --- a/xen/arch/x86/x86_emulate/private.h
> +++ b/xen/arch/x86/x86_emulate/private.h
> @@ -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
diff mbox series

Patch

diff --git a/automation/eclair_analysis/ECLAIR/tagging.ecl b/automation/eclair_analysis/ECLAIR/tagging.ecl
index 16e7adb61fe8..9318e5b10ca8 100644
--- a/automation/eclair_analysis/ECLAIR/tagging.ecl
+++ b/automation/eclair_analysis/ECLAIR/tagging.ecl
@@ -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||
diff --git a/xen/arch/x86/x86_emulate/private.h b/xen/arch/x86/x86_emulate/private.h
index 172270a458bd..ef4745f56e27 100644
--- a/xen/arch/x86/x86_emulate/private.h
+++ b/xen/arch/x86/x86_emulate/private.h
@@ -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) ({             \