Linux Kernel Selftest development
 help / color / mirror / Atom feed
* [PATCH 00/15] Fix compilation warnings in selftests
@ 2026-04-29 10:27 Eva Kurchatova
  2026-04-29 10:27 ` [PATCH 01/15] selftests/uevent: fix -Wmaybe-uninitialized warning in uevent_filtering Eva Kurchatova
                   ` (14 more replies)
  0 siblings, 15 replies; 16+ messages in thread
From: Eva Kurchatova @ 2026-04-29 10:27 UTC (permalink / raw)
  To: linux-kselftest; +Cc: eva.kurchatova, khorenko

This patchset fixes several compilation warnings in selftests,
related to unused or uninitialized variables and compiler analysis.

These warnings may be reproduced via GCC with -Wall -Wextra

Eva Kurchatova (4):
  selftests/tcp_ao: fix -Wdiscarded-qualifiers under C23
  selftests/iommu: suppress -Warray-bounds in _test_cmd_get_hw_info
  selftests/fchmodat2: suppress -Wunused-parameter
  selftests/openat2: suppress -Wsign-compare and -Wunused-parameter

Konstantin Khorenko (11):
  selftests/uevent: fix -Wmaybe-uninitialized warning in
    uevent_filtering
  selftests/prctl: remove unused variable 'j' in set-process-name
  selftests/netfilter: remove unused variables in conntrack_dump_flush
  selftests/netfilter: remove unused variable 'plen' in
    conntrack_reverse_clash
  selftests/mqueue: fix warnings in mq_perf_tests
  selftests/mqueue: fix -Wunused-variable warning for 'usage' in
    mq_open_tests
  selftests/memfd: fix -Wmaybe-uninitialized warning in memfd_test
  selftests/memfd: remove unused variable 'sig' in fuse_test
  selftests/membarrier: remove unused variable 'i'
  selftests/epoll: remove unused variable 'pfd' in epoll59 test
  selftests/clone3: remove unused variables in
    clone3_cap_checkpoint_restore

 .../selftests/clone3/clone3_cap_checkpoint_restore.c   |  4 ----
 tools/testing/selftests/fchmodat2/fchmodat2_test.c     |  2 +-
 .../selftests/filesystems/epoll/epoll_wakeup_test.c    |  1 -
 tools/testing/selftests/iommu/iommufd_utils.h          | 10 ++++++----
 .../membarrier/membarrier_test_multi_thread.c          |  1 -
 tools/testing/selftests/memfd/fuse_test.c              |  2 +-
 tools/testing/selftests/memfd/memfd_test.c             |  4 ++--
 tools/testing/selftests/mqueue/mq_open_tests.c         |  2 +-
 tools/testing/selftests/mqueue/mq_perf_tests.c         |  4 +---
 .../selftests/net/netfilter/conntrack_dump_flush.c     |  7 ++-----
 .../selftests/net/netfilter/conntrack_reverse_clash.c  |  1 -
 tools/testing/selftests/net/tcp_ao/lib/proc.c          |  2 +-
 tools/testing/selftests/openat2/openat2_test.c         | 10 +++++-----
 tools/testing/selftests/prctl/set-process-name.c       |  3 +--
 tools/testing/selftests/uevent/uevent_filtering.c      |  2 +-
 15 files changed, 22 insertions(+), 33 deletions(-)

-- 
2.54.0


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

* [PATCH 01/15] selftests/uevent: fix -Wmaybe-uninitialized warning in uevent_filtering
  2026-04-29 10:27 [PATCH 00/15] Fix compilation warnings in selftests Eva Kurchatova
@ 2026-04-29 10:27 ` Eva Kurchatova
  2026-04-29 10:27 ` [PATCH 02/15] selftests/prctl: remove unused variable 'j' in set-process-name Eva Kurchatova
                   ` (13 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Eva Kurchatova @ 2026-04-29 10:27 UTC (permalink / raw)
  To: linux-kselftest; +Cc: eva.kurchatova, khorenko

From: Konstantin Khorenko <khorenko@virtuozzo.com>

  uevent_filtering.c: In function 'trigger_uevent':
  uevent_filtering.c:217:16: warning: 'ret' may be used uninitialized
  [-Wmaybe-uninitialized]
    217 |         return ret;
        |                ^~~
  uevent_filtering.c:197:17: note: 'ret' was declared here
    197 |         int fd, ret;
        |                 ^~~

Initialize 'ret' to 0 in trigger_uevent(). If 'times' is 0, the for
loop body is never entered and 'ret' would be returned uninitialized.

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/testing/selftests/uevent/uevent_filtering.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/uevent/uevent_filtering.c b/tools/testing/selftests/uevent/uevent_filtering.c
index 974b076f9235..e3cded66233d 100644
--- a/tools/testing/selftests/uevent/uevent_filtering.c
+++ b/tools/testing/selftests/uevent/uevent_filtering.c
@@ -194,7 +194,7 @@ static int uevent_listener(unsigned long post_flags, bool expect_uevent,
 
 int trigger_uevent(unsigned int times)
 {
-	int fd, ret;
+	int fd, ret = 0;
 	unsigned int i;
 
 	fd = open(__DEV_FULL, O_RDWR | O_CLOEXEC);
-- 
2.54.0


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

* [PATCH 02/15] selftests/prctl: remove unused variable 'j' in set-process-name
  2026-04-29 10:27 [PATCH 00/15] Fix compilation warnings in selftests Eva Kurchatova
  2026-04-29 10:27 ` [PATCH 01/15] selftests/uevent: fix -Wmaybe-uninitialized warning in uevent_filtering Eva Kurchatova
@ 2026-04-29 10:27 ` Eva Kurchatova
  2026-04-29 10:27 ` [PATCH 03/15] selftests/netfilter: remove unused variables in conntrack_dump_flush Eva Kurchatova
                   ` (12 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Eva Kurchatova @ 2026-04-29 10:27 UTC (permalink / raw)
  To: linux-kselftest; +Cc: eva.kurchatova, khorenko

From: Konstantin Khorenko <khorenko@virtuozzo.com>

  set-process-name.c: In function 'check_name':
  set-process-name.c:61:13: warning: variable 'j' set but not used
  [-Wunused-but-set-variable]
     61 |         int j;
        |             ^

Remove unused 'j' to fix -Wunused-but-set-variable warning.
The snprintf() return value is not needed here.

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/testing/selftests/prctl/set-process-name.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/tools/testing/selftests/prctl/set-process-name.c b/tools/testing/selftests/prctl/set-process-name.c
index 3f7b146d36df..3c5175f873ec 100644
--- a/tools/testing/selftests/prctl/set-process-name.c
+++ b/tools/testing/selftests/prctl/set-process-name.c
@@ -58,9 +58,8 @@ int check_name(void)
 	char path[MAX_PATH_LEN] = {};
 	char name[TASK_COMM_LEN] = {};
 	char output[TASK_COMM_LEN] = {};
-	int j;
 
-	j = snprintf(path, MAX_PATH_LEN, "/proc/self/task/%d/comm", pid);
+	snprintf(path, MAX_PATH_LEN, "/proc/self/task/%d/comm", pid);
 	fptr = fopen(path, "r");
 	if (!fptr)
 		return -EIO;
-- 
2.54.0


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

* [PATCH 03/15] selftests/netfilter: remove unused variables in conntrack_dump_flush
  2026-04-29 10:27 [PATCH 00/15] Fix compilation warnings in selftests Eva Kurchatova
  2026-04-29 10:27 ` [PATCH 01/15] selftests/uevent: fix -Wmaybe-uninitialized warning in uevent_filtering Eva Kurchatova
  2026-04-29 10:27 ` [PATCH 02/15] selftests/prctl: remove unused variable 'j' in set-process-name Eva Kurchatova
@ 2026-04-29 10:27 ` Eva Kurchatova
  2026-04-29 10:28 ` [PATCH 04/15] selftests/netfilter: remove unused variable 'plen' in conntrack_reverse_clash Eva Kurchatova
                   ` (11 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Eva Kurchatova @ 2026-04-29 10:27 UTC (permalink / raw)
  To: linux-kselftest; +Cc: eva.kurchatova, khorenko

From: Konstantin Khorenko <khorenko@virtuozzo.com>

  conntrack_dump_flush.c: In function 'conntrack_data_insert':
  conntrack_dump_flush.c:105:26: warning: unused variable 'rplnlh'
  [-Wunused-variable]
    105 |         struct nlmsghdr *rplnlh;
        |                          ^~~~~~
  conntrack_dump_flush.c: In function 'conntracK_count_zone':
  conntrack_dump_flush.c:224:24: warning: unused variable 'nest'
  [-Wunused-variable]
    224 |         struct nlattr *nest;
        |                        ^~~~
  conntrack_dump_flush.c:222:32: warning: unused variable 'rplnlh'
  [-Wunused-variable]
    222 |         struct nlmsghdr *nlh, *rplnlh;
        |                                ^~~~~~
  conntrack_dump_flush.c: In function 'conntrack_flush_zone':
  conntrack_dump_flush.c:271:24: warning: unused variable 'nest'
  [-Wunused-variable]
    271 |         struct nlattr *nest;
        |                        ^~~~
  conntrack_dump_flush.c:269:32: warning: unused variable 'rplnlh'
  [-Wunused-variable]
    269 |         struct nlmsghdr *nlh, *rplnlh;
        |                                ^~~~~~

Remove unused 'rplnlh' and 'nest' variables from conntrack_data_insert(),
conntracK_count_zone() and conntrack_flush_zone() to fix -Wunused-variable
warnings.

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 .../testing/selftests/net/netfilter/conntrack_dump_flush.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/net/netfilter/conntrack_dump_flush.c b/tools/testing/selftests/net/netfilter/conntrack_dump_flush.c
index 5cecb8a1bc94..c8e4794ec5cb 100644
--- a/tools/testing/selftests/net/netfilter/conntrack_dump_flush.c
+++ b/tools/testing/selftests/net/netfilter/conntrack_dump_flush.c
@@ -102,7 +102,6 @@ static int conntrack_data_insert(struct mnl_socket *sock, struct nlmsghdr *nlh,
 				 uint16_t zone)
 {
 	char buf[MNL_SOCKET_BUFFER_SIZE];
-	struct nlmsghdr *rplnlh;
 	unsigned int portid;
 	int ret;
 
@@ -219,9 +218,8 @@ static int count_entries(const struct nlmsghdr *nlh, void *data)
 static int conntracK_count_zone(struct mnl_socket *sock, uint16_t zone)
 {
 	char buf[MNL_SOCKET_BUFFER_SIZE];
-	struct nlmsghdr *nlh, *rplnlh;
+	struct nlmsghdr *nlh;
 	struct nfgenmsg *nfh;
-	struct nlattr *nest;
 	unsigned int portid;
 	int ret;
 
@@ -266,9 +264,8 @@ static int conntracK_count_zone(struct mnl_socket *sock, uint16_t zone)
 static int conntrack_flush_zone(struct mnl_socket *sock, uint16_t zone)
 {
 	char buf[MNL_SOCKET_BUFFER_SIZE];
-	struct nlmsghdr *nlh, *rplnlh;
+	struct nlmsghdr *nlh;
 	struct nfgenmsg *nfh;
-	struct nlattr *nest;
 	unsigned int portid;
 	int ret;
 
-- 
2.54.0


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

* [PATCH 04/15] selftests/netfilter: remove unused variable 'plen' in conntrack_reverse_clash
  2026-04-29 10:27 [PATCH 00/15] Fix compilation warnings in selftests Eva Kurchatova
                   ` (2 preceding siblings ...)
  2026-04-29 10:27 ` [PATCH 03/15] selftests/netfilter: remove unused variables in conntrack_dump_flush Eva Kurchatova
@ 2026-04-29 10:28 ` Eva Kurchatova
  2026-04-29 10:28 ` [PATCH 05/15] selftests/mqueue: fix warnings in mq_perf_tests Eva Kurchatova
                   ` (10 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Eva Kurchatova @ 2026-04-29 10:28 UTC (permalink / raw)
  To: linux-kselftest; +Cc: eva.kurchatova, khorenko

From: Konstantin Khorenko <khorenko@virtuozzo.com>

  conntrack_reverse_clash.c: In function 'main':
  conntrack_reverse_clash.c:66:19: warning: unused variable 'plen'
  [-Wunused-variable]
     66 |         socklen_t plen;
        |                   ^~~~

Remove unused 'plen' to fix -Wunused-variable warning.

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/testing/selftests/net/netfilter/conntrack_reverse_clash.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/net/netfilter/conntrack_reverse_clash.c b/tools/testing/selftests/net/netfilter/conntrack_reverse_clash.c
index 462d628cc3bd..441ac9a93eac 100644
--- a/tools/testing/selftests/net/netfilter/conntrack_reverse_clash.c
+++ b/tools/testing/selftests/net/netfilter/conntrack_reverse_clash.c
@@ -68,7 +68,6 @@ int main(int argc, char *argv[])
 	};
 	int s1, s2, status;
 	time_t end, now;
-	socklen_t plen;
 	char buf[LEN];
 	bool child;
 
-- 
2.54.0


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

* [PATCH 05/15] selftests/mqueue: fix warnings in mq_perf_tests
  2026-04-29 10:27 [PATCH 00/15] Fix compilation warnings in selftests Eva Kurchatova
                   ` (3 preceding siblings ...)
  2026-04-29 10:28 ` [PATCH 04/15] selftests/netfilter: remove unused variable 'plen' in conntrack_reverse_clash Eva Kurchatova
@ 2026-04-29 10:28 ` Eva Kurchatova
  2026-04-29 10:28 ` [PATCH 06/15] selftests/mqueue: fix -Wunused-variable warning for 'usage' in mq_open_tests Eva Kurchatova
                   ` (9 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Eva Kurchatova @ 2026-04-29 10:28 UTC (permalink / raw)
  To: linux-kselftest; +Cc: eva.kurchatova, khorenko

From: Konstantin Khorenko <khorenko@virtuozzo.com>

  mq_perf_tests.c: In function 'perf_test_thread':
  mq_perf_tests.c:433:20: warning: variable 't' set but not used
  [-Wunused-but-set-variable]
    433 |         pthread_t *t;
        |                    ^
  mq_perf_tests.c: At top level:
  mq_perf_tests.c:45:14: warning: 'usage' defined but not used
  [-Wunused-variable]
     45 | static char *usage =
        |              ^~~~~

- Mark 'usage' with __attribute__((unused)) to fix -Wunused-variable.
- Remove unused variable 't' to fix -Wunused-but-set-variable.

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/testing/selftests/mqueue/mq_perf_tests.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/tools/testing/selftests/mqueue/mq_perf_tests.c b/tools/testing/selftests/mqueue/mq_perf_tests.c
index 303c46eebd94..a13378464551 100644
--- a/tools/testing/selftests/mqueue/mq_perf_tests.c
+++ b/tools/testing/selftests/mqueue/mq_perf_tests.c
@@ -42,7 +42,7 @@
 
 #include "kselftest.h"
 
-static char *usage =
+static char __attribute__((unused)) *usage =
 "Usage:\n"
 "  %s [-c #[,#..] -f] path\n"
 "\n"
@@ -430,12 +430,10 @@ void *perf_test_thread(void *arg)
 	unsigned int prio_in;
 	int i;
 	clockid_t clock;
-	pthread_t *t;
 	struct timespec res, start, middle, end, send_total, recv_total;
 	unsigned long long nsec;
 	struct test *cur_test;
 
-	t = &cpu_threads[0];
 	printf("\n\tStarted mqueue performance test thread on CPU %d\n",
 	       cpus_to_pin[0]);
 	mq_prio_max = sysconf(_SC_MQ_PRIO_MAX);
-- 
2.54.0


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

* [PATCH 06/15] selftests/mqueue: fix -Wunused-variable warning for 'usage' in mq_open_tests
  2026-04-29 10:27 [PATCH 00/15] Fix compilation warnings in selftests Eva Kurchatova
                   ` (4 preceding siblings ...)
  2026-04-29 10:28 ` [PATCH 05/15] selftests/mqueue: fix warnings in mq_perf_tests Eva Kurchatova
@ 2026-04-29 10:28 ` Eva Kurchatova
  2026-04-29 10:28 ` [PATCH 07/15] selftests/memfd: fix -Wmaybe-uninitialized warning in memfd_test Eva Kurchatova
                   ` (8 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Eva Kurchatova @ 2026-04-29 10:28 UTC (permalink / raw)
  To: linux-kselftest; +Cc: eva.kurchatova, khorenko

From: Konstantin Khorenko <khorenko@virtuozzo.com>

  mq_open_tests.c:38:14: warning: 'usage' defined but not used
  [-Wunused-variable]
     38 | static char *usage =
        |              ^~~~~

Mark 'usage' with __attribute__((unused)) to fix the warning.
The variable is kept for documentation purposes.

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/testing/selftests/mqueue/mq_open_tests.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/mqueue/mq_open_tests.c b/tools/testing/selftests/mqueue/mq_open_tests.c
index b16029c40c0f..f7955507917b 100644
--- a/tools/testing/selftests/mqueue/mq_open_tests.c
+++ b/tools/testing/selftests/mqueue/mq_open_tests.c
@@ -35,7 +35,7 @@
 
 #include "kselftest.h"
 
-static char *usage =
+static char __attribute__((unused)) *usage =
 "Usage:\n"
 "  %s path\n"
 "\n"
-- 
2.54.0


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

* [PATCH 07/15] selftests/memfd: fix -Wmaybe-uninitialized warning in memfd_test
  2026-04-29 10:27 [PATCH 00/15] Fix compilation warnings in selftests Eva Kurchatova
                   ` (5 preceding siblings ...)
  2026-04-29 10:28 ` [PATCH 06/15] selftests/mqueue: fix -Wunused-variable warning for 'usage' in mq_open_tests Eva Kurchatova
@ 2026-04-29 10:28 ` Eva Kurchatova
  2026-04-29 10:28 ` [PATCH 08/15] selftests/memfd: remove unused variable 'sig' in fuse_test Eva Kurchatova
                   ` (7 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Eva Kurchatova @ 2026-04-29 10:28 UTC (permalink / raw)
  To: linux-kselftest; +Cc: eva.kurchatova, khorenko

From: Konstantin Khorenko <khorenko@virtuozzo.com>

  memfd_test.c: In function 'mfd_fail_grow_write.part.0':
  memfd_test.c:685:13: warning: '<unknown>' may be used uninitialized
  [-Wmaybe-uninitialized]
    685 |         l = pwrite(fd, buf, mfd_def_size * 8, 0);
        |             ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

pwrite() is declared with attribute 'access (read_only, 2, 3)', so GCC
knows it reads from the buffer. malloc() returns uninitialized memory,
hence the warning. Use calloc() to zero-initialize the buffer. The
actual contents don't matter here since the test verifies that pwrite()
fails on a sealed memfd.

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 tools/testing/selftests/memfd/memfd_test.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/memfd/memfd_test.c b/tools/testing/selftests/memfd/memfd_test.c
index 2ca07ea7202a..cdab3a837624 100644
--- a/tools/testing/selftests/memfd/memfd_test.c
+++ b/tools/testing/selftests/memfd/memfd_test.c
@@ -688,9 +688,9 @@ static void mfd_assert_grow_write(int fd)
 	if (hugetlbfs_test)
 		return;
 
-	buf = malloc(mfd_def_size * 8);
+	buf = calloc(1, mfd_def_size * 8);
 	if (!buf) {
-		printf("malloc(%zu) failed: %m\n", mfd_def_size * 8);
+		printf("calloc(1, %zu) failed: %m\n", mfd_def_size * 8);
 		abort();
 	}
 
-- 
2.54.0


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

* [PATCH 08/15] selftests/memfd: remove unused variable 'sig' in fuse_test
  2026-04-29 10:27 [PATCH 00/15] Fix compilation warnings in selftests Eva Kurchatova
                   ` (6 preceding siblings ...)
  2026-04-29 10:28 ` [PATCH 07/15] selftests/memfd: fix -Wmaybe-uninitialized warning in memfd_test Eva Kurchatova
@ 2026-04-29 10:28 ` Eva Kurchatova
  2026-04-29 10:28 ` [PATCH 09/15] selftests/membarrier: remove unused variable 'i' Eva Kurchatova
                   ` (6 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Eva Kurchatova @ 2026-04-29 10:28 UTC (permalink / raw)
  To: linux-kselftest; +Cc: eva.kurchatova, khorenko

From: Konstantin Khorenko <khorenko@virtuozzo.com>

  fuse_test.c: In function 'sealing_thread_fn':
  fuse_test.c:165:13: warning: unused variable 'sig' [-Wunused-variable]
    165 |         int sig, r;
        |             ^~~

Remove unused 'sig' to fix -Wunused-variable warning.

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/testing/selftests/memfd/fuse_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/memfd/fuse_test.c b/tools/testing/selftests/memfd/fuse_test.c
index dbc171a3806d..510056c1b0d0 100644
--- a/tools/testing/selftests/memfd/fuse_test.c
+++ b/tools/testing/selftests/memfd/fuse_test.c
@@ -162,7 +162,7 @@ static void *global_p = NULL;
 
 static int sealing_thread_fn(void *arg)
 {
-	int sig, r;
+	int r;
 
 	/*
 	 * This thread first waits 200ms so any pending operation in the parent
-- 
2.54.0


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

* [PATCH 09/15] selftests/membarrier: remove unused variable 'i'
  2026-04-29 10:27 [PATCH 00/15] Fix compilation warnings in selftests Eva Kurchatova
                   ` (7 preceding siblings ...)
  2026-04-29 10:28 ` [PATCH 08/15] selftests/memfd: remove unused variable 'sig' in fuse_test Eva Kurchatova
@ 2026-04-29 10:28 ` Eva Kurchatova
  2026-04-29 10:28 ` [PATCH 10/15] selftests/epoll: remove unused variable 'pfd' in epoll59 test Eva Kurchatova
                   ` (5 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Eva Kurchatova @ 2026-04-29 10:28 UTC (permalink / raw)
  To: linux-kselftest; +Cc: eva.kurchatova, khorenko

From: Konstantin Khorenko <khorenko@virtuozzo.com>

  membarrier_test_multi_thread.c: In function 'test_mt_membarrier':
  membarrier_test_multi_thread.c:36:13: warning: unused variable 'i'
  [-Wunused-variable]
     36 |         int i;
        |             ^

Remove unused 'i' to fix -Wunused-variable warning.

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 .../testing/selftests/membarrier/membarrier_test_multi_thread.c  | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/membarrier/membarrier_test_multi_thread.c b/tools/testing/selftests/membarrier/membarrier_test_multi_thread.c
index 4e14dba81234..3dbaf1541058 100644
--- a/tools/testing/selftests/membarrier/membarrier_test_multi_thread.c
+++ b/tools/testing/selftests/membarrier/membarrier_test_multi_thread.c
@@ -33,7 +33,6 @@ void *test_membarrier_thread(void *arg)
 
 static int test_mt_membarrier(void)
 {
-	int i;
 	pthread_t test_thread;
 
 	pthread_create(&test_thread, NULL,
-- 
2.54.0


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

* [PATCH 10/15] selftests/epoll: remove unused variable 'pfd' in epoll59 test
  2026-04-29 10:27 [PATCH 00/15] Fix compilation warnings in selftests Eva Kurchatova
                   ` (8 preceding siblings ...)
  2026-04-29 10:28 ` [PATCH 09/15] selftests/membarrier: remove unused variable 'i' Eva Kurchatova
@ 2026-04-29 10:28 ` Eva Kurchatova
  2026-04-29 10:28 ` [PATCH 11/15] selftests/clone3: remove unused variables in clone3_cap_checkpoint_restore Eva Kurchatova
                   ` (4 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Eva Kurchatova @ 2026-04-29 10:28 UTC (permalink / raw)
  To: linux-kselftest; +Cc: eva.kurchatova, khorenko

From: Konstantin Khorenko <khorenko@virtuozzo.com>

  epoll_wakeup_test.c: In function 'epoll59':
  epoll_wakeup_test.c:3121:23: warning: unused variable 'pfd'
  [-Wunused-variable]
   3121 |         struct pollfd pfd;
        |                       ^~~

Remove unused 'struct pollfd pfd' to fix -Wunused-variable warning.

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c b/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c
index 8bc57a2ef966..bb20da2ce60d 100644
--- a/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c
+++ b/tools/testing/selftests/filesystems/epoll/epoll_wakeup_test.c
@@ -3118,7 +3118,6 @@ static void *epoll59_thread(void *ctx_)
 TEST(epoll59)
 {
 	pthread_t emitter;
-	struct pollfd pfd;
 	struct epoll_event e;
 	struct epoll_mtcontext ctx = { 0 };
 	int i, ret;
-- 
2.54.0


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

* [PATCH 11/15] selftests/clone3: remove unused variables in clone3_cap_checkpoint_restore
  2026-04-29 10:27 [PATCH 00/15] Fix compilation warnings in selftests Eva Kurchatova
                   ` (9 preceding siblings ...)
  2026-04-29 10:28 ` [PATCH 10/15] selftests/epoll: remove unused variable 'pfd' in epoll59 test Eva Kurchatova
@ 2026-04-29 10:28 ` Eva Kurchatova
  2026-04-29 10:28 ` [PATCH 12/15] selftests/tcp_ao: fix -Wdiscarded-qualifiers under C23 Eva Kurchatova
                   ` (3 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Eva Kurchatova @ 2026-04-29 10:28 UTC (permalink / raw)
  To: linux-kselftest; +Cc: eva.kurchatova, khorenko

From: Konstantin Khorenko <khorenko@virtuozzo.com>

  clone3_cap_checkpoint_restore.c: In function 'call_clone3_set_tid':
  clone3_cap_checkpoint_restore.c:57:22: warning: unused variable 'tmp'
  [-Wunused-variable]
     57 |                 char tmp = 0;
        |                      ^~~
  clone3_cap_checkpoint_restore.c:56:21: warning: unused variable 'ret'
  [-Wunused-variable]
     56 |                 int ret;
        |                     ^~~
  clone3_cap_checkpoint_restore.c: In function 'clone3_cap_checkpoint_restore':
  clone3_cap_checkpoint_restore.c:138:13: warning: unused variable 'ret'
  [-Wunused-variable]
    138 |         int ret = 0;
        |             ^~~

Remove unused variables 'ret' and 'tmp' to fix -Wunused-variable
warnings.

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
---
 .../testing/selftests/clone3/clone3_cap_checkpoint_restore.c  | 4 ----
 1 file changed, 4 deletions(-)

diff --git a/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c b/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c
index e82281efa273..fd4baa0695fa 100644
--- a/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c
+++ b/tools/testing/selftests/clone3/clone3_cap_checkpoint_restore.c
@@ -53,9 +53,6 @@ static int call_clone3_set_tid(struct __test_metadata *_metadata,
 	}
 
 	if (pid == 0) {
-		int ret;
-		char tmp = 0;
-
 		TH_LOG("I am the child, my PID is %d (expected %d)", getpid(), set_tid[0]);
 
 		if (set_tid[0] != getpid())
@@ -135,7 +132,6 @@ TEST(clone3_cap_checkpoint_restore)
 {
 	pid_t pid;
 	int status;
-	int ret = 0;
 	pid_t set_tid[1];
 
 	test_clone3_supported();
-- 
2.54.0


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

* [PATCH 12/15] selftests/tcp_ao: fix -Wdiscarded-qualifiers under C23
  2026-04-29 10:27 [PATCH 00/15] Fix compilation warnings in selftests Eva Kurchatova
                   ` (10 preceding siblings ...)
  2026-04-29 10:28 ` [PATCH 11/15] selftests/clone3: remove unused variables in clone3_cap_checkpoint_restore Eva Kurchatova
@ 2026-04-29 10:28 ` Eva Kurchatova
  2026-04-29 10:28 ` [PATCH 13/15] selftests/iommu: suppress -Warray-bounds in _test_cmd_get_hw_info Eva Kurchatova
                   ` (2 subsequent siblings)
  14 siblings, 0 replies; 16+ messages in thread
From: Eva Kurchatova @ 2026-04-29 10:28 UTC (permalink / raw)
  To: linux-kselftest; +Cc: eva.kurchatova, khorenko

glibc ≥ 2.42 (GCC 15) defaults to -std=gnu23, which promotes
-Wdiscarded-qualifiers to an error.

In C23, strstr() and strchr() return "const char *".

Change variable types to const char * where the pointers are never
modified (column)

Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 tools/testing/selftests/net/tcp_ao/lib/proc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/net/tcp_ao/lib/proc.c b/tools/testing/selftests/net/tcp_ao/lib/proc.c
index 8b984fa04286..50062b527a39 100644
--- a/tools/testing/selftests/net/tcp_ao/lib/proc.c
+++ b/tools/testing/selftests/net/tcp_ao/lib/proc.c
@@ -56,7 +56,7 @@ static struct netstat *lookup_get(struct netstat *ns,
 
 static struct netstat *lookup_get_column(struct netstat *ns, const char *line)
 {
-	char *column;
+	const char *column;
 
 	column = strchr(line, ':');
 	if (!column)
-- 
2.54.0


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

* [PATCH 13/15] selftests/iommu: suppress -Warray-bounds in _test_cmd_get_hw_info
  2026-04-29 10:27 [PATCH 00/15] Fix compilation warnings in selftests Eva Kurchatova
                   ` (11 preceding siblings ...)
  2026-04-29 10:28 ` [PATCH 12/15] selftests/tcp_ao: fix -Wdiscarded-qualifiers under C23 Eva Kurchatova
@ 2026-04-29 10:28 ` Eva Kurchatova
  2026-04-29 10:28 ` [PATCH 14/15] selftests/fchmodat2: suppress -Wunused-parameter Eva Kurchatova
  2026-04-29 10:28 ` [PATCH 15/15] selftests/openat2: suppress -Wsign-compare and -Wunused-parameter Eva Kurchatova
  14 siblings, 0 replies; 16+ messages in thread
From: Eva Kurchatova @ 2026-04-29 10:28 UTC (permalink / raw)
  To: linux-kselftest; +Cc: eva.kurchatova, khorenko

  In function '_test_cmd_get_hw_info',
      inlined from 'iommufd_ioas_get_hw_info' at iommufd.c:614:3,
      inlined from 'wrapper_iommufd_ioas_get_hw_info' at iommufd.c:589:1:
  iommufd_utils.h:683:37: warning: array subscript 'struct iommu_test_hw_info[0]'
  is partly outside array bounds of 'struct iommu_test_hw_info_buffer_smaller[1]'
  [-Warray-bounds=]
    683 |                         assert(!info->flags);
        |                                 ~~~~^~~~~~~

The test intentionally passes a smaller buffer to exercise the kernel's
handling of undersized user buffers. Runtime data_len checks make the
access safe, but GCC cannot prove this statically. Suppress the warning
locally via copying into properly-sized temporary structure.

Signed-off-by: Konstantin Khorenko <khorenko@virtuozzo.com>
Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 tools/testing/selftests/iommu/iommufd_utils.h | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/tools/testing/selftests/iommu/iommufd_utils.h b/tools/testing/selftests/iommu/iommufd_utils.h
index 5502751d500c..ca978b8b796d 100644
--- a/tools/testing/selftests/iommu/iommufd_utils.h
+++ b/tools/testing/selftests/iommu/iommufd_utils.h
@@ -5,6 +5,7 @@
 
 #include <unistd.h>
 #include <stddef.h>
+#include <string.h>
 #include <sys/fcntl.h>
 #include <sys/ioctl.h>
 #include <stdint.h>
@@ -826,7 +827,6 @@ static int _test_cmd_get_hw_info(int fd, __u32 device_id, __u32 data_type,
 				 void *data, size_t data_len,
 				 uint32_t *capabilities, uint8_t *max_pasid)
 {
-	struct iommu_test_hw_info *info = (struct iommu_test_hw_info *)data;
 	struct iommu_hw_info cmd = {
 		.size = sizeof(cmd),
 		.dev_id = device_id,
@@ -866,11 +866,13 @@ static int _test_cmd_get_hw_info(int fd, __u32 device_id, __u32 data_type,
 		}
 	}
 
-	if (info) {
+	if (data) {
+		struct iommu_test_hw_info info = {0};
+		memcpy(&info, data, data_len);
 		if (data_len >= offsetofend(struct iommu_test_hw_info, test_reg))
-			assert(info->test_reg == IOMMU_HW_INFO_SELFTEST_REGVAL);
+			assert(info.test_reg == IOMMU_HW_INFO_SELFTEST_REGVAL);
 		if (data_len >= offsetofend(struct iommu_test_hw_info, flags))
-			assert(!info->flags);
+			assert(!info.flags);
 	}
 
 	if (max_pasid)
-- 
2.54.0


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

* [PATCH 14/15] selftests/fchmodat2: suppress -Wunused-parameter
  2026-04-29 10:27 [PATCH 00/15] Fix compilation warnings in selftests Eva Kurchatova
                   ` (12 preceding siblings ...)
  2026-04-29 10:28 ` [PATCH 13/15] selftests/iommu: suppress -Warray-bounds in _test_cmd_get_hw_info Eva Kurchatova
@ 2026-04-29 10:28 ` Eva Kurchatova
  2026-04-29 10:28 ` [PATCH 15/15] selftests/openat2: suppress -Wsign-compare and -Wunused-parameter Eva Kurchatova
  14 siblings, 0 replies; 16+ messages in thread
From: Eva Kurchatova @ 2026-04-29 10:28 UTC (permalink / raw)
  To: linux-kselftest; +Cc: eva.kurchatova, khorenko

fchmodat2_test.c: In function ‘main’:
fchmodat2_test.c:191:14: warning: unused parameter ‘argc’ [-Wunused-parameter]
  191 | int main(int argc, char **argv)
      |          ~~~~^~~~
fchmodat2_test.c:191:27: warning: unused parameter ‘argv’ [-Wunused-parameter]
  191 | int main(int argc, char **argv)
      |                    ~~~~~~~^~~~

Remove unused argc & argv parameters to fix -Wunused-parameter warnings

Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 tools/testing/selftests/fchmodat2/fchmodat2_test.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/testing/selftests/fchmodat2/fchmodat2_test.c b/tools/testing/selftests/fchmodat2/fchmodat2_test.c
index 8e1b6384b319..409cca0dce7c 100644
--- a/tools/testing/selftests/fchmodat2/fchmodat2_test.c
+++ b/tools/testing/selftests/fchmodat2/fchmodat2_test.c
@@ -188,7 +188,7 @@ void test_symlink(void)
 
 #define NUM_TESTS 2
 
-int main(int argc, char **argv)
+int main()
 {
 	ksft_print_header();
 	ksft_set_plan(NUM_TESTS);
-- 
2.54.0


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

* [PATCH 15/15] selftests/openat2: suppress -Wsign-compare and -Wunused-parameter
  2026-04-29 10:27 [PATCH 00/15] Fix compilation warnings in selftests Eva Kurchatova
                   ` (13 preceding siblings ...)
  2026-04-29 10:28 ` [PATCH 14/15] selftests/fchmodat2: suppress -Wunused-parameter Eva Kurchatova
@ 2026-04-29 10:28 ` Eva Kurchatova
  14 siblings, 0 replies; 16+ messages in thread
From: Eva Kurchatova @ 2026-04-29 10:28 UTC (permalink / raw)
  To: linux-kselftest; +Cc: eva.kurchatova, khorenko

openat2_test.c: In function ‘test_openat2_struct’:
openat2_test.c:89:27: warning: comparison of integer expressions of
different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
   89 |         for (int i = 0; i < ARRAY_LEN(tests); i++) {
      |                           ^
openat2_test.c:93:35: warning: comparison of integer expressions of
different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
   93 |                 for (int j = 0; j < ARRAY_LEN(misalignments); j++) {
      |                                   ^
openat2_test.c: In function ‘test_openat2_flags’:
openat2_test.c:246:27: warning: comparison of integer expressions of
different signedness: ‘int’ and ‘long unsigned int’ [-Wsign-compare]
  246 |         for (int i = 0; i < ARRAY_LEN(tests); i++) {
      |                           ^
openat2_test.c:296:44: warning: comparison of integer expressions of different
signedness: ‘int’ and ‘__u64’ {aka ‘long long unsigned int’} [-Wsign-compare]
  296 |                         failed |= (fdflags != test->how.flags);
      |                                            ^~
openat2_test.c: In function ‘main’:
openat2_test.c:326:14: warning: unused parameter ‘argc’ [-Wunused-parameter]
  326 | int main(int argc, char **argv)
      |          ~~~~^~~~
openat2_test.c:326:27: warning: unused parameter ‘argv’ [-Wunused-parameter]
  326 | int main(int argc, char **argv)
      |                    ~~~~~~~^~~~

Use size_t for array loop iterator, explicitly cast open_how flags field
to fix -Wsign-compare warnings

Remove unused argc & argv parameters to fix -Wunused-parameter warnings

Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com>
---
 tools/testing/selftests/openat2/openat2_test.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/tools/testing/selftests/openat2/openat2_test.c b/tools/testing/selftests/openat2/openat2_test.c
index 0e161ef9e9e4..a8b73b62c7c5 100644
--- a/tools/testing/selftests/openat2/openat2_test.c
+++ b/tools/testing/selftests/openat2/openat2_test.c
@@ -86,11 +86,11 @@ void test_openat2_struct(void)
 	BUILD_BUG_ON(ARRAY_LEN(misalignments) != NUM_OPENAT2_STRUCT_VARIATIONS);
 	BUILD_BUG_ON(ARRAY_LEN(tests) != NUM_OPENAT2_STRUCT_TESTS);
 
-	for (int i = 0; i < ARRAY_LEN(tests); i++) {
+	for (size_t i = 0; i < ARRAY_LEN(tests); i++) {
 		struct struct_test *test = &tests[i];
 		struct open_how_ext how_ext = test->arg;
 
-		for (int j = 0; j < ARRAY_LEN(misalignments); j++) {
+		for (size_t j = 0; j < ARRAY_LEN(misalignments); j++) {
 			int fd, misalign = misalignments[j];
 			char *fdpath = NULL;
 			bool failed;
@@ -243,7 +243,7 @@ void test_openat2_flags(void)
 
 	BUILD_BUG_ON(ARRAY_LEN(tests) != NUM_OPENAT2_FLAG_TESTS);
 
-	for (int i = 0; i < ARRAY_LEN(tests); i++) {
+	for (size_t i = 0; i < ARRAY_LEN(tests); i++) {
 		int fd, fdflags = -1;
 		char *path, *fdpath = NULL;
 		bool failed = false;
@@ -293,7 +293,7 @@ void test_openat2_flags(void)
 				fdflags |= O_CREAT;
 			if (!(test->how.flags & O_LARGEFILE))
 				fdflags &= ~O_LARGEFILE;
-			failed |= (fdflags != test->how.flags);
+			failed |= (fdflags != (int)test->how.flags);
 		}
 
 		if (failed) {
@@ -323,7 +323,7 @@ void test_openat2_flags(void)
 #define NUM_TESTS (NUM_OPENAT2_STRUCT_VARIATIONS * NUM_OPENAT2_STRUCT_TESTS + \
 		   NUM_OPENAT2_FLAG_TESTS)
 
-int main(int argc, char **argv)
+int main()
 {
 	ksft_print_header();
 	ksft_set_plan(NUM_TESTS);
-- 
2.54.0


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

end of thread, other threads:[~2026-04-29 10:29 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-29 10:27 [PATCH 00/15] Fix compilation warnings in selftests Eva Kurchatova
2026-04-29 10:27 ` [PATCH 01/15] selftests/uevent: fix -Wmaybe-uninitialized warning in uevent_filtering Eva Kurchatova
2026-04-29 10:27 ` [PATCH 02/15] selftests/prctl: remove unused variable 'j' in set-process-name Eva Kurchatova
2026-04-29 10:27 ` [PATCH 03/15] selftests/netfilter: remove unused variables in conntrack_dump_flush Eva Kurchatova
2026-04-29 10:28 ` [PATCH 04/15] selftests/netfilter: remove unused variable 'plen' in conntrack_reverse_clash Eva Kurchatova
2026-04-29 10:28 ` [PATCH 05/15] selftests/mqueue: fix warnings in mq_perf_tests Eva Kurchatova
2026-04-29 10:28 ` [PATCH 06/15] selftests/mqueue: fix -Wunused-variable warning for 'usage' in mq_open_tests Eva Kurchatova
2026-04-29 10:28 ` [PATCH 07/15] selftests/memfd: fix -Wmaybe-uninitialized warning in memfd_test Eva Kurchatova
2026-04-29 10:28 ` [PATCH 08/15] selftests/memfd: remove unused variable 'sig' in fuse_test Eva Kurchatova
2026-04-29 10:28 ` [PATCH 09/15] selftests/membarrier: remove unused variable 'i' Eva Kurchatova
2026-04-29 10:28 ` [PATCH 10/15] selftests/epoll: remove unused variable 'pfd' in epoll59 test Eva Kurchatova
2026-04-29 10:28 ` [PATCH 11/15] selftests/clone3: remove unused variables in clone3_cap_checkpoint_restore Eva Kurchatova
2026-04-29 10:28 ` [PATCH 12/15] selftests/tcp_ao: fix -Wdiscarded-qualifiers under C23 Eva Kurchatova
2026-04-29 10:28 ` [PATCH 13/15] selftests/iommu: suppress -Warray-bounds in _test_cmd_get_hw_info Eva Kurchatova
2026-04-29 10:28 ` [PATCH 14/15] selftests/fchmodat2: suppress -Wunused-parameter Eva Kurchatova
2026-04-29 10:28 ` [PATCH 15/15] selftests/openat2: suppress -Wsign-compare and -Wunused-parameter Eva Kurchatova

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