1
0
mirror of https://github.com/postgres/postgres.git synced 2025-12-22 17:42:17 +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

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