Skip to content

Commit

Permalink
socket: use iov_length()
Browse files Browse the repository at this point in the history
Better to use available helpers.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Nicolas Dichtel authored and David S. Miller committed Jan 15, 2015
1 parent 4e7a84b commit 7eb35b1
Showing 1 changed file with 2 additions and 10 deletions.
12 changes: 2 additions & 10 deletions net/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -882,11 +882,7 @@ static ssize_t do_sock_read(struct msghdr *msg, struct kiocb *iocb,
unsigned long nr_segs)
{
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_t size = iov_length(iov, nr_segs);

msg->msg_name = NULL;
msg->msg_namelen = 0;
Expand Down Expand Up @@ -921,11 +917,7 @@ static ssize_t do_sock_write(struct msghdr *msg, struct kiocb *iocb,
unsigned long nr_segs)
{
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_t size = iov_length(iov, nr_segs);

msg->msg_name = NULL;
msg->msg_namelen = 0;
Expand Down

0 comments on commit 7eb35b1

Please sign in to comment.