summaryrefslogtreecommitdiff
path: root/src/tail.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2001-11-14 11:52:59 +0000
committerJim Meyering <jim@meyering.net>2001-11-14 11:52:59 +0000
commit83798242020117a3757c062a741cf356db0c3209 (patch)
treedbff9f566620db428047cd0e01c9b42ab15a0602 /src/tail.c
parent8b67554aec7e812e97cfd3011f43a0ebd033e0d7 (diff)
downloadcoreutils-83798242020117a3757c062a741cf356db0c3209.tar.xz
(file_lines): Remove unnecessary cast.
(tail_lines): Could have called file_lines even though the first lseek failed. Fix that.
Diffstat (limited to 'src/tail.c')
-rw-r--r--src/tail.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/src/tail.c b/src/tail.c
index c7f2e0e51..58ecd298b 100644
--- a/src/tail.c
+++ b/src/tail.c
@@ -439,7 +439,7 @@ file_lines (const char *pretty_filename, int fd, long int n_lines,
{
/* Not enough lines in the file; print the entire file. */
/* FIXME: check lseek return value */
- lseek (fd, (off_t) start_pos, SEEK_SET);
+ lseek (fd, start_pos, SEEK_SET);
dump_remainder (pretty_filename, fd, file_length);
return 0;
}
@@ -1100,11 +1100,8 @@ tail_lines (const char *pretty_filename, int fd, long int n_lines)
/* Use file_lines only if FD refers to a regular file for
which lseek (... SEEK_END) works. */
if (S_ISREG (stats.st_mode)
- /* Record the current position before confirming that
- we can seek to the end. */
- && ((start_pos = lseek (fd, (off_t) 0, SEEK_CUR)), 1)
- && (length = lseek (fd, (off_t) 0, SEEK_END)) >= 0
- && start_pos < length)
+ && (start_pos = lseek (fd, (off_t) 0, SEEK_CUR)) != -1
+ && start_pos < (length = lseek (fd, (off_t) 0, SEEK_END)))
{
if (length != 0 && file_lines (pretty_filename, fd, n_lines,
start_pos, length))