diff options
| author | Andrii Nakryiko <[email protected]> | 2023-10-06 17:57:42 +0000 |
|---|---|---|
| committer | Daniel Borkmann <[email protected]> | 2023-10-06 18:17:28 +0000 |
| commit | 925a01577ea5a70416731c00e42b74c97f41cb6a (patch) | |
| tree | 39947655872d56199dd9a3d986b84b02aa0b38dc /tools/testing/selftests/bpf/prog_tests/lwt_helpers.h | |
| parent | bpf: Inherit system settings for CPU security mitigations (diff) | |
| download | kernel-925a01577ea5a70416731c00e42b74c97f41cb6a.tar.gz kernel-925a01577ea5a70416731c00e42b74c97f41cb6a.zip | |
selftests/bpf: Fix compiler warnings reported in -O2 mode
Fix a bunch of potentially unitialized variable usage warnings that are
reported by GCC in -O2 mode. Also silence overzealous stringop-truncation
class of warnings.
Signed-off-by: Andrii Nakryiko <[email protected]>
Signed-off-by: Daniel Borkmann <[email protected]>
Acked-by: Jiri Olsa <[email protected]>
Link: https://lore.kernel.org/bpf/[email protected]
Diffstat (limited to 'tools/testing/selftests/bpf/prog_tests/lwt_helpers.h')
| -rw-r--r-- | tools/testing/selftests/bpf/prog_tests/lwt_helpers.h | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/tools/testing/selftests/bpf/prog_tests/lwt_helpers.h b/tools/testing/selftests/bpf/prog_tests/lwt_helpers.h index 61333f2a03f9..e9190574e79f 100644 --- a/tools/testing/selftests/bpf/prog_tests/lwt_helpers.h +++ b/tools/testing/selftests/bpf/prog_tests/lwt_helpers.h @@ -49,7 +49,8 @@ static int open_tuntap(const char *dev_name, bool need_mac) return -1; ifr.ifr_flags = IFF_NO_PI | (need_mac ? IFF_TAP : IFF_TUN); - memcpy(ifr.ifr_name, dev_name, IFNAMSIZ); + strncpy(ifr.ifr_name, dev_name, IFNAMSIZ - 1); + ifr.ifr_name[IFNAMSIZ - 1] = '\0'; err = ioctl(fd, TUNSETIFF, &ifr); if (!ASSERT_OK(err, "ioctl(TUNSETIFF)")) { |
