All of lore.kernel.org
 help / color / mirror / Atom feed
* [LTP] [COMMITTED] [PATCH] syscalls/dup203: Fix make use of SAFE_CLOSE()
@ 2017-10-04 13:24 Cyril Hrubis
  0 siblings, 0 replies; only message in thread
From: Cyril Hrubis @ 2017-10-04 13:24 UTC (permalink / raw)
  To: ltp

The patch:

commit df007542635aed8686b5ebc111b0807a67349b41
Author: Cyril Hrubis <chrubis@suse.cz>
Date:   Tue Oct 3 13:29:15 2017 +0200

    Make use of SAFE_CLOSE()

Broke the test since it opens and closes a fd in order to get free file
descriptor to pass to dup2() as newfd. The problem here is that
SAFE_CLOSE() sets the file descriptor to -1, which is usually good
thing.

This patch fixes the problem by using temporary variable to store the fd
to pass it to SAFE_CLOSE().

Fixes #219

Signed-off-by: Cyril Hrubis <chrubis@suse.cz>
---
 testcases/kernel/syscalls/dup2/dup203.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/testcases/kernel/syscalls/dup2/dup203.c b/testcases/kernel/syscalls/dup2/dup203.c
index d3c228362..e6f281adf 100644
--- a/testcases/kernel/syscalls/dup2/dup203.c
+++ b/testcases/kernel/syscalls/dup2/dup203.c
@@ -144,7 +144,9 @@ int main(int ac, char **av)
 			tst_brkm(TBROK, cleanup, "Cannot create second file");
 		}
 
-		SAFE_CLOSE(cleanup, fd2);
+		/* SAFE_CLOSE() sets the fd to -1 avoid it here */
+		rval = fd2;
+		SAFE_CLOSE(cleanup, rval);
 
 		TEST(dup2(fd0, fd2));
 
-- 
2.13.5


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2017-10-04 13:24 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-04 13:24 [LTP] [COMMITTED] [PATCH] syscalls/dup203: Fix make use of SAFE_CLOSE() Cyril Hrubis

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.