From 908e2cbcc7e30536166de713501709d3361f26a6 Mon Sep 17 00:00:00 2001 From: nekral-guest Date: Fri, 28 Dec 2007 22:24:02 +0000 Subject: [PATCH] Avoid assignments in comparisons. --- ChangeLog | 5 +++-- src/chpasswd.c | 9 ++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index 97c39a82..a1788ef8 100644 --- a/ChangeLog +++ b/ChangeLog @@ -7,6 +7,7 @@ * src/chpasswd.c: Other new functions: open_files(), close_files(). This force flushing the password database after the password file is unlocked. + * src/chpasswd.c: Avoid assignments in comparisons. 2007-12-28 Nicolas François @@ -45,7 +46,7 @@ * libmisc/copydir.c: -1 is used to indicate an error, directly set err to -1, instead of incrementing it, and checking if not nul at the end. - * libmisc/copydir.c: Avoid assignment in comparisons. + * libmisc/copydir.c: Avoid assignments in comparisons. * libmisc/copydir.c: Document selinux_file_context. * libmisc/copydir.c: Avoid implicit brackets. * libmisc/copydir.c: Avoid implicit conversions to booleans. @@ -64,7 +65,7 @@ * src/gpasswd.c: New functions: check_perms(), get_group(), change_passwd(), check_flags(). Split out of main() to simplify main(). * src/gpasswd.c: Avoid implicit brackets. - * src/gpasswd.c: Avoid assignment in comparisons. + * src/gpasswd.c: Avoid assignments in comparisons. * src/gpasswd.c: Avoid implicit conversions to booleans. 2007-12-27 Nicolas François diff --git a/src/chpasswd.c b/src/chpasswd.c index 073c7907..ff46bcce 100644 --- a/src/chpasswd.c +++ b/src/chpasswd.c @@ -346,7 +346,8 @@ int main (int argc, char **argv) */ while (fgets (buf, sizeof buf, stdin) != (char *) 0) { line++; - if ((cp = strrchr (buf, '\n'))) { + cp = strrchr (buf, '\n'); + if (NULL != cp) { *cp = '\0'; } else { fprintf (stderr, _("%s: line %d: line too long\n"), @@ -365,8 +366,10 @@ int main (int argc, char **argv) */ name = buf; - if ((cp = strchr (name, ':'))) { - *cp++ = '\0'; + cp = strchr (name, ':'); + if (NULL != cp) { + *cp = '\0'; + cp++; } else { fprintf (stderr, _("%s: line %d: missing new password\n"),