diff --git a/lib/commonio.c b/lib/commonio.c index b57cace13..1135c2949 100644 --- a/lib/commonio.c +++ b/lib/commonio.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -643,7 +644,7 @@ int commonio_open (struct commonio_db *db, int mode) if (NULL == buf) goto cleanup_errno; - while (db->ops->fgets (buf, buflen, db->fp) == buf) { + while (db->ops->fgets(buf, buflen, db->fp) != NULL) { struct commonio_entry *p; while ( (strrchr (buf, '\n') == NULL) diff --git a/lib/fields.c b/lib/fields.c index f24fcee95..90a8e778e 100644 --- a/lib/fields.c +++ b/lib/fields.c @@ -12,8 +12,9 @@ #ident "$Id$" #include -#include +#include #include +#include #include "prototypes.h" #include "string/strchr/stpspn.h" @@ -80,9 +81,8 @@ change_field(char *buf, size_t maxsize, const char *prompt) printf ("\t%s [%s]: ", prompt, buf); (void) fflush (stdout); - if (fgets (newf, maxsize, stdin) != newf) { + if (fgets(newf, maxsize, stdin) == NULL) return; - } if (stpsep(newf, "\n") == NULL) return; diff --git a/lib/fputsx.c b/lib/fputsx.c index 96aea2789..877c36427 100644 --- a/lib/fputsx.c +++ b/lib/fputsx.c @@ -9,6 +9,7 @@ #include +#include #include #include @@ -24,7 +25,7 @@ fgetsx(/*@returned@*/char *restrict buf, int cnt, FILE *restrict f) char *ep; while (cnt > 0) { - if (fgets (cp, cnt, f) != cp) { + if (fgets(cp, cnt, f) == NULL) { if (cp == buf) { return NULL; } else { diff --git a/lib/getdate.y b/lib/getdate.y index c79ade7c7..9fdfcfc5b 100644 --- a/lib/getdate.y +++ b/lib/getdate.y @@ -25,6 +25,7 @@ #endif #include +#include #include #include #include @@ -935,7 +936,7 @@ main(void) (void) fflush (stdout); buff[MAX_BUFF_LEN] = 0; - while (fgets (buff, MAX_BUFF_LEN, stdin) && buff[0]) + while (fgets(buff, MAX_BUFF_LEN, stdin) != NULL && buff[0]) { d = get_date(buff, NULL); if (d == -1) diff --git a/lib/gshadow.c b/lib/gshadow.c index e1f49ba6d..52923d75f 100644 --- a/lib/gshadow.c +++ b/lib/gshadow.c @@ -160,9 +160,8 @@ sgetsgent(const char *string) buflen *= 2; len = strlen (buf); - if (fgetsx(&buf[len], buflen - len, fp) != &buf[len]) { + if (fgetsx(&buf[len], buflen - len, fp) == NULL) return NULL; - } } stpsep(buf, "\n"); return (sgetsgent (buf)); diff --git a/lib/hushed.c b/lib/hushed.c index 8d5d9c40e..80a671404 100644 --- a/lib/hushed.c +++ b/lib/hushed.c @@ -13,6 +13,7 @@ #ident "$Id$" #include +#include #include #include #include @@ -73,7 +74,7 @@ bool hushed (const char *username) if (NULL == fp) { return false; } - for (found = false; !found && (fgets(buf, sizeof(buf), fp) == buf);) { + for (found = false; !found && (fgets(buf, sizeof(buf), fp) != NULL);) { stpsep(buf, "\n"); found = streq(buf, pw->pw_shell) || streq(buf, pw->pw_name); diff --git a/lib/loginprompt.c b/lib/loginprompt.c index e776cab70..1b59f3385 100644 --- a/lib/loginprompt.c +++ b/lib/loginprompt.c @@ -12,8 +12,9 @@ #ident "$Id$" #include -#include #include +#include +#include #include "attr.h" #include "defines.h" @@ -83,9 +84,8 @@ login_prompt(char *name, int namesize) */ MEMZERO(buf); - if (fgets(buf, sizeof(buf), stdin) != buf) { + if (fgets(buf, sizeof(buf), stdin) == NULL) exit (EXIT_FAILURE); - } if (stpsep(buf, "\n") == NULL) exit(EXIT_FAILURE); diff --git a/lib/setupenv.c b/lib/setupenv.c index 8d355d33c..e9382d47f 100644 --- a/lib/setupenv.c +++ b/lib/setupenv.c @@ -16,6 +16,7 @@ #ident "$Id$" #include +#include #include #include #include @@ -55,7 +56,7 @@ static void read_env_file (const char *filename) if (NULL == fp) { return; } - while (fgets(buf, sizeof(buf), fp) == buf) { + while (fgets(buf, sizeof(buf), fp) != NULL) { if (stpsep(buf, "\n") == NULL) break; diff --git a/lib/ttytype.c b/lib/ttytype.c index c1aae23e6..bb02e9912 100644 --- a/lib/ttytype.c +++ b/lib/ttytype.c @@ -11,6 +11,7 @@ #ident "$Id$" +#include #include #include @@ -47,7 +48,7 @@ void ttytype (const char *line) perror (typefile); return; } - while (fgets(buf, sizeof(buf), fp) == buf) { + while (fgets(buf, sizeof(buf), fp) != NULL) { if (strprefix(buf, "#")) { continue; } diff --git a/lib/user_busy.c b/lib/user_busy.c index 0b92359d7..bfd9e9018 100644 --- a/lib/user_busy.c +++ b/lib/user_busy.c @@ -12,6 +12,7 @@ #ident "$Id: $" #include +#include #include #include #include @@ -126,7 +127,7 @@ static int check_status (const char *name, const char *sname, uid_t uid) if (NULL == sfile) { return 0; } - while (fgets(line, sizeof(line), sfile) == line) { + while (fgets(line, sizeof(line), sfile) != NULL) { if (strprefix(line, "Uid:\t")) { unsigned long ruid, euid, suid; diff --git a/src/login_nopam.c b/src/login_nopam.c index 037df40e1..c7d65e306 100644 --- a/src/login_nopam.c +++ b/src/login_nopam.c @@ -97,7 +97,7 @@ login_access(const char *user, const char *from) if (NULL != fp) { int lineno = 0; /* for diagnostics */ while ( !match - && (fgets(line, sizeof(line), fp) == line)) + && (fgets(line, sizeof(line), fp) != NULL)) { char *p; diff --git a/src/useradd.c b/src/useradd.c index f943f24a6..a63a6eb74 100644 --- a/src/useradd.c +++ b/src/useradd.c @@ -18,16 +18,17 @@ #include #include #ifdef ENABLE_LASTLOG -#include +# include #endif /* ENABLE_LASTLOG */ #include #include #include #ifdef ACCT_TOOLS_SETUID -#ifdef USE_PAM -#include "pam_defs.h" -#endif /* USE_PAM */ +# ifdef USE_PAM +# include "pam_defs.h" +# endif /* USE_PAM */ #endif /* ACCT_TOOLS_SETUID */ +#include #include #include #include @@ -362,7 +363,7 @@ get_defaults(void) * Read the file a line at a time. Only the lines that have relevant * values are used, everything else can be ignored. */ - while (fgets(buf, sizeof(buf), fp) == buf) { + while (fgets(buf, sizeof(buf), fp) != NULL) { stpsep(buf, "\n"); cp = stpsep(buf, "="); @@ -602,7 +603,7 @@ set_defaults(void) goto skip; } - while (fgets(buf, sizeof(buf), ifp) == buf) { + while (fgets(buf, sizeof(buf), ifp) != NULL) { char *val; if (stpsep(buf, "\n") == NULL) {