mirror of
git://git.sv.gnu.org/coreutils.git
synced 2026-02-16 20:33:18 +02:00
maint: avoid new coverity warnings
* src/sync.c (sync_arg): Initialise variable to avoid unitialized access if assert is disabled. * src/head.c (elide_tail_bytes_file): Support this function with ---presume-input-pipe and larger files, which regressed with commit v8.23-47-g2662702. (elide_tail_lines_file): Likewise. * src/dd.c (dd_copy): Explicitly don't try to ftruncate() upon failure to lseek() (the existing check against st_size was already protecting that). * src/factor.c (factor_using_squfof): Assert (only when linting due to performance) to avoid the implication of divide by zero. * src/od.c (read_block): Remove dead code. * src/tac.c (tac_seekable): Likewise. * src/ls.c (gobble_file): Likewise.
This commit is contained in:
2
src/dd.c
2
src/dd.c
@@ -2280,7 +2280,7 @@ dd_copy (void)
|
||||
if (S_ISREG (stdout_stat.st_mode) || S_TYPEISSHM (&stdout_stat))
|
||||
{
|
||||
off_t output_offset = lseek (STDOUT_FILENO, 0, SEEK_CUR);
|
||||
if (output_offset > stdout_stat.st_size)
|
||||
if (0 <= output_offset && stdout_stat.st_size < output_offset)
|
||||
{
|
||||
if (iftruncate (STDOUT_FILENO, output_offset) != 0)
|
||||
{
|
||||
|
||||
@@ -2055,8 +2055,9 @@ factor_using_squfof (uintmax_t n1, uintmax_t n0, struct factors *factors)
|
||||
div_smallq (q, rem, S+P, Q);
|
||||
P1 = S - rem; /* P1 = q*Q - P */
|
||||
|
||||
IF_LINT (assert (q > 0 && Q > 0));
|
||||
|
||||
#if STAT_SQUFOF
|
||||
assert (q > 0);
|
||||
q_freq[0]++;
|
||||
q_freq[MIN (q, Q_FREQ_SIZE)]++;
|
||||
#endif
|
||||
|
||||
@@ -458,7 +458,7 @@ elide_tail_bytes_file (const char *filename, int fd, uintmax_t n_elide,
|
||||
struct stat const *st, off_t current_pos)
|
||||
{
|
||||
off_t size = st->st_size;
|
||||
if (size <= ST_BLKSIZE (*st))
|
||||
if (presume_input_pipe || size <= ST_BLKSIZE (*st))
|
||||
return elide_tail_bytes_pipe (filename, fd, n_elide, current_pos);
|
||||
else
|
||||
{
|
||||
@@ -747,7 +747,7 @@ elide_tail_lines_file (const char *filename, int fd, uintmax_t n_elide,
|
||||
struct stat const *st, off_t current_pos)
|
||||
{
|
||||
off_t size = st->st_size;
|
||||
if (size <= ST_BLKSIZE (*st))
|
||||
if (presume_input_pipe || size <= ST_BLKSIZE (*st))
|
||||
return elide_tail_lines_pipe (filename, fd, n_elide, current_pos);
|
||||
else
|
||||
{
|
||||
|
||||
1
src/ls.c
1
src/ls.c
@@ -2947,7 +2947,6 @@ gobble_file (char const *name, enum filetype type, ino_t inode,
|
||||
|| ((print_inode || format_needs_type)
|
||||
&& (type == symbolic_link || type == unknown)
|
||||
&& (dereference == DEREF_ALWAYS
|
||||
|| (command_line_arg && dereference != DEREF_NEVER)
|
||||
|| color_symlink_as_referent || check_symlink_color))
|
||||
/* Command line dereferences are already taken care of by the above
|
||||
assertion that the inode number is not yet known. */
|
||||
|
||||
3
src/od.c
3
src/od.c
@@ -1291,9 +1291,6 @@ read_block (size_t n, char *block, size_t *n_bytes_in_buffer)
|
||||
|
||||
*n_bytes_in_buffer = 0;
|
||||
|
||||
if (n == 0)
|
||||
return true;
|
||||
|
||||
while (in_stream != NULL) /* EOF. */
|
||||
{
|
||||
size_t n_needed;
|
||||
|
||||
@@ -117,7 +117,7 @@ sync_arg (enum sync_mode mode, char const *file)
|
||||
|
||||
if (ret == true)
|
||||
{
|
||||
int sync_status;
|
||||
int sync_status = -1;
|
||||
|
||||
switch (mode)
|
||||
{
|
||||
|
||||
@@ -321,8 +321,6 @@ tac_seekable (int input_fd, const char *file, off_t file_pos)
|
||||
'G_buffer_size'. */
|
||||
char *newbuffer;
|
||||
size_t offset = sentinel_length ? sentinel_length : 1;
|
||||
ptrdiff_t match_start_offset = match_start - G_buffer;
|
||||
ptrdiff_t past_end_offset = past_end - G_buffer;
|
||||
size_t old_G_buffer_size = G_buffer_size;
|
||||
|
||||
read_size *= 2;
|
||||
@@ -331,9 +329,6 @@ tac_seekable (int input_fd, const char *file, off_t file_pos)
|
||||
xalloc_die ();
|
||||
newbuffer = xrealloc (G_buffer - offset, G_buffer_size);
|
||||
newbuffer += offset;
|
||||
/* Adjust the pointers for the new buffer location. */
|
||||
match_start = newbuffer + match_start_offset;
|
||||
past_end = newbuffer + past_end_offset;
|
||||
G_buffer = newbuffer;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user