netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche@acm.org>
To: David Miller <davem@davemloft.net>
Cc: netdev@vger.kernel.org, Bart Van Assche <bvanassche@acm.org>,
	Sagi Grimberg <sagi@grimberg.me>, Christoph Hellwig <hch@lst.de>
Subject: [PATCH 7/7] net/utils: Use strlcpy() instead of open-coding it
Date: Thu, 21 Mar 2019 15:19:46 -0700	[thread overview]
Message-ID: <20190321221946.163803-8-bvanassche@acm.org> (raw)
In-Reply-To: <20190321221946.163803-1-bvanassche@acm.org>

This patch does not change any functionality but makes the code easier
to read.

Cc: Sagi Grimberg <sagi@grimberg.me>
Cc: Christoph Hellwig <hch@lst.de>
Signed-off-by: Bart Van Assche <bvanassche@acm.org>
---
 net/core/utils.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/net/core/utils.c b/net/core/utils.c
index 2a597ac7808e..5f11e89f173f 100644
--- a/net/core/utils.c
+++ b/net/core/utils.c
@@ -339,12 +339,8 @@ static int inet6_pton(struct net *net, const char *src, u16 port_num,
 	    src + srclen != scope_delim && *scope_delim == '%') {
 		struct net_device *dev;
 		char scope_id[16];
-		size_t scope_len = min_t(size_t, sizeof(scope_id) - 1,
-					 src + srclen - scope_delim - 1);
-
-		memcpy(scope_id, scope_delim + 1, scope_len);
-		scope_id[scope_len] = '\0';
 
+		strlcpy(scope_id, scope_delim + 1, sizeof(scope_id));
 		dev = dev_get_by_name(net, scope_id);
 		if (dev) {
 			addr6->sin6_scope_id = dev->ifindex;
-- 
2.21.0.155.ge902e9bcae20


  parent reply	other threads:[~2019-03-21 22:20 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-03-21 22:19 [PATCH 0/7] net/core patches for kernel v5.2 Bart Van Assche
2019-03-21 22:19 ` [PATCH 1/7] net/core: Document reuseport_add_sock() bind_inany argument Bart Van Assche
2019-03-21 22:19 ` [PATCH 2/7] net/core: Document all dev_ioctl() arguments Bart Van Assche
2019-03-21 22:19 ` [PATCH 3/7] net/core: Document __skb_flow_dissect() flags argument Bart Van Assche
2019-03-21 22:19 ` [PATCH 4/7] net/core: Fix rtnetlink kernel-doc headers Bart Van Assche
2019-03-21 22:19 ` [PATCH 5/7] net/core: Allow the compiler to verify declaration and definition consistency Bart Van Assche
2019-03-21 22:19 ` [PATCH 6/7] net/core: Declare a local function 'static' Bart Van Assche
2019-03-21 22:25   ` Sagi Grimberg
2019-03-21 22:19 ` Bart Van Assche [this message]
2019-03-21 22:24   ` [PATCH 7/7] net/utils: Use strlcpy() instead of open-coding it Sagi Grimberg
2019-03-22 18:46   ` Rustad, Mark D
2019-03-25 15:55     ` Bart Van Assche
2019-03-24  0:47 ` [PATCH 0/7] net/core patches for kernel v5.2 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=20190321221946.163803-8-bvanassche@acm.org \
    --to=bvanassche@acm.org \
    --cc=davem@davemloft.net \
    --cc=hch@lst.de \
    --cc=netdev@vger.kernel.org \
    --cc=sagi@grimberg.me \
    /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).