]> granicus.if.org Git - postgresql/commitdiff
Fix some remaining int64 vestiges in contrib/test_shm_mq.
authorTom Lane <tgl@sss.pgh.pa.us>
Tue, 18 Mar 2014 18:26:44 +0000 (14:26 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Tue, 18 Mar 2014 18:26:44 +0000 (14:26 -0400)
Andres Freund and Tom Lane

contrib/test_shm_mq/setup.c
contrib/test_shm_mq/test.c

index 7ad11157cf24837adb55a8fc461d942d5f11e055..612480fd4e58e77c907bca19b56dba9907a1c317 100644 (file)
@@ -92,7 +92,7 @@ setup_dynamic_shared_memory(int64 queue_size, int nworkers,
 {
        shm_toc_estimator       e;
        int                                     i;
-       uint64                  segsize;
+       Size                    segsize;
        dsm_segment        *seg;
        shm_toc            *toc;
        test_shm_mq_header *hdr;
@@ -101,8 +101,12 @@ setup_dynamic_shared_memory(int64 queue_size, int nworkers,
        if (queue_size < 0 || ((uint64) queue_size) < shm_mq_minimum_size)
                ereport(ERROR,
                                (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
-                                errmsg("queue size must be at least %lu bytes",
-                                       (unsigned long) shm_mq_minimum_size)));
+                                errmsg("queue size must be at least %zu bytes",
+                                               shm_mq_minimum_size)));
+       if (queue_size != ((Size) queue_size))
+               ereport(ERROR,
+                               (errcode(ERRCODE_INVALID_PARAMETER_VALUE),
+                                errmsg("queue size overflows size_t")));
 
        /*
         * Estimate how much shared memory we need.
@@ -116,7 +120,7 @@ setup_dynamic_shared_memory(int64 queue_size, int nworkers,
        shm_toc_initialize_estimator(&e);
        shm_toc_estimate_chunk(&e, sizeof(test_shm_mq_header));
        for (i = 0; i <= nworkers; ++i)
-               shm_toc_estimate_chunk(&e, queue_size);
+               shm_toc_estimate_chunk(&e, (Size) queue_size);
        shm_toc_estimate_keys(&e, 2 + nworkers);
        segsize = shm_toc_estimate(&e);
 
@@ -138,7 +142,8 @@ setup_dynamic_shared_memory(int64 queue_size, int nworkers,
        {
                shm_mq             *mq;
 
-               mq = shm_mq_create(shm_toc_allocate(toc, queue_size), queue_size);
+               mq = shm_mq_create(shm_toc_allocate(toc, (Size) queue_size),
+                                                  (Size) queue_size);
                shm_toc_insert(toc, i + 1, mq);
 
                if (i == 0)
index dba5e692e4db21d8647230e638af38f7a0989f98..5ff1e9a63f30467f2bef93e2b6625a595e7234fd 100644 (file)
@@ -254,12 +254,12 @@ verify_message(Size origlen, char *origdata, Size newlen, char *newdata)
        if (origlen != newlen)
                ereport(ERROR,
                                (errmsg("message corrupted"),
-                                errdetail("The original message was " UINT64_FORMAT " bytes but the final message is " UINT64_FORMAT " bytes.",
+                                errdetail("The original message was %zu bytes but the final message is %zu bytes.",
                                         origlen, newlen)));
 
        for (i = 0; i < origlen; ++i)
                if (origdata[i] != newdata[i])
                        ereport(ERROR,
                                        (errmsg("message corrupted"),
-                                        errdetail("The new and original messages differ at byte " UINT64_FORMAT " of " UINT64_FORMAT ".", i, origlen)));
+                                        errdetail("The new and original messages differ at byte %zu of %zu.", i, origlen)));
 }