Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1527582

Re: [PATCH 2/2] virtio_ring: fix complaint by sparse

From "Michael S. Tsirkin" <mst@redhat.com>
Newsgroups linux.kernel
Subject Re: [PATCH 2/2] virtio_ring: fix complaint by sparse
Date 2016-11-22 16:10 +0100
Message-ID <sGkRQ-lv-3@gated-at.bofh.it> (permalink)
References <sGchz-34U-1@gated-at.bofh.it> <sGchz-34U-7@gated-at.bofh.it>
Organization linux.* mail to news gateway

Show all headers | View raw


On Tue, Nov 22, 2016 at 01:51:50PM +0800, Gonglei wrote:
>  # make C=2 CF="-D__CHECK_ENDIAN__" ./drivers/virtio/
> 
> drivers/virtio/virtio_ring.c:423:19: warning: incorrect type in assignment (different base types)
> drivers/virtio/virtio_ring.c:423:19:    expected unsigned int [unsigned] [assigned] i
> drivers/virtio/virtio_ring.c:423:19:    got restricted __virtio16 [usertype] next
> drivers/virtio/virtio_ring.c:423:19: warning: incorrect type in assignment (different base types)
> drivers/virtio/virtio_ring.c:423:19:    expected unsigned int [unsigned] [assigned] i
> drivers/virtio/virtio_ring.c:423:19:    got restricted __virtio16 [usertype] next
> drivers/virtio/virtio_ring.c:423:19: warning: incorrect type in assignment (different base types)
> drivers/virtio/virtio_ring.c:423:19:    expected unsigned int [unsigned] [assigned] i
> drivers/virtio/virtio_ring.c:423:19:    got restricted __virtio16 [usertype] next
> drivers/virtio/virtio_ring.c:604:39: warning: incorrect type in initializer (different base types)
> drivers/virtio/virtio_ring.c:604:39:    expected unsigned short [unsigned] [usertype] nextflag
> drivers/virtio/virtio_ring.c:604:39:    got restricted __virtio16
> drivers/virtio/virtio_ring.c:612:33: warning: restricted __virtio16 degrades to integer
> 
> Signed-off-by: Gonglei <arei.gonglei@huawei.com>
> ---
>  drivers/virtio/virtio_ring.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c
> index 489bfc6..d2863c3 100644
> --- a/drivers/virtio/virtio_ring.c
> +++ b/drivers/virtio/virtio_ring.c
> @@ -420,7 +420,7 @@ static inline int virtqueue_add(struct virtqueue *_vq,
>  		if (i == err_idx)
>  			break;
>  		vring_unmap_one(vq, &desc[i]);
> -		i = vq->vring.desc[i].next;
> +		i = virtio16_to_cpu(_vq->vdev, vq->vring.desc[i].next);
>  	}
>  
>  	vq->vq.num_free += total_sg;
> @@ -601,7 +601,7 @@ bool virtqueue_kick(struct virtqueue *vq)
>  static void detach_buf(struct vring_virtqueue *vq, unsigned int head)
>  {
>  	unsigned int i, j;
> -	u16 nextflag = cpu_to_virtio16(vq->vq.vdev, VRING_DESC_F_NEXT);
> +	__virtio16 nextflag = cpu_to_virtio16(vq->vq.vdev, VRING_DESC_F_NEXT);
>  
>  	/* Clear data ptr. */
>  	vq->desc_state[head].data = NULL;
> -- 
> 1.8.3.1
> 

Wow are you saying endian-ness is all wrong for the next field?
How do things ever work then?

-- 
MST

Back to linux.kernel | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

[PATCH 0/2] virtio: fix complaint by sparse Gonglei <arei.gonglei@huawei.com> - 2016-11-22 07:00 +0100
  [PATCH 1/2] virtio_pci_modern: fix complaint by sparse Gonglei <arei.gonglei@huawei.com> - 2016-11-22 07:00 +0100
  [PATCH 2/2] virtio_ring: fix complaint by sparse Gonglei <arei.gonglei@huawei.com> - 2016-11-22 07:00 +0100
    Re: [PATCH 2/2] virtio_ring: fix complaint by sparse "Michael S. Tsirkin" <mst@redhat.com> - 2016-11-22 16:10 +0100
      Re: [PATCH 2/2] virtio_ring: fix complaint by sparse Thomas Huth <thuth@redhat.com> - 2016-11-22 16:20 +0100
        Re: [PATCH 2/2] virtio_ring: fix complaint by sparse Andy Lutomirski <luto@amacapital.net> - 2016-11-22 18:30 +0100
    Re: [PATCH 2/2] virtio_ring: fix complaint by sparse Cornelia Huck <cornelia.huck@de.ibm.com> - 2016-11-22 19:00 +0100

csiph-web