From: Alejandro Colomar <alx.manpages@gmail.com>
To: Adhemerval Zanella Netto <adhemerval.zanella@linaro.org>,
libc-alpha@sourceware.org
Cc: Alejandro Colomar <alx@kernel.org>
Subject: Re: [PATCH] Use __nonnull for the epoll_wait(2) family of syscalls
Date: Tue, 30 May 2023 01:17:24 +0200 [thread overview]
Message-ID: <f2d87527-30aa-05f4-3366-f4d474dec516@gmail.com> (raw)
In-Reply-To: <30f8c03c-ecb3-733a-b14c-cf5509356697@linaro.org>
[-- Attachment #1.1: Type: text/plain, Size: 3574 bytes --]
Hi Adhemerval!
On 5/29/23 19:39, Adhemerval Zanella Netto wrote:
> In fact, checking I am seeing a regression:
>
> ../sysdeps/unix/sysv/linux/tst-epoll.c: In function ‘do_test’:
> ../sysdeps/unix/sysv/linux/tst-epoll.c:194:11: error: argument 2 null where non-null expected [-Werror=nonnull]
> 194 | int r = epoll_pwait2 (-1, NULL, 0, NULL, NULL);
> | ^~~~~~~~~~~~
> In file included from ../include/sys/epoll.h:2,
> from ../sysdeps/unix/sysv/linux/tst-epoll.c:27:
> ../sysdeps/unix/sysv/linux/sys/epoll.h:144:12: note: in a call to function ‘epoll_pwait2’ declared ‘nonnull’
> 144 | extern int epoll_pwait2 (int __epfd, struct epoll_event *__events,
> | ^~~~~~~~~~~~
> cc1: all warnings being treated as errors
>
> And I am not sure why it was not caught by buildbots.
I didn't catch it either. I didn't run tests, since I thought if anything failed, it
would probably be at compilation stage, so I only compiled. Not sure about the
buildbots, though; those should have caught it.
>
> The check is only for test for epoll_pwait2 support, so I think it would be simpler to
> just suppress the warning:
>
> diff --git a/sysdeps/unix/sysv/linux/tst-epoll.c b/sysdeps/unix/sysv/linux/tst-epoll.c
> index 66f091c202..e2fd34e0e6 100644
> --- a/sysdeps/unix/sysv/linux/tst-epoll.c
> +++ b/sysdeps/unix/sysv/linux/tst-epoll.c
> @@ -18,12 +18,13 @@
>
> #include <errno.h>
> #include <intprops.h>
> +#include <libc-diag.h>
> +#include <stdlib.h>
> #include <support/check.h>
> #include <support/support.h>
> #include <support/xsignal.h>
> -#include <support/xunistd.h>
> #include <support/xtime.h>
> -#include <stdlib.h>
> +#include <support/xunistd.h>
> #include <sys/epoll.h>
>
> /* The test focus on checking if the timeout argument is correctly handled
> @@ -191,7 +192,12 @@ do_test (void)
> xsigaction (SIGCHLD, &sa, NULL);
> }
>
> + /* The NULL tests here is only to check if epoll_pwait2 is supported by the
> + kernel and to simplify the rest of test. */
> + DIAG_PUSH_NEEDS_COMMENT;
> + DIAG_IGNORE_NEEDS_COMMENT (7, "-Wnonnull");
> int r = epoll_pwait2 (-1, NULL, 0, NULL, NULL);
> + DIAG_POP_NEEDS_COMMENT;
> TEST_COMPARE (r, -1);
> bool pwait2_supported = errno != ENOSYS;
>
> Could you send a v3 with the change? Another possibility is to remove the
> pwait2_supported and handle it on the test itself (it would require more
> extensive changes).
I suggest a slightly different approach: passing the address of a dummy variable.
It is even simpler. See the suggested diff below. If you like it, I'll send a
revision with it (which IIRC, should be v2).
Cheers,
Alex
$ git diff
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;
--
<http://www.alejandro-colomar.es/>
GPG key fingerprint: A9348594CE31283A826FBDD8D57633D441E25BB5
[-- Attachment #2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
next prev parent reply other threads:[~2023-05-29 23:17 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-05-19 22:50 nonnull on epoll_wait(2) syscall wrappers? Alejandro Colomar
2023-05-22 20:51 ` Adhemerval Zanella Netto
2023-05-22 22:01 ` [PATCH] Use __nonnull for the epoll_wait(2) family of syscalls Alejandro Colomar
2023-05-23 12:27 ` Adhemerval Zanella Netto
2023-05-29 17:39 ` Adhemerval Zanella Netto
2023-05-29 23:17 ` Alejandro Colomar [this message]
2023-05-30 11:41 ` Adhemerval Zanella Netto
2023-05-31 20:44 ` [PATCH v2 1/2] Fix invalid use of NULL in epoll_pwait2(2) test Alejandro Colomar
2023-06-01 17:59 ` Adhemerval Zanella Netto
2023-05-31 20:44 ` [PATCH v2 2/2] Use __nonnull for the epoll_wait(2) family of syscalls Alejandro Colomar
2023-06-01 18:00 ` Adhemerval Zanella Netto
2023-06-01 23:46 ` Alejandro Colomar
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=f2d87527-30aa-05f4-3366-f4d474dec516@gmail.com \
--to=alx.manpages@gmail.com \
--cc=adhemerval.zanella@linaro.org \
--cc=alx@kernel.org \
--cc=libc-alpha@sourceware.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).