Skip to content

Commit b6ec7c9

Browse files
committed
Fix some remaining int64 vestiges in contrib/test_shm_mq.
Andres Freund and Tom Lane
1 parent c676ac0 commit b6ec7c9

File tree

2 files changed

+12
-7
lines changed

2 files changed

+12
-7
lines changed

contrib/test_shm_mq/setup.c

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ setup_dynamic_shared_memory(int64 queue_size, int nworkers,
9292
{
9393
shm_toc_estimator e;
9494
int i;
95-
uint64 segsize;
95+
Size segsize;
9696
dsm_segment *seg;
9797
shm_toc *toc;
9898
test_shm_mq_header *hdr;
@@ -101,8 +101,12 @@ setup_dynamic_shared_memory(int64 queue_size, int nworkers,
101101
if (queue_size < 0 || ((uint64) queue_size) < shm_mq_minimum_size)
102102
ereport(ERROR,
103103
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
104-
errmsg("queue size must be at least %lu bytes",
105-
(unsigned long) shm_mq_minimum_size)));
104+
errmsg("queue size must be at least %zu bytes",
105+
shm_mq_minimum_size)));
106+
if (queue_size != ((Size) queue_size))
107+
ereport(ERROR,
108+
(errcode(ERRCODE_INVALID_PARAMETER_VALUE),
109+
errmsg("queue size overflows size_t")));
106110

107111
/*
108112
* Estimate how much shared memory we need.
@@ -116,7 +120,7 @@ setup_dynamic_shared_memory(int64 queue_size, int nworkers,
116120
shm_toc_initialize_estimator(&e);
117121
shm_toc_estimate_chunk(&e, sizeof(test_shm_mq_header));
118122
for (i = 0; i <= nworkers; ++i)
119-
shm_toc_estimate_chunk(&e, queue_size);
123+
shm_toc_estimate_chunk(&e, (Size) queue_size);
120124
shm_toc_estimate_keys(&e, 2 + nworkers);
121125
segsize = shm_toc_estimate(&e);
122126

@@ -138,7 +142,8 @@ setup_dynamic_shared_memory(int64 queue_size, int nworkers,
138142
{
139143
shm_mq *mq;
140144

141-
mq = shm_mq_create(shm_toc_allocate(toc, queue_size), queue_size);
145+
mq = shm_mq_create(shm_toc_allocate(toc, (Size) queue_size),
146+
(Size) queue_size);
142147
shm_toc_insert(toc, i + 1, mq);
143148

144149
if (i == 0)

contrib/test_shm_mq/test.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -254,12 +254,12 @@ verify_message(Size origlen, char *origdata, Size newlen, char *newdata)
254254
if (origlen != newlen)
255255
ereport(ERROR,
256256
(errmsg("message corrupted"),
257-
errdetail("The original message was " UINT64_FORMAT " bytes but the final message is " UINT64_FORMAT " bytes.",
257+
errdetail("The original message was %zu bytes but the final message is %zu bytes.",
258258
origlen, newlen)));
259259

260260
for (i = 0; i < origlen; ++i)
261261
if (origdata[i] != newdata[i])
262262
ereport(ERROR,
263263
(errmsg("message corrupted"),
264-
errdetail("The new and original messages differ at byte " UINT64_FORMAT " of " UINT64_FORMAT ".", i, origlen)));
264+
errdetail("The new and original messages differ at byte %zu of %zu.", i, origlen)));
265265
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy