chunk_size = MIN(iov[i].iov_len, len);
chunk_size = MIN((size_t)iov[i].iov_len, len);
ssize_t cb_append(circ_buf *cb, const uint8_t *buf, size_t len){	ssize_t rr;	int i, count;	struct iovec iov[2];	const uint8_t *tmp;	cb_assert(cb);	assert(buf != NULL);		/* buffer is full, return an error condition */	if (cb_is_full(cb)) return -1;		/* return if len is zero */	if (len == 0) return 0;		/* setup initial values for tmp and rr */	tmp = (const uint8_t *)buf;	rr  = 0;		/* prepare for writing to buffer */	if (cb->ptr == cb->buf) {		/* space only at end of buf */		iov->iov_base = cb->ptr + cb->data_size;		iov->iov_len  = cb->buf_size - cb->data_size;		count = 1;	} else if (cb->ptr + cb->data_size >= cb->buf + cb->buf_size) {		/* space only before cb->ptr */		iov->iov_base = cb->ptr + cb->data_size - cb->buf_size;		iov->iov_len  = cb->buf_size - cb->data_size;		count = 1;	} else {		/* space at end and begining of buf */		iov[0].iov_base = cb->ptr + cb->data_size;		iov[0].iov_len  = (cb->buf_size - cb->data_size) 		                - (cb->ptr - cb->buf);		iov[1].iov_base = cb->buf;		iov[1].iov_len  = cb->ptr - cb->buf;		count = 2;	}			/* 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 *)iov[i].iov_base, (const void *)tmp, chunk_size);		tmp = tmp + chunk_size;		len -= chunk_size;		cb->data_size += chunk_size;		rr += chunk_size;		/* sanity check */		cb_assert(cb);				if (len == 0) break;	}	return rr;}