Skip to content

Commit

Permalink
vhost-user: cleanup msg size math
Browse files Browse the repository at this point in the history
We are sending msg fields, use sizeof on these
and not on local variables which happen to
have a matching type.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
mstsirkin committed Oct 29, 2015
1 parent 86abad0 commit 7fc0246
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions hw/virtio/vhost-user.c
Expand Up @@ -281,7 +281,7 @@ static int vhost_user_set_vring_addr(struct vhost_dev *dev,
.request = VHOST_USER_SET_VRING_ADDR,
.flags = VHOST_USER_VERSION,
.payload.addr = *addr,
.size = sizeof(*addr),
.size = sizeof(msg.payload.addr),
};

vhost_user_write(dev, &msg, NULL, 0);
Expand All @@ -304,7 +304,7 @@ static int vhost_set_vring(struct vhost_dev *dev,
.request = request,
.flags = VHOST_USER_VERSION,
.payload.state = *ring,
.size = sizeof(*ring),
.size = sizeof(msg.payload.state),
};

vhost_user_write(dev, &msg, NULL, 0);
Expand Down Expand Up @@ -346,7 +346,7 @@ static int vhost_user_get_vring_base(struct vhost_dev *dev,
.request = VHOST_USER_GET_VRING_BASE,
.flags = VHOST_USER_VERSION,
.payload.state = *ring,
.size = sizeof(*ring),
.size = sizeof(msg.payload.state),
};

vhost_user_write(dev, &msg, NULL, 0);
Expand Down

0 comments on commit 7fc0246

Please sign in to comment.