[PATCH v2] holetest: Use pid_t type for fork(2) return value

[Date Prev] [Date Next] [Thread Prev] [Thread Next] [Date Index] [Thread Index]



---
Hello Christoph,

I think using uint64_t is fine since pthread_t is either a pointer or a ulong,
and pid_t is an int, so uint64_t acts as a "superset" of those types. Valid
PIDs are positive, so the difference in signedness should not be a problem.

I made a minimal patch as you suggested.
 src/holetest.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/src/holetest.c b/src/holetest.c
index 1939b35..ab582f5 100644
--- a/src/holetest.c
+++ b/src/holetest.c
@@ -199,22 +199,22 @@ int test_this(int fd, loff_t sz)
 			tid[i] = (uint64_t)t[i];
 			printf("INFO: thread %d created\n", i);
 		} else {
+			pid_t pid;
 			/*
 			 * Flush stdout before fork, otherwise some lines get
 			 * duplicated... ?!?!?
 			 */
 			fflush(stdout);
-			tid[i] = fork();
-			if (tid[i] < 0) {
+			pid = fork();
+			if (pid < 0) {
 				int j;
 
 				perror("fork");
 				for (j = 0; j < i; j++)
 					waitpid(tid[j], NULL, 0);
 				exit(21);
-			}
-			/* Child? */
-			if (!tid[i]) {
+			} else if (!pid) {
+				/* Child? */
 				void *ret;
 
 				if (use_wr[i])
@@ -223,6 +223,7 @@ int test_this(int fd, loff_t sz)
 					ret = pt_page_marker(&targs[i]);
 				exit(ret ? 1 : 0);
 			}
+			tid[i] = pid;
 			printf("INFO: process %d created\n", i);
 		}
 	}
-- 
2.1.4

--
To unsubscribe from this list: send the line "unsubscribe fstests" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Filesystems Development]     [Linux NFS]     [Linux NILFS]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux