Skip to content

Commit 013d324

Browse files
committed
Add parens to ConvertToXSegs macro
The current definition is dangerous. No bugs exist in our code at present, but backpatch to 11 nonetheless where it was introduced. Author: Álvaro Herrera <alvherre@alvh.no-ip.org>
1 parent d3d8755 commit 013d324

File tree

1 file changed

+5
-2
lines changed
  • src/backend/access/transam

1 file changed

+5
-2
lines changed

src/backend/access/transam/xlog.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -744,9 +744,12 @@ static ControlFileData *ControlFile = NULL;
744744
*/
745745
#define UsableBytesInPage (XLOG_BLCKSZ - SizeOfXLogShortPHD)
746746

747-
/* Convert min_wal_size_mb and max wal_size_mb to equivalent segment count */
747+
/*
748+
* Convert min_wal_size_mb and max wal_size_mb to equivalent segment count.
749+
* Rounds down.
750+
*/
748751
#define ConvertToXSegs(x, segsize) \
749-
(x / ((segsize) / (1024 * 1024)))
752+
((x) / ((segsize) / (1024 * 1024)))
750753

751754
/* The number of bytes in a WAL segment usable for WAL data. */
752755
static int UsableBytesInSegment;

0 commit comments

Comments
 (0)