chunk_size = MIN(iov[i].iov_len, len);
chunk_size = MIN((size_t)iov[i].iov_len, len);
ssize_t cb_extract(circ_buf *cb, uint8_t *buf, size_t len){	ssize_t rr;	int i, count;	struct iovec iov[2];	cb_assert(cb);	assert(buf != NULL);		/* buffer is empty, return immediately */	if (cb_is_empty(cb)) return 0;	/* return if len is zero */	if (len == 0) return 0;	/* setup initial value for rr */	rr = 0;		/* prepare for reading from buffer */	if (cb->ptr + cb->data_size > cb->buf + cb->buf_size) {		iov[0].iov_base = cb->ptr;		iov[0].iov_len  = cb->buf_size - (cb->ptr - cb->buf);		iov[1].iov_base = cb->buf;		iov[1].iov_len  = cb->data_size - iov[0].iov_len;		count = 2;	} else {		iov[0].iov_base = cb->ptr;		iov[0].iov_len  = cb->data_size;		count = 1;	}			/* do the actual copy */	for (i = 0; i < count; ++i) {		size_t chunk_size;		chunk_size = MIN(iov[i].iov_len, len);		assert(chunk_size > 0);		memcpy((void *)buf, (const void *)iov[i].iov_base, chunk_size);		buf = buf + chunk_size;		len -= chunk_size;		rr += chunk_size;		/* sanity check */		cb_assert(cb);		if (len == 0) break;	}	/* if rr = 0 nothing needs to be changed,	 * update internal stuff only if rr > 0 */	if (rr > 0) {		assert((size_t)rr <= cb->data_size);		cb->data_size -= rr;		/* update value of cb->ptr */		cb->ptr += rr;		if (cb->ptr >= cb->buf + cb->buf_size)			cb->ptr -= cb->buf_size;		/* sanity check */		cb_assert(cb);	}	return rr;}