From db71085194be8e96d4d94156f4c88f47a747e395 Mon Sep 17 00:00:00 2001 From: Ari Sundholm Date: Wed, 20 Dec 2017 19:00:11 +0200 Subject: [PATCH] fsstress: getcwd() return value fixes 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 Reviewed-by: Eryu Guan Signed-off-by: Eryu Guan --- ltp/fsstress.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/ltp/fsstress.c b/ltp/fsstress.c index 13d5dd54..028c232c 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.47.3