* [PATCH Liburing 0/2] build and compiler warning fixes @ 2026-03-14 8:35 Yang Xiuwei 2026-03-14 8:35 ` [PATCH 1/2] examples/send-zerocopy: fix -Wstringop-truncation on ifr.ifr_name Yang Xiuwei 2026-03-14 8:35 ` [PATCH 2/2] test/cbpf_filter: skip when openat2.h is not available Yang Xiuwei 0 siblings, 2 replies; 7+ messages in thread From: Yang Xiuwei @ 2026-03-14 8:35 UTC (permalink / raw) To: axboe; +Cc: io-uring, Yang Xiuwei Fix two issues: (1) cbpf_filter test fails to build when kernel headers lack openat2.h; (2) send-zerocopy triggers -Wstringop-truncation on ifr.ifr_name. Yang Xiuwei (2): examples/send-zerocopy: fix -Wstringop-truncation on ifr.ifr_name test/cbpf_filter: skip when openat2.h is not available examples/send-zerocopy.c | 2 +- test/cbpf_filter.c | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) -- 2.25.1 ^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/2] examples/send-zerocopy: fix -Wstringop-truncation on ifr.ifr_name 2026-03-14 8:35 [PATCH Liburing 0/2] build and compiler warning fixes Yang Xiuwei @ 2026-03-14 8:35 ` Yang Xiuwei 2026-03-14 8:35 ` [PATCH 2/2] test/cbpf_filter: skip when openat2.h is not available Yang Xiuwei 1 sibling, 0 replies; 7+ messages in thread From: Yang Xiuwei @ 2026-03-14 8:35 UTC (permalink / raw) To: axboe; +Cc: io-uring, Yang Xiuwei strncpy(ifr.ifr_name, cfg_ifname, sizeof(ifr.ifr_name)) triggers -Wstringop-truncation because the bound equals the destination size, so the compiler assumes the result may not be null-terminated. Use sizeof(ifr.ifr_name) - 1 as the bound so at most 15 bytes are copied. Fixes: 3e4f05342662 ("examples/send-zerocopy: use strncpy() to copy interface name") Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn> --- examples/send-zerocopy.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/send-zerocopy.c b/examples/send-zerocopy.c index f0248d20..b2821af6 100644 --- a/examples/send-zerocopy.c +++ b/examples/send-zerocopy.c @@ -353,7 +353,7 @@ static void do_tx(struct thread_data *td, int domain, int type, int protocol) struct ifreq ifr; memset(&ifr, 0, sizeof(ifr)); - strncpy(ifr.ifr_name, cfg_ifname, sizeof(ifr.ifr_name)); + strncpy(ifr.ifr_name, cfg_ifname, sizeof(ifr.ifr_name) - 1); if (setsockopt(fd, SOL_SOCKET, SO_BINDTODEVICE, &ifr, sizeof(ifr)) < 0) t_error(1, errno, "Binding to device failed\n"); -- 2.25.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* [PATCH 2/2] test/cbpf_filter: skip when openat2.h is not available 2026-03-14 8:35 [PATCH Liburing 0/2] build and compiler warning fixes Yang Xiuwei 2026-03-14 8:35 ` [PATCH 1/2] examples/send-zerocopy: fix -Wstringop-truncation on ifr.ifr_name Yang Xiuwei @ 2026-03-14 8:35 ` Yang Xiuwei 2026-03-14 13:35 ` Jens Axboe 1 sibling, 1 reply; 7+ messages in thread From: Yang Xiuwei @ 2026-03-14 8:35 UTC (permalink / raw) To: axboe; +Cc: io-uring, Yang Xiuwei cbpf_filter.c unconditionally includes <linux/openat2.h>, so the test fails to build on systems whose kernel headers do not provide that file (e.g. older distros or LTS). configure already sets CONFIG_HAVE_OPEN_HOW=n and provides struct open_how in compat.h for the library and other tests; only this test bypassed that by including the kernel header directly. Wrap the entire test in #ifdef CONFIG_HAVE_OPEN_HOW and add a stub main that returns T_EXIT_SKIP in the #else branch. The test then always compiles; on systems without openat2.h it skips at runtime. Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn> --- test/cbpf_filter.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/test/cbpf_filter.c b/test/cbpf_filter.c index 41fd284e..050b3ac7 100644 --- a/test/cbpf_filter.c +++ b/test/cbpf_filter.c @@ -6,6 +6,7 @@ * Unlike eBPF which requires a separate compiled program, cBPF filters can * be defined inline as an array of sock_filter instructions. */ +#ifdef CONFIG_HAVE_OPEN_HOW #include <stdio.h> #include <stdlib.h> #include <string.h> @@ -1443,3 +1444,10 @@ int main(int argc, char *argv[]) return total_failed; } +#else /* #ifdef CONFIG_HAVE_OPEN_HOW */ +#include "helpers.h" +int main(void) +{ + return T_EXIT_SKIP; +} +#endif /* #ifdef CONFIG_HAVE_OPEN_HOW */ -- 2.25.1 ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] test/cbpf_filter: skip when openat2.h is not available 2026-03-14 8:35 ` [PATCH 2/2] test/cbpf_filter: skip when openat2.h is not available Yang Xiuwei @ 2026-03-14 13:35 ` Jens Axboe 2026-03-15 5:02 ` Yang Xiuwei 0 siblings, 1 reply; 7+ messages in thread From: Jens Axboe @ 2026-03-14 13:35 UTC (permalink / raw) To: Yang Xiuwei; +Cc: io-uring On 3/14/26 2:35 AM, Yang Xiuwei wrote: > cbpf_filter.c unconditionally includes <linux/openat2.h>, so the test > fails to build on systems whose kernel headers do not provide that > file (e.g. older distros or LTS). configure already sets > CONFIG_HAVE_OPEN_HOW=n and provides struct open_how in compat.h for > the library and other tests; only this test bypassed that by > including the kernel header directly. > > Wrap the entire test in #ifdef CONFIG_HAVE_OPEN_HOW and add a stub > main that returns T_EXIT_SKIP in the #else branch. The test then > always compiles; on systems without openat2.h it skips at runtime. liburing defines open_how if it's not in the system headers. I feel like all you need to do here is remove the openat2.h include, rather than disable the test entirely? -- Jens Axboe ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] test/cbpf_filter: skip when openat2.h is not available 2026-03-14 13:35 ` Jens Axboe @ 2026-03-15 5:02 ` Yang Xiuwei 2026-03-15 14:45 ` Jens Axboe 0 siblings, 1 reply; 7+ messages in thread From: Yang Xiuwei @ 2026-03-15 5:02 UTC (permalink / raw) To: axboe; +Cc: io-uring Hi Jens, On 2026-03-14 13:35 UTC, Jens Axboe wrote: > liburing defines open_how if it's not in the system headers. I feel > like all you need to do here is remove the openat2.h include, rather > than disable the test entirely? Thanks for the suggestion. I had actually tried that first: removing only the #include <linux/openat2.h> and relying on liburing's compat for struct open_how. It turned out that this test also uses the RESOLVE_IN_ROOT macro (and the filter logic is built around it). Without the header, the build fails with 'RESOLVE_IN_ROOT' undeclared. RESOLVE_IN_ROOT and the other RESOLVE_* flags come from <linux/openat2.h>; compat.h only provides struct open_how when the header is missing, not those constants. Defining RESOLVE_IN_ROOT (and friends) ourselves in compat or in the test would duplicate kernel UAPI and could get out of sync if the kernel ever changes them. So I went back to the more conservative approach: wrap the test in #ifdef CONFIG_HAVE_OPEN_HOW and provide a stub main that returns T_EXIT_SKIP when openat2.h is not available. The test then always compiles; on systems without the header it simply skips at runtime. If you have a better approach in mind, I'd be glad to follow that instead. Best regards, Yang Xiuwei ^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] test/cbpf_filter: skip when openat2.h is not available 2026-03-15 5:02 ` Yang Xiuwei @ 2026-03-15 14:45 ` Jens Axboe 2026-03-16 1:02 ` Yang Xiuwei 0 siblings, 1 reply; 7+ messages in thread From: Jens Axboe @ 2026-03-15 14:45 UTC (permalink / raw) To: Yang Xiuwei; +Cc: io-uring On 3/14/26 11:02 PM, Yang Xiuwei wrote: > Hi Jens, > > On 2026-03-14 13:35 UTC, Jens Axboe wrote: >> liburing defines open_how if it's not in the system headers. I feel >> like all you need to do here is remove the openat2.h include, rather >> than disable the test entirely? > > Thanks for the suggestion. I had actually tried that first: removing only the > #include <linux/openat2.h> and relying on liburing's compat for struct open_how. > It turned out that this test also uses the RESOLVE_IN_ROOT macro (and the > filter logic is built around it). Without the header, the build fails with > 'RESOLVE_IN_ROOT' undeclared. RESOLVE_IN_ROOT and the other RESOLVE_* flags > come from <linux/openat2.h>; compat.h only provides struct open_how when the > header is missing, not those constants. > > Defining RESOLVE_IN_ROOT (and friends) ourselves in compat or in the test > would duplicate kernel UAPI and could get out of sync if the kernel ever > changes them. So I went back to the more conservative approach: wrap the > test in #ifdef CONFIG_HAVE_OPEN_HOW and provide a stub main that returns > T_EXIT_SKIP when openat2.h is not available. The test then always compiles; > on systems without the header it simply skips at runtime. > > If you have a better approach in mind, I'd be glad to follow that instead. I think just defining RESOLVE_IN_ROOT if it's not available should be fine. And yes the test will always compile when you stub everything out, but it also won't do anything at all. This will prevent running this test case on a host with old headers, but with a current kernel. How about the below, hopefully that should do it. That'll keep the test functional, rather than wrap it all in a define that just disables it entirely. diff --git a/test/cbpf_filter.c b/test/cbpf_filter.c index 41fd284e4434..b80b15033662 100644 --- a/test/cbpf_filter.c +++ b/test/cbpf_filter.c @@ -15,12 +15,15 @@ #include <sys/wait.h> #include <sys/prctl.h> #include <linux/filter.h> -#include <linux/openat2.h> #include "liburing.h" #include "liburing/io_uring/bpf_filter.h" #include "helpers.h" +#ifndef RESOLVE_IN_ROOT +#define RESOLVE_IN_ROOT 0x10 +#endif + /* * cBPF filter context layout (struct io_uring_bpf_ctx): * offset 0: user_data (u64) -- Jens Axboe ^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH 2/2] test/cbpf_filter: skip when openat2.h is not available 2026-03-15 14:45 ` Jens Axboe @ 2026-03-16 1:02 ` Yang Xiuwei 0 siblings, 0 replies; 7+ messages in thread From: Yang Xiuwei @ 2026-03-16 1:02 UTC (permalink / raw) To: axboe; +Cc: io-uring Hi Jens, On 2026-03-15 14:45 UTC, Jens Axboe wrote: > I think just defining RESOLVE_IN_ROOT if it's not available should be > fine. And yes the test will always compile when you stub everything out, > but it also won't do anything at all. This will prevent running this > test case on a host with old headers, but with a current kernel. How > about the below, hopefully that should do it. That'll keep the test > functional, rather than wrap it all in a define that just disables it > entirely. > > diff --git a/test/cbpf_filter.c b/test/cbpf_filter.c > ... > +#ifndef RESOLVE_IN_ROOT > +#define RESOLVE_IN_ROOT 0x10 > +#endif Thanks, that works well for me. I'll send v2 with your approach. Best regards, Yang Xiuwei ^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2026-03-16 1:03 UTC | newest] Thread overview: 7+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2026-03-14 8:35 [PATCH Liburing 0/2] build and compiler warning fixes Yang Xiuwei 2026-03-14 8:35 ` [PATCH 1/2] examples/send-zerocopy: fix -Wstringop-truncation on ifr.ifr_name Yang Xiuwei 2026-03-14 8:35 ` [PATCH 2/2] test/cbpf_filter: skip when openat2.h is not available Yang Xiuwei 2026-03-14 13:35 ` Jens Axboe 2026-03-15 5:02 ` Yang Xiuwei 2026-03-15 14:45 ` Jens Axboe 2026-03-16 1:02 ` Yang Xiuwei
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox