1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-12 02:37:31 +03:00

Remove unnecessary casts in printf format arguments (%zu/%zd)

Many of these are probably left over from before use of %zu/%zd was
portable.

Reviewed-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/07fa29f9-42d7-4aac-8834-197918cbbab6%40eisentraut.org
This commit is contained in:
Peter Eisentraut
2025-12-09 06:58:39 +01:00
parent 0c3c5c3b06
commit 2b117bb014
19 changed files with 86 additions and 92 deletions

View File

@@ -46,8 +46,8 @@ gistfillbuffer(Page page, IndexTuple *itup, int len, OffsetNumber off)
l = PageAddItem(page, itup[i], sz, off, false, false); l = PageAddItem(page, itup[i], sz, off, false, false);
if (l == InvalidOffsetNumber) if (l == InvalidOffsetNumber)
elog(ERROR, "failed to add item to GiST index page, item %d out of %d, size %d bytes", elog(ERROR, "failed to add item to GiST index page, item %d out of %d, size %zu bytes",
i, len, (int) sz); i, len, sz);
off++; off++;
} }
} }

View File

@@ -99,8 +99,7 @@ gistRedoPageUpdateRecord(XLogReaderState *record)
itup = (IndexTuple) data; itup = (IndexTuple) data;
itupsize = IndexTupleSize(itup); itupsize = IndexTupleSize(itup);
if (!PageIndexTupleOverwrite(page, offnum, itup, itupsize)) if (!PageIndexTupleOverwrite(page, offnum, itup, itupsize))
elog(ERROR, "failed to add item to GiST index page, size %d bytes", elog(ERROR, "failed to add item to GiST index page, size %zu bytes", itupsize);
(int) itupsize);
data += itupsize; data += itupsize;
/* should be nothing left after consuming 1 tuple */ /* should be nothing left after consuming 1 tuple */
Assert(data - begin == datalen); Assert(data - begin == datalen);
@@ -135,8 +134,7 @@ gistRedoPageUpdateRecord(XLogReaderState *record)
l = PageAddItem(page, itup, sz, off, false, false); l = PageAddItem(page, itup, sz, off, false, false);
if (l == InvalidOffsetNumber) if (l == InvalidOffsetNumber)
elog(ERROR, "failed to add item to GiST index page, size %d bytes", elog(ERROR, "failed to add item to GiST index page, size %zu bytes", sz);
(int) sz);
off++; off++;
ninserted++; ninserted++;
} }

View File

@@ -557,8 +557,7 @@ hash_xlog_move_page_contents(XLogReaderState *record)
l = PageAddItem(writepage, itup, itemsz, towrite[ninserted], false, false); l = PageAddItem(writepage, itup, itemsz, towrite[ninserted], false, false);
if (l == InvalidOffsetNumber) if (l == InvalidOffsetNumber)
elog(ERROR, "hash_xlog_move_page_contents: failed to add item to hash index page, size %d bytes", elog(ERROR, "hash_xlog_move_page_contents: failed to add item to hash index page, size %zu bytes", itemsz);
(int) itemsz);
ninserted++; ninserted++;
} }
@@ -689,8 +688,7 @@ hash_xlog_squeeze_page(XLogReaderState *record)
l = PageAddItem(writepage, itup, itemsz, towrite[ninserted], false, false); l = PageAddItem(writepage, itup, itemsz, towrite[ninserted], false, false);
if (l == InvalidOffsetNumber) if (l == InvalidOffsetNumber)
elog(ERROR, "hash_xlog_squeeze_page: failed to add item to hash index page, size %d bytes", elog(ERROR, "hash_xlog_squeeze_page: failed to add item to hash index page, size %zu bytes", itemsz);
(int) itemsz);
ninserted++; ninserted++;
} }

View File

@@ -176,9 +176,9 @@ bbsink_server_archive_contents(bbsink *sink, size_t len)
/* short write: complain appropriately */ /* short write: complain appropriately */
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DISK_FULL), (errcode(ERRCODE_DISK_FULL),
errmsg("could not write file \"%s\": wrote only %d of %d bytes at offset %u", errmsg("could not write file \"%s\": wrote only %d of %zu bytes at offset %u",
FilePathName(mysink->file), FilePathName(mysink->file),
nbytes, (int) len, (unsigned) mysink->filepos), nbytes, len, (unsigned) mysink->filepos),
errhint("Check free disk space."))); errhint("Check free disk space.")));
} }
@@ -269,9 +269,9 @@ bbsink_server_manifest_contents(bbsink *sink, size_t len)
/* short write: complain appropriately */ /* short write: complain appropriately */
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DISK_FULL), (errcode(ERRCODE_DISK_FULL),
errmsg("could not write file \"%s\": wrote only %d of %d bytes at offset %u", errmsg("could not write file \"%s\": wrote only %d of %zu bytes at offset %u",
FilePathName(mysink->file), FilePathName(mysink->file),
nbytes, (int) len, (unsigned) mysink->filepos), nbytes, len, (unsigned) mysink->filepos),
errhint("Check free disk space."))); errhint("Check free disk space.")));
} }

View File

@@ -998,8 +998,8 @@ pg_GSS_recvauth(Port *port)
gbuf.length = buf.len; gbuf.length = buf.len;
gbuf.value = buf.data; gbuf.value = buf.data;
elog(DEBUG4, "processing received GSS token of length %u", elog(DEBUG4, "processing received GSS token of length %zu",
(unsigned int) gbuf.length); gbuf.length);
maj_stat = gss_accept_sec_context(&min_stat, maj_stat = gss_accept_sec_context(&min_stat,
&port->gss->ctx, &port->gss->ctx,
@@ -1017,9 +1017,9 @@ pg_GSS_recvauth(Port *port)
pfree(buf.data); pfree(buf.data);
elog(DEBUG5, "gss_accept_sec_context major: %u, " elog(DEBUG5, "gss_accept_sec_context major: %u, "
"minor: %u, outlen: %u, outflags: %x", "minor: %u, outlen: %zu, outflags: %x",
maj_stat, min_stat, maj_stat, min_stat,
(unsigned int) port->gss->outbuf.length, gflags); port->gss->outbuf.length, gflags);
CHECK_FOR_INTERRUPTS(); CHECK_FOR_INTERRUPTS();
@@ -1034,8 +1034,8 @@ pg_GSS_recvauth(Port *port)
/* /*
* Negotiation generated data to be sent to the client. * Negotiation generated data to be sent to the client.
*/ */
elog(DEBUG4, "sending GSS response token of length %u", elog(DEBUG4, "sending GSS response token of length %zu",
(unsigned int) port->gss->outbuf.length); port->gss->outbuf.length);
sendAuthRequest(port, AUTH_REQ_GSS_CONT, sendAuthRequest(port, AUTH_REQ_GSS_CONT,
port->gss->outbuf.value, port->gss->outbuf.length); port->gss->outbuf.value, port->gss->outbuf.length);

View File

@@ -454,9 +454,9 @@ ListenServerPort(int family, const char *hostName, unsigned short portNumber,
if (strlen(unixSocketPath) >= UNIXSOCK_PATH_BUFLEN) if (strlen(unixSocketPath) >= UNIXSOCK_PATH_BUFLEN)
{ {
ereport(LOG, ereport(LOG,
(errmsg("Unix-domain socket path \"%s\" is too long (maximum %d bytes)", (errmsg("Unix-domain socket path \"%s\" is too long (maximum %zu bytes)",
unixSocketPath, unixSocketPath,
(int) (UNIXSOCK_PATH_BUFLEN - 1)))); (UNIXSOCK_PATH_BUFLEN - 1))));
return STATUS_ERROR; return STATUS_ERROR;
} }
if (Lock_AF_UNIX(unixSocketDir, unixSocketPath) != STATUS_OK) if (Lock_AF_UNIX(unixSocketDir, unixSocketPath) != STATUS_OK)

View File

@@ -354,7 +354,7 @@ outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
if (typbyval) if (typbyval)
{ {
s = (char *) (&value); s = (char *) (&value);
appendStringInfo(str, "%u [ ", (unsigned int) length); appendStringInfo(str, "%zu [ ", length);
for (Size i = 0; i < (Size) sizeof(Datum); i++) for (Size i = 0; i < (Size) sizeof(Datum); i++)
appendStringInfo(str, "%d ", (int) (s[i])); appendStringInfo(str, "%d ", (int) (s[i]));
appendStringInfoChar(str, ']'); appendStringInfoChar(str, ']');
@@ -366,7 +366,7 @@ outDatum(StringInfo str, Datum value, int typlen, bool typbyval)
appendStringInfoString(str, "0 [ ]"); appendStringInfoString(str, "0 [ ]");
else else
{ {
appendStringInfo(str, "%u [ ", (unsigned int) length); appendStringInfo(str, "%zu [ ", length);
for (Size i = 0; i < length; i++) for (Size i = 0; i < length; i++)
appendStringInfo(str, "%d ", (int) (s[i])); appendStringInfo(str, "%d ", (int) (s[i]));
appendStringInfoChar(str, ']'); appendStringInfoChar(str, ']');

View File

@@ -785,8 +785,8 @@ PageRepairFragmentation(Page page)
if (totallen > (Size) (pd_special - pd_lower)) if (totallen > (Size) (pd_special - pd_lower))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED), (errcode(ERRCODE_DATA_CORRUPTED),
errmsg("corrupted item lengths: total %u, available space %u", errmsg("corrupted item lengths: total %zu, available space %u",
(unsigned int) totallen, pd_special - pd_lower))); totallen, pd_special - pd_lower)));
compactify_tuples(itemidbase, nstorage, page, presorted); compactify_tuples(itemidbase, nstorage, page, presorted);
} }
@@ -1088,8 +1088,8 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum)
offset != MAXALIGN(offset)) offset != MAXALIGN(offset))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED), (errcode(ERRCODE_DATA_CORRUPTED),
errmsg("corrupted line pointer: offset = %u, size = %u", errmsg("corrupted line pointer: offset = %u, size = %zu",
offset, (unsigned int) size))); offset, size)));
/* Amount of space to actually be deleted */ /* Amount of space to actually be deleted */
size = MAXALIGN(size); size = MAXALIGN(size);
@@ -1229,8 +1229,8 @@ PageIndexMultiDelete(Page page, OffsetNumber *itemnos, int nitems)
offset != MAXALIGN(offset)) offset != MAXALIGN(offset))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED), (errcode(ERRCODE_DATA_CORRUPTED),
errmsg("corrupted line pointer: offset = %u, size = %u", errmsg("corrupted line pointer: offset = %u, size = %zu",
offset, (unsigned int) size))); offset, size)));
if (nextitm < nitems && offnum == itemnos[nextitm]) if (nextitm < nitems && offnum == itemnos[nextitm])
{ {
@@ -1262,8 +1262,8 @@ PageIndexMultiDelete(Page page, OffsetNumber *itemnos, int nitems)
if (totallen > (Size) (pd_special - pd_lower)) if (totallen > (Size) (pd_special - pd_lower))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED), (errcode(ERRCODE_DATA_CORRUPTED),
errmsg("corrupted item lengths: total %u, available space %u", errmsg("corrupted item lengths: total %zu, available space %u",
(unsigned int) totallen, pd_special - pd_lower))); totallen, pd_special - pd_lower)));
/* /*
* Looks good. Overwrite the line pointers with the copy, from which we've * Looks good. Overwrite the line pointers with the copy, from which we've
@@ -1326,8 +1326,8 @@ PageIndexTupleDeleteNoCompact(Page page, OffsetNumber offnum)
offset != MAXALIGN(offset)) offset != MAXALIGN(offset))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_DATA_CORRUPTED), (errcode(ERRCODE_DATA_CORRUPTED),
errmsg("corrupted line pointer: offset = %u, size = %u", errmsg("corrupted line pointer: offset = %u, size = %zu",
offset, (unsigned int) size))); offset, size)));
/* Amount of space to actually be deleted */ /* Amount of space to actually be deleted */
size = MAXALIGN(size); size = MAXALIGN(size);

View File

@@ -271,8 +271,8 @@ EA_get_flat_size(ExpandedObjectHeader *eohptr)
if (!AllocSizeIsValid(nbytes)) if (!AllocSizeIsValid(nbytes))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array size exceeds the maximum allowed (%d)", errmsg("array size exceeds the maximum allowed (%zu)",
(int) MaxAllocSize))); MaxAllocSize)));
} }
if (dnulls) if (dnulls)

View File

@@ -333,8 +333,8 @@ array_in(PG_FUNCTION_ARGS)
if (!AllocSizeIsValid(nbytes)) if (!AllocSizeIsValid(nbytes))
ereturn(escontext, (Datum) 0, ereturn(escontext, (Datum) 0,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array size exceeds the maximum allowed (%d)", errmsg("array size exceeds the maximum allowed (%zu)",
(int) MaxAllocSize))); MaxAllocSize)));
} }
} }
if (hasnulls) if (hasnulls)
@@ -492,8 +492,8 @@ ReadArrayDimensions(char **srcptr, int *ndim_p, int *dim, int *lBound,
pg_add_s32_overflow(ub, 1, &ub)) pg_add_s32_overflow(ub, 1, &ub))
ereturn(escontext, false, ereturn(escontext, false,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array size exceeds the maximum allowed (%d)", errmsg("array size exceeds the maximum allowed (%zu)",
(int) MaxArraySize))); MaxArraySize)));
dim[ndim] = ub; dim[ndim] = ub;
ndim++; ndim++;
@@ -725,8 +725,8 @@ ReadArrayStr(char **srcptr,
if (maxitems >= MaxArraySize) if (maxitems >= MaxArraySize)
ereturn(escontext, false, ereturn(escontext, false,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array size exceeds the maximum allowed (%d)", errmsg("array size exceeds the maximum allowed (%zu)",
(int) MaxArraySize))); MaxArraySize)));
maxitems = Min(maxitems * 2, MaxArraySize); maxitems = Min(maxitems * 2, MaxArraySize);
values = repalloc_array(values, Datum, maxitems); values = repalloc_array(values, Datum, maxitems);
nulls = repalloc_array(nulls, bool, maxitems); nulls = repalloc_array(nulls, bool, maxitems);
@@ -1531,8 +1531,8 @@ ReadArrayBinary(StringInfo buf,
if (!AllocSizeIsValid(totbytes)) if (!AllocSizeIsValid(totbytes))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array size exceeds the maximum allowed (%d)", errmsg("array size exceeds the maximum allowed (%zu)",
(int) MaxAllocSize))); MaxAllocSize)));
} }
} }
*hasnulls = hasnull; *hasnulls = hasnull;
@@ -2339,8 +2339,8 @@ array_set_element(Datum arraydatum,
pg_add_s32_overflow(dim[0], addedbefore, &dim[0])) pg_add_s32_overflow(dim[0], addedbefore, &dim[0]))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array size exceeds the maximum allowed (%d)", errmsg("array size exceeds the maximum allowed (%zu)",
(int) MaxArraySize))); MaxArraySize)));
lb[0] = indx[0]; lb[0] = indx[0];
if (addedbefore > 1) if (addedbefore > 1)
newhasnulls = true; /* will insert nulls */ newhasnulls = true; /* will insert nulls */
@@ -2354,8 +2354,8 @@ array_set_element(Datum arraydatum,
pg_add_s32_overflow(dim[0], addedafter, &dim[0])) pg_add_s32_overflow(dim[0], addedafter, &dim[0]))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array size exceeds the maximum allowed (%d)", errmsg("array size exceeds the maximum allowed (%zu)",
(int) MaxArraySize))); MaxArraySize)));
if (addedafter > 1) if (addedafter > 1)
newhasnulls = true; /* will insert nulls */ newhasnulls = true; /* will insert nulls */
} }
@@ -2616,8 +2616,8 @@ array_set_element_expanded(Datum arraydatum,
pg_add_s32_overflow(dim[0], addedbefore, &dim[0])) pg_add_s32_overflow(dim[0], addedbefore, &dim[0]))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array size exceeds the maximum allowed (%d)", errmsg("array size exceeds the maximum allowed (%zu)",
(int) MaxArraySize))); MaxArraySize)));
lb[0] = indx[0]; lb[0] = indx[0];
dimschanged = true; dimschanged = true;
if (addedbefore > 1) if (addedbefore > 1)
@@ -2632,8 +2632,8 @@ array_set_element_expanded(Datum arraydatum,
pg_add_s32_overflow(dim[0], addedafter, &dim[0])) pg_add_s32_overflow(dim[0], addedafter, &dim[0]))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array size exceeds the maximum allowed (%d)", errmsg("array size exceeds the maximum allowed (%zu)",
(int) MaxArraySize))); MaxArraySize)));
dimschanged = true; dimschanged = true;
if (addedafter > 1) if (addedafter > 1)
newhasnulls = true; /* will insert nulls */ newhasnulls = true; /* will insert nulls */
@@ -2893,8 +2893,8 @@ array_set_slice(Datum arraydatum,
pg_add_s32_overflow(dim[i], 1, &dim[i])) pg_add_s32_overflow(dim[i], 1, &dim[i]))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array size exceeds the maximum allowed (%d)", errmsg("array size exceeds the maximum allowed (%zu)",
(int) MaxArraySize))); MaxArraySize)));
lb[i] = lowerIndx[i]; lb[i] = lowerIndx[i];
} }
@@ -2947,8 +2947,8 @@ array_set_slice(Datum arraydatum,
pg_add_s32_overflow(dim[0], addedbefore, &dim[0])) pg_add_s32_overflow(dim[0], addedbefore, &dim[0]))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array size exceeds the maximum allowed (%d)", errmsg("array size exceeds the maximum allowed (%zu)",
(int) MaxArraySize))); MaxArraySize)));
lb[0] = lowerIndx[0]; lb[0] = lowerIndx[0];
if (addedbefore > 1) if (addedbefore > 1)
newhasnulls = true; /* will insert nulls */ newhasnulls = true; /* will insert nulls */
@@ -2962,8 +2962,8 @@ array_set_slice(Datum arraydatum,
pg_add_s32_overflow(dim[0], addedafter, &dim[0])) pg_add_s32_overflow(dim[0], addedafter, &dim[0]))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array size exceeds the maximum allowed (%d)", errmsg("array size exceeds the maximum allowed (%zu)",
(int) MaxArraySize))); MaxArraySize)));
if (addedafter > 1) if (addedafter > 1)
newhasnulls = true; /* will insert nulls */ newhasnulls = true; /* will insert nulls */
} }
@@ -3303,8 +3303,8 @@ array_map(Datum arrayd,
if (!AllocSizeIsValid(nbytes)) if (!AllocSizeIsValid(nbytes))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array size exceeds the maximum allowed (%d)", errmsg("array size exceeds the maximum allowed (%zu)",
(int) MaxAllocSize))); MaxAllocSize)));
} }
} }
@@ -3543,8 +3543,8 @@ construct_md_array(Datum *elems,
if (!AllocSizeIsValid(nbytes)) if (!AllocSizeIsValid(nbytes))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array size exceeds the maximum allowed (%d)", errmsg("array size exceeds the maximum allowed (%zu)",
(int) MaxAllocSize))); MaxAllocSize)));
} }
/* Allocate and initialize result array */ /* Allocate and initialize result array */
@@ -5375,8 +5375,8 @@ accumArrayResult(ArrayBuildState *astate,
if (!AllocSizeIsValid(astate->alen * sizeof(Datum))) if (!AllocSizeIsValid(astate->alen * sizeof(Datum)))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array size exceeds the maximum allowed (%d)", errmsg("array size exceeds the maximum allowed (%zu)",
(int) MaxAllocSize))); MaxAllocSize)));
astate->dvalues = (Datum *) astate->dvalues = (Datum *)
repalloc(astate->dvalues, astate->alen * sizeof(Datum)); repalloc(astate->dvalues, astate->alen * sizeof(Datum));
astate->dnulls = (bool *) astate->dnulls = (bool *)
@@ -6214,8 +6214,8 @@ array_fill_internal(ArrayType *dims, ArrayType *lbs,
!AllocSizeIsValid(totbytes)) !AllocSizeIsValid(totbytes))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array size exceeds the maximum allowed (%d)", errmsg("array size exceeds the maximum allowed (%zu)",
(int) MaxAllocSize))); MaxAllocSize)));
/* /*
* This addition can't overflow, but it might cause us to go past * This addition can't overflow, but it might cause us to go past
@@ -6558,8 +6558,8 @@ array_replace_internal(ArrayType *array,
if (!AllocSizeIsValid(nbytes)) if (!AllocSizeIsValid(nbytes))
ereport(ERROR, ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED), (errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
errmsg("array size exceeds the maximum allowed (%d)", errmsg("array size exceeds the maximum allowed (%zu)",
(int) MaxAllocSize))); MaxAllocSize)));
} }
nresult++; nresult++;
} }

View File

@@ -158,8 +158,8 @@ bpchar_input(const char *s, size_t len, int32 atttypmod, Node *escontext)
if (s[j] != ' ') if (s[j] != ' ')
ereturn(escontext, NULL, ereturn(escontext, NULL,
(errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION), (errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION),
errmsg("value too long for type character(%d)", errmsg("value too long for type character(%zu)",
(int) maxlen))); maxlen)));
} }
/* /*
@@ -472,8 +472,8 @@ varchar_input(const char *s, size_t len, int32 atttypmod, Node *escontext)
if (s[j] != ' ') if (s[j] != ' ')
ereturn(escontext, NULL, ereturn(escontext, NULL,
(errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION), (errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION),
errmsg("value too long for type character varying(%d)", errmsg("value too long for type character varying(%zu)",
(int) maxlen))); maxlen)));
} }
len = mbmaxlen; len = mbmaxlen;

View File

@@ -1504,7 +1504,7 @@ InitializeGUCOptionsFromEnvironment(void)
new_limit = 2048; new_limit = 2048;
source = PGC_S_DYNAMIC_DEFAULT; source = PGC_S_DYNAMIC_DEFAULT;
} }
snprintf(limbuf, sizeof(limbuf), "%d", (int) new_limit); snprintf(limbuf, sizeof(limbuf), "%zd", new_limit);
SetConfigOption("max_stack_depth", limbuf, SetConfigOption("max_stack_depth", limbuf,
PGC_POSTMASTER, source); PGC_POSTMASTER, source);
} }

View File

@@ -259,8 +259,8 @@ flush_manifest(manifest_writer *mwriter)
if (wb < 0) if (wb < 0)
pg_fatal("could not write file \"%s\": %m", mwriter->pathname); pg_fatal("could not write file \"%s\": %m", mwriter->pathname);
else else
pg_fatal("could not write file \"%s\": wrote %d of %d", pg_fatal("could not write file \"%s\": wrote %zd of %d",
mwriter->pathname, (int) wb, mwriter->buf.len); mwriter->pathname, wb, mwriter->buf.len);
} }
if (mwriter->still_checksumming && if (mwriter->still_checksumming &&

View File

@@ -1346,8 +1346,8 @@ PrintTOCSummary(Archive *AHX)
ahprintf(AH, "; Dump Version: %d.%d-%d\n", ahprintf(AH, "; Dump Version: %d.%d-%d\n",
ARCHIVE_MAJOR(AH->version), ARCHIVE_MINOR(AH->version), ARCHIVE_REV(AH->version)); ARCHIVE_MAJOR(AH->version), ARCHIVE_MINOR(AH->version), ARCHIVE_REV(AH->version));
ahprintf(AH, "; Format: %s\n", fmtName); ahprintf(AH, "; Format: %s\n", fmtName);
ahprintf(AH, "; Integer: %d bytes\n", (int) AH->intSize); ahprintf(AH, "; Integer: %zu bytes\n", AH->intSize);
ahprintf(AH, "; Offset: %d bytes\n", (int) AH->offSize); ahprintf(AH, "; Offset: %zu bytes\n", AH->offSize);
if (AH->archiveRemoteVersion) if (AH->archiveRemoteVersion)
ahprintf(AH, "; Dumped from database version: %s\n", ahprintf(AH, "; Dumped from database version: %s\n",
AH->archiveRemoteVersion); AH->archiveRemoteVersion);
@@ -2307,8 +2307,7 @@ _discoverArchiveFormat(ArchiveHandle *AH)
if (ferror(fh)) if (ferror(fh))
pg_fatal("could not read input file: %m"); pg_fatal("could not read input file: %m");
else else
pg_fatal("input file is too short (read %lu, expected 5)", pg_fatal("input file is too short (read %zu, expected 5)", cnt);
(unsigned long) cnt);
} }
/* Save it, just in case we need it later */ /* Save it, just in case we need it later */
@@ -4185,8 +4184,7 @@ ReadHead(ArchiveHandle *AH)
AH->intSize = AH->ReadBytePtr(AH); AH->intSize = AH->ReadBytePtr(AH);
if (AH->intSize > 32) if (AH->intSize > 32)
pg_fatal("sanity check on integer size (%lu) failed", pg_fatal("sanity check on integer size (%zu) failed", AH->intSize);
(unsigned long) AH->intSize);
if (AH->intSize > sizeof(int)) if (AH->intSize > sizeof(int))
pg_log_warning("archive was made on a machine with larger integers, some operations might fail"); pg_log_warning("archive was made on a machine with larger integers, some operations might fail");

View File

@@ -459,7 +459,7 @@ process_queued_fetch_requests(libpq_source *src)
appendArrayEscapedString(&src->paths, rq->path); appendArrayEscapedString(&src->paths, rq->path);
appendStringInfo(&src->offsets, INT64_FORMAT, (int64) rq->offset); appendStringInfo(&src->offsets, INT64_FORMAT, (int64) rq->offset);
appendStringInfo(&src->lengths, INT64_FORMAT, (int64) rq->length); appendStringInfo(&src->lengths, "%zu", rq->length);
} }
appendStringInfoChar(&src->paths, '}'); appendStringInfoChar(&src->paths, '}');
appendStringInfoChar(&src->offsets, '}'); appendStringInfoChar(&src->offsets, '}');

View File

@@ -112,8 +112,8 @@ local_queue_fetch_file(rewind_source *source, const char *path, size_t len)
* check that the size of the file matches our earlier expectation. * check that the size of the file matches our earlier expectation.
*/ */
if (written_len != len) if (written_len != len)
pg_fatal("size of source file \"%s\" changed concurrently: %d bytes expected, %d copied", pg_fatal("size of source file \"%s\" changed concurrently: %zu bytes expected, %zu copied",
srcpath, (int) len, (int) written_len); srcpath, len, written_len);
if (close(srcfd) != 0) if (close(srcfd) != 0)
pg_fatal("could not close file \"%s\": %m", srcpath); pg_fatal("could not close file \"%s\": %m", srcpath);

View File

@@ -1035,8 +1035,8 @@ digestControlFile(ControlFileData *ControlFile, const char *content,
size_t size) size_t size)
{ {
if (size != PG_CONTROL_FILE_SIZE) if (size != PG_CONTROL_FILE_SIZE)
pg_fatal("unexpected control file size %d, expected %d", pg_fatal("unexpected control file size %zu, expected %d",
(int) size, PG_CONTROL_FILE_SIZE); size, PG_CONTROL_FILE_SIZE);
memcpy(ControlFile, content, sizeof(ControlFileData)); memcpy(ControlFile, content, sizeof(ControlFileData));

View File

@@ -3094,9 +3094,9 @@ keep_going: /* We will come back to here until there is
UNIXSOCK_PATH(portstr, thisport, ch->host); UNIXSOCK_PATH(portstr, thisport, ch->host);
if (strlen(portstr) >= UNIXSOCK_PATH_BUFLEN) if (strlen(portstr) >= UNIXSOCK_PATH_BUFLEN)
{ {
libpq_append_conn_error(conn, "Unix-domain socket path \"%s\" is too long (maximum %d bytes)", libpq_append_conn_error(conn, "Unix-domain socket path \"%s\" is too long (maximum %zu bytes)",
portstr, portstr,
(int) (UNIXSOCK_PATH_BUFLEN - 1)); (UNIXSOCK_PATH_BUFLEN - 1));
goto keep_going; goto keep_going;
} }

View File

@@ -236,8 +236,8 @@ pqGetInt(int *result, size_t bytes, PGconn *conn)
break; break;
default: default:
pqInternalNotice(&conn->noticeHooks, pqInternalNotice(&conn->noticeHooks,
"integer of size %lu not supported by pqGetInt", "integer of size %zu not supported by pqGetInt",
(unsigned long) bytes); bytes);
return EOF; return EOF;
} }
@@ -269,8 +269,8 @@ pqPutInt(int value, size_t bytes, PGconn *conn)
break; break;
default: default:
pqInternalNotice(&conn->noticeHooks, pqInternalNotice(&conn->noticeHooks,
"integer of size %lu not supported by pqPutInt", "integer of size %zu not supported by pqPutInt",
(unsigned long) bytes); bytes);
return EOF; return EOF;
} }