lkml.org 
[lkml]   [2019]   [Aug]   [30]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: [PATCH] virtio: Change typecasts in vring_init()
Date
On 8/30/2019 4:48 AM, Jason Wang wrote:
>
> On 2019/8/27 下午11:20, Matej Genci wrote:
>> Compilers such as g++ 7.3 complain about assigning void* variable to
>> a non-void* variable (like struct pointers) and pointer arithmetics
>> on void*.
>>
>> Signed-off-by: Matej Genci <matej.genci@nutanix.com>
>> ---
>> include/uapi/linux/virtio_ring.h | 9 +++++----
>> 1 file changed, 5 insertions(+), 4 deletions(-)
>>
>> diff --git a/include/uapi/linux/virtio_ring.h b/include/uapi/linux/virtio_ring.h
>> index 4c4e24c291a5..2c339b9e2923 100644
>> --- a/include/uapi/linux/virtio_ring.h
>> +++ b/include/uapi/linux/virtio_ring.h
>> @@ -168,10 +168,11 @@ static inline void vring_init(struct vring *vr, unsigned int num, void *p,
>> unsigned long align)
>> {
>> vr->num = num;
>> - vr->desc = p;
>> - vr->avail = p + num*sizeof(struct vring_desc);
>> - vr->used = (void *)(((uintptr_t)&vr->avail->ring[num] + sizeof(__virtio16)
>> - + align-1) & ~(align - 1));
>> + vr->desc = (struct vring_desc *)p;
>> + vr->avail = (struct vring_avail *)((uintptr_t)p
>> + + num*sizeof(struct vring_desc));
>
>
> It's better to let the code pass checkpath.pl here.
>
It passes for me

--------8<--------
./scripts/checkpatch.pl 0001-virtio-Change-typecasts-in-vring_init.patch
total: 0 errors, 0 warnings, 15 lines checked

0001-virtio-Change-typecasts-in-vring_init.patch has no obvious style problems and is ready for submission.
--------8<--------

Is there something I'm missing?

> Other looks good.
>
> Thanks
>
>
>> + vr->used = (struct vring_used *)(((uintptr_t)&vr->avail->ring[num]
>> + + sizeof(__virtio16) + align-1) & ~(align - 1));
>> }
>>
>> static inline unsigned vring_size(unsigned int num, unsigned long align)

\
 
 \ /
  Last update: 2019-08-30 19:38    [W:0.115 / U:0.572 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site