aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarcel Holtmann <marcel@holtmann.org>2022-12-22 21:36:49 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2023-01-11 10:44:35 +0100
commit950a2f2eff1aa39620ff78be4485f6290939d8dd (patch)
tree7079c97e3848a21913955c5d6ff0e08eecdcc84a
parent86e61e4233b8de44805914475669c0ca906809c0 (diff)
libvhost-user: Fix assignment in vring_set_avail_event
Since it was proposed to change the code in libvduse.c to use memcpy instead of an assignment, the code in libvhost-user.c should also be changed to use memcpy. Signed-off-by: Marcel Holtmann <marcel@holtmann.org> Suggested-by: Paolo Bonzini <pbonzini@redhat.com> Message-Id: <502b22723264db064e4b05008233a9c1f2f8aaaa.1671741278.git.marcel@holtmann.org> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
-rw-r--r--subprojects/libvhost-user/libvhost-user.c5
1 files changed, 2 insertions, 3 deletions
diff --git a/subprojects/libvhost-user/libvhost-user.c b/subprojects/libvhost-user/libvhost-user.c
index b28b66cdb1..fc69783d2b 100644
--- a/subprojects/libvhost-user/libvhost-user.c
+++ b/subprojects/libvhost-user/libvhost-user.c
@@ -2478,14 +2478,13 @@ vring_used_flags_unset_bit(VuVirtq *vq, int mask)
static inline void
vring_set_avail_event(VuVirtq *vq, uint16_t val)
{
- uint16_t *avail;
+ uint16_t val_le = htole16(val);
if (!vq->notification) {
return;
}
- avail = (uint16_t *)&vq->vring.used->ring[vq->vring.num];
- *avail = htole16(val);
+ memcpy(&vq->vring.used->ring[vq->vring.num], &val_le, sizeof(uint16_t));
}
void