hw/i386/x86: Eliminate two if statements in x86_bios_rom_init()

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>
This commit is contained in:
Bernhard Beschow 2024-04-30 17:06:38 +02:00 committed by Philippe Mathieu-Daudé
parent 8793d601f3
commit 014dbdac87

View File

@ -1163,9 +1163,7 @@ void x86_bios_rom_init(MachineState *ms, const char *default_firmware,
load_image_size(filename, ptr, bios_size); load_image_size(filename, ptr, bios_size);
x86_firmware_configure(ptr, bios_size); x86_firmware_configure(ptr, bios_size);
} else { } else {
if (!isapc_ram_fw) { memory_region_set_readonly(bios, !isapc_ram_fw);
memory_region_set_readonly(bios, true);
}
ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1); ret = rom_add_file_fixed(bios_name, (uint32_t)(-bios_size), -1);
if (ret != 0) { if (ret != 0) {
goto bios_error; goto bios_error;
@ -1182,9 +1180,7 @@ void x86_bios_rom_init(MachineState *ms, const char *default_firmware,
0x100000 - isa_bios_size, 0x100000 - isa_bios_size,
isa_bios, isa_bios,
1); 1);
if (!isapc_ram_fw) { memory_region_set_readonly(isa_bios, !isapc_ram_fw);
memory_region_set_readonly(isa_bios, true);
}
/* map all the bios at the top of memory */ /* map all the bios at the top of memory */
memory_region_add_subregion(rom_memory, memory_region_add_subregion(rom_memory,