[PATCH 2/2] fsstress: getcwd() return value fixes

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



Add a check for the return value of getcwd(). Fix another check
which mistakenly checks if the return value is less than zero
instead of checking whether the return value is NULL.

Signed-off-by: Ari Sundholm <ari@xxxxxxxxxx>
---
 ltp/fsstress.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/ltp/fsstress.c b/ltp/fsstress.c
index 13d5dd5..028c232 100644
--- a/ltp/fsstress.c
+++ b/ltp/fsstress.c
@@ -495,7 +495,7 @@ int main(int argc, char **argv)
 
 	(void)mkdir(dirname, 0777);
 	if (logname && logname[0] != '/') {
-		if (getcwd(rpath, sizeof(rpath)) < 0){
+		if (!getcwd(rpath, sizeof(rpath))){
 			perror("getcwd failed");
 			exit(1);
 		}
@@ -970,6 +970,10 @@ doproc(void)
 	}
 	top_ino = statbuf.st_ino;
 	homedir = getcwd(NULL, 0);
+	if (!homedir) {
+		perror("getcwd failed");
+		_exit(1);
+	}
 	seed += procid;
 	srandom(seed);
 	if (namerand)
-- 
2.7.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