Skip to content

Commit

Permalink
scsi: Fuse g_malloc(); memset() into g_malloc0()
Browse files Browse the repository at this point in the history
Coccinelle semantic patch:

    @@
    expression LHS, SZ;
    @@
    -       LHS = g_malloc(SZ);
    -       memset(LHS, 0, SZ);
    +       LHS = g_malloc0(SZ);

Signed-off-by: Markus Armbruster <armbru@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Fam Zheng <famz@redhat.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Markus Armbruster authored and bonzini committed Dec 15, 2014
1 parent 1c3381a commit 0bd0adb
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions hw/scsi/megasas.c
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 0bd0adb

Please sign in to comment.