[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] Re: [XEN PATCH 05/11] drivers/pci: move variable definitions to address MISRA C:2012 Rule 2.1
On Wed, 2 Aug 2023, Nicola Vetrini wrote: > Variable declarations between a switch statement guard and before > any case label are unreachable code, and hence violate Rule 2.1: > "A project shall not contain unreachable code". > > Therefore the variable declarations are moved in the smallest enclosing > scope, near other variable definitions. > > Signed-off-by: Nicola Vetrini <nicola.vetrini@xxxxxxxxxxx> > --- > xen/drivers/passthrough/pci.c | 10 ++++------ > 1 file changed, 4 insertions(+), 6 deletions(-) > > diff --git a/xen/drivers/passthrough/pci.c b/xen/drivers/passthrough/pci.c > index 33452791a8..3f5fa5beef 100644 > --- a/xen/drivers/passthrough/pci.c > +++ b/xen/drivers/passthrough/pci.c > @@ -315,6 +315,7 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg, > u8 bus, u8 devfn) > struct pci_dev *pdev; > unsigned int pos; > int rc; > + unsigned int cap, sec_bus, sub_bus; > > list_for_each_entry ( pdev, &pseg->alldevs_list, alldevs_list ) > if ( pdev->bus == bus && pdev->devfn == devfn ) > @@ -343,8 +344,6 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg, > u8 bus, u8 devfn) > /* update bus2bridge */ > switch ( pdev->type = pdev_type(pseg->nr, bus, devfn) ) > { > - unsigned int cap, sec_bus, sub_bus; sub_bus and sec_bus could go under case DEV_TYPE_LEGACY_PCI_BRIDGE cap could go under case DEV_TYPE_PCIe_ENDPOINT > case DEV_TYPE_PCIe2PCI_BRIDGE: > case DEV_TYPE_LEGACY_PCI_BRIDGE: > sec_bus = pci_conf_read8(pdev->sbdf, PCI_SECONDARY_BUS); > @@ -424,11 +423,11 @@ static struct pci_dev *alloc_pdev(struct pci_seg *pseg, > u8 bus, u8 devfn) > > static void free_pdev(struct pci_seg *pseg, struct pci_dev *pdev) > { > + unsigned int sec_bus, sub_bus; > + > /* update bus2bridge */ > switch ( pdev->type ) > { > - unsigned int sec_bus, sub_bus; They could go under case DEV_TYPE_LEGACY_PCI_BRIDGE > case DEV_TYPE_PCIe2PCI_BRIDGE: > case DEV_TYPE_LEGACY_PCI_BRIDGE: > sec_bus = pci_conf_read8(pdev->sbdf, PCI_SECONDARY_BUS); > @@ -1555,11 +1554,10 @@ int iommu_do_pci_domctl( > u8 bus, devfn; > int ret = 0; > uint32_t machine_sbdf; > + unsigned int flags; > > switch ( domctl->cmd ) > { > - unsigned int flags; it could go under case XEN_DOMCTL_test_assign_device > case XEN_DOMCTL_get_device_group: > { > u32 max_sdevs; > -- > 2.34.1 >
|
![]() |
Lists.xenproject.org is hosted with RackSpace, monitoring our |