* [PATCH] selftests/futex: Fix storing address of local variable
@ 2025-11-18 16:26 Ankit Khushwaha
2025-11-18 16:34 ` André Almeida
0 siblings, 1 reply; 3+ messages in thread
From: Ankit Khushwaha @ 2025-11-18 16:26 UTC (permalink / raw)
To: Thomas Gleixner, Ingo Molnar, Peter Zijlstra, Darren Hart,
Davidlohr Bueso, andrealmeid, Shuah Khan
Cc: linux-kernel, linux-kselftest, Ankit Khushwaha
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset=8, Size: 1475 bytes --]
In `child_circular_list()` address of local variable ‘struct lock_struct a’
is assigned to `head.list.next` raising the following 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;
| ^~~~
Defining the value with static keyword to fix this.
Signed-off-by: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
---
tools/testing/selftests/futex/functional/robust_list.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/tools/testing/selftests/futex/functional/robust_list.c b/tools/testing/selftests/futex/functional/robust_list.c
index e7d1254e18ca..d1aab1cc5a37 100644
--- a/tools/testing/selftests/futex/functional/robust_list.c
+++ b/tools/testing/selftests/futex/functional/robust_list.c
@@ -510,7 +510,7 @@ TEST(test_robust_list_multiple_elements)
static int child_circular_list(void *arg)
{
static struct robust_list_head head;
- struct lock_struct a, b, c;
+ static struct lock_struct a, b, c;
int ret;
ret = set_list(&head);
--
2.51.1
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] selftests/futex: Fix storing address of local variable
2025-11-18 16:26 [PATCH] selftests/futex: Fix storing address of local variable Ankit Khushwaha
@ 2025-11-18 16:34 ` André Almeida
2025-11-18 17:03 ` Ankit Khushwaha
0 siblings, 1 reply; 3+ messages in thread
From: André Almeida @ 2025-11-18 16:34 UTC (permalink / raw)
To: Ankit Khushwaha
Cc: linux-kernel, Ingo Molnar, Darren Hart, Thomas Gleixner,
Shuah Khan, Peter Zijlstra, linux-kselftest, Davidlohr Bueso
Em 18/11/2025 13:26, Ankit Khushwaha escreveu:
> In `child_circular_list()` address of local variable ‘struct lock_struct a’
> is assigned to `head.list.next` raising the following 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;
> | ^~~~
>
> Defining the value with static keyword to fix this.
>
> Signed-off-by: Ankit Khushwaha <ankitkhushwaha.linux@gmail.com>
> ---
> tools/testing/selftests/futex/functional/robust_list.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/tools/testing/selftests/futex/functional/robust_list.c b/tools/testing/selftests/futex/functional/robust_list.c
> index e7d1254e18ca..d1aab1cc5a37 100644
> --- a/tools/testing/selftests/futex/functional/robust_list.c
> +++ b/tools/testing/selftests/futex/functional/robust_list.c
> @@ -510,7 +510,7 @@ TEST(test_robust_list_multiple_elements)
> static int child_circular_list(void *arg)
> {
> static struct robust_list_head head;
> - struct lock_struct a, b, c;
> + static struct lock_struct a, b, c;
I believe that the right fix here would be to drop the static from
`head` declaration, WDYT?
^ permalink raw reply [flat|nested] 3+ messages in thread* Re: [PATCH] selftests/futex: Fix storing address of local variable
2025-11-18 16:34 ` André Almeida
@ 2025-11-18 17:03 ` Ankit Khushwaha
0 siblings, 0 replies; 3+ messages in thread
From: Ankit Khushwaha @ 2025-11-18 17:03 UTC (permalink / raw)
To: André Almeida
Cc: linux-kernel, Ingo Molnar, Darren Hart, Thomas Gleixner,
Shuah Khan, Peter Zijlstra, linux-kselftest, Davidlohr Bueso
On Tue, Nov 18, 2025 at 01:34:59PM -0300, André Almeida wrote:
> > diff --git a/tools/testing/selftests/futex/functional/robust_list.c b/tools/testing/selftests/futex/functional/robust_list.c
> > index e7d1254e18ca..d1aab1cc5a37 100644
> > --- a/tools/testing/selftests/futex/functional/robust_list.c
> > +++ b/tools/testing/selftests/futex/functional/robust_list.c
> > @@ -510,7 +510,7 @@ TEST(test_robust_list_multiple_elements)
> > static int child_circular_list(void *arg)
> > {
> > static struct robust_list_head head;
> > - struct lock_struct a, b, c;
> > + static struct lock_struct a, b, c;
>
> I believe that the right fix here would be to drop the static from `head`
> declaration, WDYT?
Hi André,
I have tested your suggested changes.
It works fine. will send v2 patch for this.
Thanks,
-- Ankit
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-11-18 17:03 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-11-18 16:26 [PATCH] selftests/futex: Fix storing address of local variable Ankit Khushwaha
2025-11-18 16:34 ` André Almeida
2025-11-18 17:03 ` Ankit Khushwaha
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox