public inbox for ltp@lists.linux.it
 help / color / mirror / Atom feed
* [LTP] [PATCH] Fix temporary file creation in mmapstress tests
@ 2009-06-07  0:32 Jiri Palecek
  0 siblings, 0 replies; 2+ messages in thread
From: Jiri Palecek @ 2009-06-07  0:32 UTC (permalink / raw)
  Cc: ltp-list

Hello,

these are two little fixes of the mmapstress test.

 - the mkstemp() function returns -1 on error; the tests treat 0 as
   error instead

 - mkstemp() returns a file descriptor; no need to open the file once
   more later

Regards
    Jiri Palecek

Signed-off-by: Jiri Palecek <jpalecek@web.de>
---
 testcases/kernel/mem/mmapstress/mmapstress02.c |    6 +-----
 testcases/kernel/mem/mmapstress/mmapstress05.c |    6 +-----
 2 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/testcases/kernel/mem/mmapstress/mmapstress02.c b/testcases/kernel/mem/mmapstress/mmapstress02.c
index a0f0693..f801a2e 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress02.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress02.c
@@ -101,7 +101,7 @@ main(int argc, char *argv[]) {
 		return 1;
 	}
 	(void)time(&t);
-	if (!(fd = mkstemp(tmpname))) {
+	if ((fd = mkstemp(tmpname)) == -1) {
 		ERROR("mkstemp failed");
 		anyfail();
 	}
@@ -114,10 +114,6 @@ main(int argc, char *argv[]) {
         CATCH_SIG(SIGINT);
         CATCH_SIG(SIGQUIT);
         CATCH_SIG(SIGTERM);
-	if ((fd = open(tmpname, O_CREAT|O_RDWR, 0777)) == -1) {
-		ERROR("couldn't open temporary file");
-		anyfail();
-	}
 	if (sbrk(2*pagesize - ((ulong)sbrk(0) & (pagesize-1))) == (char *)-1) {
 		CLEANERROR("couldn't round up brk");
 		anyfail();
diff --git a/testcases/kernel/mem/mmapstress/mmapstress05.c b/testcases/kernel/mem/mmapstress/mmapstress05.c
index 9155834..4d25b8d 100644
--- a/testcases/kernel/mem/mmapstress/mmapstress05.c
+++ b/testcases/kernel/mem/mmapstress/mmapstress05.c
@@ -133,7 +133,7 @@ main(int argc, char *argv[])
 	-- sreeni
 	*/
 
-	if (!(fd = mkstemp(tmpname))) {
+	if ((fd = mkstemp(tmpname))==-1) {
 		ERROR("mkstemp failed");
 		anyfail();
 	}
@@ -146,10 +146,6 @@ main(int argc, char *argv[])
 	CATCH_SIG(SIGINT);
         CATCH_SIG(SIGQUIT);
         CATCH_SIG(SIGTERM);
-	if ((fd = open(tmpname, O_RDWR|O_CREAT, 0777)) == -1) {
-		ERROR("open failed");
-		anyfail();
-	}
 	for (i = 0; i < pagesize; i++)
 		buf[i] = 'a';
 	if (write(fd, buf, pagesize) != pagesize) {
-- 
1.6.4.3




------------------------------------------------------------------------------
Come build with us! The BlackBerry&reg; Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay 
ahead of the curve. Join us from November 9&#45;12, 2009. Register now&#33;
http://p.sf.net/sfu/devconf
_______________________________________________
Ltp-list mailing list
Ltp-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/ltp-list

^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2009-10-26 17:02 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
     [not found] <200910041139.n94Bde05022152@e33.co.us.ibm.com>
2009-10-26 17:02 ` [LTP] [PATCH] Fix temporary file creation in mmapstress tests Subrata Modak
2009-06-07  0:32 Jiri Palecek

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox