/* Each buffer in the virtqueues is actually a chain of descriptors. This function returns the next descriptor in the chain, or vq->vring.num if we're at the end.  */
static unsigned next_desc(struct vring_desc *desc, unsigned int i, unsigned int max)
/* Each buffer in the virtqueues is actually a chain of descriptors. This function returns the next descriptor in the chain, or vq->vring.num if we're at the end.  */
static unsigned next_desc(struct vring_desc *desc, unsigned int i, unsigned int max)
{
	unsigned int next;
	if (!(desc[i].flags & VRING_DESC_F_NEXT))
		return max;
	next = desc[i].next;
	wmb();
	if (next >= max)
		errx(1, "Desc next is %u", next);
	return next;
}