[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 04/29] exec.c: subpage->sub_section is already initia
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 04/29] exec.c: subpage->sub_section is already initialized to 0 |
Date: |
Mon, 16 Sep 2019 16:41:44 +0200 |
From: Wei Yang <address@hidden>
In subpage_init(), we will set subpage->sub_section to
PHYS_SECTION_UNASSIGNED by subpage_register. Since
PHYS_SECTION_UNASSIGNED is defined to be 0, and we allocate subpage with
g_malloc0, this means subpage->sub_section is already initialized to 0.
This patch removes the redundant setup for a new subpage and also fix
the code style.
Signed-off-by: Wei Yang <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
exec.c | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/exec.c b/exec.c
index ff3cb3e..d9827ef 100644
--- a/exec.c
+++ b/exec.c
@@ -1491,8 +1491,8 @@ hwaddr memory_region_section_get_iotlb(CPUState *cpu,
#if !defined(CONFIG_USER_ONLY)
-static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end,
- uint16_t section);
+static int subpage_register(subpage_t *mmio, uint32_t start, uint32_t end,
+ uint16_t section);
static subpage_t *subpage_init(FlatView *fv, hwaddr base);
static void *(*phys_mem_alloc)(size_t size, uint64_t *align, bool shared) =
@@ -2913,8 +2913,8 @@ static const MemoryRegionOps subpage_ops = {
.endianness = DEVICE_NATIVE_ENDIAN,
};
-static int subpage_register (subpage_t *mmio, uint32_t start, uint32_t end,
- uint16_t section)
+static int subpage_register(subpage_t *mmio, uint32_t start, uint32_t end,
+ uint16_t section)
{
int idx, eidx;
@@ -2937,6 +2937,7 @@ static subpage_t *subpage_init(FlatView *fv, hwaddr base)
{
subpage_t *mmio;
+ /* mmio->sub_section is set to PHYS_SECTION_UNASSIGNED with g_malloc0 */
mmio = g_malloc0(sizeof(subpage_t) + TARGET_PAGE_SIZE * sizeof(uint16_t));
mmio->fv = fv;
mmio->base = base;
@@ -2947,7 +2948,6 @@ static subpage_t *subpage_init(FlatView *fv, hwaddr base)
printf("%s: %p base " TARGET_FMT_plx " len %08x\n", __func__,
mmio, base, TARGET_PAGE_SIZE);
#endif
- subpage_register(mmio, 0, TARGET_PAGE_SIZE-1, PHYS_SECTION_UNASSIGNED);
return mmio;
}
--
1.8.3.1
- [Qemu-devel] [PULL 00/29] Misc patches for 2019-09-16, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 01/29] i386/kvm: support guest access CORE cstate, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 02/29] exec.c: replace hwaddr with uint64_t for better understanding, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 03/29] exec.c: get nodes_nb_alloc with one MAX calculation, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 04/29] exec.c: subpage->sub_section is already initialized to 0,
Paolo Bonzini <=
- [Qemu-devel] [PULL 06/29] exec.c: add a check between constants to see whether we could skip, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 05/29] exec.c: correct the maximum skip value during compact, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 07/29] win32: fix README file in NSIS installer, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 08/29] test-char: fix AddressSanitizer failure, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 09/29] hw/i386: Move CONFIG_ACPI_PCI to CONFIG_PC, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 10/29] elf-ops.h: fix int overflow in load_elf(), Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 12/29] memory: inline and optimize devend_memop, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 11/29] memory: fetch pmem size in get_file_size(), Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 15/29] hw/i386/pc: Use e820_get_num_entries() to access e820_entries, Paolo Bonzini, 2019/09/16
- [Qemu-devel] [PULL 14/29] cpus: Fix throttling during vm_stop, Paolo Bonzini, 2019/09/16