Il 12/03/2012 20:14, Michael Tokarev ha scritto:
> +    for (i = 0, done = 0; done < bytes && i < iov_cnt; i++) {
> +        if (offset < iov[i].iov_len) {
> +            size_t len = MIN(iov[i].iov_len - offset, bytes - done);
> +            memcpy(iov[i].iov_base + offset, buf + done, len);
> +            done += len;
> +            offset = 0;
> +        } else {
> +            offset -= iov[i].iov_len;
>          }
> -        iovec_off += iov[i].iov_len;
>      }
> -    return buf_off;
> +    assert(offset == 0);

This needs to be assert(offset == 0 || done == 0).

> +    return done;

Otherwise looks good, but I must say I do not like changing the API
*and* the implementation in the same patch.  It seems like a
bisectability nightmare (and reviewing nightmare, too).  I do prefer
your new code though.

Paolo

Reply via email to