Misc MISRA fixes from Arm allcode report
Subsystems (2)
cover Misc MISRA fixes from Arm allcode report
The number of violations for clean rules drops from 22 down to 5:
https://gitlab.com/xen-project/people/morzel/xen/-/pipelines/2423381226
Michal Orzel (3):
xen/arm: acpi: Rename local acpi_size to avoid shadowing typedef xen/arm: pci: Narrow scope of file-local symbols xen/arm: vpci: Move content of xen/arch/arm/vpci.h to arch header
xen/arch/arm/acpi/domain_build.c | 14 +++++----- xen/arch/arm/domain.c | 2 +- xen/arch/arm/include/asm/vpci.h | 18 +++++++++++++ xen/arch/arm/pci/pci-host-common.c | 4 +-- xen/arch/arm/pci/pci-host-rcar4.c | 5 ++-- xen/arch/arm/pci/pci-host-zynqmp.c | 2 +- xen/arch/arm/vpci.h | 42 ------------------------------ 7 files changed, 32 insertions(+), 55 deletions(-) delete mode 100644 xen/arch/arm/vpci.h
Signature · 1 line
2.43.0
PATCH 1/3 xen/arm: acpi: Rename local acpi_size to avoid shadowing typedef
Rename the local variable acpi_size to acpi_len in estimate_acpi_efi_size() to avoid shadowing the acpi_size typedef from xen/include/acpi/actypes.h.
This resolves a MISRA C Rule 5.6 violation.
--- xen/arch/arm/acpi/domain_build.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-)
xen/arch/arm/acpi/domain_build.c +7 -7
@@ -447,18 +447,18 @@ static int __init acpi_create_fadt(struct domain *d, struct membank tbl_add[])static int __init estimate_acpi_efi_size (struct domain *d,const struct kernel_info *kinfo) { -size_t efi_size, acpi_size, madt_size; +size_t efi_size, acpi_len, madt_size;u64 addr;struct acpi_table_rsdp *rsdp_tbl;struct acpi_table_header *table; efi_size =estimate_efi_size (kernel_info_get_mem_const (kinfo)->nr_banks); - acpi_size =ROUNDUP (sizeof (struct acpi_table_fadt ),8 ); - acpi_size +=ROUNDUP (sizeof (struct acpi_table_stao ),8 ); + acpi_len =ROUNDUP (sizeof (struct acpi_table_fadt ),8 ); + acpi_len +=ROUNDUP (sizeof (struct acpi_table_stao ),8 ); madt_size =gic_get_hwdom_madt_size (d); - acpi_size +=ROUNDUP (madt_size,8 ); + acpi_len +=ROUNDUP (madt_size,8 ); addr =acpi_os_get_root_pointer ();if ( !addr )
@@ -484,12 +484,12 @@ static int __init estimate_acpi_efi_size(struct domain *d, }/* Add place for STAO table in XSDT table */ - acpi_size +=ROUNDUP (table->length +sizeof (u64),8 ); + acpi_len +=ROUNDUP (table->length +sizeof (u64),8 );acpi_os_unmap_memory (table,sizeof (struct acpi_table_header )); - acpi_size +=ROUNDUP (sizeof (struct acpi_table_rsdp ),8 ); + acpi_len +=ROUNDUP (sizeof (struct acpi_table_rsdp ),8 ); d->arch.efi_acpi_len =PAGE_ALIGN (ROUNDUP (efi_size,8 ) - +ROUNDUP (acpi_size,8 )); + +ROUNDUP (acpi_len,8 ));return 0 ; }
Signature · 1 line
2.43.0
Re: [PATCH 1/3] xen/arm: acpi: Rename local acpi_size to avoid shadowing typedef
Hi Michal,
Quoted 3 lines · Michal Orzel
Rename the local variable
acpi_sizetoacpi_leninestimate_acpi_efi_size()to avoid shadowing theacpi_sizetypedef fromxen/include/acpi/actypes.h.
We can't change actypes.h but I wish they were suffixing the types with _t.
Quoted 4 lines
This resolves a MISRA C Rule 5.6 violation.
Signed-off-by Michal Orzel <[email protected]>
Cheers,
Signature · 1 line
Julien Grall
PATCH 2/3 xen/arm: pci: Narrow scope of file-local symbols
In reply to Michal OrzelMake pci_alloc_host_bridge() and pci_add_host_bridge() in pci-host-common.c, rcar4_pcie_ops and rcar4_pcie_child_ops in pci-host-rcar4.c, and nwl_pcie_ops in pci-host-zynqmp.c static, as they are only used within their respective translation units.
Also include pci-host-rcar4.h in pci-host-rcar4.c so that the declarations of its externally visible functions are visible at the point of definition.
This resolves MISRA C Rule 8.4 violations.
--- xen/arch/arm/pci/pci-host-common.c | 4 ++-- xen/arch/arm/pci/pci-host-rcar4.c | 5 +++-- xen/arch/arm/pci/pci-host-zynqmp.c | 2 +- 3 files changed, 6 insertions(+), 5 deletions(-)
xen/arch/arm/pci/pci-host-common.c +2 -2
@@ -158,7 +158,7 @@ err_exit:return NULL ; } -struct pci_host_bridge *pci_alloc_host_bridge (void ) +static struct pci_host_bridge *pci_alloc_host_bridge (void ) { struct pci_host_bridge *bridge = xzalloc(struct pci_host_bridge);
@@ -170,7 +170,7 @@ struct pci_host_bridge *pci_alloc_host_bridge(void)return bridge; } -void pci_add_host_bridge (struct pci_host_bridge *bridge) +static void pci_add_host_bridge (struct pci_host_bridge *bridge) {list_add_tail (&bridge->node, &pci_host_bridges); }
xen/arch/arm/pci/pci-host-rcar4.c +3 -2
@@ -13,6 +13,7 @@#include <asm/pci.h> #include "pci-designware.h" +#include "pci-host-rcar4.h" #define RCAR4_DWC_VERSION 0x520A
@@ -61,7 +62,7 @@ static int __init rcar4_child_cfg_reg_index(struct dt_device_node *np) }/* ECAM ops */ -const struct pci_ecam_ops rcar4_pcie_ops = { +static const struct pci_ecam_ops rcar4_pcie_ops = { .bus_shift =20 , .cfg_reg_index = rcar4_cfg_reg_index, .pci_ops = {
@@ -73,7 +74,7 @@ const struct pci_ecam_ops rcar4_pcie_ops = { } }; -const struct pci_ecam_ops rcar4_pcie_child_ops = { +static const struct pci_ecam_ops rcar4_pcie_child_ops = { .bus_shift =20 , .cfg_reg_index = rcar4_child_cfg_reg_index, .pci_ops = {
xen/arch/arm/pci/pci-host-zynqmp.c +1 -1
@@ -27,7 +27,7 @@ static int __init nwl_cfg_reg_index(struct dt_device_node *np) }/* ECAM ops */ -const struct pci_ecam_ops nwl_pcie_ops = { +static const struct pci_ecam_ops nwl_pcie_ops = { .bus_shift =20 , .cfg_reg_index = nwl_cfg_reg_index, .pci_ops = {
Signature · 1 line
2.43.0
Re: [PATCH 2/3] xen/arm: pci: Narrow scope of file-local symbols
Hi Michal,
Quoted 5 lines · Michal Orzel
Make
pci_alloc_host_bridge()andpci_add_host_bridge()inpci-host-common.c,rcar4_pcie_opsandrcar4_pcie_child_opsinpci-host-rcar4.c, andnwl_pcie_opsinpci-host-zynqmp.cstatic, as they are only used within their respective translation units.
Quoted 7 lines
Also include
pci-host-rcar4.hinpci-host-rcar4.cso that the declarations of its externally visible functions are visible at the point of definition.This resolves MISRA C Rule 8.4 violations.
Signed-off-by Michal Orzel <[email protected]>
Cheers,
Signature · 1 line
Julien Grall
PATCH 3/3 xen/arm: vpci: Move content of xen/arch/arm/vpci.h to arch header
In reply to Michal OrzelMove domain_vpci_init() and domain_vpci_get_num_mmio_handlers() declarations from the private xen/arch/arm/vpci.h into the public xen/arch/arm/include/asm/vpci.h, and remove the now redundant private header.
Update domain.c to include <asm/vpci.h> instead of the removed private header.
This ensures the declarations are visible where the functions are defined, resolving a MISRA C Rule 8.4 violation.
---
I'm moving a file with GPL2+ license to a file with GPL2-only. I consider this ok in this case becase the copyright on a file with just prototypes does not make any sense and a license text was most likely blindly copy-pasted like for most of the files in that era.
--- xen/arch/arm/domain.c | 2 +- xen/arch/arm/include/asm/vpci.h | 18 ++++++++++++++ xen/arch/arm/vpci.h | 42 --------------------------------- 3 files changed, 19 insertions(+), 43 deletions(-) delete mode 100644 xen/arch/arm/vpci.h
xen/arch/arm/domain.c +1 -1
@@ -31,10 +31,10 @@#include <asm/tee/tee.h> #include <asm/vfp.h> #include <asm/vgic.h> +#include <asm/vpci.h> #include <asm/vpsci.h> #include <asm/vtimer.h> -#include "vpci.h" #include "vuart.h" DEFINE_PER_CPU(struct vcpu *, curr_vcpu);
xen/arch/arm/include/asm/vpci.h +18 -0
@@ -2,6 +2,9 @@#ifndef ARM_VPCI_H #define ARM_VPCI_H +struct domain ; + +#ifdef CONFIG_HAS_VPCI /* Arch-specific MSI data for vPCI. */ struct vpci_arch_msi { };
@@ -10,4 +13,19 @@ struct vpci_arch_msi {struct vpci_arch_msix_entry { }; + +int domain_vpci_init (struct domain *d); +unsigned int domain_vpci_get_num_mmio_handlers (struct domain *d); +#else +static inline int domain_vpci_init (struct domain *d) +{ +return 0 ; +} + +static inline unsigned int domain_vpci_get_num_mmio_handlers (struct domain *d) +{ +return 0 ; +} +#endif /* CONFIG_HAS_VPCI */ +#endif /* ARM_VPCI_H */
xen/arch/arm/vpci.h deleted +0 -42
42 lines not on this page · raw message
Signature · 1 line
2.43.0
Re: [PATCH 3/3] xen/arm: vpci: Move content of xen/arch/arm/vpci.h to arch header
Hi Michal,
Quoted 4 lines · Michal Orzel
Move
domain_vpci_init()anddomain_vpci_get_num_mmio_handlers()declarations from the privatexen/arch/arm/vpci.hinto the publicxen/arch/arm/include/asm/vpci.h, and remove the now redundant private header.
Can you provide a brief explanation why we don't couldn't include "vpci.h" from "arch/arm/vpci.c"? Such approach would ...
Quoted 7 lines
Update
domain.cto include <asm/vpci.h> instead of the removed private header.This ensures the declarations are visible where the functions are defined, resolving a MISRA C Rule 8.4 violation.
Quoted 6 lines
Signed-off-by Michal Orzel <[email protected]>---
I'm moving a file with GPL2+ license to a file with GPL2-only. I consider this ok in this case becase the copyright on a file with just prototypes does not make any sense and a license text was most likely blindly copy-pasted like for most of the files in that era.
... avoid the licensing discussion. I am in the opinion that it is ok to move from GPLv2+ to GPLv2 because the license says "either version 2 of the License, or (at your option) any later version". But I remember not everyone agrees on this interpretation and we never solved the discussion on whether we need to request permission from the original copyright holder.
Alternatively, I see this file was only modified by two companies (EPAM and Arm). I see one employee of each company are already CCed. So you could confirm with them if the change is fine.
Cheers,
Signature · 1 line
Julien Grall
Re: [PATCH 3/3] xen/arm: vpci: Move content of xen/arch/arm/vpci.h to arch header
+Rahul
Quoted 10 lines · Julien Grall
Hi Michal,
Quoted 4 lines · Michal Orzel
Move
domain_vpci_init()anddomain_vpci_get_num_mmio_handlers()declarations from the privatexen/arch/arm/vpci.hinto the publicxen/arch/arm/include/asm/vpci.h, and remove the now redundant private header.Can you provide a brief explanation why we don't couldn't include "
vpci.h" from "arch/arm/vpci.c"? Such approach would ...
Yes, we could but I think it's better not to use local headers if the main ones under include already exists. This matches the x86.
Quoted 22 lines
Quoted 8 lines
Update
domain.cto include <asm/vpci.h> instead of the removed private header.This ensures the declarations are visible where the functions are defined, resolving a MISRA C Rule 8.4 violation.
Quoted 6 lines
Signed-off-by Michal Orzel <[email protected]>---
I'm moving a file with GPL2+ license to a file with GPL2-only. I consider this ok in this case becase the copyright on a file with just prototypes does not make any sense and a license text was most likely blindly copy-pasted like for most of the files in that era.... avoid the licensing discussion. I am in the opinion that it is ok to move from GPLv2+ to GPLv2 because the license says "either version 2 of the License, or (at your option) any later version". But I remember not everyone agrees on this interpretation and we never solved the discussion on whether we need to request permission from the original copyright holder.
Quoted 3 lines
Alternatively, I see this file was only modified by two companies (EPAM and Arm). I see one employee of each company are already CCed. So you could confirm with them if the change is fine.
The header was introduced by Rahul Singh from Arm and Oleksandr Andruschenko from EPAM. @Rahul, @Bertrand, @Volodymyr - are you ok to move this file to GPL2-only?
~Michal
Volodymyr Babchuk
Acked-byRe: [PATCH 3/3] xen/arm: vpci: Move content of xen/arch/arm/vpci.h to arch header
Hi Michal,
Quoted 38 lines · Michal
+Rahul
Quoted 10 lines · Julien Grall
Hi Michal,
Quoted 4 lines · Michal Orzel
Move
domain_vpci_init()anddomain_vpci_get_num_mmio_handlers()declarations from the privatexen/arch/arm/vpci.hinto the publicxen/arch/arm/include/asm/vpci.h, and remove the now redundant private header.Can you provide a brief explanation why we don't couldn't include "
vpci.h" from "arch/arm/vpci.c"? Such approach would ...Yes, we could but I think it's better not to use local headers if the main ones under include already exists. This matches the x86.
Quoted 22 lines
Quoted 8 lines
Update
domain.cto include <asm/vpci.h> instead of the removed private header.This ensures the declarations are visible where the functions are defined, resolving a MISRA C Rule 8.4 violation.
Quoted 6 lines
Signed-off-by Michal Orzel <[email protected]>---
I'm moving a file with GPL2+ license to a file with GPL2-only. I consider this ok in this case becase the copyright on a file with just prototypes does not make any sense and a license text was most likely blindly copy-pasted like for most of the files in that era.... avoid the licensing discussion. I am in the opinion that it is ok to move from GPLv2+ to GPLv2 because the license says "either version 2 of the License, or (at your option) any later version". But I remember not everyone agrees on this interpretation and we never solved the discussion on whether we need to request permission from the original copyright holder.
Quoted 6 lines
Quoted 3 lines
Alternatively, I see this file was only modified by two companies (EPAM and Arm). I see one employee of each company are already CCed. So you could confirm with them if the change is fine.
The header was introduced by Rahul Singh from Arm and Oleksandr Andruschenko from EPAM. @Rahul, @Bertrand, @Volodymyr - are you ok to move this file to GPL2-only?
Yes, I'm okay with that:
Signature · 1 line
WBR, Volodymyr
Re: [PATCH 3/3] xen/arm: vpci: Move content of xen/arch/arm/vpci.h to arch header
In reply to Michal OrzelHi Michal,
Quoted 20 lines · Michal Orzel
Move
domain_vpci_init()anddomain_vpci_get_num_mmio_handlers()declarations from the privatexen/arch/arm/vpci.hinto the publicxen/arch/arm/include/asm/vpci.h, and remove the now redundant private header.Update
domain.cto include <asm/vpci.h> instead of the removed private header.This ensures the declarations are visible where the functions are defined, resolving a MISRA C Rule 8.4 violation.
Signed-off-by Michal Orzel <[email protected]>---
I'm moving a file with GPL2+ license to a file with GPL2-only. I consider this ok in this case becase the copyright on a file with just prototypes does not make any sense and a license text was most likely blindly copy-pasted like for most of the files in that era.
---
Quoted 5 lines
xen/arch/arm/domain.c | 2 +- xen/arch/arm/include/asm/vpci.h | 18 ++++++++++++++ xen/arch/arm/vpci.h | 42 --------------------------------- 3 files changed, 19 insertions(+), 43 deletions(-)delete mode 100644
xen/arch/arm/vpci.h
I’m ok for the move, you need to chase EPAM approval