[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [XEN PATCH 05/11] drivers/pci: move variable definitions to address MISRA C:2012 Rule 2.1
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; - 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; - 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; - case XEN_DOMCTL_get_device_group: { u32 max_sdevs; -- 2.34.1
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |