Skip to content

Commit 0c08856

Browse files
committed
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
1 parent 0d2cb6b commit 0c08856

File tree

1 file changed

+9
-6
lines changed
  • src/backend/storage/file

1 file changed

+9
-6
lines changed

src/backend/storage/file/fd.c

+9-6
Original file line numberDiff line numberDiff line change
@@ -1065,20 +1065,23 @@ BasicOpenFilePerm(const char *fileName, int fileFlags, mode_t fileMode)
10651065
*/
10661066
StaticAssertStmt((PG_O_DIRECT &
10671067
(O_APPEND |
1068-
#if defined(O_CLOEXEC)
1069-
O_CLOEXEC |
1070-
#endif
10711068
O_CREAT |
1072-
#if defined(O_DSYNC)
1073-
O_DSYNC |
1074-
#endif
10751069
O_EXCL |
10761070
O_RDWR |
10771071
O_RDONLY |
10781072
O_SYNC |
10791073
O_TRUNC |
10801074
O_WRONLY)) == 0,
10811075
"PG_O_DIRECT value collides with standard flag");
1076+
#if defined(O_CLOEXEC)
1077+
StaticAssertStmt((PG_O_DIRECT & O_CLOEXEC) == 0,
1078+
"PG_O_DIRECT value collides with O_CLOEXEC");
1079+
#endif
1080+
#if defined(O_DSYNC)
1081+
StaticAssertStmt((PG_O_DIRECT & O_DSYNC) == 0,
1082+
"PG_O_DIRECT value collides with O_DSYNC");
1083+
#endif
1084+
10821085
fd = open(fileName, fileFlags & ~PG_O_DIRECT, fileMode);
10831086
#else
10841087
fd = open(fileName, fileFlags, fileMode);

0 commit comments

Comments
 (0)