mirror of
https://github.com/postgres/postgres.git
synced 2025-08-27 07:42:10 +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:
@@ -647,7 +647,7 @@ durable_rename(const char *oldfile, const char *newfile, int elevel)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (CloseTransientFile(fd))
|
||||
if (CloseTransientFile(fd) != 0)
|
||||
{
|
||||
ereport(elevel,
|
||||
(errcode_for_file_access(),
|
||||
@@ -1047,7 +1047,7 @@ LruDelete(File file)
|
||||
* Close the file. We aren't expecting this to fail; if it does, better
|
||||
* to leak the FD than to mess up our internal state.
|
||||
*/
|
||||
if (close(vfdP->fd))
|
||||
if (close(vfdP->fd) != 0)
|
||||
elog(vfdP->fdstate & FD_TEMP_FILE_LIMIT ? LOG : data_sync_elevel(LOG),
|
||||
"could not close file \"%s\": %m", vfdP->fileName);
|
||||
vfdP->fd = VFD_CLOSED;
|
||||
@@ -1724,7 +1724,7 @@ FileClose(File file)
|
||||
if (!FileIsNotOpen(file))
|
||||
{
|
||||
/* close the file */
|
||||
if (close(vfdP->fd))
|
||||
if (close(vfdP->fd) != 0)
|
||||
{
|
||||
/*
|
||||
* We may need to panic on failure to close non-temporary files;
|
||||
@@ -3302,7 +3302,7 @@ pre_sync_fname(const char *fname, bool isdir, int elevel)
|
||||
*/
|
||||
pg_flush_data(fd, 0, 0);
|
||||
|
||||
if (CloseTransientFile(fd))
|
||||
if (CloseTransientFile(fd) != 0)
|
||||
ereport(elevel,
|
||||
(errcode_for_file_access(),
|
||||
errmsg("could not close file \"%s\": %m", fname)));
|
||||
@@ -3404,7 +3404,7 @@ fsync_fname_ext(const char *fname, bool isdir, bool ignore_perm, int elevel)
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (CloseTransientFile(fd))
|
||||
if (CloseTransientFile(fd) != 0)
|
||||
{
|
||||
ereport(elevel,
|
||||
(errcode_for_file_access(),
|
||||
|
Reference in New Issue
Block a user