[PATCH v2 4/8] selftests: vDSO: vdso_test_getrandom: Drop some dead code

Thomas Weißschuh posted 8 patches 9 months, 1 week ago
There is a newer version of this series
[PATCH v2 4/8] selftests: vDSO: vdso_test_getrandom: Drop some dead code
Posted by Thomas Weißschuh 9 months, 1 week ago
vgetrandom_put_state() and the variable ret in kselftest() are never used.

Drop the dead code.

Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
---
 tools/testing/selftests/vDSO/vdso_test_getrandom.c | 11 +----------
 1 file changed, 1 insertion(+), 10 deletions(-)

diff --git a/tools/testing/selftests/vDSO/vdso_test_getrandom.c b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
index f36e50f372f935e6d4da3175c81e210653bdce1d..b0e0d664508a38d6dde9df0a61ec8198ee928a17 100644
--- a/tools/testing/selftests/vDSO/vdso_test_getrandom.c
+++ b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
@@ -100,15 +100,6 @@ static void *vgetrandom_get_state(void)
 	return state;
 }
 
-static void vgetrandom_put_state(void *state)
-{
-	if (!state)
-		return;
-	pthread_mutex_lock(&vgrnd.lock);
-	vgrnd.states[vgrnd.len++] = state;
-	pthread_mutex_unlock(&vgrnd.lock);
-}
-
 static void vgetrandom_init(void)
 {
 	const char *version = versions[VDSO_VERSION];
@@ -264,7 +255,7 @@ static void kselftest(void)
 	}
 	for (;;) {
 		struct ptrace_syscall_info info = { 0 };
-		int status, ret;
+		int status;
 		ksft_assert(waitpid(child, &status, 0) >= 0);
 		if (WIFEXITED(status)) {
 			ksft_assert(WEXITSTATUS(status) == 0);

-- 
2.49.0

Re: [PATCH v2 4/8] selftests: vDSO: vdso_test_getrandom: Drop some dead code
Posted by Jason A. Donenfeld 9 months, 1 week ago
Hi Thomas,

On Mon, May 5, 2025 at 11:19 AM Thomas Weißschuh
<thomas.weissschuh@linutronix.de> wrote:
>
> vgetrandom_put_state() and the variable ret in kselftest() are never used.
>
> Drop the dead code.
>
> Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> ---
>  tools/testing/selftests/vDSO/vdso_test_getrandom.c | 11 +----------
>  1 file changed, 1 insertion(+), 10 deletions(-)
>
> diff --git a/tools/testing/selftests/vDSO/vdso_test_getrandom.c b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
> index f36e50f372f935e6d4da3175c81e210653bdce1d..b0e0d664508a38d6dde9df0a61ec8198ee928a17 100644
> --- a/tools/testing/selftests/vDSO/vdso_test_getrandom.c
> +++ b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
> @@ -100,15 +100,6 @@ static void *vgetrandom_get_state(void)
>         return state;
>  }
>
> -static void vgetrandom_put_state(void *state)
> -{
> -       if (!state)
> -               return;
> -       pthread_mutex_lock(&vgrnd.lock);
> -       vgrnd.states[vgrnd.len++] = state;
> -       pthread_mutex_unlock(&vgrnd.lock);
> -}

This sort of acts as example code / basic reference code for libcs and
such. So I like having this function around. Could you just mark it as
unused with an attribute but otherwise keep it?

Jason
Re: [PATCH v2 4/8] selftests: vDSO: vdso_test_getrandom: Drop some dead code
Posted by Thomas Weißschuh 9 months, 1 week ago
On Mon, May 05, 2025 at 02:58:06PM +0200, Jason A. Donenfeld wrote:
> Hi Thomas,
> 
> On Mon, May 5, 2025 at 11:19 AM Thomas Weißschuh
> <thomas.weissschuh@linutronix.de> wrote:
> >
> > vgetrandom_put_state() and the variable ret in kselftest() are never used.
> >
> > Drop the dead code.
> >
> > Signed-off-by: Thomas Weißschuh <thomas.weissschuh@linutronix.de>
> > Reviewed-by: Muhammad Usama Anjum <usama.anjum@collabora.com>
> > ---
> >  tools/testing/selftests/vDSO/vdso_test_getrandom.c | 11 +----------
> >  1 file changed, 1 insertion(+), 10 deletions(-)
> >
> > diff --git a/tools/testing/selftests/vDSO/vdso_test_getrandom.c b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
> > index f36e50f372f935e6d4da3175c81e210653bdce1d..b0e0d664508a38d6dde9df0a61ec8198ee928a17 100644
> > --- a/tools/testing/selftests/vDSO/vdso_test_getrandom.c
> > +++ b/tools/testing/selftests/vDSO/vdso_test_getrandom.c
> > @@ -100,15 +100,6 @@ static void *vgetrandom_get_state(void)
> >         return state;
> >  }
> >
> > -static void vgetrandom_put_state(void *state)
> > -{
> > -       if (!state)
> > -               return;
> > -       pthread_mutex_lock(&vgrnd.lock);
> > -       vgrnd.states[vgrnd.len++] = state;
> > -       pthread_mutex_unlock(&vgrnd.lock);
> > -}
> 
> This sort of acts as example code / basic reference code for libcs and
> such. So I like having this function around. Could you just mark it as
> unused with an attribute but otherwise keep it?

Sure, I'll do so.

If it is meant as an example, maybe the test could be extended to show how
to use it?


Thomas