]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
(file_lines): Remove unnecessary cast.
authorJim Meyering <jim@meyering.net>
Wed, 14 Nov 2001 11:52:59 +0000 (11:52 +0000)
committerJim Meyering <jim@meyering.net>
Wed, 14 Nov 2001 11:52:59 +0000 (11:52 +0000)
(tail_lines): Could have called file_lines even though the first
lseek failed.  Fix that.

src/tail.c

index c7f2e0e51f446933adf1f685078ffe79c5aa7bf6..58ecd298b682b04fa3dea221d9e4f95a56fd12af 100644 (file)
@@ -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))