public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
From: Petr Vorel <pvorel@suse.cz>
To: ltp@lists.linux.it
Subject: [LTP] [PATCH 2/2] close_range02: Add simpler test and Check invalid params
Date: Tue, 16 Feb 2021 07:48:46 +0100	[thread overview]
Message-ID: <YCtqzlNKb/GbGXBM@pevik> (raw)
In-Reply-To: <20210215155322.32623-1-rpalethorpe@suse.com>

Hi Richard,

> This adds some coverage for invalid parameters and a min fd above or
> on the limits. There is also some overlap with close_range01, but this
> test is simpler and has less requirements.

Reviewed-by: Petr Vorel <pvorel@suse.cz>

LGTM, just minor nit: could we close file descriptor?
Otherwise it fails on higher -i (> 50). Something like code below?

Kind regards,
Petr

diff --git testcases/kernel/syscalls/close_range/close_range02.c testcases/kernel/syscalls/close_range/close_range02.c
index 9e099cec4..237b3d759 100644
--- testcases/kernel/syscalls/close_range/close_range02.c
+++ testcases/kernel/syscalls/close_range/close_range02.c
@@ -42,7 +42,7 @@ static void run(unsigned int n)
 		.flags = CLONE_FILES,
 		.exit_signal = SIGCHLD,
 	};
-	int fd, res;
+	int fd = -1, res;
 
 	switch (n) {
 	case 0:
@@ -101,6 +101,9 @@ static void run(unsigned int n)
 
 		TST_EXP_PASS(fcntl(fd, F_GETFD), "%d is open", fd);
 	}
+
+	if (n != 0 && fd > 0)
+		SAFE_CLOSE(fd);
 }
 
 static struct tst_test test = {

      reply	other threads:[~2021-02-16  6:48 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-15 15:53 [LTP] [PATCH 2/2] close_range02: Add simpler test and Check invalid params Richard Palethorpe
2021-02-16  6:48 ` Petr Vorel [this message]

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=YCtqzlNKb/GbGXBM@pevik \
    --to=pvorel@suse.cz \
    --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