Re: [PATCH bpf-next] selftests/bpf: Fix strncpy() fortify warning

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 11/1/22 3:23 PM, Rong Tao wrote:
From: Rong Tao <rongtao@xxxxxxxx>

move libbpf_strlcpy() to bpf_util.h, and replace strncpy() with
libbpf_strlcpy(), fix compile warning.

Compile samples/bpf, warning:
$ cd samples/bpf
$ make
...
cgroup_helpers.c: In function ‘__enable_controllers’:
cgroup_helpers.c:80:17: warning: ‘strncpy’ specified bound 4097 equals destination size [-Wstringop-truncation]
    80 |                 strncpy(enable, controllers, sizeof(enable));
       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Rong Tao <rongtao@xxxxxxxx>

Nope, BPF CI fails once again with:

https://github.com/kernel-patches/bpf/actions/runs/3370230622/jobs/5590876906

  [...]
    TEST-OBJ [test_progs-no_alu32] connect_ping.test.o
    TEST-OBJ [test_progs-no_alu32] map_kptr.test.o
  In file included from /tmp/work/bpf/bpf/tools/testing/selftests/bpf/prog_tests/perf_branches.c:7:
  /tmp/work/bpf/bpf/tools/testing/selftests/bpf/tools/include/bpf/libbpf_internal.h:200:20: error: redefinition of 'libbpf_strlcpy'
  static inline void libbpf_strlcpy(char *dst, const char *src, size_t sz)
                     ^
  /tmp/work/bpf/bpf/tools/testing/selftests/bpf/bpf_util.h:29:20: note: previous definition is here
  static inline void libbpf_strlcpy(char *dst, const char *src, size_t sz)
                     ^
  1 error generated.
    TEST-OBJ [test_progs-no_alu32] hash_large_key.test.o
  make: *** [Makefile:539: /tmp/work/bpf/bpf/tools/testing/selftests/bpf/no_alu32/perf_branches.test.o] Error 1
  make: *** Waiting for unfinished jobs....
  make: Leaving directory '/tmp/work/bpf/bpf/tools/testing/selftests/bpf'
  Error: Process completed with exit code 2.

Please do not send broken stuff that was not even compile tested.

Here's a small howto for running BPF selftests:

https://git.kernel.org/pub/scm/linux/kernel/git/bpf/bpf-next.git/tree/tools/testing/selftests/bpf/README.rst#n48



[Index of Archives]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Share Photos]     [IDE]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux ATA RAID]     [Samba]     [Device Mapper]

  Powered by Linux