[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v1 07/59] unicore32/softmmu.c: remove 'do_fault' label in get_phy
From: |
Daniel Henrique Barboza |
Subject: |
[PATCH v1 07/59] unicore32/softmmu.c: remove 'do_fault' label in get_phys_addr_ucv2() |
Date: |
Mon, 6 Jan 2020 15:23:33 -0300 |
'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 <address@hidden>
Signed-off-by: Daniel Henrique Barboza <address@hidden>
---
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
- [PATCH v1 17/59] block/dmg.c: remove unneeded 'fail' label in dmg_read_mish_block(), (continued)
- [PATCH v1 17/59] block/dmg.c: remove unneeded 'fail' label in dmg_read_mish_block(), Daniel Henrique Barboza, 2020/01/06
- [PATCH v1 19/59] block/ssh.c: remove unneeded labels, Daniel Henrique Barboza, 2020/01/06
- [PATCH v1 03/59] kvm-all.c: remove unneeded labels, Daniel Henrique Barboza, 2020/01/06
- [PATCH v1 01/59] spapr.c: remove 'out' label in spapr_dt_cas_updates(), Daniel Henrique Barboza, 2020/01/06
- [PATCH v1 02/59] ppc440_bamboo.c: remove label from bamboo_load_device_tree(), Daniel Henrique Barboza, 2020/01/06
- [PATCH v1 04/59] paaudio.c: remove unneeded labels, Daniel Henrique Barboza, 2020/01/06
- [PATCH v1 07/59] unicore32/softmmu.c: remove 'do_fault' label in get_phys_addr_ucv2(),
Daniel Henrique Barboza <=
- [PATCH v1 08/59] chardev/char-mux.c: remove 'send_char' label, Daniel Henrique Barboza, 2020/01/06
- [PATCH v1 10/59] chardev/char-win.c: remove 'fail' label in win_chr_serial_init(), Daniel Henrique Barboza, 2020/01/06
- [PATCH v1 11/59] exec.c: remove 'err' label in ram_block_discard_range(), Daniel Henrique Barboza, 2020/01/06
- [PATCH v1 12/59] virtfs-proxy-helper.c: remove 'err_out' label in setugid(), Daniel Henrique Barboza, 2020/01/06