Skip to contentSkip to conversation

setuid/setuid04.c: Fix a double cleanup() error

PATCH Superseded MaShimiao 2 participants 2 messages Sep 25, 2013

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

MaShimiao

author
#0 lore raw

PATCH 1/1 setuid/setuid04.c: Fix a double cleanup() error

On some systems which do not support 16-bit version syscall, the cleanup() will be called twice in this case leading to a case failure.

This patch makes sure calling tst_rmdir() only when the temp dir still exists.

---
  testcases/kernel/syscalls/setuid/setuid04.c |    6 +++++-
  1 files changed, 5 insertions(+), 1 deletions(-)
testcases/kernel/syscalls/setuid/setuid04.c +5 -1
index d8e991e..4f2cabd 100644
@@ -175,7 +175,11 @@ static void setup(void)
  
  static void cleanup(void)
  {
+	char *tmpdir;
  	close(fd);
-	tst_rmdir();
+	tmpdir = get_tst_tmpdir();
+	if (!access(tmpdir, F_OK))
+		tst_rmdir();
+	free(tmpdir);
  	TEST_CLEANUP;
  }
Signature · 13 lines
1.7.1


------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list
#1 lore raw

Hi!

Quoted 19 lines

On some systems which do not support 16-bit version syscall, the cleanup() will be called twice in this case leading to a case failure.

This patch makes sure calling tst_rmdir() only when the temp dir still exists.

---
  testcases/kernel/syscalls/setuid/setuid04.c |    6 +++++-
  1 files changed, 5 insertions(+), 1 deletions(-)
testcases/kernel/syscalls/setuid/setuid04.c +0 -0
index d8e991e..4f2cabd 100644
@@ -175,7 +175,11 @@ static void setup(void)
 

testcases/kernel/syscalls/setuid/setuid04.c static void setup(void) · line 184

Quoted 10 lines
testcases/kernel/syscalls/setuid/setuid04.c +5 -1
  static void cleanup(void)
  {
+	char *tmpdir;
  	close(fd);
-	tst_rmdir();
+	tmpdir = get_tst_tmpdir();
+	if (!access(tmpdir, F_OK))
+		tst_rmdir();
+	free(tmpdir);
  	TEST_CLEANUP;

This is not the best course of action.

It would be better to figure out why the cleanup is executed twice and fix the cause rather than the symptoms.

Signature · 13 lines
Cyril Hrubis
[email protected]

------------------------------------------------------------------------------
October Webinars: Code for Performance
Free Intel webinars can help you accelerate application performance.
Explore tips for MPI, OpenMP, advanced profiling, and more. Get the most from 
the latest Intel processors and coprocessors. See abstracts and register >
http://pubads.g.doubleclick.net/gampad/clk?id=60133471&iu=/4140/ostg.clktrk
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list