From 368d7f3297e7e1304da03904d2e1310d79fa82a9 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Wed, 24 Jun 2020 14:00:37 -0400 Subject: [PATCH] Add parens to ConvertToXSegs macro MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 --- src/backend/access/transam/xlog.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index a1256a103b6..34ede80c44f 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -760,9 +760,12 @@ static ControlFileData *ControlFile = NULL; */ #define UsableBytesInPage (XLOG_BLCKSZ - SizeOfXLogShortPHD) -/* Convert values of GUCs measured in megabytes to equiv. segment count */ +/* + * Convert values of GUCs measured in megabytes to equiv. 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; -- 2.39.5