From d9b6475d85e58f23319cdd40376515c73f50c024 Mon Sep 17 00:00:00 2001 From: Jesse Smith Date: Fri, 30 Mar 2018 22:15:04 -0300 Subject: [PATCH] Removed unneeded "count" variable in utmpdump.c. Fixed typo in accidental wrote_wtmp_rlevel == 0 || wrote_wtmp_rlevel comparison so the latter is wrote_utmp_rlevel. Simplified logic in mountpoint.c when testing for same device or same inode. Thanks to David Binderman for pointing out the above three issues. --- doc/Changelog | 10 ++++++++++ src/init.c | 2 +- src/mountpoint.c | 10 ++++++++-- src/utmpdump.c | 2 -- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/doc/Changelog b/doc/Changelog index 6374c52..5481d5a 100644 --- a/doc/Changelog +++ b/doc/Changelog @@ -1,3 +1,13 @@ +sysvinit (2.90) UNRELEASED; urgency=low + + [ Jesse Smith ] + * Removed unneeded "count" variable in utmpdump.c. + * Fixed typo in accidental wrote_wtmp_rlevel == 0 || wrote_wtmp_rlevel + comparison so the latter is wrote_utmp_rlevel. + * Simplified logic in mountpoint.c when testing for same device or same inode. + Thanks to David Binderman for pointing out the above three issues. + + sysvinit (2.89) world; urgency=low [ Jesse Smith ] diff --git a/src/init.c b/src/init.c index ae4f63d..4c785ce 100644 --- a/src/init.c +++ b/src/init.c @@ -2228,7 +2228,7 @@ void redo_utmp_wtmp(void) if ((wrote_wtmp_reboot == 0) || (wrote_utmp_reboot == 0)) write_utmp_wtmp("reboot", "~~", 0, BOOT_TIME, "~"); - if ((wrote_wtmp_rlevel == 0) || (wrote_wtmp_rlevel == 0)) + if ((wrote_wtmp_rlevel == 0) || (wrote_utmp_rlevel == 0)) write_utmp_wtmp("runlevel", "~~", thislevel + 256 * prevlevel, RUN_LVL, "~"); } diff --git a/src/mountpoint.c b/src/mountpoint.c index 5cdffec..717ce89 100644 --- a/src/mountpoint.c +++ b/src/mountpoint.c @@ -167,8 +167,14 @@ int main(int argc, char **argv) if (dostat(buf, &st2, 0, quiet) < 0) return 1; - r = (st.st_dev != st2.st_dev) || - (st.st_dev == st2.st_dev && st.st_ino == st2.st_ino); + /* r = ( (st.st_dev != st2.st_dev) || + ( (st.st_dev == st2.st_dev) && (st.st_ino == st2.st_ino) ) ; + + (A || (!A && B)) is the same as (A || B) so simplifying this below. + Thanks to David Binderman for pointing this out. -- Jesse + */ + r = ( (st.st_dev != st2.st_dev) || (st.st_ino == st2.st_ino) ); + /* Mount point was not found yet. If we have access to /proc we can check there too. */ if ( (!r) && (check_proc) ) diff --git a/src/utmpdump.c b/src/utmpdump.c index 91a3d3a..f918041 100644 --- a/src/utmpdump.c +++ b/src/utmpdump.c @@ -219,7 +219,6 @@ undump(FILE *fp, int forever, int oldfmt) struct utmp ut; struct oldutmp uto; char s_addr[16], s_time[29], *linestart; - int count = 0; linestart = malloc(1024 * sizeof *linestart); s_addr[15] = 0; @@ -248,7 +247,6 @@ undump(FILE *fp, int forever, int oldfmt) } else fwrite(&ut, sizeof(ut), 1, stdout); - ++count; } free(linestart);