[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH 3/4] hw/i386/x86: Eliminate two if statements in x86_bios_rom_ini
From: |
Bernhard Beschow |
Subject: |
[PATCH 3/4] hw/i386/x86: Eliminate two if statements in x86_bios_rom_init() |
Date: |
Mon, 22 Apr 2024 22:06:24 +0200 |
Given that memory_region_set_readonly() is a no-op when the readonlyness is
already as requested it is possible to simplify the pattern
if (condition) {
foo(true);
}
to
foo(condition);
which is shorter and allows to see the invariant of the code more easily.
Signed-off-by: Bernhard Beschow <shentey@gmail.com>
---
hw/i386/x86.c | 8 ++------
1 file changed, 2 insertions(+), 6 deletions(-)
diff --git a/hw/i386/x86.c b/hw/i386/x86.c
index ffbda48917..32cd22a4a8 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -1171,9 +1171,7 @@ void x86_bios_rom_init(MachineState *ms, const char
*default_firmware,
load_image_size(filename, ptr, bios_size);
x86_firmware_configure(ptr, bios_size);
} else {
- if (!isapc_ram_fw) {
- memory_region_set_readonly(bios, true);
- }
+ memory_region_set_readonly(bios, !isapc_ram_fw);
ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
if (ret != 0) {
goto bios_error;
@@ -1190,9 +1188,7 @@ void x86_bios_rom_init(MachineState *ms, const char
*default_firmware,
0x100000 - isa_bios_size,
isa_bios,
1);
- if (!isapc_ram_fw) {
- memory_region_set_readonly(isa_bios, true);
- }
+ memory_region_set_readonly(isa_bios, !isapc_ram_fw);
/* map all the bios at the top of memory */
memory_region_add_subregion(rom_memory,
--
2.44.0
- [PATCH 0/4] X86: Alias isa-bios area and clean up, Bernhard Beschow, 2024/04/22
- [PATCH 1/4] hw/i386/pc_sysfw: Remove unused parameter from pc_isa_bios_init(), Bernhard Beschow, 2024/04/22
- [PATCH 2/4] hw/i386/pc_sysfw: Alias rather than copy isa-bios region, Bernhard Beschow, 2024/04/22
- [PATCH 3/4] hw/i386/x86: Eliminate two if statements in x86_bios_rom_init(),
Bernhard Beschow <=
- [PATCH 4/4] hw/i386: Consolidate isa-bios creation, Bernhard Beschow, 2024/04/22
- Re: [PATCH 0/4] X86: Alias isa-bios area and clean up, Bernhard Beschow, 2024/04/24
- Re: [PATCH 0/4] X86: Alias isa-bios area and clean up, Philippe Mathieu-Daudé, 2024/04/25
- Re: [PATCH 0/4] X86: Alias isa-bios area and clean up, Michael S. Tsirkin, 2024/04/25