diff options
author | Ari Sundholm <ari@tuxera.com> | 2017-12-20 19:00:11 +0200 |
---|---|---|
committer | Eryu Guan <eguan@redhat.com> | 2017-12-24 21:30:58 +0800 |
commit | db71085194be8e96d4d94156f4c88f47a747e395 (patch) | |
tree | e6bdb4407bf1e2cac9c9ce3637a27cb053b99f67 | |
parent | 6db67b725296e7a633c0a99e6b218695b95c6a01 (diff) | |
download | xfstests-db71085194be8e96d4d94156f4c88f47a747e395.tar.gz |
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 <ari@tuxera.com>
Reviewed-by: Eryu Guan <eguan@redhat.com>
Signed-off-by: Eryu Guan <eguan@redhat.com>
-rw-r--r-- | ltp/fsstress.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ltp/fsstress.c b/ltp/fsstress.c index 13d5dd54b1..028c232c11 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) |