public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
* [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; 5+ 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] 5+ 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; 5+ 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] 5+ 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; 5+ 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] 5+ 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; 5+ 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] 5+ 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
  0 siblings, 0 replies; 5+ 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] 5+ messages in thread

end of thread, other threads:[~2026-03-15  5:02 UTC | newest]

Thread overview: 5+ 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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox