1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-15 19:21:59 +03:00

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);
}