summaryrefslogtreecommitdiff
path: root/src/backend/utils
diff options
context:
space:
mode:
authorPeter Eisentraut <peter@eisentraut.org>2025-12-09 06:58:39 +0100
committerPeter Eisentraut <peter@eisentraut.org>2025-12-09 07:33:08 +0100
commit2b117bb014d066549c319dcd73bd538e32b0c408 (patch)
tree3241b0bd942cdcb6bbaac7b83dcb06aabb042e81 /src/backend/utils
parent0c3c5c3b06a37c13a811ea93044202e06523b705 (diff)
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
Diffstat (limited to 'src/backend/utils')
-rw-r--r--src/backend/utils/adt/array_expanded.c4
-rw-r--r--src/backend/utils/adt/arrayfuncs.c64
-rw-r--r--src/backend/utils/adt/varchar.c8
-rw-r--r--src/backend/utils/misc/guc.c2
4 files changed, 39 insertions, 39 deletions
diff --git a/src/backend/utils/adt/array_expanded.c b/src/backend/utils/adt/array_expanded.c
index fc036d1eb30..23627114f57 100644
--- a/src/backend/utils/adt/array_expanded.c
+++ b/src/backend/utils/adt/array_expanded.c
@@ -271,8 +271,8 @@ EA_get_flat_size(ExpandedObjectHeader *eohptr)
if (!AllocSizeIsValid(nbytes))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxAllocSize)));
+ errmsg("array size exceeds the maximum allowed (%zu)",
+ MaxAllocSize)));
}
if (dnulls)
diff --git a/src/backend/utils/adt/arrayfuncs.c b/src/backend/utils/adt/arrayfuncs.c
index cc76bdde723..24e5b2adea1 100644
--- a/src/backend/utils/adt/arrayfuncs.c
+++ b/src/backend/utils/adt/arrayfuncs.c
@@ -333,8 +333,8 @@ array_in(PG_FUNCTION_ARGS)
if (!AllocSizeIsValid(nbytes))
ereturn(escontext, (Datum) 0,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxAllocSize)));
+ errmsg("array size exceeds the maximum allowed (%zu)",
+ MaxAllocSize)));
}
}
if (hasnulls)
@@ -492,8 +492,8 @@ ReadArrayDimensions(char **srcptr, int *ndim_p, int *dim, int *lBound,
pg_add_s32_overflow(ub, 1, &ub))
ereturn(escontext, false,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxArraySize)));
+ errmsg("array size exceeds the maximum allowed (%zu)",
+ MaxArraySize)));
dim[ndim] = ub;
ndim++;
@@ -725,8 +725,8 @@ ReadArrayStr(char **srcptr,
if (maxitems >= MaxArraySize)
ereturn(escontext, false,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxArraySize)));
+ errmsg("array size exceeds the maximum allowed (%zu)",
+ MaxArraySize)));
maxitems = Min(maxitems * 2, MaxArraySize);
values = repalloc_array(values, Datum, maxitems);
nulls = repalloc_array(nulls, bool, maxitems);
@@ -1531,8 +1531,8 @@ ReadArrayBinary(StringInfo buf,
if (!AllocSizeIsValid(totbytes))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxAllocSize)));
+ errmsg("array size exceeds the maximum allowed (%zu)",
+ MaxAllocSize)));
}
}
*hasnulls = hasnull;
@@ -2339,8 +2339,8 @@ array_set_element(Datum arraydatum,
pg_add_s32_overflow(dim[0], addedbefore, &dim[0]))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxArraySize)));
+ errmsg("array size exceeds the maximum allowed (%zu)",
+ MaxArraySize)));
lb[0] = indx[0];
if (addedbefore > 1)
newhasnulls = true; /* will insert nulls */
@@ -2354,8 +2354,8 @@ array_set_element(Datum arraydatum,
pg_add_s32_overflow(dim[0], addedafter, &dim[0]))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxArraySize)));
+ errmsg("array size exceeds the maximum allowed (%zu)",
+ MaxArraySize)));
if (addedafter > 1)
newhasnulls = true; /* will insert nulls */
}
@@ -2616,8 +2616,8 @@ array_set_element_expanded(Datum arraydatum,
pg_add_s32_overflow(dim[0], addedbefore, &dim[0]))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxArraySize)));
+ errmsg("array size exceeds the maximum allowed (%zu)",
+ MaxArraySize)));
lb[0] = indx[0];
dimschanged = true;
if (addedbefore > 1)
@@ -2632,8 +2632,8 @@ array_set_element_expanded(Datum arraydatum,
pg_add_s32_overflow(dim[0], addedafter, &dim[0]))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxArraySize)));
+ errmsg("array size exceeds the maximum allowed (%zu)",
+ MaxArraySize)));
dimschanged = true;
if (addedafter > 1)
newhasnulls = true; /* will insert nulls */
@@ -2893,8 +2893,8 @@ array_set_slice(Datum arraydatum,
pg_add_s32_overflow(dim[i], 1, &dim[i]))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxArraySize)));
+ errmsg("array size exceeds the maximum allowed (%zu)",
+ MaxArraySize)));
lb[i] = lowerIndx[i];
}
@@ -2947,8 +2947,8 @@ array_set_slice(Datum arraydatum,
pg_add_s32_overflow(dim[0], addedbefore, &dim[0]))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxArraySize)));
+ errmsg("array size exceeds the maximum allowed (%zu)",
+ MaxArraySize)));
lb[0] = lowerIndx[0];
if (addedbefore > 1)
newhasnulls = true; /* will insert nulls */
@@ -2962,8 +2962,8 @@ array_set_slice(Datum arraydatum,
pg_add_s32_overflow(dim[0], addedafter, &dim[0]))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxArraySize)));
+ errmsg("array size exceeds the maximum allowed (%zu)",
+ MaxArraySize)));
if (addedafter > 1)
newhasnulls = true; /* will insert nulls */
}
@@ -3303,8 +3303,8 @@ array_map(Datum arrayd,
if (!AllocSizeIsValid(nbytes))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxAllocSize)));
+ errmsg("array size exceeds the maximum allowed (%zu)",
+ MaxAllocSize)));
}
}
@@ -3543,8 +3543,8 @@ construct_md_array(Datum *elems,
if (!AllocSizeIsValid(nbytes))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxAllocSize)));
+ errmsg("array size exceeds the maximum allowed (%zu)",
+ MaxAllocSize)));
}
/* Allocate and initialize result array */
@@ -5375,8 +5375,8 @@ accumArrayResult(ArrayBuildState *astate,
if (!AllocSizeIsValid(astate->alen * sizeof(Datum)))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxAllocSize)));
+ errmsg("array size exceeds the maximum allowed (%zu)",
+ MaxAllocSize)));
astate->dvalues = (Datum *)
repalloc(astate->dvalues, astate->alen * sizeof(Datum));
astate->dnulls = (bool *)
@@ -6214,8 +6214,8 @@ array_fill_internal(ArrayType *dims, ArrayType *lbs,
!AllocSizeIsValid(totbytes))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxAllocSize)));
+ errmsg("array size exceeds the maximum allowed (%zu)",
+ MaxAllocSize)));
/*
* 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))
ereport(ERROR,
(errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
- errmsg("array size exceeds the maximum allowed (%d)",
- (int) MaxAllocSize)));
+ errmsg("array size exceeds the maximum allowed (%zu)",
+ MaxAllocSize)));
}
nresult++;
}
diff --git a/src/backend/utils/adt/varchar.c b/src/backend/utils/adt/varchar.c
index 3f40c9da1a0..39fc27e1f11 100644
--- a/src/backend/utils/adt/varchar.c
+++ b/src/backend/utils/adt/varchar.c
@@ -158,8 +158,8 @@ bpchar_input(const char *s, size_t len, int32 atttypmod, Node *escontext)
if (s[j] != ' ')
ereturn(escontext, NULL,
(errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION),
- errmsg("value too long for type character(%d)",
- (int) maxlen)));
+ errmsg("value too long for type character(%zu)",
+ maxlen)));
}
/*
@@ -472,8 +472,8 @@ varchar_input(const char *s, size_t len, int32 atttypmod, Node *escontext)
if (s[j] != ' ')
ereturn(escontext, NULL,
(errcode(ERRCODE_STRING_DATA_RIGHT_TRUNCATION),
- errmsg("value too long for type character varying(%d)",
- (int) maxlen)));
+ errmsg("value too long for type character varying(%zu)",
+ maxlen)));
}
len = mbmaxlen;
diff --git a/src/backend/utils/misc/guc.c b/src/backend/utils/misc/guc.c
index c6484aea087..d495ff15945 100644
--- a/src/backend/utils/misc/guc.c
+++ b/src/backend/utils/misc/guc.c
@@ -1504,7 +1504,7 @@ InitializeGUCOptionsFromEnvironment(void)
new_limit = 2048;
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,
PGC_POSTMASTER, source);
}