netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH bpf-next 1/2] libbpf: use memcpy instead of strncpy to please GCC
@ 2020-12-03 23:54 Andrii Nakryiko
  2020-12-03 23:54 ` [PATCH bpf-next 2/2] selftests/bpf: fix invalid use of strncat in test_sockmap Andrii Nakryiko
  0 siblings, 1 reply; 2+ messages in thread
From: Andrii Nakryiko @ 2020-12-03 23:54 UTC (permalink / raw)
  To: bpf, netdev, ast, daniel; +Cc: andrii, kernel-team

Some versions of GCC are really nit-picky about strncpy() use. Use memcpy(),
as they are pretty much equivalent for the case of fixed length strings.

Fixes: e459f49b4394 ("libbpf: Separate XDP program load with xsk socket creation")
Signed-off-by: Andrii Nakryiko <andrii@kernel.org>
---
 tools/lib/bpf/xsk.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/lib/bpf/xsk.c b/tools/lib/bpf/xsk.c
index 4b051ec7cfbb..e3e41ceeb1bc 100644
--- a/tools/lib/bpf/xsk.c
+++ b/tools/lib/bpf/xsk.c
@@ -583,7 +583,7 @@ static int xsk_create_xsk_struct(int ifindex, struct xsk_socket *xsk)
 	}
 
 	ctx->ifindex = ifindex;
-	strncpy(ctx->ifname, ifname, IFNAMSIZ - 1);
+	memcpy(ctx->ifname, ifname, IFNAMSIZ -1);
 	ctx->ifname[IFNAMSIZ - 1] = 0;
 
 	xsk->ctx = ctx;
-- 
2.24.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-12-03 23:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-12-03 23:54 [PATCH bpf-next 1/2] libbpf: use memcpy instead of strncpy to please GCC Andrii Nakryiko
2020-12-03 23:54 ` [PATCH bpf-next 2/2] selftests/bpf: fix invalid use of strncat in test_sockmap Andrii Nakryiko

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).