Remove useless casts to (void *) in arguments of some system functions

The affected functions are: bsearch, memcmp, memcpy, memset, memmove,
qsort, repalloc

Reviewed-by: Corey Huinker <corey.huinker@gmail.com>
Discussion: https://www.postgresql.org/message-id/flat/fd9adf5d-b1aa-e82f-e4c7-263c30145807%40enterprisedb.com
This commit is contained in:
Peter Eisentraut 2023-02-07 06:53:05 +01:00
parent d9d7fe68d3
commit aa69541046
52 changed files with 116 additions and 119 deletions

View File

@ -84,7 +84,7 @@ gbt_bit_xfrm(bytea *leaf)
while (sz < padded_sz)
((char *) out)[sz++] = 0;
SET_VARSIZE(out, padded_sz);
memcpy((void *) VARDATA(out), (void *) VARBITS(leaf), VARBITBYTES(leaf));
memcpy(VARDATA(out), VARBITS(leaf), VARBITBYTES(leaf));
return out;
}

View File

@ -157,8 +157,8 @@ gbt_intv_compress(PG_FUNCTION_ARGS)
{
Interval *key = DatumGetIntervalP(entry->key);
memcpy((void *) r, (void *) key, INTERVALSIZE);
memcpy((void *) (r + INTERVALSIZE), (void *) key, INTERVALSIZE);
memcpy(r, key, INTERVALSIZE);
memcpy(r + INTERVALSIZE, key, INTERVALSIZE);
}
else
{

View File

@ -87,8 +87,8 @@ gbt_num_compress(GISTENTRY *entry, const gbtree_ninfo *tinfo)
Assert(tinfo->indexsize >= 2 * tinfo->size);
memcpy((void *) &r[0], leaf, tinfo->size);
memcpy((void *) &r[tinfo->size], leaf, tinfo->size);
memcpy(&r[0], leaf, tinfo->size);
memcpy(&r[tinfo->size], leaf, tinfo->size);
retval = palloc(sizeof(GISTENTRY));
gistentryinit(*retval, PointerGetDatum(r), entry->rel, entry->page,
entry->offset, false);
@ -184,7 +184,7 @@ gbt_num_union(GBT_NUMKEY *out, const GistEntryVector *entryvec, const gbtree_nin
o.lower = &((GBT_NUMKEY *) out)[0];
o.upper = &((GBT_NUMKEY *) out)[tinfo->size];
memcpy((void *) out, (void *) cur, 2 * tinfo->size);
memcpy(out, cur, 2 * tinfo->size);
for (i = 1; i < numranges; i++)
{
@ -360,7 +360,7 @@ gbt_num_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v,
arr[i].t = (GBT_NUMKEY *) DatumGetPointer((entryvec->vector[i].key));
arr[i].i = i;
}
qsort_arg((void *) &arr[FirstOffsetNumber], maxoff - FirstOffsetNumber + 1, sizeof(Nsrt), (qsort_arg_comparator) tinfo->f_cmp, (void *) flinfo);
qsort_arg(&arr[FirstOffsetNumber], maxoff - FirstOffsetNumber + 1, sizeof(Nsrt), (qsort_arg_comparator) tinfo->f_cmp, flinfo);
/* We do simply create two parts */

View File

@ -502,11 +502,11 @@ gbt_var_picksplit(const GistEntryVector *entryvec, GIST_SPLITVEC *v,
varg.tinfo = tinfo;
varg.collation = collation;
varg.flinfo = flinfo;
qsort_arg((void *) &arr[FirstOffsetNumber],
qsort_arg(&arr[FirstOffsetNumber],
maxoff - FirstOffsetNumber + 1,
sizeof(Vsrt),
gbt_vsrt_cmp,
(void *) &varg);
&varg);
/* We do simply create two parts */

View File

@ -110,8 +110,8 @@ gbt_uuid_compress(PG_FUNCTION_ARGS)
retval = palloc(sizeof(GISTENTRY));
memcpy((void *) r, (void *) key, UUID_LEN);
memcpy((void *) (r + UUID_LEN), (void *) key, UUID_LEN);
memcpy(r, key, UUID_LEN);
memcpy(r + UUID_LEN, key, UUID_LEN);
gistentryinit(*retval, PointerGetDatum(r),
entry->rel, entry->page,
entry->offset, false);

View File

@ -80,7 +80,7 @@ internal_citext_pattern_cmp(text *left, text *right, Oid collid)
llen = strlen(lcstr);
rlen = strlen(rcstr);
result = memcmp((void *) lcstr, (void *) rcstr, Min(llen, rlen));
result = memcmp(lcstr, rcstr, Min(llen, rlen));
if (result == 0)
{
if (llen < rlen)

View File

@ -436,7 +436,7 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
size_beta = hemdist(datum_r, _j, siglen);
costvector[j - 1].cost = abs(size_alpha - size_beta);
}
qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
qsort(costvector, maxoff, sizeof(SPLITCOST), comparecost);
union_l = GETSIGN(datum_l);
union_r = GETSIGN(datum_r);
@ -465,7 +465,7 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_l) || ISALLTRUE(_j))
{
if (!ISALLTRUE(datum_l))
memset((void *) union_l, 0xff, siglen);
memset(union_l, 0xff, siglen);
}
else
{
@ -481,7 +481,7 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_r) || ISALLTRUE(_j))
{
if (!ISALLTRUE(datum_r))
memset((void *) union_r, 0xff, siglen);
memset(union_r, 0xff, siglen);
}
else
{

View File

@ -365,7 +365,7 @@ hstoreUniquePairs(Pairs *a, int32 l, int32 *buflen)
return l;
}
qsort((void *) a, l, sizeof(Pairs), comparePairs);
qsort(a, l, sizeof(Pairs), comparePairs);
/*
* We can't use qunique here because we have some clean-up code to run on

View File

@ -243,7 +243,7 @@ g_int_compress(PG_FUNCTION_ARGS)
/*
* shunt everything down to start at the right place
*/
memmove((void *) &dr[0], (void *) &dr[2 * j], 2 * (len - j) * sizeof(int32));
memmove(&dr[0], &dr[2 * j], 2 * (len - j) * sizeof(int32));
}
/*
@ -260,7 +260,7 @@ g_int_compress(PG_FUNCTION_ARGS)
min = ((int64) dr[i] - (int64) dr[i - 1]);
cand = i;
}
memmove((void *) &dr[cand - 1], (void *) &dr[cand + 1], (len - cand - 1) * sizeof(int32));
memmove(&dr[cand - 1], &dr[cand + 1], (len - cand - 1) * sizeof(int32));
len -= 2;
}
@ -542,7 +542,7 @@ g_int_picksplit(PG_FUNCTION_ARGS)
pfree(union_d);
costvector[i - 1].cost = fabsf((size_alpha - size_l) - (size_beta - size_r));
}
qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
qsort(costvector, maxoff, sizeof(SPLITCOST), comparecost);
/*
* Now split up the regions between the two seeds. An important property

View File

@ -212,7 +212,7 @@ isort(int32 *a, int len)
{
bool r = false;
qsort_arg(a, len, sizeof(int32), isort_cmp, (void *) &r);
qsort_arg(a, len, sizeof(int32), isort_cmp, &r);
return r;
}

View File

@ -395,7 +395,7 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
size_beta = hemdist(datum_r, _j, siglen);
costvector[j - 1].cost = abs(size_alpha - size_beta);
}
qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
qsort(costvector, maxoff, sizeof(SPLITCOST), comparecost);
union_l = GETSIGN(datum_l);
union_r = GETSIGN(datum_r);
@ -424,7 +424,7 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_l) || ISALLTRUE(_j))
{
if (!ISALLTRUE(datum_l))
memset((void *) union_l, 0xff, siglen);
memset(union_l, 0xff, siglen);
}
else
{
@ -440,7 +440,7 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_r) || ISALLTRUE(_j))
{
if (!ISALLTRUE(datum_r))
memset((void *) union_r, 0xff, siglen);
memset(union_r, 0xff, siglen);
}
else
{

View File

@ -319,7 +319,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
size_beta = hemdist(datum_r, _j, siglen);
costvector[j - 1].cost = abs(size_alpha - size_beta);
}
qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
qsort(costvector, maxoff, sizeof(SPLITCOST), comparecost);
union_l = LTG_SIGN(datum_l);
union_r = LTG_SIGN(datum_r);
@ -348,7 +348,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
if (LTG_ISALLTRUE(datum_l) || LTG_ISALLTRUE(_j))
{
if (!LTG_ISALLTRUE(datum_l))
memset((void *) union_l, 0xff, siglen);
memset(union_l, 0xff, siglen);
}
else
{
@ -364,7 +364,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
if (LTG_ISALLTRUE(datum_r) || LTG_ISALLTRUE(_j))
{
if (!LTG_ISALLTRUE(datum_r))
memset((void *) union_r, 0xff, siglen);
memset(union_r, 0xff, siglen);
}
else
{

View File

@ -328,7 +328,7 @@ ltree_picksplit(PG_FUNCTION_ARGS)
array[j].r = LTG_GETLNODE(lu, siglen);
}
qsort((void *) &array[FirstOffsetNumber], maxoff - FirstOffsetNumber + 1,
qsort(&array[FirstOffsetNumber], maxoff - FirstOffsetNumber + 1,
sizeof(RIX), treekey_cmp);
lu_l = lu_r = ru_l = ru_r = NULL;

View File

@ -195,10 +195,10 @@ pushval_asis(QPRS_STATE *state, int type, char *strval, int lenval, uint16 flag)
int32 tmp = state->curop - state->op;
state->lenop *= 2;
state->op = (char *) repalloc((void *) state->op, state->lenop);
state->op = (char *) repalloc(state->op, state->lenop);
state->curop = state->op + tmp;
}
memcpy((void *) state->curop, (void *) strval, lenval);
memcpy(state->curop, strval, lenval);
state->curop += lenval;
*(state->curop) = '\0';
state->curop++;
@ -391,7 +391,7 @@ queryin(char *buf, struct Node *escontext)
}
/* set user-friendly operand view */
memcpy((void *) GETOPERAND(query), (void *) state.op, state.sumlen);
memcpy(GETOPERAND(query), state.op, state.sumlen);
pfree(state.op);
/* set left operand's position for every operator */

View File

@ -131,7 +131,7 @@ heap_force_common(FunctionCallInfo fcinfo, HeapTupleForceOption heap_force_opt)
* array.
*/
if (ntids > 1)
qsort((void *) tids, ntids, sizeof(ItemPointerData), tidcmp);
qsort(tids, ntids, sizeof(ItemPointerData), tidcmp);
curr_start_ptr = next_start_ptr = 0;
nblocks = RelationGetNumberOfBlocks(rel);

View File

@ -102,7 +102,7 @@ makesign(BITVECP sign, TRGM *a, int siglen)
trgm *ptr = GETARR(a);
int32 tmp = 0;
MemSet((void *) sign, 0, siglen);
MemSet(sign, 0, siglen);
SETBIT(sign, SIGLENBIT(siglen)); /* set last unused bit */
for (k = 0; k < len; k++)
{
@ -755,7 +755,7 @@ fillcache(CACHESIGN *item, TRGM *key, BITVECP sign, int siglen)
else if (ISALLTRUE(key))
item->allistrue = true;
else
memcpy((void *) item->sign, (void *) GETSIGN(key), siglen);
memcpy(item->sign, GETSIGN(key), siglen);
}
#define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
@ -872,7 +872,7 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
size_beta = hemdistcache(&(cache[seed_2]), &(cache[j]), siglen);
costvector[j - 1].cost = abs(size_alpha - size_beta);
}
qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
qsort(costvector, maxoff, sizeof(SPLITCOST), comparecost);
for (k = 0; k < maxoff; k++)
{
@ -921,7 +921,7 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_l) || cache[j].allistrue)
{
if (!ISALLTRUE(datum_l))
memset((void *) GETSIGN(datum_l), 0xff, siglen);
memset(GETSIGN(datum_l), 0xff, siglen);
}
else
{
@ -937,7 +937,7 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_r) || cache[j].allistrue)
{
if (!ISALLTRUE(datum_r))
memset((void *) GETSIGN(datum_r), 0xff, siglen);
memset(GETSIGN(datum_r), 0xff, siglen);
}
else
{

View File

@ -376,7 +376,7 @@ generate_trgm(char *str, int slen)
*/
if (len > 1)
{
qsort((void *) GETARR(trg), len, sizeof(trgm), comp_trgm);
qsort(GETARR(trg), len, sizeof(trgm), comp_trgm);
len = qunique(GETARR(trg), len, sizeof(trgm), comp_trgm);
}
@ -929,7 +929,7 @@ generate_wildcard_trgm(const char *str, int slen)
*/
if (len > 1)
{
qsort((void *) GETARR(trg), len, sizeof(trgm), comp_trgm);
qsort(GETARR(trg), len, sizeof(trgm), comp_trgm);
len = qunique(GETARR(trg), len, sizeof(trgm), comp_trgm);
}

View File

@ -2456,8 +2456,8 @@ copytext(PG_FUNCTION_ARGS)
* VARDATA is a pointer to the data region of the new struct. The source
* could be a short datum, so retrieve its data through VARDATA_ANY.
*/
memcpy((void *) VARDATA(new_t), /* destination */
(void *) VARDATA_ANY(t), /* source */
memcpy(VARDATA(new_t), /* destination */
VARDATA_ANY(t), /* source */
VARSIZE_ANY_EXHDR(t)); /* how many bytes */
PG_RETURN_TEXT_P(new_t);
}

View File

@ -543,7 +543,7 @@ range_deduplicate_values(Ranges *range)
*/
qsort_arg(&range->values[start],
range->nvalues, sizeof(Datum),
compare_values, (void *) &cxt);
compare_values, &cxt);
n = 1;
for (i = 1; i < range->nvalues; i++)
@ -1197,7 +1197,7 @@ sort_expanded_ranges(FmgrInfo *cmp, Oid colloid,
* some of the points) and do merge sort.
*/
qsort_arg(eranges, neranges, sizeof(ExpandedRange),
compare_expanded_ranges, (void *) &cxt);
compare_expanded_ranges, &cxt);
/*
* Deduplicate the ranges - simply compare each range to the preceding
@ -1535,7 +1535,7 @@ reduce_expanded_ranges(ExpandedRange *eranges, int neranges,
* sorted result.
*/
qsort_arg(values, nvalues, sizeof(Datum),
compare_values, (void *) &cxt);
compare_values, &cxt);
/* We have nvalues boundary values, which means nvalues/2 ranges. */
for (i = 0; i < (nvalues / 2); i++)

View File

@ -560,7 +560,7 @@ ginExtractEntries(GinState *ginstate, OffsetNumber attnum,
arg.collation = ginstate->supportCollation[attnum - 1];
arg.haveDups = false;
qsort_arg(keydata, *nentries, sizeof(keyEntryData),
cmpEntries, (void *) &arg);
cmpEntries, &arg);
if (arg.haveDups)
{

View File

@ -173,7 +173,7 @@ gist_box_union(PG_FUNCTION_ARGS)
numranges = entryvec->n;
pageunion = (BOX *) palloc(sizeof(BOX));
cur = DatumGetBoxP(entryvec->vector[0].key);
memcpy((void *) pageunion, (void *) cur, sizeof(BOX));
memcpy(pageunion, cur, sizeof(BOX));
for (i = 1; i < numranges; i++)
{
@ -1043,7 +1043,7 @@ gist_poly_compress(PG_FUNCTION_ARGS)
BOX *r;
r = (BOX *) palloc(sizeof(BOX));
memcpy((void *) r, (void *) &(in->boundbox), sizeof(BOX));
memcpy(r, &(in->boundbox), sizeof(BOX));
retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
gistentryinit(*retval, PointerGetDatum(r),

View File

@ -113,7 +113,7 @@ gistextractpage(Page page, int *len /* out */ )
IndexTuple *
gistjoinvector(IndexTuple *itvec, int *len, IndexTuple *additvec, int addlen)
{
itvec = (IndexTuple *) repalloc((void *) itvec, sizeof(IndexTuple) * ((*len) + addlen));
itvec = (IndexTuple *) repalloc(itvec, sizeof(IndexTuple) * ((*len) + addlen));
memmove(&itvec[*len], additvec, sizeof(IndexTuple) * addlen);
*len += addlen;
return itvec;

View File

@ -488,8 +488,8 @@ _bt_sort_array_elements(IndexScanDesc scan, ScanKey skey,
fmgr_info(cmp_proc, &cxt.flinfo);
cxt.collation = skey->sk_collation;
cxt.reverse = reverse;
qsort_arg((void *) elems, nelems, sizeof(Datum),
_bt_compare_array_elements, (void *) &cxt);
qsort_arg(elems, nelems, sizeof(Datum),
_bt_compare_array_elements, &cxt);
/* Now scan the sorted elements and remove duplicates */
return qunique_arg(elems, nelems, sizeof(Datum),

View File

@ -967,7 +967,7 @@ findDependentObjects(const ObjectAddress *object,
* first within ObjectAddressAndFlags.
*/
if (numDependentObjects > 1)
qsort((void *) dependentObjects, numDependentObjects,
qsort(dependentObjects, numDependentObjects,
sizeof(ObjectAddressAndFlags),
object_address_comparator);
@ -2442,7 +2442,7 @@ eliminate_duplicate_dependencies(ObjectAddresses *addrs)
return; /* nothing to do */
/* Sort the refs so that duplicates are adjacent */
qsort((void *) addrs->refs, addrs->numrefs, sizeof(ObjectAddress),
qsort(addrs->refs, addrs->numrefs, sizeof(ObjectAddress),
object_address_comparator);
/* Remove dups */
@ -2809,7 +2809,7 @@ void
sort_object_addresses(ObjectAddresses *addrs)
{
if (addrs->numrefs > 1)
qsort((void *) addrs->refs, addrs->numrefs,
qsort(addrs->refs, addrs->numrefs,
sizeof(ObjectAddress),
object_address_comparator);
}

View File

@ -762,7 +762,7 @@ checkSharedDependencies(Oid classId, Oid objectId,
* Sort and report local and shared objects.
*/
if (numobjects > 1)
qsort((void *) objects, numobjects,
qsort(objects, numobjects,
sizeof(ShDependObjectInfo), shared_dependency_comparator);
for (int i = 0; i < numobjects; i++)

View File

@ -1304,7 +1304,7 @@ acquire_sample_rows(Relation onerel, int elevel,
* tuples are already sorted.
*/
if (numrows == targrows)
qsort_interruptible((void *) rows, numrows, sizeof(HeapTuple),
qsort_interruptible(rows, numrows, sizeof(HeapTuple),
compare_rows, NULL);
/*
@ -2479,8 +2479,8 @@ compute_scalar_stats(VacAttrStatsP stats,
/* Sort the collected values */
cxt.ssup = &ssup;
cxt.tupnoLink = tupnoLink;
qsort_interruptible((void *) values, values_cnt, sizeof(ScalarItem),
compare_scalars, (void *) &cxt);
qsort_interruptible(values, values_cnt, sizeof(ScalarItem),
compare_scalars, &cxt);
/*
* Now scan the values in order, find the most common ones, and also
@ -2724,7 +2724,7 @@ compute_scalar_stats(VacAttrStatsP stats,
deltafrac;
/* Sort the MCV items into position order to speed next loop */
qsort_interruptible((void *) track, num_mcv, sizeof(ScalarMCVItem),
qsort_interruptible(track, num_mcv, sizeof(ScalarMCVItem),
compare_mcvs, NULL);
/*

View File

@ -878,7 +878,7 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
* created such a pg_collation entry above, and that one will win.)
*/
if (naliases > 1)
qsort((void *) aliases, naliases, sizeof(CollAliasData), cmpaliases);
qsort(aliases, naliases, sizeof(CollAliasData), cmpaliases);
/* Now add aliases, ignoring any that match pre-existing entries */
for (i = 0; i < naliases; i++)

View File

@ -2384,8 +2384,8 @@ vac_tid_reaped(ItemPointer itemptr, void *state)
if (item < litem || item > ritem)
return false;
res = (ItemPointer) bsearch((void *) itemptr,
(void *) dead_items->items,
res = (ItemPointer) bsearch(itemptr,
dead_items->items,
dead_items->num_items,
sizeof(ItemPointerData),
vac_cmp_itemptr);

View File

@ -266,7 +266,7 @@ TidListEval(TidScanState *tidstate)
/* CurrentOfExpr could never appear OR'd with something else */
Assert(!tidstate->tss_isCurrentOf);
qsort((void *) tidList, numTids, sizeof(ItemPointerData),
qsort(tidList, numTids, sizeof(ItemPointerData),
itemptr_comparator);
numTids = qunique(tidList, numTids, sizeof(ItemPointerData),
itemptr_comparator);

View File

@ -853,11 +853,11 @@ tbm_prepare_shared_iterate(TIDBitmap *tbm)
if (ptbase != NULL)
pg_atomic_init_u32(&ptbase->refcount, 0);
if (npages > 1)
qsort_arg((void *) (ptpages->index), npages, sizeof(int),
tbm_shared_comparator, (void *) ptbase->ptentry);
qsort_arg(ptpages->index, npages, sizeof(int),
tbm_shared_comparator, ptbase->ptentry);
if (nchunks > 1)
qsort_arg((void *) (ptchunks->index), nchunks, sizeof(int),
tbm_shared_comparator, (void *) ptbase->ptentry);
qsort_arg(ptchunks->index, nchunks, sizeof(int),
tbm_shared_comparator, ptbase->ptentry);
}
/*

View File

@ -531,7 +531,7 @@ create_list_bounds(PartitionBoundSpec **boundspecs, int nparts,
Assert(j == ndatums);
qsort_arg(all_values, ndatums, sizeof(PartitionListValue),
qsort_partition_list_value_cmp, (void *) key);
qsort_partition_list_value_cmp, key);
boundinfo->ndatums = ndatums;
boundinfo->datums = (Datum **) palloc0(ndatums * sizeof(Datum *));
@ -737,7 +737,7 @@ create_range_bounds(PartitionBoundSpec **boundspecs, int nparts,
qsort_arg(all_bounds, ndatums,
sizeof(PartitionRangeBound *),
qsort_partition_rbound_cmp,
(void *) key);
key);
/* Save distinct bounds from all_bounds into rbounds. */
rbounds = (PartitionRangeBound **)

View File

@ -1129,7 +1129,7 @@ build_sorted_items(StatsBuildData *data, int *nitems,
}
/* do the sort, using the multi-sort */
qsort_interruptible((void *) items, nrows, sizeof(SortItem),
qsort_interruptible(items, nrows, sizeof(SortItem),
multi_sort_compare, mss);
return items;

View File

@ -457,7 +457,7 @@ build_distinct_groups(int numrows, SortItem *items, MultiSortSupport mss,
Assert(j + 1 == ngroups);
/* Sort the distinct groups by frequency (in descending order). */
qsort_interruptible((void *) groups, ngroups, sizeof(SortItem),
qsort_interruptible(groups, ngroups, sizeof(SortItem),
compare_sort_item_count, NULL);
*ndistinct = ngroups;
@ -528,7 +528,7 @@ build_column_frequencies(SortItem *groups, int ngroups,
}
/* sort the values, deduplicate */
qsort_interruptible((void *) result[dim], ngroups, sizeof(SortItem),
qsort_interruptible(result[dim], ngroups, sizeof(SortItem),
sort_item_compare, ssup);
/*

View File

@ -489,7 +489,7 @@ ndistinct_for_combination(double totalrows, StatsBuildData *data,
}
/* We can sort the array now ... */
qsort_interruptible((void *) items, numrows, sizeof(SortItem),
qsort_interruptible(items, numrows, sizeof(SortItem),
multi_sort_compare, mss);
/* ... and count the number of distinct combinations */

View File

@ -2394,7 +2394,7 @@ GetSnapshotData(Snapshot snapshot)
pg_read_barrier(); /* pairs with GetNewTransactionId */
memcpy(snapshot->subxip + subcount,
(void *) proc->subxids.xids,
proc->subxids.xids,
nsubxids * sizeof(TransactionId));
subcount += nsubxids;
}
@ -2846,7 +2846,7 @@ GetRunningTransactionData(void)
/* barrier not really required, as XidGenLock is held, but ... */
pg_read_barrier(); /* pairs with GetNewTransactionId */
memcpy(&xids[count], (void *) proc->subxids.xids,
memcpy(&xids[count], proc->subxids.xids,
nsubxids * sizeof(TransactionId));
count += nsubxids;
subcount += nsubxids;

View File

@ -695,7 +695,7 @@ NIAddAffix(IspellDict *Conf, const char *flag, char flagflags, const char *mask,
if (Conf->maffixes)
{
Conf->maffixes *= 2;
Conf->Affix = (AFFIX *) repalloc((void *) Conf->Affix, Conf->maffixes * sizeof(AFFIX));
Conf->Affix = (AFFIX *) repalloc(Conf->Affix, Conf->maffixes * sizeof(AFFIX));
}
else
{
@ -1116,7 +1116,7 @@ addCompoundAffixFlagValue(IspellDict *Conf, char *s, uint32 val)
{
Conf->mCompoundAffixFlag *= 2;
Conf->CompoundAffixFlags = (CompoundAffixFlag *)
repalloc((void *) Conf->CompoundAffixFlags,
repalloc(Conf->CompoundAffixFlags,
Conf->mCompoundAffixFlag * sizeof(CompoundAffixFlag));
}
else
@ -1158,7 +1158,7 @@ getCompoundAffixFlagValue(IspellDict *Conf, char *s)
setCompoundAffixFlagValue(Conf, &key, sflag, 0);
found = (CompoundAffixFlag *)
bsearch(&key, (void *) Conf->CompoundAffixFlags,
bsearch(&key, Conf->CompoundAffixFlags,
Conf->nCompoundAffixFlag, sizeof(CompoundAffixFlag),
cmpcmdflag);
if (found != NULL)
@ -1305,7 +1305,7 @@ NIImportOOAffixes(IspellDict *Conf, const char *filename)
tsearch_readline_end(&trst);
if (Conf->nCompoundAffixFlag > 1)
qsort((void *) Conf->CompoundAffixFlags, Conf->nCompoundAffixFlag,
qsort(Conf->CompoundAffixFlags, Conf->nCompoundAffixFlag,
sizeof(CompoundAffixFlag), cmpcmdflag);
if (!tsearch_readline_begin(&trst, filename))
@ -1789,7 +1789,7 @@ NISortDictionary(IspellDict *Conf)
else
{
/* Count the number of different flags used in the dictionary */
qsort((void *) Conf->Spell, Conf->nspell, sizeof(SPELL *),
qsort(Conf->Spell, Conf->nspell, sizeof(SPELL *),
cmpspellaffix);
naffix = 0;
@ -1827,7 +1827,7 @@ NISortDictionary(IspellDict *Conf)
}
/* Start build a prefix tree */
qsort((void *) Conf->Spell, Conf->nspell, sizeof(SPELL *), cmpspell);
qsort(Conf->Spell, Conf->nspell, sizeof(SPELL *), cmpspell);
Conf->Dictionary = mkSPNode(Conf, 0, Conf->nspell, 0);
}
@ -2001,7 +2001,7 @@ NISortAffixes(IspellDict *Conf)
/* Store compound affixes in the Conf->CompoundAffix array */
if (Conf->naffixes > 1)
qsort((void *) Conf->Affix, Conf->naffixes, sizeof(AFFIX), cmpaffix);
qsort(Conf->Affix, Conf->naffixes, sizeof(AFFIX), cmpaffix);
Conf->CompoundAffix = ptr = (CMPDAffix *) palloc(sizeof(CMPDAffix) * Conf->naffixes);
ptr->affix = NULL;

View File

@ -97,7 +97,7 @@ uniqueWORD(ParsedWord *a, int32 l)
/*
* Sort words with its positions
*/
qsort((void *) a, l, sizeof(ParsedWord), compareWORD);
qsort(a, l, sizeof(ParsedWord), compareWORD);
/*
* Initialize first word and its first position

View File

@ -410,7 +410,7 @@ parsetext(Oid cfgId, ParsedText *prs, char *buf, int buflen)
if (prs->curwords == prs->lenwords)
{
prs->lenwords *= 2;
prs->words = (ParsedWord *) repalloc((void *) prs->words, prs->lenwords * sizeof(ParsedWord));
prs->words = (ParsedWord *) repalloc(prs->words, prs->lenwords * sizeof(ParsedWord));
}
if (ptr->flags & TSL_ADDPOS)
@ -442,7 +442,7 @@ hladdword(HeadlineParsedText *prs, char *buf, int buflen, int type)
if (prs->curwords >= prs->lenwords)
{
prs->lenwords *= 2;
prs->words = (HeadlineWordEntry *) repalloc((void *) prs->words, prs->lenwords * sizeof(HeadlineWordEntry));
prs->words = (HeadlineWordEntry *) repalloc(prs->words, prs->lenwords * sizeof(HeadlineWordEntry));
}
memset(&(prs->words[prs->curwords]), 0, sizeof(HeadlineWordEntry));
prs->words[prs->curwords].type = (uint8) type;
@ -470,7 +470,7 @@ hlfinditem(HeadlineParsedText *prs, TSQuery query, int32 pos, char *buf, int buf
while (prs->curwords + query->size >= prs->lenwords)
{
prs->lenwords *= 2;
prs->words = (HeadlineWordEntry *) repalloc((void *) prs->words, prs->lenwords * sizeof(HeadlineWordEntry));
prs->words = (HeadlineWordEntry *) repalloc(prs->words, prs->lenwords * sizeof(HeadlineWordEntry));
}
word = &(prs->words[prs->curwords - 1]);

View File

@ -109,8 +109,7 @@ readstoplist(const char *fname, StopList *s, char *(*wordop) (const char *))
else
{
reallen *= 2;
stop = (char **) repalloc((void *) stop,
sizeof(char *) * reallen);
stop = (char **) repalloc(stop, sizeof(char *) * reallen);
}
}

View File

@ -143,7 +143,7 @@ makesign(BITVECP sign, SignTSVector *a, int siglen)
len = ARRNELEM(a);
int32 *ptr = GETARR(a);
MemSet((void *) sign, 0, siglen);
MemSet(sign, 0, siglen);
for (k = 0; k < len; k++)
HASH(sign, ptr[k], siglen);
}
@ -204,7 +204,7 @@ gtsvector_compress(PG_FUNCTION_ARGS)
* val->size
*/
len = CALCGTSIZE(ARRKEY, len);
res = (SignTSVector *) repalloc((void *) res, len);
res = (SignTSVector *) repalloc(res, len);
SET_VARSIZE(res, len);
}
@ -577,7 +577,7 @@ fillcache(CACHESIGN *item, SignTSVector *key, int siglen)
else if (ISALLTRUE(key))
item->allistrue = true;
else
memcpy((void *) item->sign, (void *) GETSIGN(key), siglen);
memcpy(item->sign, GETSIGN(key), siglen);
}
#define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
@ -704,7 +704,7 @@ gtsvector_picksplit(PG_FUNCTION_ARGS)
size_beta = hemdistcache(&(cache[seed_2]), &(cache[j]), siglen);
costvector[j - 1].cost = abs(size_alpha - size_beta);
}
qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
qsort(costvector, maxoff, sizeof(SPLITCOST), comparecost);
for (k = 0; k < maxoff; k++)
{
@ -755,7 +755,7 @@ gtsvector_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_l) || cache[j].allistrue)
{
if (!ISALLTRUE(datum_l))
memset((void *) GETSIGN(datum_l), 0xff, siglen);
memset(GETSIGN(datum_l), 0xff, siglen);
}
else
{
@ -771,7 +771,7 @@ gtsvector_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_r) || cache[j].allistrue)
{
if (!ISALLTRUE(datum_r))
memset((void *) GETSIGN(datum_r), 0xff, siglen);
memset(GETSIGN(datum_r), 0xff, siglen);
}
else
{

View File

@ -602,10 +602,10 @@ pushValue(TSQueryParserState state, char *strval, int lenval, int16 weight, bool
int used = state->curop - state->op;
state->lenop *= 2;
state->op = (char *) repalloc((void *) state->op, state->lenop);
state->op = (char *) repalloc(state->op, state->lenop);
state->curop = state->op + used;
}
memcpy((void *) state->curop, (void *) strval, lenval);
memcpy(state->curop, strval, lenval);
state->curop += lenval;
*(state->curop) = '\0';
state->curop++;
@ -924,7 +924,7 @@ parse_tsquery(char *buf,
}
/* Copy all the operand strings to TSQuery */
memcpy((void *) GETOPERAND(query), (void *) state.op, state.sumlen);
memcpy(GETOPERAND(query), state.op, state.sumlen);
pfree(state.op);
/*

View File

@ -67,9 +67,9 @@ plainnode(PLAINTREE *state, NODE *node)
if (state->cur == state->len)
{
state->len *= 2;
state->ptr = (QueryItem *) repalloc((void *) state->ptr, state->len * sizeof(QueryItem));
state->ptr = (QueryItem *) repalloc(state->ptr, state->len * sizeof(QueryItem));
}
memcpy((void *) &(state->ptr[state->cur]), (void *) node->valnode, sizeof(QueryItem));
memcpy(&(state->ptr[state->cur]), node->valnode, sizeof(QueryItem));
if (node->valnode->type == QI_VAL)
state->cur++;
else if (node->valnode->qoperator.oper == OP_NOT)

View File

@ -222,7 +222,7 @@ gtsquery_picksplit(PG_FUNCTION_ARGS)
size_beta = hemdist(GETENTRY(entryvec, seed_2), GETENTRY(entryvec, j));
costvector[j - 1].cost = abs(size_alpha - size_beta);
}
qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
qsort(costvector, maxoff, sizeof(SPLITCOST), comparecost);
for (k = 0; k < maxoff; k++)
{

View File

@ -173,7 +173,7 @@ QTNSort(QTNode *in)
for (i = 0; i < in->nchild; i++)
QTNSort(in->child[i]);
if (in->nchild > 1 && in->valnode->qoperator.oper != OP_PHRASE)
qsort((void *) in->child, in->nchild, sizeof(QTNode *), cmpQTN);
qsort(in->child, in->nchild, sizeof(QTNode *), cmpQTN);
}
/*

View File

@ -176,7 +176,7 @@ SortAndUniqItems(TSQuery q, int *size)
if (*size < 2)
return res;
qsort_arg(res, *size, sizeof(QueryOperand *), compareQueryOperand, (void *) operand);
qsort_arg(res, *size, sizeof(QueryOperand *), compareQueryOperand, operand);
ptr = res + 1;
prevptr = res;
@ -804,7 +804,7 @@ get_docrep(TSVector txt, QueryRepresentation *qr, int *doclen)
/*
* Sort representation in ascending order by pos and entry
*/
qsort((void *) doc, cur, sizeof(DocRepresentation), compareDocR);
qsort(doc, cur, sizeof(DocRepresentation), compareDocR);
/*
* Join QueryItem per WordEntry and it's position

View File

@ -58,7 +58,7 @@ uniquePos(WordEntryPos *a, int l)
if (l <= 1)
return l;
qsort((void *) a, l, sizeof(WordEntryPos), compareWordEntryPos);
qsort(a, l, sizeof(WordEntryPos), compareWordEntryPos);
res = a;
ptr = a + 1;
@ -107,8 +107,7 @@ uniqueentry(WordEntryIN *a, int l, char *buf, int *outbuflen)
Assert(l >= 1);
if (l > 1)
qsort_arg((void *) a, l, sizeof(WordEntryIN), compareentry,
(void *) buf);
qsort_arg(a, l, sizeof(WordEntryIN), compareentry, buf);
buflen = 0;
res = a;
@ -232,19 +231,19 @@ tsvectorin(PG_FUNCTION_ARGS)
{
arrlen *= 2;
arr = (WordEntryIN *)
repalloc((void *) arr, sizeof(WordEntryIN) * arrlen);
repalloc(arr, sizeof(WordEntryIN) * arrlen);
}
while ((cur - tmpbuf) + toklen >= buflen)
{
int dist = cur - tmpbuf;
buflen *= 2;
tmpbuf = (char *) repalloc((void *) tmpbuf, buflen);
tmpbuf = (char *) repalloc(tmpbuf, buflen);
cur = tmpbuf + dist;
}
arr[len].entry.len = toklen;
arr[len].entry.pos = cur - tmpbuf;
memcpy((void *) cur, (void *) token, toklen);
memcpy(cur, token, toklen);
cur += toklen;
if (poslen != 0)
@ -552,8 +551,8 @@ tsvectorrecv(PG_FUNCTION_ARGS)
SET_VARSIZE(vec, hdrlen + datalen);
if (needSort)
qsort_arg((void *) ARRPTR(vec), vec->size, sizeof(WordEntry),
compareentry, (void *) STRPTR(vec));
qsort_arg(ARRPTR(vec), vec->size, sizeof(WordEntry),
compareentry, STRPTR(vec));
PG_RETURN_TSVECTOR(vec);
}

View File

@ -1736,7 +1736,7 @@ pgpipe(int handles[2])
return -1;
}
memset((void *) &serv_addr, 0, sizeof(serv_addr));
memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = pg_hton16(0);
serv_addr.sin_addr.s_addr = pg_hton32(INADDR_LOOPBACK);

View File

@ -2363,8 +2363,7 @@ WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate)
}
if (ntes > 1)
qsort((void *) tes, ntes, sizeof(TocEntry *),
TocEntrySizeCompare);
qsort(tes, ntes, sizeof(TocEntry *), TocEntrySizeCompare);
for (int i = 0; i < ntes; i++)
DispatchJobForTocEntry(AH, pstate, tes[i], ACT_DUMP,

View File

@ -186,7 +186,7 @@ void
sortDumpableObjectsByTypeName(DumpableObject **objs, int numObjs)
{
if (numObjs > 1)
qsort((void *) objs, numObjs, sizeof(DumpableObject *),
qsort(objs, numObjs, sizeof(DumpableObject *),
DOTypeNameCompare);
}

View File

@ -136,7 +136,7 @@ check_loadable_libraries(void)
* consistent order, which is important for reproducible behavior if one
* library depends on another.
*/
qsort((void *) os_info.libraries, os_info.num_libraries,
qsort(os_info.libraries, os_info.num_libraries,
sizeof(LibraryInfo), library_name_compare);
for (libnum = 0; libnum < os_info.num_libraries; libnum++)

View File

@ -1604,15 +1604,15 @@ lookupVariable(Variables *variables, char *name)
/* Sort if we have to */
if (!variables->vars_sorted)
{
qsort((void *) variables->vars, variables->nvars, sizeof(Variable),
qsort(variables->vars, variables->nvars, sizeof(Variable),
compareVariableNames);
variables->vars_sorted = true;
}
/* Now we can search */
key.name = name;
return (Variable *) bsearch((void *) &key,
(void *) variables->vars,
return (Variable *) bsearch(&key,
variables->vars,
variables->nvars,
sizeof(Variable),
compareVariableNames);

View File

@ -78,8 +78,8 @@ copytext(PG_FUNCTION_ARGS)
* VARDATA is a pointer to the data region of the new struct. The source
* could be a short datum, so retrieve its data through VARDATA_ANY.
*/
memcpy((void *) VARDATA(new_t), /* destination */
(void *) VARDATA_ANY(t), /* source */
memcpy(VARDATA(new_t), /* destination */
VARDATA_ANY(t), /* source */
VARSIZE_ANY_EXHDR(t)); /* how many bytes */
PG_RETURN_TEXT_P(new_t);
}