exec.c: subpage->sub_section is already initialized to 0

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.

Backports commit b797ab1a15ba8d2b2fc4ec3e1f24d755f6855d05 from qemu
This commit is contained in:
Wei Yang 2019-11-20 13:14:20 -05:00 committed by Lioncash
parent ef3cf096e7
commit 2e55ddd339
No known key found for this signature in database
GPG key ID: 4E3C3CC1031BA9C7

View file

@ -1745,6 +1745,7 @@ static subpage_t *subpage_init(FlatView *fv, hwaddr base)
AddressSpaceDispatch *d = flatview_to_dispatch(fv);
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;
@ -1756,7 +1757,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;
}