mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-31 05:51:53 -06:00
scsi: Use g_new() & friends where that makes obvious sense
g_new(T, n) is neater than g_malloc(sizeof(T) * n). It's also safer, for two reasons. One, it catches multiplication overflowing size_t. Two, it returns T * rather than void *, which lets the compiler catch more type errors. This commit only touches allocations with size arguments of the form sizeof(T). 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>
This commit is contained in:
parent
0bd0adbe5b
commit
3c55fe2a13
2 changed files with 2 additions and 2 deletions
|
@ -781,7 +781,7 @@ static void lsi_do_command(LSIState *s)
|
||||||
}
|
}
|
||||||
|
|
||||||
assert(s->current == NULL);
|
assert(s->current == NULL);
|
||||||
s->current = g_malloc0(sizeof(lsi_request));
|
s->current = g_new0(lsi_request, 1);
|
||||||
s->current->tag = s->select_tag;
|
s->current->tag = s->select_tag;
|
||||||
s->current->req = scsi_req_new(dev, s->current->tag, s->current_lun, buf,
|
s->current->req = scsi_req_new(dev, s->current->tag, s->current_lun, buf,
|
||||||
s->current);
|
s->current);
|
||||||
|
|
|
@ -829,7 +829,7 @@ void virtio_scsi_common_realize(DeviceState *dev, Error **errp,
|
||||||
virtio_cleanup(vdev);
|
virtio_cleanup(vdev);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
s->cmd_vqs = g_malloc0(s->conf.num_queues * sizeof(VirtQueue *));
|
s->cmd_vqs = g_new0(VirtQueue *, s->conf.num_queues);
|
||||||
s->sense_size = VIRTIO_SCSI_SENSE_SIZE;
|
s->sense_size = VIRTIO_SCSI_SENSE_SIZE;
|
||||||
s->cdb_size = VIRTIO_SCSI_CDB_SIZE;
|
s->cdb_size = VIRTIO_SCSI_CDB_SIZE;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue