arm: fix malloc type mismatch
PATCH 1/1 arm: fix malloc type mismatch
cpregs_keys is an uint32_t* so the allocation should use uint32_t. g_new is even better because it is type-safe.
Signed-off-by Paolo Bonzini <[email protected]>
--- target/arm/gdbstub.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
target/arm/gdbstub.c +1 -2
@@ -157,8 +157,7 @@ int arm_gen_dynamic_xml(CPUState *cs)RegisterSysregXmlParam param = {cs, s}; cpu->dyn_xml.num_cpregs =0 ; - cpu->dyn_xml.cpregs_keys =g_malloc (sizeof (uint32_t *) * -g_hash_table_size (cpu->cp_regs)); + cpu->dyn_xml.cpregs_keys =g_new (uint32_t,g_hash_table_size (cpu->cp_regs));g_string_printf (s,"<?xml version=\"1.0\"?>" );g_string_append_printf (s,"<!DOCTYPE target SYSTEM \"gdb-target.dtd\">" );g_string_append_printf (s,"<feature name=\"org.qemu.gdb.arm.sys.regs\">" );
Signature · 1 line
2.17.0
Cc'ing qemu-devel for patchew and co
Quoted 4 lines · Paolo Bonzini
cpregs_keysis an uint32_t* so the allocation should useuint32_t.g_newis even better because it is type-safe.Signed-off-by Paolo Bonzini <[email protected]>
Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Quoted 19 lines
--- target/arm/gdbstub.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)target/arm/gdbstub.c +1
-2@@ -157,8 +157,7 @@ int arm_gen_dynamic_xml(CPUState *cs)RegisterSysregXmlParam param = {cs, s}; cpu->dyn_xml.num_cpregs =0 ; - cpu->dyn_xml.cpregs_keys =g_malloc (sizeof (uint32_t *) * -g_hash_table_size (cpu->cp_regs)); + cpu->dyn_xml.cpregs_keys =g_new (uint32_t,g_hash_table_size (cpu->cp_regs));g_string_printf (s,"<?xml version=\"1.0\"?>" );g_string_append_printf (s,"<!DOCTYPE target SYSTEM \"gdb-target.dtd\">" );g_string_append_printf (s,"<feature name=\"org.qemu.gdb.arm.sys.regs\">" );
Peter Maydell
AppliedQuoted 9 lines · Philippe Mathieu-Daudé
Cc'ing qemu-devel for patchew and co
Quoted 4 lines · Paolo Bonzini
cpregs_keysis an uint32_t* so the allocation should useuint32_t.g_newis even better because it is type-safe.Signed-off-by Paolo Bonzini <[email protected]>Reviewed-by Philippe Mathieu-Daudé <[email protected]>
Applied to target-arm.next, thanks.
-- PMM