From 3f5403220f2e3c0df4e436f908b97fe8cafd6616 Mon Sep 17 00:00:00 2001 From: Slava Semushin Date: Sat, 6 Jun 2009 21:53:38 +0700 Subject: testsuite/nsswitch/get{gr,pw}ent_r.c(dump_{gr,pw}ent): fixed wrong condition. When fopen() fails it return NULL, so condition where return value less than zero never evaluated to truth. Found by cppcheck. --- testsuite/nsswitch/getgrent_r.c | 2 +- testsuite/nsswitch/getpwent_r.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'testsuite/nsswitch') diff --git a/testsuite/nsswitch/getgrent_r.c b/testsuite/nsswitch/getgrent_r.c index 3eac8aa218..4f1f0ce8f5 100644 --- a/testsuite/nsswitch/getgrent_r.c +++ b/testsuite/nsswitch/getgrent_r.c @@ -21,7 +21,7 @@ void dump_grent(char *id) sprintf(fname, "/tmp/getgrent_r-%s.out-%d", id, getpid()); - if ((fptr = fopen(fname, "w")) < 0) { + if ((fptr = fopen(fname, "w")) == NULL) { fprintf(stderr, "ERROR: could not open file %s: %s\n", fname, sys_errlist[errno]); return; diff --git a/testsuite/nsswitch/getpwent_r.c b/testsuite/nsswitch/getpwent_r.c index 2ba7ea96f1..5e774911de 100644 --- a/testsuite/nsswitch/getpwent_r.c +++ b/testsuite/nsswitch/getpwent_r.c @@ -21,7 +21,7 @@ void dump_pwent(char *id) sprintf(fname, "/tmp/getpwent_r-%s.out-%d", id, getpid()); - if ((fptr = fopen(fname, "w")) < 0) { + if ((fptr = fopen(fname, "w")) == 0) { fprintf(stderr, "ERROR: could not open file %s: %s\n", fname, sys_errlist[errno]); return; -- cgit