public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Jinseok Kim <always.starving0@gmail.com>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH] poll: fix LTP check warnings and improve poll01 validation
Date: Wed, 25 Feb 2026 23:32:04 +0900	[thread overview]
Message-ID: <20260225143205.36806-1-always.starving0@gmail.com> (raw)

Remove extra blank lines, mark helper functions as static, and fix
documentation comments starting with '/*\'.

Add explicit checks for poll() return value and validate that no
unexpected revents bits are set for POLLIN and POLLOUT cases.

Signed-off-by: Jinseok Kim <always.starving0@gmail.com>
---
 testcases/kernel/syscalls/poll/poll01.c | 24 ++++++++++++++++++------
 testcases/kernel/syscalls/poll/poll02.c |  4 ++--
 2 files changed, 20 insertions(+), 8 deletions(-)

diff --git a/testcases/kernel/syscalls/poll/poll01.c b/testcases/kernel/syscalls/poll/poll01.c
index b05e809ab..ca68ec9c4 100644
--- a/testcases/kernel/syscalls/poll/poll01.c
+++ b/testcases/kernel/syscalls/poll/poll01.c
@@ -5,7 +5,7 @@
  * Copyright (C) 2015 Cyril Hrubis <chrubis@suse.cz>
  */

-/*
+/*\
  * Check that poll() works for POLLOUT and POLLIN and that revents is set
  * correctly.
  */
@@ -34,11 +34,14 @@ static void verify_pollout(void)
 		return;
 	}

-	if (outfds[0].revents != POLLOUT) {
-		tst_res(TFAIL | TTERRNO, "poll() failed to set POLLOUT");
+	if (TST_RET != 1) {
+		tst_res(TFAIL, "Unexpected poll() return value %ld in POLLOUT", TST_RET);
 		return;
 	}

+	TST_EXP_EXPR(outfds[0].revents & POLLOUT);
+	TST_EXP_EXPR((outfds[0].revents & ~POLLOUT) == 0);
+
 	tst_res(TPASS, "poll() POLLOUT");
 }

@@ -60,11 +63,20 @@ static void verify_pollin(void)
 		goto end;
 	}

-	if (infds[0].revents != POLLIN) {
-		tst_res(TFAIL, "poll() failed to set POLLIN");
+	if (TST_RET != 1) {
+		tst_res(TFAIL, "Unexpected poll() return value %ld in POLLIN", TST_RET);
 		goto end;
 	}

+	if (!(infds[0].revents & POLLIN)) {
+		tst_res(TFAIL, "infds[0].revents & POLLIN");
+		goto end;
+	}
+
+	if (!((infds[0].revents & ~POLLIN) == 0)) {
+		tst_res(TFAIL, "infds[0].revents & ~POLLIN) == 0");
+		goto end;
+	}

 	tst_res(TPASS, "poll() POLLIN");

@@ -72,7 +84,7 @@ end:
 	SAFE_READ(1, fildes[0], read_buf, sizeof(write_buf));
 }

-void verify_poll(unsigned int n)
+static void verify_poll(unsigned int n)
 {
 	switch (n) {
 	case 0:
diff --git a/testcases/kernel/syscalls/poll/poll02.c b/testcases/kernel/syscalls/poll/poll02.c
index c0665927b..47e323451 100644
--- a/testcases/kernel/syscalls/poll/poll02.c
+++ b/testcases/kernel/syscalls/poll/poll02.c
@@ -3,7 +3,7 @@
  * Copyright (C) 2015-2017 Cyril Hrubis <chrubis@suse.cz>
  */

-/*
+/*\
  * Check that poll() timeouts correctly.
  */
 #include <errno.h>
@@ -15,7 +15,7 @@

 static int fds[2];

-int sample_fn(int clk_id, long long usec)
+static int sample_fn(int clk_id, long long usec)
 {
 	unsigned int sleep_ms = usec / 1000;

--
2.43.0

-- 
Mailing list info: https://lists.linux.it/listinfo/ltp

             reply	other threads:[~2026-02-25 14:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-25 14:32 Jinseok Kim [this message]
2026-03-10 17:20 ` [LTP] [PATCH] poll: fix LTP check warnings and improve poll01 validation Petr Vorel
2026-03-13 13:51   ` [LTP] [PATCH v2] poll: fix make check findings " Jinseok Kim
2026-03-13 16:30     ` Petr Vorel

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=20260225143205.36806-1-always.starving0@gmail.com \
    --to=always.starving0@gmail.com \
    --cc=ltp@lists.linux.it \
    /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