Skip to contentSkip to conversation

Fix temporary file creation in mmapstress tests

PATCH Subrata Modak 1 participant 1 message Oct 26, 2009 1 message not in the archive

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw
Quoted 7 lines · Jiri Palecek

Hello,

these are two little fixes of the mmapstress test.

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

Quoted 7 lines

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

Regards
Jiri Palecek

Thanks.

Regards--
Subrata

Quoted 43 lines
---
 testcases/kernel/mem/mmapstress/mmapstress02.c |    6 +-----
 testcases/kernel/mem/mmapstress/mmapstress05.c |    6 +-----
 2 files changed, 2 insertions(+), 10 deletions(-)
testcases/kernel/mem/mmapstress/mmapstress02.c +1 -5
index a0f0693..f801a2e 100644
@@ -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();
testcases/kernel/mem/mmapstress/mmapstress05.c +1 -1
index 9155834..4d25b8d 100644
@@ -133,7 +133,7 @@ main(int argc, char *argv[])
 	-- sreeni
 	*/
 
-	if (!(fd = mkstemp(tmpname))) {
+	if ((fd = mkstemp(tmpname))==-1) {
 		ERROR("mkstemp failed");
 		anyfail();
 	}

testcases/kernel/mem/mmapstress/mmapstress05.c main(int argc, char *argv[]) · line 151

Quoted 10 lines
testcases/kernel/mem/mmapstress/mmapstress05.c +0 -4
@@ -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) {

------------------------------------------------------------------------------
Come build with us! The BlackBerry(R) 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 - 12, 2009. Register now!
http://p.sf.net/sfu/devconference
_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list