[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 18/47] x86: Fuse g_malloc(); memset() into g_malloc0(
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 18/47] x86: Fuse g_malloc(); memset() into g_malloc0() |
Date: |
Mon, 15 Dec 2014 17:38:02 +0100 |
From: Markus Armbruster <address@hidden>
Coccinelle semantic patch:
@@
expression LHS, SZ;
@@
- LHS = g_malloc(SZ);
- memset(LHS, 0, SZ);
+ LHS = g_malloc0(SZ);
Signed-off-by: Markus Armbruster <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
target-i386/arch_dump.c | 16 ++++------------
1 file changed, 4 insertions(+), 12 deletions(-)
diff --git a/target-i386/arch_dump.c b/target-i386/arch_dump.c
index 0bbed23..eccd803 100644
--- a/target-i386/arch_dump.c
+++ b/target-i386/arch_dump.c
@@ -78,9 +78,7 @@ static int x86_64_write_elf64_note(WriteCoreDumpFunction f,
descsz = sizeof(x86_64_elf_prstatus);
note_size = ((sizeof(Elf64_Nhdr) + 3) / 4 + (name_size + 3) / 4 +
(descsz + 3) / 4) * 4;
- note = g_malloc(note_size);
-
- memset(note, 0, note_size);
+ note = g_malloc0(note_size);
note->n_namesz = cpu_to_le32(name_size);
note->n_descsz = cpu_to_le32(descsz);
note->n_type = cpu_to_le32(NT_PRSTATUS);
@@ -159,9 +157,7 @@ static int x86_write_elf64_note(WriteCoreDumpFunction f,
CPUX86State *env,
descsz = sizeof(x86_elf_prstatus);
note_size = ((sizeof(Elf64_Nhdr) + 3) / 4 + (name_size + 3) / 4 +
(descsz + 3) / 4) * 4;
- note = g_malloc(note_size);
-
- memset(note, 0, note_size);
+ note = g_malloc0(note_size);
note->n_namesz = cpu_to_le32(name_size);
note->n_descsz = cpu_to_le32(descsz);
note->n_type = cpu_to_le32(NT_PRSTATUS);
@@ -216,9 +212,7 @@ int x86_cpu_write_elf32_note(WriteCoreDumpFunction f,
CPUState *cs,
descsz = sizeof(x86_elf_prstatus);
note_size = ((sizeof(Elf32_Nhdr) + 3) / 4 + (name_size + 3) / 4 +
(descsz + 3) / 4) * 4;
- note = g_malloc(note_size);
-
- memset(note, 0, note_size);
+ note = g_malloc0(note_size);
note->n_namesz = cpu_to_le32(name_size);
note->n_descsz = cpu_to_le32(descsz);
note->n_type = cpu_to_le32(NT_PRSTATUS);
@@ -345,9 +339,7 @@ static inline int cpu_write_qemu_note(WriteCoreDumpFunction
f,
}
note_size = ((note_head_size + 3) / 4 + (name_size + 3) / 4 +
(descsz + 3) / 4) * 4;
- note = g_malloc(note_size);
-
- memset(note, 0, note_size);
+ note = g_malloc0(note_size);
if (type == 0) {
note32 = note;
note32->n_namesz = cpu_to_le32(name_size);
--
1.8.3.1
- [Qemu-devel] [PULL 06/47] valgrind/i386: avoid false positives on KVM_SET_CLOCK ioctl, (continued)
- [Qemu-devel] [PULL 06/47] valgrind/i386: avoid false positives on KVM_SET_CLOCK ioctl, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 08/47] valgrind/i386: avoid false positives on KVM_SET_XCRS ioctl, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 09/47] valgrind/i386: avoid false positives on KVM_SET_MSRS ioctl, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 10/47] valgrind/i386: avoid false positives on KVM_GET_MSRS ioctl, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 11/47] valgrind/i386: avoid false positives on KVM_SET_VCPU_EVENTS ioctl, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 12/47] valgrind/s390x: avoid false positives on KVM_SET_FPU ioctl, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 14/47] target-i386: add feature flags for CPUID[EAX=0xd, ECX=1], Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 13/47] coverity/s390x: avoid false positive in kvm_irqchip_add_adapter_route, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 16/47] target-i386: get/set/migrate XSAVES state, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 15/47] target-mips: kvm: do not use get_clock(), Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 18/47] x86: Fuse g_malloc(); memset() into g_malloc0(),
Paolo Bonzini <=
- [Qemu-devel] [PULL 17/47] x86: Drop superfluous conditionals around g_free(), Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 19/47] x86: Use g_new() & friends where that makes obvious sense, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 20/47] x86: Drop some superfluous casts from void *, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 21/47] scsi: Drop superfluous conditionals around g_free(), Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 22/47] scsi: Fuse g_malloc(); memset() into g_malloc0(), Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 23/47] scsi: Use g_new() & friends where that makes obvious sense, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 24/47] scsi-disk: provide maximum transfer length, Paolo Bonzini, 2014/12/15
- [Qemu-devel] [PULL 26/47] cpu-exec: reset exception_index correctly, Paolo Bonzini, 2014/12/15