diff mbox series

[XEN,v2,2/4] x86/mm: remove variable to avoid shadowing

Message ID 734fa59e3f1ee384a5481fb9952f79c8751f04cc.1690788513.git.nicola.vetrini@bugseng.com (mailing list archive)
State Superseded
Headers show
Series x86: address MISRA C:2012 Rule 5.3 | expand

Commit Message

Nicola Vetrini July 31, 2023, 7:33 a.m. UTC
The local variable 'p2mt' shadows a declaration of the same variable
in the enclosing scope, but removing the inner declaration
does not alter the semantics ('p2mt' is an output for the get_gfn
call later on) and this resolves a violation of
MISRA C:2012 Rule 5.3.

Both variables were last introduced by commit
d4f699a0df6cea907c1de5c277500b98c0729685.

No functional changes.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
---
Change in v2:
- removed the innermost p2mt instead of renaming it.
---
 xen/arch/x86/mm/p2m.c | 2 --
 1 file changed, 2 deletions(-)

--
2.34.1

Comments

Jan Beulich July 31, 2023, 11:47 a.m. UTC | #1
On 31.07.2023 09:33, Nicola Vetrini wrote:
> The local variable 'p2mt' shadows a declaration of the same variable
> in the enclosing scope, but removing the inner declaration
> does not alter the semantics ('p2mt' is an output for the get_gfn
> call later on) and this resolves a violation of
> MISRA C:2012 Rule 5.3.
> 
> Both variables were last introduced by commit
> d4f699a0df6cea907c1de5c277500b98c0729685.

No, that commit moved the function (without correcting the issue,
perhaps because of not noticing it, but perhaps also intentionally).

> No functional changes.
> 
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>

With the misleading part of the description either dropped (which
I'd be okay doing while committing) or made meaningful:
Reviewed-by: Jan Beulich <jbeulich@suse.com>

Jan
diff mbox series

Patch

diff --git a/xen/arch/x86/mm/p2m.c b/xen/arch/x86/mm/p2m.c
index 714358f953..f6df35767a 100644
--- a/xen/arch/x86/mm/p2m.c
+++ b/xen/arch/x86/mm/p2m.c
@@ -2439,8 +2439,6 @@  int xenmem_add_to_physmap_one(

     case XENMAPSPACE_gmfn:
     {
-        p2m_type_t p2mt;
-
         gfn = idx;
         mfn = get_gfn_unshare(d, gfn, &p2mt);
         /* If the page is still shared, exit early */