public inbox for io-uring@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2 0/2] build and compiler warning fixes
@ 2026-03-16  1:36 Yang Xiuwei
  2026-03-16  1:36 ` [PATCH v2 1/2] examples/send-zerocopy: fix -Wstringop-truncation on ifr.ifr_name Yang Xiuwei
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Yang Xiuwei @ 2026-03-16  1:36 UTC (permalink / raw)
  To: axboe; +Cc: io-uring, Yang Xiuwei

Fix two issues: (1) send-zerocopy -Wstringop-truncation on ifr.ifr_name;
(2) cbpf_filter build failure when kernel headers lack openat2.h.

Changes since v1:
  - Patch 2/2: Per Jens's suggestion, use RESOLVE_IN_ROOT fallback instead
    of stubbing the test. 
  - Patch 1/2 unchanged.

  v1: https://lore.kernel.org/io-uring/20260314083538.791693-1-yangxiuwei@kylinos.cn/

Yang Xiuwei (2):
  examples/send-zerocopy: fix -Wstringop-truncation on ifr.ifr_name
  test/cbpf_filter: fix build when openat2.h is not available

 examples/send-zerocopy.c |  2 +-
 test/cbpf_filter.c       |  5 ++++-
 2 files changed, 5 insertions(+), 2 deletions(-)

-- 
2.25.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2 1/2] examples/send-zerocopy: fix -Wstringop-truncation on ifr.ifr_name
  2026-03-16  1:36 [PATCH v2 0/2] build and compiler warning fixes Yang Xiuwei
@ 2026-03-16  1:36 ` Yang Xiuwei
  2026-03-16  1:36 ` [PATCH v2 2/2] test/cbpf_filter: fix build when openat2.h is not available Yang Xiuwei
  2026-03-16 10:37 ` [PATCH v2 0/2] build and compiler warning fixes Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Yang Xiuwei @ 2026-03-16  1:36 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] 4+ messages in thread

* [PATCH v2 2/2] test/cbpf_filter: fix build when openat2.h is not available
  2026-03-16  1:36 [PATCH v2 0/2] build and compiler warning fixes Yang Xiuwei
  2026-03-16  1:36 ` [PATCH v2 1/2] examples/send-zerocopy: fix -Wstringop-truncation on ifr.ifr_name Yang Xiuwei
@ 2026-03-16  1:36 ` Yang Xiuwei
  2026-03-16 10:37 ` [PATCH v2 0/2] build and compiler warning fixes Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Yang Xiuwei @ 2026-03-16  1:36 UTC (permalink / raw)
  To: axboe; +Cc: io-uring, Yang Xiuwei

cbpf_filter.c included <linux/openat2.h> for struct open_how and
RESOLVE_IN_ROOT, so the test failed to build on systems without that
header (e.g. older distros). liburing's compat already provides
struct open_how; add a fallback #define for RESOLVE_IN_ROOT (0x10)
when the header is missing, so the test both builds and runs on
old headers with a current kernel.

Suggested-by: Jens Axboe <axboe@kernel.dk>
Signed-off-by: Yang Xiuwei <yangxiuwei@kylinos.cn>
---
 test/cbpf_filter.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/test/cbpf_filter.c b/test/cbpf_filter.c
index 41fd284e..b80b1503 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)
-- 
2.25.1


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH v2 0/2] build and compiler warning fixes
  2026-03-16  1:36 [PATCH v2 0/2] build and compiler warning fixes Yang Xiuwei
  2026-03-16  1:36 ` [PATCH v2 1/2] examples/send-zerocopy: fix -Wstringop-truncation on ifr.ifr_name Yang Xiuwei
  2026-03-16  1:36 ` [PATCH v2 2/2] test/cbpf_filter: fix build when openat2.h is not available Yang Xiuwei
@ 2026-03-16 10:37 ` Jens Axboe
  2 siblings, 0 replies; 4+ messages in thread
From: Jens Axboe @ 2026-03-16 10:37 UTC (permalink / raw)
  To: Yang Xiuwei; +Cc: io-uring


On Mon, 16 Mar 2026 09:36:19 +0800, Yang Xiuwei wrote:
> Fix two issues: (1) send-zerocopy -Wstringop-truncation on ifr.ifr_name;
> (2) cbpf_filter build failure when kernel headers lack openat2.h.
> 
> Changes since v1:
>   - Patch 2/2: Per Jens's suggestion, use RESOLVE_IN_ROOT fallback instead
>     of stubbing the test.
>   - Patch 1/2 unchanged.
> 
> [...]

Applied, thanks!

[1/2] examples/send-zerocopy: fix -Wstringop-truncation on ifr.ifr_name
      commit: b6a45c81fe1dd6d657f0ea96873cf38a69b0a410
[2/2] test/cbpf_filter: fix build when openat2.h is not available
      commit: a6e7bd5522be2ece8fe1accd2dbb4082742300a6

Best regards,
-- 
Jens Axboe




^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-03-16 10:37 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-16  1:36 [PATCH v2 0/2] build and compiler warning fixes Yang Xiuwei
2026-03-16  1:36 ` [PATCH v2 1/2] examples/send-zerocopy: fix -Wstringop-truncation on ifr.ifr_name Yang Xiuwei
2026-03-16  1:36 ` [PATCH v2 2/2] test/cbpf_filter: fix build when openat2.h is not available Yang Xiuwei
2026-03-16 10:37 ` [PATCH v2 0/2] build and compiler warning fixes Jens Axboe

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