[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 12/26] hw/i386/x86: Eliminate two if statements in x86_bios_rom_in
From: |
Philippe Mathieu-Daudé |
Subject: |
[PULL 12/26] hw/i386/x86: Eliminate two if statements in x86_bios_rom_init() |
Date: |
Wed, 8 May 2024 19:44:56 +0200 |
From: Bernhard Beschow <shentey@gmail.com>
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>
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Message-ID: <20240430150643.111976-2-shentey@gmail.com>
Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
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 3d5b51e92d..2a4f3ee285 100644
--- a/hw/i386/x86.c
+++ b/hw/i386/x86.c
@@ -1163,9 +1163,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;
@@ -1182,9 +1180,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.41.0
- [PULL 03/26] hw/hppa/machine: Replace g_memdup() by g_memdup2(), (continued)
- [PULL 03/26] hw/hppa/machine: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2024/05/08
- [PULL 06/26] system/physmem: Replace qemu_mutex_lock() calls with QEMU_LOCK_GUARD, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 02/26] target/ppc: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2024/05/08
- [PULL 07/26] system/physmem: Propagate AddressSpace to MapClient helpers, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 13/26] hw/i386: Have x86_bios_rom_init() take X86MachineState rather than MachineState, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 09/26] hw/i386/pc: Allow to compile without CONFIG_FDC_ISA, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 04/26] hw/ppc/spapr_pci: Replace g_memdup() by g_memdup2(), Philippe Mathieu-Daudé, 2024/05/08
- [PULL 05/26] hw/remote/vfio-user: Fix config space access byte order, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 12/26] hw/i386/x86: Eliminate two if statements in x86_bios_rom_init(),
Philippe Mathieu-Daudé <=
- [PULL 14/26] hw/i386/x86: Don't leak "isa-bios" memory regions, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 10/26] hw/i386/Kconfig: Allow to compile Q35 without FDC_ISA, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 08/26] system/physmem: Per-AddressSpace bounce buffering, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 11/26] hw/i386: Add the possibility to use i440fx and isapc without FDC, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 15/26] hw/usb/dev-network: Remove unused struct 'rndis_config_parameter', Philippe Mathieu-Daudé, 2024/05/08
- [PULL 16/26] hw/gpio: Handle clock migration in STM32L4x5 gpios, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 17/26] hw/ppc: Deprecate 'ref405ep' machine and 405 CPUs, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 18/26] hw/loongarch: move memory map to boot.c, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 19/26] hw/loongarch/virt: Fix memory leak, Philippe Mathieu-Daudé, 2024/05/08
- [PULL 20/26] hw/loongarch: Rename LOONGARCH_MACHINE with LOONGARCH_VIRT_MACHINE, Philippe Mathieu-Daudé, 2024/05/08