Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit16d3dbe

Browse files
committed
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 relatedmacros. Even if it accidentally works as intended on every supportedplatform, 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 foraccess()'s modes, there'd not be an observable behavior differencehere; but I'm being paranoid today.)
1 parentd014b38 commit16d3dbe

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

‎contrib/adminpack/adminpack.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ pg_file_rename(PG_FUNCTION_ARGS)
173173
fn1=convert_and_check_filename(PG_GETARG_TEXT_PP(0), false);
174174
fn2=convert_and_check_filename(PG_GETARG_TEXT_PP(1), false);
175175
if (PG_ARGISNULL(2))
176-
fn3=0;
176+
fn3=NULL;
177177
else
178178
fn3=convert_and_check_filename(PG_GETARG_TEXT_PP(2), false);
179179

@@ -195,7 +195,7 @@ pg_file_rename(PG_FUNCTION_ARGS)
195195
PG_RETURN_BOOL(false);
196196
}
197197

198-
rc=access(fn3 ?fn3 :fn2,2);
198+
rc=access(fn3 ?fn3 :fn2,W_OK);
199199
if (rc >=0||errno!=ENOENT)
200200
{
201201
ereport(ERROR,

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp