Don't use #if inside function-like macro arguments.
authorThomas Munro <tmunro@postgresql.org>
Mon, 19 Jul 2021 22:49:08 +0000 (10:49 +1200)
committerThomas Munro <tmunro@postgresql.org>
Mon, 19 Jul 2021 23:19:13 +0000 (11:19 +1200)
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

src/backend/storage/file/fd.c

index abb054ad7f3799a98d1ce3dbaf922de0bae31ae0..5d5e8ae94e001e6e159c364fc0d3e3c8d5177241 100644 (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);