diff mbox series

[XEN,v3,2/2] x86/setup: address MISRA C:2012 Rule 5.3 and 8.3

Message ID 05ff36ef9e1838ac782201998f49f6f56f78332a.1691488505.git.nicola.vetrini@bugseng.com (mailing list archive)
State New, archived
Headers show
Series x86: address MISRA C:2012 Rule 5.3 and 8.3 | expand

Commit Message

Nicola Vetrini Aug. 8, 2023, 12:22 p.m. UTC
The parameters in the function declaration 'construct_dom0' violate
Rule 8.3:
"All declarations of an object or function shall use the same names
and type qualifiers", but also cause shadowing inside the declaration
scope with the variable "static struct file __initdata kernel;" in
'xen/common/efi/boot.c'. Renaming the parameters in the declaration
resolves both issues

The local variable 'mask' is removed because it shadows the homonymous
variable defined in an outer scope. There's no change to the semantics since
the last use of this variable is in the scope touched by this commit.

No functional changes.

Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>
---
Changes in v2:
- Clarified commit message

As mentioned in the preivious iteration's thread:
the declaration itself is a scope and shadowing can happen, as in:

int x;
void f(int x, int arr[x]);

Now, the example is a bit contrived, but the fact that the rule does not list any
exception motivates the declaration of 'construct_dom0' being considered a
violation.
---
 xen/arch/x86/include/asm/setup.h | 2 +-
 xen/arch/x86/setup.c             | 3 +--
 2 files changed, 2 insertions(+), 3 deletions(-)

Comments

Jan Beulich Aug. 8, 2023, 1:27 p.m. UTC | #1
On 08.08.2023 14:22, Nicola Vetrini wrote:
> The parameters in the function declaration 'construct_dom0' violate
> Rule 8.3:
> "All declarations of an object or function shall use the same names
> and type qualifiers", but also cause shadowing inside the declaration
> scope with the variable "static struct file __initdata kernel;" in
> 'xen/common/efi/boot.c'. Renaming the parameters in the declaration
> resolves both issues
> 
> The local variable 'mask' is removed because it shadows the homonymous
> variable defined in an outer scope. There's no change to the semantics since
> the last use of this variable is in the scope touched by this commit.
> 
> No functional changes.
> 
> Signed-off-by: Nicola Vetrini <nicola.vetrini@bugseng.com>
> Reviewed-by: Stefano Stabellini <sstabellini@kernel.org>

Acked-by: Jan Beulich <jbeulich@suse.com>
diff mbox series

Patch

diff --git a/xen/arch/x86/include/asm/setup.h b/xen/arch/x86/include/asm/setup.h
index 51fce66607..b0e6a39e23 100644
--- a/xen/arch/x86/include/asm/setup.h
+++ b/xen/arch/x86/include/asm/setup.h
@@ -33,7 +33,7 @@  static inline void vesa_init(void) {};
 
 int construct_dom0(
     struct domain *d,
-    const module_t *kernel, unsigned long kernel_headroom,
+    const module_t *image, unsigned long image_headroom,
     module_t *initrd,
     const char *cmdline);
 void setup_io_bitmap(struct domain *d);
diff --git a/xen/arch/x86/setup.c b/xen/arch/x86/setup.c
index 2dbe9857aa..80ae973d64 100644
--- a/xen/arch/x86/setup.c
+++ b/xen/arch/x86/setup.c
@@ -1577,8 +1577,7 @@  void __init noreturn __start_xen(unsigned long mbi_p)
         s = map_s;
         if ( s < map_e )
         {
-            uint64_t mask = (1UL << L2_PAGETABLE_SHIFT) - 1;
-
+            mask = (1UL << L2_PAGETABLE_SHIFT) - 1;
             map_s = (s + mask) & ~mask;
             map_e &= ~mask;
             init_boot_pages(map_s, map_e);