mirror of
https://github.com/netdata/libbpf.git
synced 2026-04-07 00:59:07 +08:00
libbpf: Use memcpy instead of strncpy to please GCC
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>
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Link: https://lore.kernel.org/bpf/20201203235440.2302137-1-andrii@kernel.org
This commit is contained in:
committed by
Andrii Nakryiko
parent
d95b12da56
commit
b2a34784b2
@@ -583,7 +583,7 @@ static int xsk_create_xsk_struct(int ifindex, struct xsk_socket *xsk)
|
|||||||
}
|
}
|
||||||
|
|
||||||
ctx->ifindex = ifindex;
|
ctx->ifindex = ifindex;
|
||||||
strncpy(ctx->ifname, ifname, IFNAMSIZ - 1);
|
memcpy(ctx->ifname, ifname, IFNAMSIZ -1);
|
||||||
ctx->ifname[IFNAMSIZ - 1] = 0;
|
ctx->ifname[IFNAMSIZ - 1] = 0;
|
||||||
|
|
||||||
xsk->ctx = ctx;
|
xsk->ctx = ctx;
|
||||||
|
|||||||
Reference in New Issue
Block a user