[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [PATCH v3 10/10] libvduse: Fix assignment in vring_set_avail_event
From: |
Marcel Holtmann |
Subject: |
Re: [PATCH v3 10/10] libvduse: Fix assignment in vring_set_avail_event |
Date: |
Thu, 22 Dec 2022 21:38:30 +0100 |
Hi Paolo,
>> static inline void vring_set_avail_event(VduseVirtq *vq, uint16_t val)
>> {
>> - *((uint16_t *)&vq->vring.used->ring[vq->vring.num]) = htole16(val);
>> + uint16_t *avail;
>> +
>> + avail = (uint16_t *)&vq->vring.used->ring[vq->vring.num];
>> + *avail = htole16(val);
>
> That this doesn't warn is basically a compiler bug.
>
> Please use memcpy instead, i.e.
>
> uint16_t val_le = htole16(val);
> memcpy(&vq->vring.used->ring[vq->vring.num]), &val_le, sizeof(uint16_t));
excellent. Thanks for this. I included a version that fixes this for
libvhost-user as well.
Regards
Marcel
- [PATCH v3 04/10] libvhost-user: Use unsigned int i for some for-loop iterations, (continued)
- [PATCH v3 04/10] libvhost-user: Use unsigned int i for some for-loop iterations, Marcel Holtmann, 2022/12/21
- [PATCH v3 07/10] libvhost-user: Switch to unsigned int for inuse field in struct VuVirtq, Marcel Holtmann, 2022/12/21
- [PATCH v3 08/10] libvduse: Provide _GNU_SOURCE when compiling outside of QEMU, Marcel Holtmann, 2022/12/21
- [PATCH v3 03/10] libvhost-user: Cast rc variable to avoid compiler warning, Marcel Holtmann, 2022/12/21
- [PATCH v3 02/10] libvhost-user: Replace typeof with __typeof__, Marcel Holtmann, 2022/12/21
- [PATCH v3 06/10] libvhost-user: Change dev->postcopy_ufd assignment to make it C90 compliant, Marcel Holtmann, 2022/12/21
- [PATCH v3 10/10] libvduse: Fix assignment in vring_set_avail_event, Marcel Holtmann, 2022/12/21
- [PATCH v3 09/10] libvduse: Switch to unsigned int for inuse field in struct VduseVirtq, Marcel Holtmann, 2022/12/21