]> Git Repo - linux.git/commit
libbpf: silence GCC8 warning about string truncation
authorAndrii Nakryiko <[email protected]>
Wed, 24 Jul 2019 21:47:53 +0000 (14:47 -0700)
committerAlexei Starovoitov <[email protected]>
Thu, 25 Jul 2019 17:13:31 +0000 (10:13 -0700)
commitcb8ffde5694ae5fffb456eae932aac442aa3a207
tree0617a7e2179b05e4ddccc9182448a8d42c64f112
parentdecb705e01a5d325c9876b9674043cde4b54f0db
libbpf: silence GCC8 warning about string truncation

Despite a proper NULL-termination after strncpy(..., ..., IFNAMSIZ - 1),
GCC8 still complains about *expected* string truncation:

  xsk.c:330:2: error: 'strncpy' output may be truncated copying 15 bytes
  from a string of length 15 [-Werror=stringop-truncation]
    strncpy(ifr.ifr_name, xsk->ifname, IFNAMSIZ - 1);

This patch gets rid of the issue altogether by using memcpy instead.
There is no performance regression, as strncpy will still copy and fill
all of the bytes anyway.

v1->v2:
- rebase against bpf tree.

Cc: Magnus Karlsson <[email protected]>
Signed-off-by: Andrii Nakryiko <[email protected]>
Acked-by: Magnus Karlsson <[email protected]>
Acked-by: Song Liu <[email protected]>
Signed-off-by: Alexei Starovoitov <[email protected]>
tools/lib/bpf/xsk.c
This page took 0.072783 seconds and 4 git commands to generate.