]> git.ipfire.org Git - thirdparty/postgresql.git/commitdiff
Add parens to ConvertToXSegs macro
authorAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 24 Jun 2020 17:57:21 +0000 (13:57 -0400)
committerAlvaro Herrera <alvherre@alvh.no-ip.org>
Wed, 24 Jun 2020 17:57:21 +0000 (13:57 -0400)
The current definition (introduced in 9a3215026bd6) is dangerous.  No
bugs exist in our code at present, but backpatch to 11 nonetheless,
where that commit debuted.

Author: Álvaro Herrera <alvherre@alvh.no-ip.org>

src/backend/access/transam/xlog.c

index bceef897d6eb5f32f6d8a424c086a6476924175b..28292393d199c64714ce8548b284054187eb6cb4 100644 (file)
@@ -738,9 +738,12 @@ static ControlFileData *ControlFile = NULL;
  */
 #define UsableBytesInPage (XLOG_BLCKSZ - SizeOfXLogShortPHD)
 
-/* Convert min_wal_size_mb and max wal_size_mb to equivalent segment count */
+/*
+ * Convert min_wal_size_mb and max wal_size_mb to equivalent segment count.
+ * Rounds down.
+ */
 #define ConvertToXSegs(x, segsize)     \
-       (x / ((segsize) / (1024 * 1024)))
+       ((x) / ((segsize) / (1024 * 1024)))
 
 /* The number of bytes in a WAL segment usable for WAL data. */
 static int     UsableBytesInSegment;