aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2018-04-15 13:02:11 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2018-04-15 13:02:11 -0400
commit3a2d6365984d2cd98ee03467cd901785941cf772 (patch)
treec7ab4d1689f02882f2d20e0ac8360fdd8266841e
parentf8a187bdbae6e9d3b7407c0c37e3494518496200 (diff)
downloadpostgresql-3a2d6365984d2cd98ee03467cd901785941cf772.tar.gz
postgresql-3a2d6365984d2cd98ee03467cd901785941cf772.zip
Fix potentially-unportable code in contrib/adminpack.
Spelling access(2)'s second argument as "2" is just horrid. POSIX makes no promises as to the numeric values of W_OK and related macros. Even if it accidentally works as intended on every supported platform, it's still unreadable and inconsistent with adjacent code. In passing, don't spell "NULL" as "0" either. Yes, that's legal C; no, it's not project style. Back-patch, just in case the unportability is real and not theoretical. (Most likely, even if a platform had different bit assignments for access()'s modes, there'd not be an observable behavior difference here; but I'm being paranoid today.)
-rw-r--r--contrib/adminpack/adminpack.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/contrib/adminpack/adminpack.c b/contrib/adminpack/adminpack.c
index 2ce337e7b5a..0a27701e9c6 100644
--- a/contrib/adminpack/adminpack.c
+++ b/contrib/adminpack/adminpack.c
@@ -298,7 +298,7 @@ pg_file_rename_internal(text *file1, text *file2, text *file3)
fn2 = convert_and_check_filename(file2, false);
if (file3 == NULL)
- fn3 = 0;
+ fn3 = NULL;
else
fn3 = convert_and_check_filename(file3, false);
@@ -320,7 +320,7 @@ pg_file_rename_internal(text *file1, text *file2, text *file3)
return false;
}
- rc = access(fn3 ? fn3 : fn2, 2);
+ rc = access(fn3 ? fn3 : fn2, W_OK);
if (rc >= 0 || errno != ENOENT)
{
ereport(ERROR,