mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Use consistent style for checking return from system calls
Use if (something() != 0) error ... instead of just if (something) error ... The latter is not incorrect, but it's a bit confusing and not the common style. Discussion: https://www.postgresql.org/message-id/flat/5de61b6b-8be9-7771-0048-860328efe027%402ndquadrant.com
This commit is contained in:
@ -1202,7 +1202,7 @@ heap_xlog_logical_rewrite(XLogReaderState *r)
|
||||
errmsg("could not fsync file \"%s\": %m", path)));
|
||||
pgstat_report_wait_end();
|
||||
|
||||
if (CloseTransientFile(fd))
|
||||
if (CloseTransientFile(fd) != 0)
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not close file \"%s\": %m", path)));
|
||||
@ -1304,7 +1304,7 @@ CheckPointLogicalRewriteHeap(void)
|
||||
errmsg("could not fsync file \"%s\": %m", path)));
|
||||
pgstat_report_wait_end();
|
||||
|
||||
if (CloseTransientFile(fd))
|
||||
if (CloseTransientFile(fd) != 0)
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not close file \"%s\": %m", path)));
|
||||
|
@ -621,7 +621,7 @@ SimpleLruDoesPhysicalPageExist(SlruCtl ctl, int pageno)
|
||||
|
||||
result = endpos >= (off_t) (offset + BLCKSZ);
|
||||
|
||||
if (CloseTransientFile(fd))
|
||||
if (CloseTransientFile(fd) != 0)
|
||||
{
|
||||
slru_errcause = SLRU_CLOSE_FAILED;
|
||||
slru_errno = errno;
|
||||
@ -697,7 +697,7 @@ SlruPhysicalReadPage(SlruCtl ctl, int pageno, int slotno)
|
||||
}
|
||||
pgstat_report_wait_end();
|
||||
|
||||
if (CloseTransientFile(fd))
|
||||
if (CloseTransientFile(fd) != 0)
|
||||
{
|
||||
slru_errcause = SLRU_CLOSE_FAILED;
|
||||
slru_errno = errno;
|
||||
@ -869,7 +869,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruFlush fdata)
|
||||
if (!fdata)
|
||||
{
|
||||
pgstat_report_wait_start(WAIT_EVENT_SLRU_SYNC);
|
||||
if (ctl->do_fsync && pg_fsync(fd))
|
||||
if (ctl->do_fsync && pg_fsync(fd) != 0)
|
||||
{
|
||||
pgstat_report_wait_end();
|
||||
slru_errcause = SLRU_FSYNC_FAILED;
|
||||
@ -879,7 +879,7 @@ SlruPhysicalWritePage(SlruCtl ctl, int pageno, int slotno, SlruFlush fdata)
|
||||
}
|
||||
pgstat_report_wait_end();
|
||||
|
||||
if (CloseTransientFile(fd))
|
||||
if (CloseTransientFile(fd) != 0)
|
||||
{
|
||||
slru_errcause = SLRU_CLOSE_FAILED;
|
||||
slru_errno = errno;
|
||||
@ -1146,7 +1146,7 @@ SimpleLruFlush(SlruCtl ctl, bool allow_redirtied)
|
||||
for (i = 0; i < fdata.num_files; i++)
|
||||
{
|
||||
pgstat_report_wait_start(WAIT_EVENT_SLRU_FLUSH_SYNC);
|
||||
if (ctl->do_fsync && pg_fsync(fdata.fd[i]))
|
||||
if (ctl->do_fsync && pg_fsync(fdata.fd[i]) != 0)
|
||||
{
|
||||
slru_errcause = SLRU_FSYNC_FAILED;
|
||||
slru_errno = errno;
|
||||
@ -1155,7 +1155,7 @@ SimpleLruFlush(SlruCtl ctl, bool allow_redirtied)
|
||||
}
|
||||
pgstat_report_wait_end();
|
||||
|
||||
if (CloseTransientFile(fdata.fd[i]))
|
||||
if (CloseTransientFile(fdata.fd[i]) != 0)
|
||||
{
|
||||
slru_errcause = SLRU_CLOSE_FAILED;
|
||||
slru_errno = errno;
|
||||
|
@ -371,7 +371,7 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI,
|
||||
pgstat_report_wait_end();
|
||||
}
|
||||
|
||||
if (CloseTransientFile(srcfd))
|
||||
if (CloseTransientFile(srcfd) != 0)
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not close file \"%s\": %m", path)));
|
||||
@ -415,7 +415,7 @@ writeTimeLineHistory(TimeLineID newTLI, TimeLineID parentTLI,
|
||||
errmsg("could not fsync file \"%s\": %m", tmppath)));
|
||||
pgstat_report_wait_end();
|
||||
|
||||
if (CloseTransientFile(fd))
|
||||
if (CloseTransientFile(fd) != 0)
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not close file \"%s\": %m", tmppath)));
|
||||
@ -493,7 +493,7 @@ writeTimeLineHistoryFile(TimeLineID tli, char *content, int size)
|
||||
errmsg("could not fsync file \"%s\": %m", tmppath)));
|
||||
pgstat_report_wait_end();
|
||||
|
||||
if (CloseTransientFile(fd))
|
||||
if (CloseTransientFile(fd) != 0)
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not close file \"%s\": %m", tmppath)));
|
||||
|
@ -1299,7 +1299,7 @@ ReadTwoPhaseFile(TransactionId xid, bool missing_ok)
|
||||
|
||||
pgstat_report_wait_end();
|
||||
|
||||
if (CloseTransientFile(fd))
|
||||
if (CloseTransientFile(fd) != 0)
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not close file \"%s\": %m", path)));
|
||||
|
@ -3321,7 +3321,7 @@ XLogFileInit(XLogSegNo logsegno, bool *use_existent, bool use_lock)
|
||||
}
|
||||
pgstat_report_wait_end();
|
||||
|
||||
if (close(fd))
|
||||
if (close(fd) != 0)
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not close file \"%s\": %m", tmppath)));
|
||||
@ -3489,12 +3489,12 @@ XLogFileCopy(XLogSegNo destsegno, TimeLineID srcTLI, XLogSegNo srcsegno,
|
||||
errmsg("could not fsync file \"%s\": %m", tmppath)));
|
||||
pgstat_report_wait_end();
|
||||
|
||||
if (CloseTransientFile(fd))
|
||||
if (CloseTransientFile(fd) != 0)
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not close file \"%s\": %m", tmppath)));
|
||||
|
||||
if (CloseTransientFile(srcfd))
|
||||
if (CloseTransientFile(srcfd) != 0)
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not close file \"%s\": %m", path)));
|
||||
@ -3791,7 +3791,7 @@ XLogFileClose(void)
|
||||
(void) posix_fadvise(openLogFile, 0, 0, POSIX_FADV_DONTNEED);
|
||||
#endif
|
||||
|
||||
if (close(openLogFile))
|
||||
if (close(openLogFile) != 0)
|
||||
ereport(PANIC,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not close file \"%s\": %m",
|
||||
@ -4566,7 +4566,7 @@ WriteControlFile(void)
|
||||
XLOG_CONTROL_FILE)));
|
||||
pgstat_report_wait_end();
|
||||
|
||||
if (close(fd))
|
||||
if (close(fd) != 0)
|
||||
ereport(PANIC,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not close file \"%s\": %m",
|
||||
@ -5225,7 +5225,7 @@ BootStrapXLOG(void)
|
||||
errmsg("could not fsync bootstrap write-ahead log file: %m")));
|
||||
pgstat_report_wait_end();
|
||||
|
||||
if (close(openLogFile))
|
||||
if (close(openLogFile) != 0)
|
||||
ereport(PANIC,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not close bootstrap write-ahead log file: %m")));
|
||||
@ -5527,7 +5527,7 @@ exitArchiveRecovery(TimeLineID endTLI, XLogRecPtr endOfLog)
|
||||
|
||||
fd = XLogFileInit(startLogSegNo, &use_existent, true);
|
||||
|
||||
if (close(fd))
|
||||
if (close(fd) != 0)
|
||||
ereport(ERROR,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not close file \"%s\": %m",
|
||||
|
Reference in New Issue
Block a user