FreeBSD Bugzilla – Attachment 42892 Details for
Bug 66765
"lastcomm string" is broken on -current
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 1.53 KB, created by
Dan Nelson
on 2004-05-17 18:30:17 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
Dan Nelson
Created:
2004-05-17 18:30:17 UTC
Size:
1.53 KB
patch
obsolete
>Index: lastcomm.c >=================================================================== >RCS file: /home/ncvs/src/usr.bin/lastcomm/lastcomm.c,v >retrieving revision 1.18 >diff -u -p -r1.18 lastcomm.c >--- lastcomm.c 27 Jan 2003 18:16:32 -0000 1.18 >+++ lastcomm.c 14 Apr 2004 03:18:39 -0000 >@@ -134,7 +134,7 @@ main(int argc, char *argv[]) > > /* Open the file. */ > if ((fp = fopen(acctfile, "r")) == NULL || fstat(fileno(fp), &sb)) >- err(1, "%s", acctfile); >+ err(1, "could not open %s", acctfile); > > /* > * Round off to integral number of accounting records, probably >@@ -146,17 +146,13 @@ main(int argc, char *argv[]) > if ((unsigned)size < sizeof(struct acct)) > exit(0); > >- /* >- * Seek to before the last entry in the file; use lseek(2) in case >- * the file is bigger than a "long". >- */ >- size -= sizeof(struct acct); >- if (lseek(fileno(fp), size, SEEK_SET) == -1) >- err(1, "%s", acctfile); >- >- for (;;) { >- if (fread(&ab, sizeof(struct acct), 1, fp) != 1) >- err(1, "%s", acctfile); >+ do { >+ int rv; >+ size -= sizeof(struct acct); >+ if (fseeko(fp, size, SEEK_SET) == -1) >+ err(1, "seek %s failed", acctfile); >+ if ((rv = fread(&ab, sizeof(struct acct), 1, fp)) != 1) >+ err(1, "read %s returned %d", acctfile, rv); > > if (ab.ac_comm[0] == '\0') { > ab.ac_comm[0] = '?'; >@@ -211,12 +207,7 @@ main(int argc, char *argv[]) > } > printf("\n"); > >- if (size == 0) >- break; >- size -= sizeof(struct acct); >- if (fseek(fp, 2 * -(long)sizeof(struct acct), SEEK_CUR) == -1) >- err(1, "%s", acctfile); >- } >+ } while (size > 0); > exit(0); > }
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 66765
: 42892