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

From: Nicolas Dichtel <[email-masked]>
Date: Fri, 16 Jan 2015 14:31:54 +0100

Le 15/01/2015 22:45, Al Viro a écrit :
> 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?
>
I'm not an expert, but it seems you're right. I will send a patch.