Patchwork [V2,20/20] pci: convert goto into scope in bridge_filter

login
register
mail settings
Submitter Isaku Yamahata
Date Nov. 13, 2009, 4:29 a.m.
Message ID <1258086596-3584-21-git-send-email-yamahata@valinux.co.jp>
Download mbox | patch
Permalink /patch/38337/
State New
Headers show

Comments

Isaku Yamahata - Nov. 13, 2009, 4:29 a.m.
From: Michael S. Tsirkin <mst@redhat.com>

goto into scope is evil. rearrange pci_bridge_filter
so that we always go to end of function on error.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Acked-by: Isaku Yamahata <yamahata@valinux.co.jp>
---
 hw/pci.c |   13 +++++++------
 1 files changed, 7 insertions(+), 6 deletions(-)

Patch

diff --git a/hw/pci.c b/hw/pci.c
index 7d930eb..a06003e 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -716,13 +716,14 @@  static void pci_bridge_filter(PCIDevice *d, pcibus_t *addr, pcibus_t *size,
     }
 
     if (base > limit) {
-    no_map:
-        *addr = PCI_BAR_UNMAPPED;
-        *size = 0;
-    } else {
-        *addr = base;
-        *size = limit - base + 1;
+        goto no_map;
     }
+    *addr = base;
+    *size = limit - base + 1;
+    return;
+no_map:
+    *addr = PCI_BAR_UNMAPPED;
+    *size = 0;
 }
 
 static pcibus_t pci_bar_address(PCIDevice *d,