Skip to contentSkip to conversation

selftests/fs/mount-notify: fix the indentation in the fsmount test

PATCH Applied Sasha Levin 6 participants 18 messages Nov 3 – Nov 18

Subsystems (5)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 selftests/fs/mount-notify: fix the indentation in the fsmount test

A few lines in the fsmount test are indented with spaces instead of a tab. That puts them deeper than the ASSERT_*() in front of them, which ends in a for loop with an empty body, so clang warns:

mount-notify_test.c:338:18: warning: for loop has empty body [-Wempty-body]

Indent them with tabs.

---
Found with clang 21; KernelCI's clang builds show the same warnings. Amir's pending fanotify series moves this file to filesystems/fanotify/, and its rename still applies on top of this.

 .../filesystems/mount-notify/mount-notify_test.c          | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
tools/testing/selftests/filesystems/mount-notify/mount-notify_test.c +4 -4
index 6381af6a40e30..6c95c275b1629 100644
@@ -337,18 +337,18 @@ TEST_F(fanotify, fsmount)
 	fs = fsopen("tmpfs", 0);
 	ASSERT_GE(fs, 0);
 
-        ret = fsconfig(fs, FSCONFIG_CMD_CREATE, 0, 0, 0);
+	ret = fsconfig(fs, FSCONFIG_CMD_CREATE, 0, 0, 0);
 	ASSERT_EQ(ret, 0);
 
-        mnt = fsmount(fs, 0, 0);
+	mnt = fsmount(fs, 0, 0);
 	ASSERT_GE(mnt, 0);
 
-        close(fs);
+	close(fs);
 
 	ret = move_mount(mnt, "", AT_FDCWD, "/a", MOVE_MOUNT_F_EMPTY_PATH);
 	ASSERT_EQ(ret, 0);
 
-        close(mnt);
+	close(mnt);
 
 	mnts[1] = expect_notify_mask(_metadata, self, FAN_MNT_ATTACH);
 	ASSERT_NE(mnts[0], mnts[1]);
Signature · 1 line
2.53.0
#1 lore raw

PATCH 1/1 selftests/filesystems: remove the unused list_del()

Nothing uses list_del() in utils.c, and clang warns about it in each test that builds utils.c with -Wall:

../utils.c:106:20: warning: unused function 'list_del' [-Wunused-function]

Remove it.

---
Found with clang 21; KernelCI's clang builds show the same warning.

 tools/testing/selftests/filesystems/utils.c | 10 ----------
 1 file changed, 10 deletions(-)
tools/testing/selftests/filesystems/utils.c +0 -10
index d73d7d8171db6..4321f1a552587 100644
@@ -103,16 +103,6 @@ static inline void list_add_tail(struct list *head, struct list *list)
 	__list_add(list, head->prev, head);
 }
 
-static inline void list_del(struct list *list)
-{
-	struct list *next, *prev;
-
-	next = list->next;
-	prev = list->prev;
-	next->prev = prev;
-	prev->next = next;
-}
-
 static ssize_t read_nointr(int fd, void *buf, size_t count)
 {
 	ssize_t ret;
Signature · 1 line
2.53.0
maintainer Applied
#2 lore raw

Re: (subset) [PATCH] selftests/filesystems: remove the unused list_del()

Quoted 8 lines · Sasha Levin

Nothing uses list_del() in utils.c, and clang warns about it in each test that builds utils.c with -Wall:

../utils.c:106:20: warning: unused function 'list_del' [-Wunused-function]

Remove it.

[...]

Applied to the vfs-7.5.misc branch of the vfs/vfs.git tree. Patches in the vfs-7.5.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.5.misc

[1/1] selftests/filesystems: remove the unused list_del()

      https://git.kernel.org/vfs/vfs/c/65c9cbad74a7
#3 lore raw

PATCH 1/1 selftests/statmount: initialize the byte written to the child

In reply to Sasha Levin

test_listmount_ns() writes pval to the child only to let it exit, but never sets it, and clang 21 warns:

statmount_test_ns.c:334:35: warning: variable 'pval' is uninitialized when passed as a const pointer argument here [-Wuninitialized-const-pointer]

Initialize it to 0.

---
Found with clang 21; KernelCI's clang builds show the same warning.

 .../testing/selftests/filesystems/statmount/statmount_test_ns.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/filesystems/statmount/statmount_test_ns.c +1 -1
index e500905e4c078..e7261d4f3be4e 100644
@@ -275,7 +275,7 @@ static int validate_external_listmount(pid_t pid, uint64_t child_nr_mounts)
 static void test_listmount_ns(void)
 {
 	uint64_t nr_mounts;
-	char pval;
+	char pval = 0;
 	int child_ready_pipe[2];
 	int parent_ready_pipe[2];
 	pid_t pid;
Signature · 1 line
2.53.0
maintainer Applied
#4 lore raw

Re: (subset) [PATCH] selftests/statmount: initialize the byte written to the child

Quoted 8 lines · Sasha Levin

test_listmount_ns() writes pval to the child only to let it exit, but never sets it, and clang 21 warns:

statmount_test_ns.c:334:35: warning: variable 'pval' is uninitialized when passed as a const pointer argument here [-Wuninitialized-const-pointer]

Initialize it to 0.

[...]

Applied to the vfs-7.5.misc branch of the vfs/vfs.git tree. Patches in the vfs-7.5.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.5.misc

[1/1] selftests/statmount: initialize the byte written to the child

      https://git.kernel.org/vfs/vfs/c/678e669241c8
#5 lore raw

PATCH 1/1 selftests/namespaces: initialize the byte the children write

In reply to Sasha Levin

The children in listns_pagination_bug and stress_test write c to the parent only to say they are ready, but never set it, and clang 21 warns:

stress_test.c:137:22: warning: variable 'c' is uninitialized when passed as a const pointer argument here [-Wuninitialized-const-pointer]

Initialize it to 'X', as the parent does with its byte.

---
Found with clang 21. The namespaces tests aren't in TARGETS in tools/testing/selftests/Makefile, so CI doesn't build or run them. Is that on purpose?

 tools/testing/selftests/namespaces/listns_pagination_bug.c | 2 +-
 tools/testing/selftests/namespaces/stress_test.c           | 4 ++--
 2 files changed, 3 insertions(+), 3 deletions(-)
tools/testing/selftests/namespaces/listns_pagination_bug.c +1 -1
index da7d33f963972..6452825e88506 100644
@@ -46,7 +46,7 @@ TEST(pagination_with_type_filter)
 		ASSERT_GE(pids[i], 0);
 
 		if (pids[i] == 0) {
-			char c;
+			char c = 'X';
 			close(sv[0]);
 
 			if (setup_userns() < 0) {
tools/testing/selftests/namespaces/stress_test.c +2 -2
index dd7df7d6cb277..6a27b98c5bc2a 100644
@@ -124,7 +124,7 @@ TEST(many_concurrent_namespaces)
 
 		if (pids[i] == 0) {
 			/* Child: create user namespace and wait for parent signal */
-			char c;
+			char c = 'X';
 
 			close(sv[0]);
 
@@ -366,7 +366,7 @@ TEST(listns_pagination_stress)
 		ASSERT_GE(pids[i], 0);
 
 		if (pids[i] == 0) {
-			char c;
+			char c = 'X';
 			close(sv[0]);
 
 			if (setup_userns() < 0) {
Signature · 1 line
2.53.0
maintainer Applied
#6 lore raw

Re: (subset) [PATCH] selftests/namespaces: initialize the byte the children write

Quoted 9 lines · Sasha Levin

The children in listns_pagination_bug and stress_test write c to the parent only to say they are ready, but never set it, and clang 21 warns:

stress_test.c:137:22: warning: variable 'c' is uninitialized when passed as a const pointer argument here [-Wuninitialized-const-pointer]

Initialize it to 'X', as the parent does with its byte.

[...]

Applied to the vfs-7.5.misc branch of the vfs/vfs.git tree. Patches in the vfs-7.5.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.5.misc

[1/1] selftests/namespaces: initialize the byte the children write

      https://git.kernel.org/vfs/vfs/c/b2971bf97205
#7 lore raw

Re: [PATCH] selftests/namespaces: initialize the byte the children write

In reply to Sasha Levin
Quoted 3 lines · Sasha Levin

Found with clang 21. The namespaces tests aren't in TARGETS in tools/testing/selftests/Makefile, so CI doesn't build or run them. Is that on purpose?

That's an accident. Please send a patch adding it. Thanks for spotting it.

#8 lore raw

PATCH 1/1 selftests: add namespaces to TARGETS

The namespaces tests are not in TARGETS, so "make kselftest" and the CI systems that use the top-level Makefile never build or run them. Add them.

---
Tested on vfs-7.5.misc with gcc 16 and clang 21 on x86_64: all 13 tests pass in a VM with the namespaces config fragment, and they also build for i386 and arm64.

 tools/testing/selftests/Makefile | 1 +
 1 file changed, 1 insertion(+)
tools/testing/selftests/Makefile +1 -0
index 07c3719f8b04b..f8fb771d3b0e8 100644
@@ -85,6 +85,7 @@ TARGETS += mount_setattr
 TARGETS += move_mount_set_group
 TARGETS += mqueue
 TARGETS += mseal_system_mappings
+TARGETS += namespaces
 TARGETS += nci
 TARGETS += net
 TARGETS += net/af_unix

base-commit: 8f92edb375bc5b54b211686231d489912a91b32a

Signature · 1 line
2.53.0
maintainer Applied
#9 lore raw

Re: [PATCH] selftests: add namespaces to TARGETS

Quoted 3 lines · Sasha Levin

The namespaces tests are not in TARGETS, so "make kselftest" and the CI systems that use the top-level Makefile never build or run them. Add them.

Applied to the vfs-7.5.misc branch of the vfs/vfs.git tree. Patches in the vfs-7.5.misc branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs-7.5.misc

[1/1] selftests: add namespaces to TARGETS

      https://git.kernel.org/vfs/vfs/c/c07b5d746feb
#10 lore raw

PATCH 1/1 selftests: netfilter: nf_queue: drop the no-op loop initializer

In reply to Sasha Levin

The out-of-order verdict loop starts with "for (ooo_count; ...", and clang warns about the unused expression:

nf_queue.c:354:10: warning: expression result unused [-Wunused-value]

Leave the initializer empty.

---
KernelCI's clang builds show this warning.

 tools/testing/selftests/net/netfilter/nf_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/netfilter/nf_queue.c +1 -1
index cca6c3cfa9e46..bc0b2f601a0a4 100644
@@ -351,7 +351,7 @@ static int mainloop(void)
 		if (opts.out_of_order) {
 			ooo_ids[ooo_count] = id;
 			if (ooo_count >= 15) {
-				for (ooo_count; ooo_count >= 0; ooo_count--) {
+				for (; ooo_count >= 0; ooo_count--) {
 					nlh = nfq_build_verdict(buf, ooo_ids[ooo_count],
 								opts.queue_num, opts.verdict);
 					if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#11 lore raw

Re: [PATCH nf-next] selftests: netfilter: nf_queue: drop the no-op loop initializer

Quoted 30 lines · Sasha Levin

The out-of-order verdict loop starts with "for (ooo_count; ...", and clang warns about the unused expression:

nf_queue.c:354:10: warning: expression result unused [-Wunused-value]

Leave the initializer empty.

---
KernelCI's clang builds show this warning.

 tools/testing/selftests/net/netfilter/nf_queue.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/netfilter/nf_queue.c +1 -1
index cca6c3cfa9e46..bc0b2f601a0a4 100644
@@ -351,7 +351,7 @@ static int mainloop(void)
 		if (opts.out_of_order) {
 			ooo_ids[ooo_count] = id;
 			if (ooo_count >= 15) {
-				for (ooo_count; ooo_count >= 0; ooo_count--) {
+				for (; ooo_count >= 0; ooo_count--) {
 					nlh = nfq_build_verdict(buf, ooo_ids[ooo_count],
 								opts.queue_num, opts.verdict);
 					if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#12 lore raw

Re: [PATCH nf-next] selftests: netfilter: nf_queue: drop the no-op loop initializer

In reply to Sasha Levin
Quoted 19 lines · Sasha Levin

The out-of-order verdict loop starts with "for (ooo_count; ...", and clang warns about the unused expression:

nf_queue.c:354:10: warning: expression result unused [-Wunused-value]

Leave the initializer empty.

---
KernelCI's clang builds show this warning.

  tools/testing/selftests/net/netfilter/nf_queue.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/netfilter/nf_queue.c +0 -0
index cca6c3cfa9e46..bc0b2f601a0a4 100644

tools/testing/selftests/net/netfilter/nf_queue.c static int mainloop(void) · line 357

Quoted 8 lines
tools/testing/selftests/net/netfilter/nf_queue.c +1 -1
@@ -351,7 +351,7 @@ static int mainloop(void)
  		if (opts.out_of_order) {
  			ooo_ids[ooo_count] = id;
  			if (ooo_count >= 15) {
-				for (ooo_count; ooo_count >= 0; ooo_count--) {
+				for (; ooo_count >= 0; ooo_count--) {
  					nlh = nfq_build_verdict(buf, ooo_ids[ooo_count],
  								opts.queue_num, opts.verdict);
  					if (mnl_socket_sendto(nl, nlh, nlh->nlmsg_len) < 0) {

Thanks!

#13 lore raw

PATCH 1/1 selftests: net: tcp_ao: make the netstat column pointer const

In reply to Sasha Levin

lookup_get_column() stores the result of strchr() on a const string in a plain char pointer. Since glibc 2.43, strchr() returns a const char pointer for a const argument when C23 features are enabled, as they are with _GNU_SOURCE, so gcc and clang warn:

lib/proc.c:61:16: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

The pointer is only used to compute the length, so make it const.

---
Found with gcc 16 and clang 21 on glibc 2.43; KernelCI's gcc 15 builds show the same warning.

 tools/testing/selftests/net/tcp_ao/lib/proc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/tcp_ao/lib/proc.c +1 -1
index 8b984fa042869..50062b527a393 100644
@@ -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)
Signature · 1 line
2.53.0
Reviewed-by on v1 1/1
#14 lore raw

Re: [PATCH net-next] selftests: net: tcp_ao: make the netstat column pointer const

Quoted 33 lines · Sasha Levin

lookup_get_column() stores the result of strchr() on a const string in a plain char pointer. Since glibc 2.43, strchr() returns a const char pointer for a const argument when C23 features are enabled, as they are with _GNU_SOURCE, so gcc and clang warn:

lib/proc.c:61:16: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

The pointer is only used to compute the length, so make it const.

---
Found with gcc 16 and clang 21 on glibc 2.43; KernelCI's gcc 15 builds show the same warning.

 tools/testing/selftests/net/tcp_ao/lib/proc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/tcp_ao/lib/proc.c +1 -1
index 8b984fa042869..50062b527a393 100644
@@ -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)
Signature · 1 line
2.53.0
Acked-by on v1 1/1
#15 lore raw

Re: [PATCH net-next] selftests: net: tcp_ao: make the netstat column pointer const

In reply to Sasha Levin
Quoted 11 lines · Sasha Levin

lookup_get_column() stores the result of strchr() on a const string in a plain char pointer. Since glibc 2.43, strchr() returns a const char pointer for a const argument when C23 features are enabled, as they are with _GNU_SOURCE, so gcc and clang warn:

lib/proc.c:61:16: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

The pointer is only used to compute the length, so make it const.

Thanks!

Quoted 23 lines

---
Found with gcc 16 and clang 21 on glibc 2.43; KernelCI's gcc 15 builds show the same warning.

 tools/testing/selftests/net/tcp_ao/lib/proc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/net/tcp_ao/lib/proc.c +1 -2
index 8b984fa042869..50062b527a393 100644
@@ -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.53.0

#16 lore raw

Re: [PATCH net-next] selftests: net: tcp_ao: make the netstat column pointer const

In reply to Sasha Levin
This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (main) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Tue, 3 Nov 2026 11:54:19 -0500 you wrote:

lookup_get_column() stores the result of strchr() on a const string in a plain char pointer. Since glibc 2.43, strchr() returns a const char pointer for a const argument when C23 features are enabled, as they are with _GNU_SOURCE, so gcc and clang warn:

lib/proc.c:61:16: warning: assignment discards 'const' qualifier from pointer target type [-Wdiscarded-qualifiers]

[...]

Here is the summary with links:
- [net-next] selftests: net: tcp_ao: make the netstat column pointer const

    https://git.kernel.org/netdev/net-next/c/f13fc72ba243

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
maintainer Applied
#17 lore raw
In reply to Sasha Levin
Quoted 9 lines · Sasha Levin

A few lines in the fsmount test are indented with spaces instead of a tab. That puts them deeper than the ASSERT_*() in front of them, which ends in a for loop with an empty body, so clang warns:

mount-notify_test.c:338:18: warning: for loop has empty body [-Wempty-body]

Indent them with tabs.

[...]

Applied to the vfs.fixes branch of the vfs/vfs.git tree. Patches in the vfs.fixes branch should appear in linux-next soon.

Please report any outstanding bugs that were missed during review in a new review to the original patch series allowing us to drop it.

It's encouraged to provide Acked-bys and Reviewed-bys even though the patch has now been applied. If possible patch trailers will be updated.

Note that commit hashes shown below are subject to change due to rebase, trailer updates or similar. If in doubt, please check the listed branch.

tree:   https://git.kernel.org/pub/scm/linux/kernel/git/vfs/vfs.git
branch: vfs.fixes

[1/1] selftests/fs/mount-notify: fix the indentation in the fsmount test

      https://git.kernel.org/vfs/vfs/c/5e042e208dfe