From 0a553c12c71d5627abf223a926ab9688a5573f54 Mon Sep 17 00:00:00 2001 From: Markus Armbruster Date: Fri, 23 Sep 2022 14:00:24 +0200 Subject: Drop useless casts from g_malloc() & friends to pointer These memory allocation functions return void *, and casting to another pointer type is useless clutter. Drop these casts. If you really want another pointer type, consider g_new(). Signed-off-by: Markus Armbruster Reviewed-by: Laurent Vivier Message-Id: <20220923120025.448759-3-armbru@redhat.com> Signed-off-by: Laurent Vivier --- target/i386/kvm/kvm.c | 3 +-- target/i386/whpx/whpx-all.c | 5 ++--- 2 files changed, 3 insertions(+), 5 deletions(-) (limited to 'target/i386') diff --git a/target/i386/kvm/kvm.c b/target/i386/kvm/kvm.c index dac100c67c..4df0428089 100644 --- a/target/i386/kvm/kvm.c +++ b/target/i386/kvm/kvm.c @@ -2262,8 +2262,7 @@ static int kvm_get_supported_feature_msrs(KVMState *s) } assert(msr_list.nmsrs > 0); - kvm_feature_msrs = (struct kvm_msr_list *) \ - g_malloc0(sizeof(msr_list) + + kvm_feature_msrs = g_malloc0(sizeof(msr_list) + msr_list.nmsrs * sizeof(msr_list.indices[0])); kvm_feature_msrs->nmsrs = msr_list.nmsrs; diff --git a/target/i386/whpx/whpx-all.c b/target/i386/whpx/whpx-all.c index 8e4969edeb..e738d83e81 100644 --- a/target/i386/whpx/whpx-all.c +++ b/target/i386/whpx/whpx-all.c @@ -1164,9 +1164,8 @@ static void whpx_translate_cpu_breakpoints( (breakpoints->breakpoints ? breakpoints->breakpoints->used : 0); struct whpx_breakpoint_collection *new_breakpoints = - (struct whpx_breakpoint_collection *)g_malloc0( - sizeof(struct whpx_breakpoint_collection) + - max_breakpoints * sizeof(struct whpx_breakpoint)); + g_malloc0(sizeof(struct whpx_breakpoint_collection) + + max_breakpoints * sizeof(struct whpx_breakpoint)); new_breakpoints->allocated = max_breakpoints; new_breakpoints->used = 0; -- cgit v1.2.3