public inbox for [email protected]  
help / color / mirror / Atom feed
From: =?gb18030?B?emVuZ21hbg==?= <[email protected]>
To: =?gb18030?B?SGVpa2tpIExpbm5ha2FuZ2Fz?= <[email protected]>
Cc: =?gb18030?B?cGdzcWwtaGFja2Vycw==?= <[email protected]>
Subject: Re: POC: make mxidoff 64 bits
Date: Tue, 30 Dec 2025 09:49:36 +0800
Message-ID: <[email protected]> (raw)
In-Reply-To: <[email protected]>
References: <CACG=ezaWg7_nt-8ey4aKv2w9LcuLthHknwCawmBgEeTnJrJTcw@mail.gmail.com>
	<CACG=ezYbYO_KHWdeDedbDcY0tOS0JfaqBxG3=bG5+DdsDK4MpQ@mail.gmail.com>
	<CACG=ezYpZRPwoRCz_h3Qerd3XJNdpTHCpwGbZphNdy26tA4_qQ@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<CACG=ezYUJSvnuxntkURNWo_1vZ+AtmcQfqd_h6WgDzGaudfw+Q@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<CAExHW5tUEkiQrvm9hgccjKUNkWBnJ5_HDUrAwiHBTxu+Vuj29Q@mail.gmail.com>
	<[email protected]>
	<CAExHW5t3kzJiVqmoqCLyGmfkTjD4Rwa27kXH-S_XvHWLkM2fzw@mail.gmail.com>
	<CAExHW5ucnoyjd6p7UVVhQTeV7hc8-vX81ti8f7sU0COqfUWzQg@mail.gmail.com>
	<[email protected]>
	<CAExHW5s_uNeD_xYjdbSR8khMXwWJQOY9Qg=j4T+5KOfGz5-RsQ@mail.gmail.com>
	<[email protected]>
	<[email protected]>
	<[email protected]>
	<[email protected]>

Hi,

I'm currently looking into the `SlruReadSwitchPageSlow` function and have a question regarding the expression `&state->buf.data + bytes_read` — 
I suspect the ampersand (&) here might be misused. Would you be able to help me verify this?

```
	while (bytes_read < BLCKSZ)
	{
		ssize_t		rc;

		rc = pg_pread(state->fd,
					  &state->buf.data + bytes_read,
					  BLCKSZ - bytes_read,
					  offset);
		if (rc < 0)
		{
			if (errno == EINTR)
				continue;
			pg_fatal("could not read file \"%s\": %m", state->fn);
		}
		if (rc == 0)
		{
			/* unexpected EOF */
			pg_log(PG_WARNING, "unexpected EOF reading file \"%s\" at offset %u, reading as zeros",
				   state->fn, (unsigned int) offset);
			memset(&state->buf.data + bytes_read, 0, BLCKSZ - bytes_read);
			break;
		}
		bytes_read += rc;
		offset += rc;
	}
```

```
		rc = pg_pread(state->fd,
					  &state->buf.data + bytes_read,
					  BLCKSZ - bytes_read,
					  offset);
memset(&state->buf.data + bytes_read, 0, BLCKSZ - bytes_read);
```

--
Regards,
Man Zeng
www.openhalo.org

Attachments:

  [application/octet-stream] slru_io.diff (853B, 2-slru_io.diff)
  download | inline diff:
diff --git a/src/bin/pg_upgrade/slru_io.c b/src/bin/pg_upgrade/slru_io.c
index 0862cd33e6c..2df0a1d0a76 100644
--- a/src/bin/pg_upgrade/slru_io.c
+++ b/src/bin/pg_upgrade/slru_io.c
@@ -121,7 +121,7 @@ SlruReadSwitchPageSlow(SlruSegState *state, uint64 pageno)
 		ssize_t		rc;
 
 		rc = pg_pread(state->fd,
-					  &state->buf.data + bytes_read,
+					  state->buf.data + bytes_read,
 					  BLCKSZ - bytes_read,
 					  offset);
 		if (rc < 0)
@@ -135,7 +135,7 @@ SlruReadSwitchPageSlow(SlruSegState *state, uint64 pageno)
 			/* unexpected EOF */
 			pg_log(PG_WARNING, "unexpected EOF reading file \"%s\" at offset %u, reading as zeros",
 				   state->fn, (unsigned int) offset);
-			memset(&state->buf.data + bytes_read, 0, BLCKSZ - bytes_read);
+			memset(state->buf.data + bytes_read, 0, BLCKSZ - bytes_read);
 			break;
 		}
 		bytes_read += rc;


view thread (79+ messages)  latest in thread

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: [email protected]
  Cc: [email protected], [email protected], [email protected]
  Subject: Re: POC: make mxidoff 64 bits
  In-Reply-To: <[email protected]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox