Skip to content

Commit 4c92447

Browse files
committed
remove superfluous ferror() branch in close_file()
file read ferror() handling in close_file() after reporting when input closed does not require separate logic, the whole thing just ends; also avoids unlikely, but possible, timing issues in -z decompression thread synchronization
1 parent fb244a8 commit 4c92447

1 file changed

Lines changed: 0 additions & 40 deletions

File tree

src/ugrep.cpp

Lines changed: 0 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -3824,48 +3824,8 @@ struct Grep {
38243824
{
38253825
// check if the input has no error conditions, but do not check stdin which is nonblocking and handled differently
38263826
if (file_in != NULL && file_in != stdin && file_in != Static::source && ferror(file_in))
3827-
{
38283827
warning("cannot read", pathname);
38293828

3830-
#ifdef HAVE_LIBZ
3831-
#ifdef WITH_DECOMPRESSION_THREAD
3832-
3833-
if (flag_decompress)
3834-
{
3835-
// close the input FILE* and its underlying pipe previously created with pipe() and fdopen()
3836-
if (input.file() != NULL)
3837-
{
3838-
// close and unassign input, i.e. input.file() == NULL, also closes pipe_fd[0] per fdopen()
3839-
fclose(input.file());
3840-
input.clear();
3841-
}
3842-
3843-
zthread.cancel();
3844-
}
3845-
3846-
#else
3847-
3848-
if (stream != NULL)
3849-
{
3850-
delete stream;
3851-
stream = NULL;
3852-
}
3853-
3854-
#endif
3855-
#endif
3856-
3857-
// close the current input file
3858-
if (file_in != NULL && file_in != stdin && file_in != Static::source)
3859-
{
3860-
fclose(file_in);
3861-
file_in = NULL;
3862-
}
3863-
3864-
input.clear();
3865-
3866-
return false;
3867-
}
3868-
38693829
#ifdef HAVE_LIBZ
38703830
#ifdef WITH_DECOMPRESSION_THREAD
38713831

0 commit comments

Comments
 (0)