Commit 473f0b15 authored by Markus Elfring's avatar Markus Elfring Committed by Michael S. Tsirkin

vhost/scsi: Improve a size determination in four functions

Replace the specification of four data structures by pointer dereferences
as the parameter for the operator "sizeof" to make the corresponding size
determination a bit safer according to the Linux coding style convention.
Signed-off-by: default avatarMarkus Elfring <elfring@users.sourceforge.net>
Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: default avatarMichael S. Tsirkin <mst@redhat.com>
parent 4d32029b
...@@ -586,8 +586,7 @@ vhost_scsi_get_tag(struct vhost_virtqueue *vq, struct vhost_scsi_tpg *tpg, ...@@ -586,8 +586,7 @@ vhost_scsi_get_tag(struct vhost_virtqueue *vq, struct vhost_scsi_tpg *tpg,
sg = cmd->tvc_sgl; sg = cmd->tvc_sgl;
prot_sg = cmd->tvc_prot_sgl; prot_sg = cmd->tvc_prot_sgl;
pages = cmd->tvc_upages; pages = cmd->tvc_upages;
memset(cmd, 0, sizeof(struct vhost_scsi_cmd)); memset(cmd, 0, sizeof(*cmd));
cmd->tvc_sgl = sg; cmd->tvc_sgl = sg;
cmd->tvc_prot_sgl = prot_sg; cmd->tvc_prot_sgl = prot_sg;
cmd->tvc_upages = pages; cmd->tvc_upages = pages;
...@@ -1725,7 +1724,7 @@ static int vhost_scsi_make_nexus(struct vhost_scsi_tpg *tpg, ...@@ -1725,7 +1724,7 @@ static int vhost_scsi_make_nexus(struct vhost_scsi_tpg *tpg,
return -EEXIST; return -EEXIST;
} }
tv_nexus = kzalloc(sizeof(struct vhost_scsi_nexus), GFP_KERNEL); tv_nexus = kzalloc(sizeof(*tv_nexus), GFP_KERNEL);
if (!tv_nexus) { if (!tv_nexus) {
mutex_unlock(&tpg->tv_tpg_mutex); mutex_unlock(&tpg->tv_tpg_mutex);
pr_err("Unable to allocate struct vhost_scsi_nexus\n"); pr_err("Unable to allocate struct vhost_scsi_nexus\n");
...@@ -1926,7 +1925,7 @@ vhost_scsi_make_tpg(struct se_wwn *wwn, ...@@ -1926,7 +1925,7 @@ vhost_scsi_make_tpg(struct se_wwn *wwn,
if (kstrtou16(name + 5, 10, &tpgt) || tpgt >= VHOST_SCSI_MAX_TARGET) if (kstrtou16(name + 5, 10, &tpgt) || tpgt >= VHOST_SCSI_MAX_TARGET)
return ERR_PTR(-EINVAL); return ERR_PTR(-EINVAL);
tpg = kzalloc(sizeof(struct vhost_scsi_tpg), GFP_KERNEL); tpg = kzalloc(sizeof(*tpg), GFP_KERNEL);
if (!tpg) { if (!tpg) {
pr_err("Unable to allocate struct vhost_scsi_tpg"); pr_err("Unable to allocate struct vhost_scsi_tpg");
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
...@@ -1980,7 +1979,7 @@ vhost_scsi_make_tport(struct target_fabric_configfs *tf, ...@@ -1980,7 +1979,7 @@ vhost_scsi_make_tport(struct target_fabric_configfs *tf,
/* if (vhost_scsi_parse_wwn(name, &wwpn, 1) < 0) /* if (vhost_scsi_parse_wwn(name, &wwpn, 1) < 0)
return ERR_PTR(-EINVAL); */ return ERR_PTR(-EINVAL); */
tport = kzalloc(sizeof(struct vhost_scsi_tport), GFP_KERNEL); tport = kzalloc(sizeof(*tport), GFP_KERNEL);
if (!tport) { if (!tport) {
pr_err("Unable to allocate struct vhost_scsi_tport"); pr_err("Unable to allocate struct vhost_scsi_tport");
return ERR_PTR(-ENOMEM); return ERR_PTR(-ENOMEM);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment