Skip to contentSkip to conversation

selftests/futex: Remove static keyword from 'head'

PATCH RESEND Applied Ankit Khushwaha 2 participants 2 messages Apr 20 – Jul 5

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

PATCH RESEND v3 1/1 selftests/futex: Remove static keyword from 'head'

'head' is defined as 'static struct robust_list_head' that stores the local variable of 'struct lock_struct a' raising the Wdangling-pointer warning.

robust_list.c: In function ‘child_circular_list’:
robust_list.c:522:24: warning: storing the address of local variable ‘a’ in ‘head.list.next’ [-Wdangling-pointer=]

  522 |         head.list.next = &a.list;
      |         ~~~~~~~~~~~~~~~^~~~~~~~~

robust_list.c:513:28: note: ‘a’ declared here
513 | struct lock_struct a, b, c;
| ^
robust_list.c:512:40: note: ‘head’ declared here
512 | static struct robust_list_head head;
| ^~~~

Since 'head' doesn't need static storge duration, removing the static keyword of it to fix this.

---
v3: https://lore.kernel.org/all/[email protected]/
Updated the patch name and msg as suggested by André.

v2: https://lore.kernel.org/all/[email protected]/
Added changes suggested by André.

v1: https://lore.kernel.org/all/[email protected]/

---
 tools/testing/selftests/futex/functional/robust_list.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/futex/functional/robust_list.c +1 -1
index e7d1254e18ca..ef21a7ec9def 100644
@@ -509,7 +509,7 @@ TEST(test_robust_list_multiple_elements)
 
 static int child_circular_list(void *arg)
 {
-	static struct robust_list_head head;
+	struct robust_list_head head;
 	struct lock_struct a, b, c;
 	int ret;
 

--
2.53.0

#1 lore raw
The following commit has been merged into the locking/futex branch of tip:

The following commit has been merged into the locking/futex branch of tip:

Commit-ID:     dfa2f2378fb18c1917e097d710b55ae16442c3e3
Gitweb:        https://git.kernel.org/tip/dfa2f2378fb18c1917e097d710b55ae16442c3e3
Author:        Ankit Khushwaha <[email protected]>
AuthorDate:    Mon, 20 Apr 2026 23:05:44 +05:30
Committer:     Thomas Gleixner <[email protected]>
CommitterDate: Sun, 05 Jul 2026 21:49:17 +02:00

selftests/futex: Remove static keyword from 'head'

'head' is defined as 'static struct robust_list_head' that stores the local variable of 'struct lock_struct a' raising the Wdangling-pointer warning.

robust_list.c: In function ‘child_circular_list’:
robust_list.c:522:24: warning: storing the address of local variable ‘a’ in ‘head.list.next’ [-Wdangling-pointer=]

  522 |         head.list.next = &a.list;
      |         ~~~~~~~~~~~~~~~^~~~~~~~~

robust_list.c:513:28: note: ‘a’ declared here
513 | struct lock_struct a, b, c;
| ^
robust_list.c:512:40: note: ‘head’ declared here
512 | static struct robust_list_head head;
| ^~~~

Since 'head' doesn't need static storge duration, removing the static keyword of it to fix this.

---
 tools/testing/selftests/futex/functional/robust_list.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
tools/testing/selftests/futex/functional/robust_list.c +1 -1
index b3fab60..12feec1 100644
@@ -522,7 +522,7 @@ TEST(test_robust_list_multiple_elements)
 
 static int child_circular_list(void *arg)
 {
-	static struct robust_list_head head;
+	struct robust_list_head head;
 	struct lock_struct a, b, c;
 	int ret;