Skip to content

Commit e4c084f

Browse files
committed
Do not print errno in error messages in cases when a file descriptor is invalid and I/O functions were not called before
1 parent 556c3fd commit e4c084f

File tree

1 file changed

+11
-8
lines changed

1 file changed

+11
-8
lines changed

src/jrd/os/posix/unix.cpp

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ static jrd_file* seek_file(jrd_file*, BufferDesc*, FB_UINT64*, FbStatusVector*);
127127
static jrd_file* setup_file(Database*, const PathName&, const int, const bool, const bool, const bool);
128128
static void lockDatabaseFile(int& desc, const bool shareMode, const bool temporary,
129129
const char* fileName, ISC_STATUS operation);
130-
static bool unix_error(const TEXT*, const jrd_file*, ISC_STATUS, FbStatusVector* = NULL);
130+
static bool unix_error(const TEXT*, const jrd_file*, ISC_STATUS, FbStatusVector* = NULL, bool print_errno = true);
131131
static bool block_size_error(const jrd_file*, off_t, FbStatusVector* = NULL);
132132
#if !(defined HAVE_PREAD && defined HAVE_PWRITE)
133133
static SLONG pread(int, SCHAR*, SLONG, SLONG);
@@ -480,7 +480,7 @@ ULONG PIO_get_number_of_pages(const jrd_file* file, const USHORT pagesize)
480480
**************************************/
481481

482482
if (file->fil_desc == -1)
483-
unix_error("PIO_get_number_of_pages", file, isc_io_access_err);
483+
unix_error("PIO_get_number_of_pages", file, isc_io_access_err, NULL, false);
484484

485485
struct STAT statistics;
486486
if (os_utils::fstat(file->fil_desc, &statistics))
@@ -546,7 +546,7 @@ void PIO_header(thread_db* tdbb, UCHAR* address, int length)
546546
jrd_file* file = pageSpace->file;
547547

548548
if (file->fil_desc == -1)
549-
unix_error("PIO_header", file, isc_io_read_err);
549+
unix_error("PIO_header", file, isc_io_read_err, NULL, false);
550550

551551
for (i = 0; i < IO_RETRY; i++)
552552
{
@@ -752,7 +752,7 @@ bool PIO_read(thread_db* tdbb, jrd_file* file, BufferDesc* bdb, Ods::pag* page,
752752
FB_UINT64 offset;
753753

754754
if (file->fil_desc == -1)
755-
return unix_error("PIO_read", file, isc_io_read_err, status_vector);
755+
return unix_error("PIO_read", file, isc_io_read_err, status_vector, false);
756756

757757
Database* const dbb = tdbb->getDatabase();
758758

@@ -804,7 +804,7 @@ bool PIO_write(thread_db* tdbb, jrd_file* file, BufferDesc* bdb, Ods::pag* page,
804804
FB_UINT64 offset;
805805

806806
if (file->fil_desc == -1)
807-
return unix_error("PIO_write", file, isc_io_write_err, status_vector);
807+
return unix_error("PIO_write", file, isc_io_write_err, status_vector, false);
808808

809809
Database* const dbb = tdbb->getDatabase();
810810

@@ -860,7 +860,7 @@ static jrd_file* seek_file(jrd_file* file, BufferDesc* bdb, FB_UINT64* offset,
860860

861861
if (file->fil_desc == -1)
862862
{
863-
unix_error("seek_file", file, isc_io_access_err, status_vector);
863+
unix_error("seek_file", file, isc_io_access_err, status_vector, false);
864864
return 0;
865865
}
866866

@@ -1015,7 +1015,7 @@ static void lockDatabaseFile(int& desc, const bool share, const bool temporary,
10151015

10161016
static bool unix_error(const TEXT* string,
10171017
const jrd_file* file, ISC_STATUS operation,
1018-
FbStatusVector* status_vector)
1018+
FbStatusVector* status_vector, bool print_errno)
10191019
{
10201020
/**************************************
10211021
*
@@ -1030,7 +1030,10 @@ static bool unix_error(const TEXT* string,
10301030
**************************************/
10311031
Arg::Gds err(isc_io_error);
10321032
err << string << file->fil_string <<
1033-
Arg::Gds(operation) << Arg::Unix(errno);
1033+
Arg::Gds(operation);
1034+
1035+
if (print_errno)
1036+
err << Arg::Unix(errno);
10341037

10351038
if (!status_vector)
10361039
ERR_post(err);

0 commit comments

Comments
 (0)