From: nekral-guest Date: Fri, 13 Jun 2008 19:50:49 +0000 (+0000) Subject: * libmisc/log.c: Avoid assignments in comparisons. X-Git-Tag: 4.1.3~389 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=fe0e4f635ead81a82d682f038fa198182bdede7f;p=shadow * libmisc/log.c: Avoid assignments in comparisons. * libmisc/log.c: Add brackets and parenthesis. * libmisc/log.c: read() returns a ssize_t (note size_t). * libmisc/log.c: Avoid implicit conversion of pointers to booleans. * libmisc/log.c: Ignore return value of time() when use with a non NULL argument. --- diff --git a/ChangeLog b/ChangeLog index 4988e9e6..6326af00 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2008-06-13 Nicolas François + + * libmisc/log.c: Avoid assignments in comparisons. + * libmisc/log.c: Add brackets and parenthesis. + * libmisc/log.c: read() returns a ssize_t (note size_t). + * libmisc/log.c: Avoid implicit conversion of pointers to + booleans. + * libmisc/log.c: Ignore return value of time() when use with a + non NULL argument. + 2008-06-13 Nicolas François * libmisc/strtoday.c: Avoid implicit conversion of pointers to diff --git a/libmisc/log.c b/libmisc/log.c index 9582534e..35a21953 100644 --- a/libmisc/log.c +++ b/libmisc/log.c @@ -62,8 +62,10 @@ dolastlog (struct lastlog *ll, const struct passwd *pw, const char *line, * If the file does not exist, don't create it. */ - if ((fd = open (LASTLOG_FILE, O_RDWR)) == -1) + fd = open (LASTLOG_FILE, O_RDWR); + if (-1 == fd) { return; + } /* * The file is indexed by UID number. Seek to the record @@ -83,19 +85,23 @@ dolastlog (struct lastlog *ll, const struct passwd *pw, const char *line, * the way we read the old one in. */ - if (read (fd, (char *) &newlog, sizeof newlog) != sizeof newlog) + if (read (fd, (char *) &newlog, sizeof newlog) != (ssize_t) sizeof newlog) { memzero (&newlog, sizeof newlog); - if (ll) + } + if (NULL != ll) { *ll = newlog; + } ll_time = newlog.ll_time; - time (&ll_time); + (void) time (&ll_time); newlog.ll_time = ll_time; strncpy (newlog.ll_line, line, sizeof newlog.ll_line); #if HAVE_LL_HOST strncpy (newlog.ll_host, host, sizeof newlog.ll_host); #endif - if (lseek (fd, offset, SEEK_SET) == offset) + if (lseek (fd, offset, SEEK_SET) == offset) { write (fd, (char *) &newlog, sizeof newlog); + } close (fd); } +