Skip to content

Commit

Permalink
libbpf: Use memcpy instead of strncpy to please GCC
Browse files Browse the repository at this point in the history
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: e459f49 ("libbpf: Separate XDP program load with xsk socket creation")
Signed-off-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
  • Loading branch information
anakryiko authored and Alexei Starovoitov committed Dec 4, 2020
1 parent 8158c5f commit 3015b50
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion tools/lib/bpf/xsk.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit 3015b50

Please sign in to comment.