netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicolas Dichtel <nicolas.dichtel@6wind.com>
To: netdev@vger.kernel.org
Cc: davem@davemloft.net, Nicolas Dichtel <nicolas.dichtel@6wind.com>
Subject: [PATCH net-next v2] socket: use iov_length()
Date: Thu, 15 Jan 2015 10:35:58 +0100	[thread overview]
Message-ID: <1421314558-4252-1-git-send-email-nicolas.dichtel@6wind.com> (raw)
In-Reply-To: <20150114.164528.230093054757243054.davem@davemloft.net>

Better to use available helpers.

Signed-off-by: Nicolas Dichtel <nicolas.dichtel@6wind.com>
---

v2: initialize size variable with iov_length() result

 net/socket.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/net/socket.c b/net/socket.c
index a2c33a4dc7ba..e1278d7e1d5d 100644
--- a/net/socket.c
+++ b/net/socket.c
@@ -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;
@@ -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;
-- 
2.1.0

  reply	other threads:[~2015-01-15  9:36 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-14 10:07 [PATCH net-next] socket: use iov_length() Nicolas Dichtel
2015-01-14 21:45 ` David Miller
2015-01-15  9:35   ` Nicolas Dichtel [this message]
2015-01-15 18:57     ` [PATCH net-next v2] " David Miller
2015-01-15 21:45 ` [PATCH net-next] " Al Viro
2015-01-16 13:31   ` Nicolas Dichtel
2015-01-16 13:35   ` [PATCH net-next] socket: use ki_nbytes instead of iov_length() Nicolas Dichtel
2015-01-18  4:58     ` David Miller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1421314558-4252-1-git-send-email-nicolas.dichtel@6wind.com \
    --to=nicolas.dichtel@6wind.com \
    --cc=davem@davemloft.net \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).