mirror of
https://github.com/postgres/postgres.git
synced 2026-06-11 09:40:25 -04:00
Avoid casting void * function arguments
In many cases, the cast would silently drop a const qualifier. To fix, drop the unnecessary cast and let the compiler check the types and qualifiers. Add const to read-only local variables, preserving the const qualifiers from the function signatures. Co-authored-by: Bertrand Drouvot <bertranddrouvot.pg@gmail.com> Co-authored-by: Peter Eisentraut <peter@eisentraut.org> Discussion: https://postgr.es/m/aUQHy/MmWq7c97wK%40ip-10-97-1-34.eu-west-3.compute.internal
This commit is contained in:
parent
707f905399
commit
c3c240537f
16 changed files with 58 additions and 58 deletions
|
|
@ -857,8 +857,8 @@ brin_range_deserialize(int maxvalues, SerializedRanges *serialized)
|
||||||
static int
|
static int
|
||||||
compare_expanded_ranges(const void *a, const void *b, void *arg)
|
compare_expanded_ranges(const void *a, const void *b, void *arg)
|
||||||
{
|
{
|
||||||
ExpandedRange *ra = (ExpandedRange *) a;
|
const ExpandedRange *ra = a;
|
||||||
ExpandedRange *rb = (ExpandedRange *) b;
|
const ExpandedRange *rb = b;
|
||||||
Datum r;
|
Datum r;
|
||||||
|
|
||||||
compare_context *cxt = (compare_context *) arg;
|
compare_context *cxt = (compare_context *) arg;
|
||||||
|
|
@ -895,8 +895,8 @@ compare_expanded_ranges(const void *a, const void *b, void *arg)
|
||||||
static int
|
static int
|
||||||
compare_values(const void *a, const void *b, void *arg)
|
compare_values(const void *a, const void *b, void *arg)
|
||||||
{
|
{
|
||||||
Datum *da = (Datum *) a;
|
const Datum *da = a;
|
||||||
Datum *db = (Datum *) b;
|
const Datum *db = b;
|
||||||
Datum r;
|
Datum r;
|
||||||
|
|
||||||
compare_context *cxt = (compare_context *) arg;
|
compare_context *cxt = (compare_context *) arg;
|
||||||
|
|
@ -1304,8 +1304,8 @@ merge_overlapping_ranges(FmgrInfo *cmp, Oid colloid,
|
||||||
static int
|
static int
|
||||||
compare_distances(const void *a, const void *b)
|
compare_distances(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
DistanceValue *da = (DistanceValue *) a;
|
const DistanceValue *da = a;
|
||||||
DistanceValue *db = (DistanceValue *) b;
|
const DistanceValue *db = b;
|
||||||
|
|
||||||
if (da->value < db->value)
|
if (da->value < db->value)
|
||||||
return 1;
|
return 1;
|
||||||
|
|
|
||||||
|
|
@ -103,7 +103,7 @@ static HTAB *missing_cache = NULL;
|
||||||
static uint32
|
static uint32
|
||||||
missing_hash(const void *key, Size keysize)
|
missing_hash(const void *key, Size keysize)
|
||||||
{
|
{
|
||||||
const missing_cache_key *entry = (missing_cache_key *) key;
|
const missing_cache_key *entry = key;
|
||||||
|
|
||||||
return hash_bytes((const unsigned char *) DatumGetPointer(entry->value), entry->len);
|
return hash_bytes((const unsigned char *) DatumGetPointer(entry->value), entry->len);
|
||||||
}
|
}
|
||||||
|
|
@ -111,8 +111,8 @@ missing_hash(const void *key, Size keysize)
|
||||||
static int
|
static int
|
||||||
missing_match(const void *key1, const void *key2, Size keysize)
|
missing_match(const void *key1, const void *key2, Size keysize)
|
||||||
{
|
{
|
||||||
const missing_cache_key *entry1 = (missing_cache_key *) key1;
|
const missing_cache_key *entry1 = key1;
|
||||||
const missing_cache_key *entry2 = (missing_cache_key *) key2;
|
const missing_cache_key *entry2 = key2;
|
||||||
|
|
||||||
if (entry1->len != entry2->len)
|
if (entry1->len != entry2->len)
|
||||||
return entry1->len > entry2->len ? 1 : -1;
|
return entry1->len > entry2->len ? 1 : -1;
|
||||||
|
|
|
||||||
|
|
@ -2021,8 +2021,8 @@ heap_log_freeze_eq(xlhp_freeze_plan *plan, HeapTupleFreeze *frz)
|
||||||
static int
|
static int
|
||||||
heap_log_freeze_cmp(const void *arg1, const void *arg2)
|
heap_log_freeze_cmp(const void *arg1, const void *arg2)
|
||||||
{
|
{
|
||||||
HeapTupleFreeze *frz1 = (HeapTupleFreeze *) arg1;
|
const HeapTupleFreeze *frz1 = arg1;
|
||||||
HeapTupleFreeze *frz2 = (HeapTupleFreeze *) arg2;
|
const HeapTupleFreeze *frz2 = arg2;
|
||||||
|
|
||||||
if (frz1->xmax < frz2->xmax)
|
if (frz1->xmax < frz2->xmax)
|
||||||
return -1;
|
return -1;
|
||||||
|
|
|
||||||
|
|
@ -1462,8 +1462,8 @@ _bt_delitems_update(BTVacuumPosting *updatable, int nupdatable,
|
||||||
static int
|
static int
|
||||||
_bt_delitems_cmp(const void *a, const void *b)
|
_bt_delitems_cmp(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
TM_IndexDelete *indexdelete1 = (TM_IndexDelete *) a;
|
const TM_IndexDelete *indexdelete1 = a;
|
||||||
TM_IndexDelete *indexdelete2 = (TM_IndexDelete *) b;
|
const TM_IndexDelete *indexdelete2 = b;
|
||||||
|
|
||||||
Assert(indexdelete1->id != indexdelete2->id);
|
Assert(indexdelete1->id != indexdelete2->id);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1792,8 +1792,8 @@ _bt_unmark_keys(IndexScanDesc scan, int *keyDataMap)
|
||||||
static int
|
static int
|
||||||
_bt_reorder_array_cmp(const void *a, const void *b)
|
_bt_reorder_array_cmp(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
BTArrayKeyInfo *arraya = (BTArrayKeyInfo *) a;
|
const BTArrayKeyInfo *arraya = a;
|
||||||
BTArrayKeyInfo *arrayb = (BTArrayKeyInfo *) b;
|
const BTArrayKeyInfo *arrayb = b;
|
||||||
|
|
||||||
return pg_cmp_s32(arraya->scan_key, arrayb->scan_key);
|
return pg_cmp_s32(arraya->scan_key, arrayb->scan_key);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -594,8 +594,8 @@ _bt_deltasortsplits(FindSplitData *state, double fillfactormult,
|
||||||
static int
|
static int
|
||||||
_bt_splitcmp(const void *arg1, const void *arg2)
|
_bt_splitcmp(const void *arg1, const void *arg2)
|
||||||
{
|
{
|
||||||
SplitPoint *split1 = (SplitPoint *) arg1;
|
const SplitPoint *split1 = arg1;
|
||||||
SplitPoint *split2 = (SplitPoint *) arg2;
|
const SplitPoint *split2 = arg2;
|
||||||
|
|
||||||
return pg_cmp_s16(split1->curdelta, split2->curdelta);
|
return pg_cmp_s16(split1->curdelta, split2->curdelta);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -84,8 +84,8 @@ typedef struct SortedPoint
|
||||||
static int
|
static int
|
||||||
x_cmp(const void *a, const void *b)
|
x_cmp(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
SortedPoint *pa = (SortedPoint *) a;
|
const SortedPoint *pa = a;
|
||||||
SortedPoint *pb = (SortedPoint *) b;
|
const SortedPoint *pb = b;
|
||||||
|
|
||||||
if (pa->p->x == pb->p->x)
|
if (pa->p->x == pb->p->x)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -95,8 +95,8 @@ x_cmp(const void *a, const void *b)
|
||||||
static int
|
static int
|
||||||
y_cmp(const void *a, const void *b)
|
y_cmp(const void *a, const void *b)
|
||||||
{
|
{
|
||||||
SortedPoint *pa = (SortedPoint *) a;
|
const SortedPoint *pa = a;
|
||||||
SortedPoint *pb = (SortedPoint *) b;
|
const SortedPoint *pb = b;
|
||||||
|
|
||||||
if (pa->p->y == pb->p->y)
|
if (pa->p->y == pb->p->y)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
|
||||||
|
|
@ -862,8 +862,8 @@ int
|
||||||
multi_sort_compare(const void *a, const void *b, void *arg)
|
multi_sort_compare(const void *a, const void *b, void *arg)
|
||||||
{
|
{
|
||||||
MultiSortSupport mss = (MultiSortSupport) arg;
|
MultiSortSupport mss = (MultiSortSupport) arg;
|
||||||
SortItem *ia = (SortItem *) a;
|
const SortItem *ia = a;
|
||||||
SortItem *ib = (SortItem *) b;
|
const SortItem *ib = b;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < mss->ndims; i++)
|
for (i = 0; i < mss->ndims; i++)
|
||||||
|
|
|
||||||
|
|
@ -402,8 +402,8 @@ count_distinct_groups(int numrows, SortItem *items, MultiSortSupport mss)
|
||||||
static int
|
static int
|
||||||
compare_sort_item_count(const void *a, const void *b, void *arg)
|
compare_sort_item_count(const void *a, const void *b, void *arg)
|
||||||
{
|
{
|
||||||
SortItem *ia = (SortItem *) a;
|
const SortItem *ia = a;
|
||||||
SortItem *ib = (SortItem *) b;
|
const SortItem *ib = b;
|
||||||
|
|
||||||
if (ia->count == ib->count)
|
if (ia->count == ib->count)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
@ -465,8 +465,8 @@ static int
|
||||||
sort_item_compare(const void *a, const void *b, void *arg)
|
sort_item_compare(const void *a, const void *b, void *arg)
|
||||||
{
|
{
|
||||||
SortSupport ssup = (SortSupport) arg;
|
SortSupport ssup = (SortSupport) arg;
|
||||||
SortItem *ia = (SortItem *) a;
|
const SortItem *ia = a;
|
||||||
SortItem *ib = (SortItem *) b;
|
const SortItem *ib = b;
|
||||||
|
|
||||||
return ApplySortComparator(ia->values[0], ia->isnull[0],
|
return ApplySortComparator(ia->values[0], ia->isnull[0],
|
||||||
ib->values[0], ib->isnull[0],
|
ib->values[0], ib->isnull[0],
|
||||||
|
|
|
||||||
|
|
@ -210,8 +210,8 @@ cmpspellaffix(const void *s1, const void *s2)
|
||||||
static int
|
static int
|
||||||
cmpcmdflag(const void *f1, const void *f2)
|
cmpcmdflag(const void *f1, const void *f2)
|
||||||
{
|
{
|
||||||
CompoundAffixFlag *fv1 = (CompoundAffixFlag *) f1,
|
const CompoundAffixFlag *fv1 = f1;
|
||||||
*fv2 = (CompoundAffixFlag *) f2;
|
const CompoundAffixFlag *fv2 = f2;
|
||||||
|
|
||||||
Assert(fv1->flagMode == fv2->flagMode);
|
Assert(fv1->flagMode == fv2->flagMode);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1729,9 +1729,9 @@ get_gist_range_class(RangeType *range)
|
||||||
static int
|
static int
|
||||||
single_bound_cmp(const void *a, const void *b, void *arg)
|
single_bound_cmp(const void *a, const void *b, void *arg)
|
||||||
{
|
{
|
||||||
SingleBoundSortItem *i1 = (SingleBoundSortItem *) a;
|
const SingleBoundSortItem *i1 = a;
|
||||||
SingleBoundSortItem *i2 = (SingleBoundSortItem *) b;
|
const SingleBoundSortItem *i2 = b;
|
||||||
TypeCacheEntry *typcache = (TypeCacheEntry *) arg;
|
TypeCacheEntry *typcache = arg;
|
||||||
|
|
||||||
return range_cmp_bounds(typcache, &i1->bound, &i2->bound);
|
return range_cmp_bounds(typcache, &i1->bound, &i2->bound);
|
||||||
}
|
}
|
||||||
|
|
@ -1742,9 +1742,9 @@ single_bound_cmp(const void *a, const void *b, void *arg)
|
||||||
static int
|
static int
|
||||||
interval_cmp_lower(const void *a, const void *b, void *arg)
|
interval_cmp_lower(const void *a, const void *b, void *arg)
|
||||||
{
|
{
|
||||||
NonEmptyRange *i1 = (NonEmptyRange *) a;
|
const NonEmptyRange *i1 = a;
|
||||||
NonEmptyRange *i2 = (NonEmptyRange *) b;
|
const NonEmptyRange *i2 = b;
|
||||||
TypeCacheEntry *typcache = (TypeCacheEntry *) arg;
|
TypeCacheEntry *typcache = arg;
|
||||||
|
|
||||||
return range_cmp_bounds(typcache, &i1->lower, &i2->lower);
|
return range_cmp_bounds(typcache, &i1->lower, &i2->lower);
|
||||||
}
|
}
|
||||||
|
|
@ -1755,9 +1755,9 @@ interval_cmp_lower(const void *a, const void *b, void *arg)
|
||||||
static int
|
static int
|
||||||
interval_cmp_upper(const void *a, const void *b, void *arg)
|
interval_cmp_upper(const void *a, const void *b, void *arg)
|
||||||
{
|
{
|
||||||
NonEmptyRange *i1 = (NonEmptyRange *) a;
|
const NonEmptyRange *i1 = a;
|
||||||
NonEmptyRange *i2 = (NonEmptyRange *) b;
|
const NonEmptyRange *i2 = b;
|
||||||
TypeCacheEntry *typcache = (TypeCacheEntry *) arg;
|
TypeCacheEntry *typcache = arg;
|
||||||
|
|
||||||
return range_cmp_bounds(typcache, &i1->upper, &i2->upper);
|
return range_cmp_bounds(typcache, &i1->upper, &i2->upper);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -185,9 +185,9 @@ spg_range_quad_choose(PG_FUNCTION_ARGS)
|
||||||
static int
|
static int
|
||||||
bound_cmp(const void *a, const void *b, void *arg)
|
bound_cmp(const void *a, const void *b, void *arg)
|
||||||
{
|
{
|
||||||
RangeBound *ba = (RangeBound *) a;
|
const RangeBound *ba = a;
|
||||||
RangeBound *bb = (RangeBound *) b;
|
const RangeBound *bb = b;
|
||||||
TypeCacheEntry *typcache = (TypeCacheEntry *) arg;
|
TypeCacheEntry *typcache = arg;
|
||||||
|
|
||||||
return range_cmp_bounds(typcache, ba, bb);
|
return range_cmp_bounds(typcache, ba, bb);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -111,9 +111,9 @@ float8_qsort_cmp(const void *a1, const void *a2, void *arg)
|
||||||
static int
|
static int
|
||||||
range_bound_qsort_cmp(const void *a1, const void *a2, void *arg)
|
range_bound_qsort_cmp(const void *a1, const void *a2, void *arg)
|
||||||
{
|
{
|
||||||
RangeBound *b1 = (RangeBound *) a1;
|
const RangeBound *b1 = a1;
|
||||||
RangeBound *b2 = (RangeBound *) a2;
|
const RangeBound *b2 = a2;
|
||||||
TypeCacheEntry *typcache = (TypeCacheEntry *) arg;
|
TypeCacheEntry *typcache = arg;
|
||||||
|
|
||||||
return range_cmp_bounds(typcache, b1, b2);
|
return range_cmp_bounds(typcache, b1, b2);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
14
src/backend/utils/cache/typcache.c
vendored
14
src/backend/utils/cache/typcache.c
vendored
|
|
@ -235,8 +235,8 @@ shared_record_table_compare(const void *a, const void *b, size_t size,
|
||||||
void *arg)
|
void *arg)
|
||||||
{
|
{
|
||||||
dsa_area *area = (dsa_area *) arg;
|
dsa_area *area = (dsa_area *) arg;
|
||||||
SharedRecordTableKey *k1 = (SharedRecordTableKey *) a;
|
const SharedRecordTableKey *k1 = a;
|
||||||
SharedRecordTableKey *k2 = (SharedRecordTableKey *) b;
|
const SharedRecordTableKey *k2 = b;
|
||||||
TupleDesc t1;
|
TupleDesc t1;
|
||||||
TupleDesc t2;
|
TupleDesc t2;
|
||||||
|
|
||||||
|
|
@ -259,8 +259,8 @@ shared_record_table_compare(const void *a, const void *b, size_t size,
|
||||||
static uint32
|
static uint32
|
||||||
shared_record_table_hash(const void *a, size_t size, void *arg)
|
shared_record_table_hash(const void *a, size_t size, void *arg)
|
||||||
{
|
{
|
||||||
dsa_area *area = (dsa_area *) arg;
|
dsa_area *area = arg;
|
||||||
SharedRecordTableKey *k = (SharedRecordTableKey *) a;
|
const SharedRecordTableKey *k = a;
|
||||||
TupleDesc t;
|
TupleDesc t;
|
||||||
|
|
||||||
if (k->shared)
|
if (k->shared)
|
||||||
|
|
@ -2013,7 +2013,7 @@ lookup_rowtype_tupdesc_domain(Oid type_id, int32 typmod, bool noError)
|
||||||
static uint32
|
static uint32
|
||||||
record_type_typmod_hash(const void *data, size_t size)
|
record_type_typmod_hash(const void *data, size_t size)
|
||||||
{
|
{
|
||||||
RecordCacheEntry *entry = (RecordCacheEntry *) data;
|
const RecordCacheEntry *entry = data;
|
||||||
|
|
||||||
return hashRowType(entry->tupdesc);
|
return hashRowType(entry->tupdesc);
|
||||||
}
|
}
|
||||||
|
|
@ -2024,8 +2024,8 @@ record_type_typmod_hash(const void *data, size_t size)
|
||||||
static int
|
static int
|
||||||
record_type_typmod_compare(const void *a, const void *b, size_t size)
|
record_type_typmod_compare(const void *a, const void *b, size_t size)
|
||||||
{
|
{
|
||||||
RecordCacheEntry *left = (RecordCacheEntry *) a;
|
const RecordCacheEntry *left = a;
|
||||||
RecordCacheEntry *right = (RecordCacheEntry *) b;
|
const RecordCacheEntry *right = b;
|
||||||
|
|
||||||
return equalRowTypes(left->tupdesc, right->tupdesc) ? 0 : 1;
|
return equalRowTypes(left->tupdesc, right->tupdesc) ? 0 : 1;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -11102,7 +11102,7 @@ fetchAttributeStats(Archive *fout)
|
||||||
static char *
|
static char *
|
||||||
dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
|
dumpRelationStats_dumper(Archive *fout, const void *userArg, const TocEntry *te)
|
||||||
{
|
{
|
||||||
const RelStatsInfo *rsinfo = (RelStatsInfo *) userArg;
|
const RelStatsInfo *rsinfo = userArg;
|
||||||
static PGresult *res;
|
static PGresult *res;
|
||||||
static int rownum;
|
static int rownum;
|
||||||
PQExpBuffer query;
|
PQExpBuffer query;
|
||||||
|
|
|
||||||
|
|
@ -189,7 +189,7 @@ injection_init_shmem(void)
|
||||||
* otherwise.
|
* otherwise.
|
||||||
*/
|
*/
|
||||||
static bool
|
static bool
|
||||||
injection_point_allowed(InjectionPointCondition *condition)
|
injection_point_allowed(const InjectionPointCondition *condition)
|
||||||
{
|
{
|
||||||
bool result = true;
|
bool result = true;
|
||||||
|
|
||||||
|
|
@ -232,8 +232,8 @@ injection_points_cleanup(int code, Datum arg)
|
||||||
void
|
void
|
||||||
injection_error(const char *name, const void *private_data, void *arg)
|
injection_error(const char *name, const void *private_data, void *arg)
|
||||||
{
|
{
|
||||||
InjectionPointCondition *condition = (InjectionPointCondition *) private_data;
|
const InjectionPointCondition *condition = private_data;
|
||||||
char *argstr = (char *) arg;
|
char *argstr = arg;
|
||||||
|
|
||||||
if (!injection_point_allowed(condition))
|
if (!injection_point_allowed(condition))
|
||||||
return;
|
return;
|
||||||
|
|
@ -248,8 +248,8 @@ injection_error(const char *name, const void *private_data, void *arg)
|
||||||
void
|
void
|
||||||
injection_notice(const char *name, const void *private_data, void *arg)
|
injection_notice(const char *name, const void *private_data, void *arg)
|
||||||
{
|
{
|
||||||
InjectionPointCondition *condition = (InjectionPointCondition *) private_data;
|
const InjectionPointCondition *condition = private_data;
|
||||||
char *argstr = (char *) arg;
|
char *argstr = arg;
|
||||||
|
|
||||||
if (!injection_point_allowed(condition))
|
if (!injection_point_allowed(condition))
|
||||||
return;
|
return;
|
||||||
|
|
@ -268,7 +268,7 @@ injection_wait(const char *name, const void *private_data, void *arg)
|
||||||
uint32 old_wait_counts = 0;
|
uint32 old_wait_counts = 0;
|
||||||
int index = -1;
|
int index = -1;
|
||||||
uint32 injection_wait_event = 0;
|
uint32 injection_wait_event = 0;
|
||||||
InjectionPointCondition *condition = (InjectionPointCondition *) private_data;
|
const InjectionPointCondition *condition = private_data;
|
||||||
|
|
||||||
if (inj_state == NULL)
|
if (inj_state == NULL)
|
||||||
injection_init_shmem();
|
injection_init_shmem();
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue