size_t count;
while ((ctx->bufcnt < ctx->buflen) && ctx->total) {
- count = min(ctx->sg->length - ctx->offset, ctx->total);
- count = min(count, ctx->buflen - ctx->bufcnt);
+ count = min3(ctx->sg->length - ctx->offset, ctx->total,
+ ctx->buflen - ctx->bufcnt);
- if (count <= 0) {
+ if (count == 0) {
/*
- * Check if count <= 0 because the buffer is full or
+ * Check if count == 0 because the buffer is full or
* because the sg length is 0. In the latest case,
* check if there is another sg in the list, a 0 length
* sg doesn't necessarily mean the end of the sg list.