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 1:21 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));
       |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


BPF CI now throws a new warning after your patch:

https://github.com/kernel-patches/bpf/actions/runs/3369416153/jobs/5589052613

  [...]
  xsk.c:536:2: error: call to undeclared function 'libbpf_strlcpy'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
          libbpf_strlcpy(ifr.ifr_name, ctx->ifname, IFNAMSIZ);
          ^
  xsk.c:755:2: error: call to undeclared function 'libbpf_strlcpy'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
          libbpf_strlcpy(ctx->ifname, ifname, IFNAMSIZ);
          ^
  xsk.c:942:2: error: call to undeclared function 'libbpf_strlcpy'; ISO C99 and later do not support implicit function declarations [-Wimplicit-function-declaration]
          libbpf_strlcpy(ctx->ifname, ifname, IFNAMSIZ);
          ^
  3 errors generated.
  make: *** [Makefile:166: /tmp/work/bpf/bpf/tools/testing/selftests/bpf/xsk.o] Error 1
  make: *** Waiting for unfinished jobs....



[Index of Archives]     [Linux Samsung SoC]     [Linux Rockchip SoC]     [Linux Actions SoC]     [Linux for Synopsys ARC Processors]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]


  Powered by Linux