Don't use #if inside function-like macro arguments.

No concrete problem reported, but in the past it's been known to cause
problems on some compilers so let's avoid doing that.

Reported-by: Tom Lane <tgl@sss.pgh.pa.us>
Discussion: https://postgr.es/m/234364.1626704007%40sss.pgh.pa.us
This commit is contained in:
Thomas Munro 2021-07-20 10:49:08 +12:00
parent 0d2cb6b2bb
commit 0c08856856
1 changed files with 9 additions and 6 deletions

View File

@ -1065,13 +1065,7 @@ tryAgain:
*/
StaticAssertStmt((PG_O_DIRECT &
(O_APPEND |
#if defined(O_CLOEXEC)
O_CLOEXEC |
#endif
O_CREAT |
#if defined(O_DSYNC)
O_DSYNC |
#endif
O_EXCL |
O_RDWR |
O_RDONLY |
@ -1079,6 +1073,15 @@ tryAgain:
O_TRUNC |
O_WRONLY)) == 0,
"PG_O_DIRECT value collides with standard flag");
#if defined(O_CLOEXEC)
StaticAssertStmt((PG_O_DIRECT & O_CLOEXEC) == 0,
"PG_O_DIRECT value collides with O_CLOEXEC");
#endif
#if defined(O_DSYNC)
StaticAssertStmt((PG_O_DIRECT & O_DSYNC) == 0,
"PG_O_DIRECT value collides with O_DSYNC");
#endif
fd = open(fileName, fileFlags & ~PG_O_DIRECT, fileMode);
#else
fd = open(fileName, fileFlags, fileMode);