aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/vhost
diff options
context:
space:
mode:
authorMichael S. Tsirkin <mst@redhat.com>2014-10-24 07:19:48 -0400
committerMichael S. Tsirkin <mst@redhat.com>2014-12-09 05:05:29 -0500
commit8b38694a2dc8b18374310df50174f1e4376d6824 (patch)
tree6eab5ca0936192876d12faa2ef76a1cb04fe5af8 /drivers/vhost
parent3b1bbe89351a8003857aeb5cbef3595f5d0ee609 (diff)
vhost/net: virtio 1.0 byte swap
I had to add an explicit tag to suppress compiler warning: gcc isn't smart enough to notice that len is always initialized since function is called with size > 0. Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com>
Diffstat (limited to 'drivers/vhost')
-rw-r--r--drivers/vhost/net.c15
1 files changed, 10 insertions, 5 deletions
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c
index dce5c58174b7..c218188c8880 100644
--- a/drivers/vhost/net.c
+++ b/drivers/vhost/net.c
@@ -416,7 +416,7 @@ static void handle_tx(struct vhost_net *net)
416 struct ubuf_info *ubuf; 416 struct ubuf_info *ubuf;
417 ubuf = nvq->ubuf_info + nvq->upend_idx; 417 ubuf = nvq->ubuf_info + nvq->upend_idx;
418 418
419 vq->heads[nvq->upend_idx].id = head; 419 vq->heads[nvq->upend_idx].id = cpu_to_vhost32(vq, head);
420 vq->heads[nvq->upend_idx].len = VHOST_DMA_IN_PROGRESS; 420 vq->heads[nvq->upend_idx].len = VHOST_DMA_IN_PROGRESS;
421 ubuf->callback = vhost_zerocopy_callback; 421 ubuf->callback = vhost_zerocopy_callback;
422 ubuf->ctx = nvq->ubufs; 422 ubuf->ctx = nvq->ubufs;
@@ -500,6 +500,10 @@ static int get_rx_bufs(struct vhost_virtqueue *vq,
500 int headcount = 0; 500 int headcount = 0;
501 unsigned d; 501 unsigned d;
502 int r, nlogs = 0; 502 int r, nlogs = 0;
503 /* len is always initialized before use since we are always called with
504 * datalen > 0.
505 */
506 u32 uninitialized_var(len);
503 507
504 while (datalen > 0 && headcount < quota) { 508 while (datalen > 0 && headcount < quota) {
505 if (unlikely(seg >= UIO_MAXIOV)) { 509 if (unlikely(seg >= UIO_MAXIOV)) {
@@ -527,13 +531,14 @@ static int get_rx_bufs(struct vhost_virtqueue *vq,
527 nlogs += *log_num; 531 nlogs += *log_num;
528 log += *log_num; 532 log += *log_num;
529 } 533 }
530 heads[headcount].id = d; 534 heads[headcount].id = cpu_to_vhost32(vq, d);
531 heads[headcount].len = iov_length(vq->iov + seg, in); 535 len = iov_length(vq->iov + seg, in);
532 datalen -= heads[headcount].len; 536 heads[headcount].len = cpu_to_vhost32(vq, len);
537 datalen -= len;
533 ++headcount; 538 ++headcount;
534 seg += in; 539 seg += in;
535 } 540 }
536 heads[headcount - 1].len += datalen; 541 heads[headcount - 1].len = cpu_to_vhost32(vq, len - datalen);
537 *iovcount = seg; 542 *iovcount = seg;
538 if (unlikely(log)) 543 if (unlikely(log))
539 *log_num = nlogs; 544 *log_num = nlogs;