[PATCH v1 07/59] unicore32/softmmu.c: remove 'do_fault' label in get_phys_addr_ucv2()

Daniel Henrique Barboza posted 59 patches 6 years, 1 month ago
Maintainers: Aurelien Jarno <aurelien@aurel32.net>, Max Reitz <mreitz@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, Greg Kurz <groug@kaod.org>, Jason Wang <jasowang@redhat.com>, Corey Minyard <minyard@acm.org>, Aleksandar Markovic <amarkovic@wavecomp.com>, Kevin Wolf <kwolf@redhat.com>, Stefan Hajnoczi <stefanha@redhat.com>, David Hildenbrand <david@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, David Gibson <david@gibson.dropbear.id.au>, "Daniel P. Berrangé" <berrange@redhat.com>, Laurent Vivier <laurent@vivier.eu>, Wen Congyang <wencongyang2@huawei.com>, "Michael S. Tsirkin" <mst@redhat.com>, Cornelia Huck <cohuck@redhat.com>, "Richard W.M. Jones" <rjones@redhat.com>, Jeff Cody <codyprime@gmail.com>, Riku Voipio <riku.voipio@iki.fi>, Stefan Weil <sw@weilnetz.de>, Michael Roth <mdroth@linux.vnet.ibm.com>, Richard Henderson <rth@twiddle.net>, Eduardo Habkost <ehabkost@redhat.com>, Yuval Shaia <yuval.shaia.ml@gmail.com>, Fam Zheng <fam@euphon.net>, Xie Changlong <xiechanglong.d@gmail.com>, Marcel Apfelbaum <marcel.apfelbaum@gmail.com>, Halil Pasic <pasic@linux.ibm.com>, Juan Quintela <quintela@redhat.com>, John Snow <jsnow@redhat.com>, Dmitry Fleytman <dmitry.fleytman@gmail.com>, Pavel Dovgalyuk <pavel.dovgaluk@ispras.ru>, Christian Borntraeger <borntraeger@de.ibm.com>, Aleksandar Rikalo <aleksandar.rikalo@rt-rk.com>, "Gonglei (Arei)" <arei.gonglei@huawei.com>, Guan Xuetao <gxt@mprc.pku.edu.cn>, Paolo Bonzini <pbonzini@redhat.com>
[PATCH v1 07/59] unicore32/softmmu.c: remove 'do_fault' label in get_phys_addr_ucv2()
Posted by Daniel Henrique Barboza 6 years, 1 month ago
'do_fault' is a label that executes 'return code'. The 'code'
variable is an integer that is set to zero, then in all instances
it is set to another value right before 'do_fault'.

We can get rid of both the label and the variable to make
the code a bit cleaner.

CC: Guan Xuetao <gxt@mprc.pku.edu.cn>
Signed-off-by: Daniel Henrique Barboza <danielhb413@gmail.com>
---
 target/unicore32/softmmu.c | 23 +++++++----------------
 1 file changed, 7 insertions(+), 16 deletions(-)

diff --git a/target/unicore32/softmmu.c b/target/unicore32/softmmu.c
index cbdaa500b7..3373400cba 100644
--- a/target/unicore32/softmmu.c
+++ b/target/unicore32/softmmu.c
@@ -125,7 +125,6 @@ static int get_phys_addr_ucv2(CPUUniCore32State *env, uint32_t address,
         target_ulong *page_size)
 {
     CPUState *cs = env_cpu(env);
-    int code;
     uint32_t table;
     uint32_t desc;
     uint32_t phys_addr;
@@ -135,13 +134,11 @@ static int get_phys_addr_ucv2(CPUUniCore32State *env, uint32_t address,
     table = env->cp0.c2_base & 0xfffff000;
     table |= (address >> 20) & 0xffc;
     desc = ldl_phys(cs->as, table);
-    code = 0;
     switch (PAGETABLE_TYPE(desc)) {
     case 3:
         /* Superpage  */
         if (!(desc & UC32_PAGETABLE_EXIST)) {
-            code = 0x0b; /* superpage miss */
-            goto do_fault;
+            return 0x0b; /* superpage miss */
         }
         phys_addr = (desc & 0xffc00000) | (address & 0x003fffff);
         *page_size = SUPERPAGE_SIZE;
@@ -152,8 +149,7 @@ static int get_phys_addr_ucv2(CPUUniCore32State *env, uint32_t address,
             DPRINTF("PGD address %x, desc %x\n", table, desc);
         }
         if (!(desc & UC32_PAGETABLE_EXIST)) {
-            code = 0x05; /* second pagetable miss */
-            goto do_fault;
+            return 0x05; /* second pagetable miss */
         }
         table = (desc & 0xfffff000) | ((address >> 10) & 0xffc);
         desc = ldl_phys(cs->as, table);
@@ -162,8 +158,7 @@ static int get_phys_addr_ucv2(CPUUniCore32State *env, uint32_t address,
             DPRINTF("PTE address %x, desc %x\n", table, desc);
         }
         if (!(desc & UC32_PAGETABLE_EXIST)) {
-            code = 0x08; /* page miss */
-            goto do_fault;
+            return 0x08; /* page miss */
         }
         switch (PAGETABLE_TYPE(desc)) {
         case 0:
@@ -185,8 +180,7 @@ static int get_phys_addr_ucv2(CPUUniCore32State *env, uint32_t address,
         *prot |= PAGE_READ;
     } else {
         if (is_user && (access_type == 0)) {
-            code = 0x11; /* access unreadable area */
-            goto do_fault;
+            return 0x11; /* access unreadable area */
         }
     }
 
@@ -194,8 +188,7 @@ static int get_phys_addr_ucv2(CPUUniCore32State *env, uint32_t address,
         *prot |= PAGE_WRITE;
     } else {
         if (is_user && (access_type == 1)) {
-            code = 0x12; /* access unwritable area */
-            goto do_fault;
+            return 0x12; /* access unwritable area */
         }
     }
 
@@ -203,13 +196,11 @@ static int get_phys_addr_ucv2(CPUUniCore32State *env, uint32_t address,
         *prot |= PAGE_EXEC;
     } else {
         if (is_user && (access_type == 2)) {
-            code = 0x13; /* access unexecutable area */
-            goto do_fault;
+            return 0x13; /* access unexecutable area */
         }
     }
 
-do_fault:
-    return code;
+    return 0;
 }
 
 bool uc32_cpu_tlb_fill(CPUState *cs, vaddr address, int size,
-- 
2.24.1