Subject: Re: [PATCH net-next] socket: use iov_length()

From: Al Viro <[email-masked]>
Date: Thu, 15 Jan 2015 21:45:20 +0000

On Wed, Jan 14, 2015 at 11:07:50AM +0100, Nicolas Dichtel wrote:
> Better to use available helpers.
> 
> Signed-off-by: Nicolas Dichtel <[email-masked]>
> ---
>  net/socket.c | 8 ++------
>  1 file changed, 2 insertions(+), 6 deletions(-)
> 
> diff --git a/net/socket.c b/net/socket.c
> index a2c33a4dc7ba..b1f3fa4da020 100644
> --- a/net/socket.c
> +++ b/net/socket.c
> @@ -883,10 +883,8 @@ static ssize_t do_sock_read(struct msghdr *msg, struct kiocb *iocb,
>  {
>  	struct socket *sock = file->private_data;
>  	size_t size = 0;
> -	int i;
>  
> -	for (i = 0; i < nr_segs; i++)
> -		size += iov[i].iov_len;
> +	size = iov_length(iov, nr_segs);

What's wrong with size = iocb->ki_nbytes instead of calling anything?