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.
This commit is contained in:
Jesse Smith 2018-03-30 22:15:04 -03:00
parent e02e001f7a
commit d9b6475d85
4 changed files with 19 additions and 5 deletions

View File

@ -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 ]

View File

@ -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, "~");
}

View File

@ -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) )

View File

@ -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);