[v2,1/2] Fix invalid use of NULL in epoll_pwait2(2) test

Message ID 20230531204422.18052-1-alx@kernel.org
State Committed
Commit cc5372806a4bf34cb5c9038d1716b5ea6202abd0
Headers
Series [v2,1/2] Fix invalid use of NULL in epoll_pwait2(2) test |

Commit Message

Alejandro Colomar May 31, 2023, 8:44 p.m. UTC
  epoll_pwait2(2)'s second argument should be nonnull.  We're going to add
__nonnull to the prototype, so let's fix the test accordingly.  We can
use a dummy variable to avoid passing NULL.

Reported-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
Signed-off-by: Alejandro Colomar <alx@kernel.org>
---
 sysdeps/unix/sysv/linux/tst-epoll.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
  

Comments

Adhemerval Zanella Netto June 1, 2023, 5:59 p.m. UTC | #1
On 31/05/23 17:44, Alejandro Colomar wrote:
> epoll_pwait2(2)'s second argument should be nonnull.  We're going to add
> __nonnull to the prototype, so let's fix the test accordingly.  We can
> use a dummy variable to avoid passing NULL.
> 
> Reported-by: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>
> Signed-off-by: Alejandro Colomar <alx@kernel.org>

LGTM, thanks.

Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>

> ---
>  sysdeps/unix/sysv/linux/tst-epoll.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/sysdeps/unix/sysv/linux/tst-epoll.c b/sysdeps/unix/sysv/linux/tst-epoll.c
> index 66f091c202..abda45c427 100644
> --- a/sysdeps/unix/sysv/linux/tst-epoll.c
> +++ b/sysdeps/unix/sysv/linux/tst-epoll.c
> @@ -180,6 +180,8 @@ epoll_pwait2_check (int epfd, struct epoll_event *ev, int maxev, int tmo,
>  static int
>  do_test (void)
>  {
> +  struct epoll_event ev;
> +
>    {
>      struct sigaction sa;
>      sa.sa_handler = handler;
> @@ -191,7 +193,7 @@ do_test (void)
>      xsigaction (SIGCHLD, &sa, NULL);
>    }
>  
> -  int r = epoll_pwait2 (-1, NULL, 0, NULL, NULL);
> +  int r = epoll_pwait2 (-1, &ev, 0, NULL, NULL);
>    TEST_COMPARE (r, -1);
>    bool pwait2_supported = errno != ENOSYS;
>
  

Patch

diff --git a/sysdeps/unix/sysv/linux/tst-epoll.c b/sysdeps/unix/sysv/linux/tst-epoll.c
index 66f091c202..abda45c427 100644
--- a/sysdeps/unix/sysv/linux/tst-epoll.c
+++ b/sysdeps/unix/sysv/linux/tst-epoll.c
@@ -180,6 +180,8 @@  epoll_pwait2_check (int epfd, struct epoll_event *ev, int maxev, int tmo,
 static int
 do_test (void)
 {
+  struct epoll_event ev;
+
   {
     struct sigaction sa;
     sa.sa_handler = handler;
@@ -191,7 +193,7 @@  do_test (void)
     xsigaction (SIGCHLD, &sa, NULL);
   }
 
-  int r = epoll_pwait2 (-1, NULL, 0, NULL, NULL);
+  int r = epoll_pwait2 (-1, &ev, 0, NULL, NULL);
   TEST_COMPARE (r, -1);
   bool pwait2_supported = errno != ENOSYS;