Skip to contentSkip to conversation

pipeio: convert strerror(errno) to TERRNO

PATCH In review Jan Stancek 1 participant 1 message Dec 15, 2011

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/2 pipeio: convert strerror(errno) to TERRNO

---
 testcases/kernel/ipc/pipeio/pipeio.c |   32 
++++++++++++++++----------------
 1 files changed, 16 insertions(+), 16 deletions(-)
testcases/kernel/ipc/pipeio/pipeio.c +16 -16
index 1c28c9b..22ab3a7 100644
@@ -433,7 +433,7 @@ char *av[];
 
 	if ((writebuf = (char *) malloc(size)) == NULL ||
 	    (readbuf = (char *) malloc(size)) == NULL) {
-		tst_resm (TFAIL, "malloc() failed: %s", strerror(errno));
+		tst_resm (TFAIL|TERRNO, "malloc() failed");
   		SAFE_FREE(writebuf);
 		SAFE_FREE(readbuf);
 		exit(1);
@@ -444,15 +444,15 @@ char *av[];
 	writebuf[size-1] = 'A';	/* to detect partial read/write problem */
 
 	if ((sem_id = semget(IPC_PRIVATE, 1, IPC_CREAT|S_IRWXU)) == -1) {
-		tst_brkm(TBROK, NULL, "Couldn't allocate semaphore: %s", strerror(errno));
+		tst_brkm(TBROK|TERRNO, NULL, "Couldn't allocate semaphore");
 	}
 
 	if (semctl(sem_id, 0, SETVAL, u) == -1)
-		tst_brkm(TBROK, NULL, "Couldn't initialize semaphore value: %s", strerror(errno));
+		tst_brkm(TBROK|TERRNO, NULL, "Couldn't initialize semaphore value");
 
 	if (background) {
 	    if ((n=fork()) == -1) {
-		tst_resm (TFAIL, "fork() failed: %s", strerror(errno));
+		tst_resm (TFAIL|TERRNO, "fork() failed");
 		exit(1);
 	    }
 	    else if (n != 0) /* parent */
@@ -461,7 +461,7 @@ char *av[];
 
 	if (unpipe) {
 		if (pipe(fds) == -1) {
-			tst_resm (TFAIL, "pipe() failed to create un-named pipe: %s", strerror(errno));
+			tst_resm (TFAIL|TERRNO, "pipe() failed to create un-named pipe");
 			exit(1);
 		}
 		read_fd = fds[0];
@@ -470,14 +470,14 @@ char *av[];
 		blk_type = UNNAMED_IO;
 	} else {
 		if (strlen(dir) && chdir(dir) == -1) {
-			tst_resm (TFAIL, "chdir(%s) failed: %s", dir, strerror(errno));
+			tst_resm (TFAIL|TERRNO, "chdir(%s) failed", dir);
 			exit(1);
 		}
 
 		if (stat(pname, &stbuf) == -1) {
 
 		    if (mkfifo(pname,0777) == -1) {
-			tst_resm (TFAIL, "mkfifo(%s,0777) failed: %s", pname, strerror(errno));
+			tst_resm (TFAIL|TERRNO, "mkfifo(%s,0777) failed", pname);
 			exit(1);
 		    }
 		}
@@ -510,7 +510,7 @@ printf("num_wrters = %d\n", num_wrters);
 
 	for (i=num_wrters; i > 0; --i) {
 		if ((c=fork()) < 0) {
-			tst_resm (TFAIL, "fork() failed: %s", strerror(errno));
+			tst_resm (TFAIL|TERRNO, "fork() failed");
 			exit(1);
 		}
 		if (c == 0) break;	/* stop child from forking */
@@ -521,11 +521,11 @@ printf("child after fork pid = %d\n", getpid());
 #endif
 		if (! unpipe) {
 			if ((write_fd = open(pname,O_WRONLY)) == -1) {
-				tst_resm (TFAIL, "child pipe open(%s, %#o) failed: %s", pname, O_WRONLY|ndelay, strerror(errno));
+				tst_resm (TFAIL|TERRNO, "child pipe open(%s, %#o) failed", pname, O_WRONLY|ndelay);
 				exit(1);
 			}
 			if (ndelay && fcntl(write_fd, F_SETFL, O_NONBLOCK) == -1) {
-				tst_brkm(TBROK, NULL, "Failed setting the pipe to nonblocking mode: %s", strerror(errno));
+				tst_brkm(TBROK|TERRNO, NULL, "Failed setting the pipe to nonblocking mode");
 			}
 		}
 		else {
@@ -539,7 +539,7 @@ printf("child after fork pid = %d\n", getpid());
 		};
 
 		if (semop(sem_id, &sem_op, 1) == -1)
-			tst_brkm(TBROK, NULL, "Couldn't raise the semaphore: %s", strerror(errno));
+			tst_brkm(TBROK|TERRNO, NULL, "Couldn't raise the semaphore");
 
 		pid_word = (int *)&writebuf[0];
 		count_word = (int *)&writebuf[NBPW];
@@ -567,7 +567,7 @@ printf("child after fork pid = %d\n", getpid());
 			 * If lio_write_buffer returns a negative number,
 			 * the return will be -errno.
 			 */
-													tst_resm (TFAIL, "pass %d: lio_write_buffer(%s) failed; it returned %d: %s", j, cp, nb, strerror(-nb));
+				tst_resm (TFAIL, "pass %d: lio_write_buffer(%s) failed; it returned %d: %s", j, cp, nb, strerror(-nb));
 				exit(1);
 			}
 			else if (nb != size) {
@@ -591,11 +591,11 @@ printf("child after fork pid = %d\n", getpid());
 
 		if (! unpipe) {
 			if ((read_fd = open(pname,O_RDONLY)) == -1) {
-				tst_resm (TFAIL, "parent pipe open(%s, %#o) failed: %s", pname, O_RDONLY, strerror(errno));
+				tst_resm (TFAIL|TERRNO, "parent pipe open(%s, %#o) failed", pname, O_RDONLY);
 				exit(1);
 			}
 			if (ndelay && fcntl(read_fd, F_SETFL, O_NONBLOCK) == -1) {
-				tst_brkm(TBROK, NULL, "Failed setting the pipe to nonblocking mode: %s", strerror(errno));
+				tst_brkm(TBROK|TERRNO, NULL, "Failed setting the pipe to nonblocking mode");
 			}
 		}
 		else {
@@ -612,7 +612,7 @@ printf("child after fork pid = %d\n", getpid());
 			if (errno == EINTR) {
 				continue;
 			}
-			tst_brkm(TBROK, NULL, "Couldn't wait on semaphore: %s", strerror(errno));
+			tst_brkm(TBROK|TERRNO, NULL, "Couldn't wait on semaphore");
 		}
 
 		for (i=num_wrters*num_writes; i > 0 || loop; --i) {
@@ -884,4 +884,4 @@ sig_handler(int sig)
     fflush(stdout);
     exit(3);
 
-}
\ No newline at end of file
+}

------------------------------------------------------------------------------
10 Tips for Better Server Consolidation
Server virtualization is being driven by many needs. But none more important than the need to reduce IT complexity while improving strategic productivity. Learn More!
http://www.accelacomm.com/jaw/sdnl/114/51507609/

_______________________________________________
Ltp-list mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/ltp-list