From 7823bceebb9188d6817b8bc6516f4c6a8828033b Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Mon, 1 Dec 2025 08:18:16 +0100 Subject: [PATCH 3/3] pg_test_fsync: Align test data using PGAlignedXLogBlock for code simplification --- src/bin/pg_test_fsync/pg_test_fsync.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/bin/pg_test_fsync/pg_test_fsync.c b/src/bin/pg_test_fsync/pg_test_fsync.c index a63d6f1a54f..3d0c242cc20 100644 --- a/src/bin/pg_test_fsync/pg_test_fsync.c +++ b/src/bin/pg_test_fsync/pg_test_fsync.c @@ -68,9 +68,8 @@ static const char *progname; static unsigned int secs_per_test = 5; static int needs_unlink = 0; -static char full_buf[DEFAULT_XLOG_SEG_SIZE], - *buf, - *filename = FSYNC_FILENAME; +static alignas(PGAlignedXLogBlock) char buf[DEFAULT_XLOG_SEG_SIZE]; +static char *filename = FSYNC_FILENAME; static struct timeval start_t, stop_t; static sig_atomic_t alarm_triggered = false; @@ -232,9 +231,7 @@ prepare_buf(void) /* write random data into buffer */ for (ops = 0; ops < DEFAULT_XLOG_SEG_SIZE; ops++) - full_buf[ops] = (char) pg_prng_int32(&pg_global_prng_state); - - buf = (char *) TYPEALIGN(PG_IO_ALIGN_SIZE, full_buf); + buf[ops] = (char) pg_prng_int32(&pg_global_prng_state); } static void @@ -248,7 +245,7 @@ test_open(void) if ((tmpfile = open(filename, O_RDWR | O_CREAT | PG_BINARY, S_IRUSR | S_IWUSR)) == -1) die("could not open output file"); needs_unlink = 1; - if (write(tmpfile, full_buf, DEFAULT_XLOG_SEG_SIZE) != + if (write(tmpfile, buf, DEFAULT_XLOG_SEG_SIZE) != DEFAULT_XLOG_SEG_SIZE) die("write failed"); -- 2.52.0