[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 2/3] scsi: Fuse g_malloc(); memset() into g_malloc0
From: |
Markus Armbruster |
Subject: |
[Qemu-devel] [PATCH 2/3] scsi: Fuse g_malloc(); memset() into g_malloc0() |
Date: |
Thu, 4 Dec 2014 14:12:44 +0100 |
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>
---
hw/scsi/megasas.c | 6 ++----
1 file changed, 2 insertions(+), 4 deletions(-)
diff --git a/hw/scsi/megasas.c b/hw/scsi/megasas.c
index 604252a..4852237 100644
--- a/hw/scsi/megasas.c
+++ b/hw/scsi/megasas.c
@@ -1018,8 +1018,7 @@ static int megasas_pd_get_info_submit(SCSIDevice *sdev,
int lun,
size_t len, resid;
if (!cmd->iov_buf) {
- cmd->iov_buf = g_malloc(dcmd_size);
- memset(cmd->iov_buf, 0, dcmd_size);
+ cmd->iov_buf = g_malloc0(dcmd_size);
info = cmd->iov_buf;
info->inquiry_data[0] = 0x7f; /* Force PQual 0x3, PType 0x1f */
info->vpd_page83[0] = 0x7f;
@@ -1221,8 +1220,7 @@ static int megasas_ld_get_info_submit(SCSIDevice *sdev,
int lun,
uint64_t ld_size;
if (!cmd->iov_buf) {
- cmd->iov_buf = g_malloc(dcmd_size);
- memset(cmd->iov_buf, 0x0, dcmd_size);
+ cmd->iov_buf = g_malloc0(dcmd_size);
info = cmd->iov_buf;
megasas_setup_inquiry(cdb, 0x83, sizeof(info->vpd_page83));
req = scsi_req_new(sdev, cmd->index, lun, cdb, cmd);
--
1.9.3
- [Qemu-devel] [PATCH 0/3] scsi: Trivial cleanups around g_malloc(), Markus Armbruster, 2014/12/04
- [Qemu-devel] [PATCH 2/3] scsi: Fuse g_malloc(); memset() into g_malloc0(),
Markus Armbruster <=
- [Qemu-devel] [PATCH 3/3] scsi: Use g_new() & friends where that makes obvious sense, Markus Armbruster, 2014/12/04
- [Qemu-devel] [PATCH 1/3] scsi: Drop superfluous conditionals around g_free(), Markus Armbruster, 2014/12/04
- Re: [Qemu-devel] [PATCH 0/3] scsi: Trivial cleanups around g_malloc(), Eric Blake, 2014/12/04
- Re: [Qemu-devel] [PATCH 0/3] scsi: Trivial cleanups around g_malloc(), Fam Zheng, 2014/12/05
- Re: [Qemu-devel] [PATCH 0/3] scsi: Trivial cleanups around g_malloc(), Paolo Bonzini, 2014/12/05