]> git.ipfire.org Git - thirdparty/coreutils.git/commitdiff
maint: remove redundant checks on buffer sizes in tail
authorNikolay Nechaev <Nikolay_Nechaev@mail.ru>
Sun, 20 Jun 2021 14:54:01 +0000 (17:54 +0300)
committerPádraig Brady <P@draigBrady.com>
Mon, 21 Jun 2021 12:17:06 +0000 (13:17 +0100)
* src/tail.c: remove redundant size checks before calls to
`xwrite_stdout`

src/tail.c

index ff567560dc0637adc48a64bbebf04690eaee36af..b91fcfd82c07a84a0d0ddf31309150ffa7387028 100644 (file)
@@ -579,8 +579,7 @@ file_lines (char const *pretty_filename, int fd, uintmax_t n_lines,
             {
               /* If this newline isn't the last character in the buffer,
                  output the part that is after it.  */
-              if (n != bytes_read - 1)
-                xwrite_stdout (nl + 1, bytes_read - (n + 1));
+              xwrite_stdout (nl + 1, bytes_read - (n + 1));
               *read_pos += dump_remainder (false, pretty_filename, fd,
                                            end_pos - (pos + bytes_read));
               return true;
@@ -881,8 +880,8 @@ start_bytes (char const *pretty_filename, int fd, uintmax_t n_bytes,
       else
         {
           size_t n_remaining = bytes_read - n_bytes;
-          if (n_remaining)
-            xwrite_stdout (&buffer[n_bytes], n_remaining);
+          // Print extra characters if there are any
+          xwrite_stdout (&buffer[n_bytes], n_remaining);
           break;
         }
     }