1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-19 13:42:17 +03:00

Remove useless casts to (void *)

Many of them just seem to have been copied around for no real reason.
Their presence causes (small) risks of hiding actual type mismatches
or silently discarding qualifiers

Discussion: https://www.postgresql.org/message-id/flat/461ea37c-8b58-43b4-9736-52884e862820@eisentraut.org
This commit is contained in:
Peter Eisentraut
2024-11-28 08:19:22 +01:00
parent 97525bc5c8
commit 7f798aca1d
158 changed files with 491 additions and 550 deletions

View File

@@ -1808,7 +1808,7 @@ aclexplode(PG_FUNCTION_ARGS)
idx = (int *) palloc(sizeof(int[2]));
idx[0] = 0; /* ACL array item index */
idx[1] = -1; /* privilege type counter */
funcctx->user_fctx = (void *) idx;
funcctx->user_fctx = idx;
MemoryContextSwitchTo(oldcontext);
}

View File

@@ -685,7 +685,7 @@ array_agg_serialize(PG_FUNCTION_ARGS)
&typisvarlena);
fmgr_info_cxt(typsend, &iodata->typsend,
fcinfo->flinfo->fn_mcxt);
fcinfo->flinfo->fn_extra = (void *) iodata;
fcinfo->flinfo->fn_extra = iodata;
}
for (i = 0; i < state->nelems; i++)
@@ -776,7 +776,7 @@ array_agg_deserialize(PG_FUNCTION_ARGS)
&iodata->typioparam);
fmgr_info_cxt(typreceive, &iodata->typreceive,
fcinfo->flinfo->fn_mcxt);
fcinfo->flinfo->fn_extra = (void *) iodata;
fcinfo->flinfo->fn_extra = iodata;
}
for (int i = 0; i < nelems; i++)
@@ -1642,7 +1642,7 @@ array_shuffle(PG_FUNCTION_ARGS)
if (typentry == NULL || typentry->type_id != elmtyp)
{
typentry = lookup_type_cache(elmtyp, 0);
fcinfo->flinfo->fn_extra = (void *) typentry;
fcinfo->flinfo->fn_extra = typentry;
}
result = array_shuffle_n(array, ARR_DIMS(array)[0], true, elmtyp, typentry);
@@ -1678,7 +1678,7 @@ array_sample(PG_FUNCTION_ARGS)
if (typentry == NULL || typentry->type_id != elmtyp)
{
typentry = lookup_type_cache(elmtyp, 0);
fcinfo->flinfo->fn_extra = (void *) typentry;
fcinfo->flinfo->fn_extra = typentry;
}
result = array_shuffle_n(array, n, false, elmtyp, typentry);

View File

@@ -3863,7 +3863,7 @@ array_eq(PG_FUNCTION_ARGS)
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("could not identify an equality operator for type %s",
format_type_be(element_type))));
fcinfo->flinfo->fn_extra = (void *) typentry;
fcinfo->flinfo->fn_extra = typentry;
}
typlen = typentry->typlen;
typbyval = typentry->typbyval;
@@ -4027,7 +4027,7 @@ array_cmp(FunctionCallInfo fcinfo)
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("could not identify a comparison function for type %s",
format_type_be(element_type))));
fcinfo->flinfo->fn_extra = (void *) typentry;
fcinfo->flinfo->fn_extra = typentry;
}
typlen = typentry->typlen;
typbyval = typentry->typbyval;
@@ -4222,7 +4222,7 @@ hash_array(PG_FUNCTION_ARGS)
typentry = record_typentry;
}
fcinfo->flinfo->fn_extra = (void *) typentry;
fcinfo->flinfo->fn_extra = typentry;
}
typlen = typentry->typlen;
@@ -4316,7 +4316,7 @@ hash_array_extended(PG_FUNCTION_ARGS)
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("could not identify an extended hash function for type %s",
format_type_be(element_type))));
fcinfo->flinfo->fn_extra = (void *) typentry;
fcinfo->flinfo->fn_extra = typentry;
}
typlen = typentry->typlen;
typbyval = typentry->typbyval;
@@ -4418,7 +4418,7 @@ array_contain_compare(AnyArrayType *array1, AnyArrayType *array2, Oid collation,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("could not identify an equality operator for type %s",
format_type_be(element_type))));
*fn_extra = (void *) typentry;
*fn_extra = typentry;
}
typlen = typentry->typlen;
typbyval = typentry->typbyval;
@@ -6437,7 +6437,7 @@ array_replace_internal(ArrayType *array,
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("could not identify an equality operator for type %s",
format_type_be(element_type))));
fcinfo->flinfo->fn_extra = (void *) typentry;
fcinfo->flinfo->fn_extra = typentry;
}
typlen = typentry->typlen;
typbyval = typentry->typbyval;
@@ -6723,7 +6723,7 @@ width_bucket_array(PG_FUNCTION_ARGS)
(errcode(ERRCODE_UNDEFINED_FUNCTION),
errmsg("could not identify a comparison function for type %s",
format_type_be(element_type))));
fcinfo->flinfo->fn_extra = (void *) typentry;
fcinfo->flinfo->fn_extra = typentry;
}
/*

View File

@@ -5031,7 +5031,7 @@ pg_timezone_abbrevs(PG_FUNCTION_ARGS)
/* allocate memory for user context */
pindex = (int *) palloc(sizeof(int));
*pindex = 0;
funcctx->user_fctx = (void *) pindex;
funcctx->user_fctx = pindex;
if (get_call_result_type(fcinfo, NULL, &tupdesc) != TYPEFUNC_COMPOSITE)
elog(ERROR, "return type must be a row type");

View File

@@ -149,7 +149,7 @@ datumCopy(Datum value, bool typByVal, int typLen)
resultsize = EOH_get_flat_size(eoh);
resultptr = (char *) palloc(resultsize);
EOH_flatten_into(eoh, (void *) resultptr, resultsize);
EOH_flatten_into(eoh, resultptr, resultsize);
res = PointerGetDatum(resultptr);
}
else
@@ -495,7 +495,7 @@ datumSerialize(Datum value, bool isnull, bool typByVal, int typLen,
* so we can't store directly to *start_address.
*/
tmp = (char *) palloc(header);
EOH_flatten_into(eoh, (void *) tmp, header);
EOH_flatten_into(eoh, tmp, header);
memcpy(*start_address, tmp, header);
*start_address += header;

View File

@@ -255,7 +255,7 @@ domain_in(PG_FUNCTION_ARGS)
{
my_extra = domain_state_setup(domainType, false,
fcinfo->flinfo->fn_mcxt);
fcinfo->flinfo->fn_extra = (void *) my_extra;
fcinfo->flinfo->fn_extra = my_extra;
}
/*
@@ -314,7 +314,7 @@ domain_recv(PG_FUNCTION_ARGS)
{
my_extra = domain_state_setup(domainType, true,
fcinfo->flinfo->fn_mcxt);
fcinfo->flinfo->fn_extra = (void *) my_extra;
fcinfo->flinfo->fn_extra = my_extra;
}
/*
@@ -388,7 +388,7 @@ domain_check_internal(Datum value, bool isnull, Oid domainType,
{
my_extra = domain_state_setup(domainType, true, mcxt);
if (extra)
*extra = (void *) my_extra;
*extra = my_extra;
}
/*

View File

@@ -295,7 +295,7 @@ enum_cmp_internal(Oid arg1, Oid arg2, FunctionCallInfo fcinfo)
ReleaseSysCache(enum_tup);
/* Now locate and remember the typcache entry */
tcache = lookup_type_cache(typeoid, 0);
fcinfo->flinfo->fn_extra = (void *) tcache;
fcinfo->flinfo->fn_extra = tcache;
}
/* The remaining comparison logic is in typcache.c */

View File

@@ -161,7 +161,7 @@ make_expanded_record_from_typeid(Oid type_id, int32 typmod,
{
/* Register callback to release the refcount */
erh->er_mcb.func = ER_mc_callback;
erh->er_mcb.arg = (void *) erh;
erh->er_mcb.arg = erh;
MemoryContextRegisterResetCallback(erh->hdr.eoh_context,
&erh->er_mcb);
@@ -289,7 +289,7 @@ make_expanded_record_from_tupdesc(TupleDesc tupdesc,
{
/* Register callback to release the refcount */
erh->er_mcb.func = ER_mc_callback;
erh->er_mcb.arg = (void *) erh;
erh->er_mcb.arg = erh;
MemoryContextRegisterResetCallback(erh->hdr.eoh_context,
&erh->er_mcb);
@@ -385,7 +385,7 @@ make_expanded_record_from_exprecord(ExpandedRecordHeader *olderh,
{
/* Register callback to release the refcount */
erh->er_mcb.func = ER_mc_callback;
erh->er_mcb.arg = (void *) erh;
erh->er_mcb.arg = erh;
MemoryContextRegisterResetCallback(erh->hdr.eoh_context,
&erh->er_mcb);
@@ -844,7 +844,7 @@ expanded_record_fetch_tupdesc(ExpandedRecordHeader *erh)
if (erh->er_mcb.arg == NULL)
{
erh->er_mcb.func = ER_mc_callback;
erh->er_mcb.arg = (void *) erh;
erh->er_mcb.arg = erh;
MemoryContextRegisterResetCallback(erh->hdr.eoh_context,
&erh->er_mcb);
}

View File

@@ -257,7 +257,7 @@ jsonb_from_cstring(char *json, int len, bool unique_keys, Node *escontext)
state.unique_keys = unique_keys;
state.escontext = escontext;
sem.semstate = (void *) &state;
sem.semstate = &state;
sem.object_start = jsonb_in_object_start;
sem.array_start = jsonb_in_array_start;
@@ -758,7 +758,7 @@ datum_to_jsonb_internal(Datum val, bool is_null, JsonbInState *result,
memset(&sem, 0, sizeof(sem));
sem.semstate = (void *) result;
sem.semstate = result;
sem.object_start = jsonb_in_object_start;
sem.array_start = jsonb_in_array_start;

View File

@@ -617,7 +617,7 @@ jsonb_object_keys(PG_FUNCTION_ARGS)
}
MemoryContextSwitchTo(oldcontext);
funcctx->user_fctx = (void *) state;
funcctx->user_fctx = state;
}
funcctx = SRF_PERCALL_SETUP();
@@ -752,7 +752,7 @@ json_object_keys(PG_FUNCTION_ARGS)
state->sent_count = 0;
state->result = palloc(256 * sizeof(char *));
sem->semstate = (void *) state;
sem->semstate = state;
sem->array_start = okeys_array_start;
sem->scalar = okeys_scalar;
sem->object_field_start = okeys_object_field_start;
@@ -765,7 +765,7 @@ json_object_keys(PG_FUNCTION_ARGS)
pfree(sem);
MemoryContextSwitchTo(oldcontext);
funcctx->user_fctx = (void *) state;
funcctx->user_fctx = state;
}
funcctx = SRF_PERCALL_SETUP();
@@ -1123,7 +1123,7 @@ get_worker(text *json,
if (npath > 0)
state->pathok[0] = true;
sem->semstate = (void *) state;
sem->semstate = state;
/*
* Not all variants need all the semantic routines. Only set the ones that
@@ -1863,7 +1863,7 @@ json_array_length(PG_FUNCTION_ARGS)
#endif
sem = palloc0(sizeof(JsonSemAction));
sem->semstate = (void *) state;
sem->semstate = state;
sem->object_start = alen_object_start;
sem->scalar = alen_scalar;
sem->array_element_start = alen_array_element_start;
@@ -2071,7 +2071,7 @@ each_worker(FunctionCallInfo fcinfo, bool as_text)
state->tuple_store = rsi->setResult;
state->ret_tdesc = rsi->setDesc;
sem->semstate = (void *) state;
sem->semstate = state;
sem->array_start = each_array_start;
sem->scalar = each_scalar;
sem->object_field_start = each_object_field_start;
@@ -2323,7 +2323,7 @@ elements_worker(FunctionCallInfo fcinfo, const char *funcname, bool as_text)
state->tuple_store = rsi->setResult;
state->ret_tdesc = rsi->setDesc;
sem->semstate = (void *) state;
sem->semstate = state;
sem->object_start = elements_object_start;
sem->scalar = elements_scalar;
sem->array_element_start = elements_array_element_start;
@@ -2795,7 +2795,7 @@ populate_array_json(PopulateArrayContext *ctx, const char *json, int len)
state.ctx = ctx;
memset(&sem, 0, sizeof(sem));
sem.semstate = (void *) &state;
sem.semstate = &state;
sem.object_start = populate_array_object_start;
sem.array_end = populate_array_array_end;
sem.array_element_start = populate_array_element_start;
@@ -3831,7 +3831,7 @@ get_json_object_as_hash(const char *json, int len, const char *funcname,
state->lex = makeJsonLexContextCstringLen(NULL, json, len,
GetDatabaseEncoding(), true);
sem->semstate = (void *) state;
sem->semstate = state;
sem->array_start = hash_array_start;
sem->scalar = hash_scalar;
sem->object_field_start = hash_object_field_start;
@@ -4144,7 +4144,7 @@ populate_recordset_worker(FunctionCallInfo fcinfo, const char *funcname,
makeJsonLexContext(&lex, json, true);
sem->semstate = (void *) state;
sem->semstate = state;
sem->array_start = populate_recordset_array_start;
sem->array_element_start = populate_recordset_array_element_start;
sem->scalar = populate_recordset_scalar;
@@ -4504,7 +4504,7 @@ json_strip_nulls(PG_FUNCTION_ARGS)
state->strval = makeStringInfo();
state->skip_next_null = false;
sem->semstate = (void *) state;
sem->semstate = state;
sem->object_start = sn_object_start;
sem->object_end = sn_object_end;
sem->array_start = sn_array_start;
@@ -5718,7 +5718,7 @@ iterate_json_values(text *json, uint32 flags, void *action_state,
state->action_state = action_state;
state->flags = flags;
sem->semstate = (void *) state;
sem->semstate = state;
sem->scalar = iterate_values_scalar;
sem->object_field_start = iterate_values_object_field_start;
@@ -5839,7 +5839,7 @@ transform_json_string_values(text *json, void *action_state,
state->action = transform_action;
state->action_state = action_state;
sem->semstate = (void *) state;
sem->semstate = state;
sem->object_start = transform_string_values_object_start;
sem->object_end = transform_string_values_object_end;
sem->array_start = transform_string_values_array_start;

View File

@@ -3615,7 +3615,7 @@ JsonbType(JsonbValue *jb)
if (jb->type == jbvBinary)
{
JsonbContainer *jbc = (void *) jb->val.binary.data;
JsonbContainer *jbc = jb->val.binary.data;
/* Scalars should be always extracted during jsonpath execution. */
Assert(!JsonContainerIsScalar(jbc));

View File

@@ -564,7 +564,7 @@ parsejsonpath(const char *str, int len, struct Node *escontext)
jsonpath_scanner_init(str, len);
if (jsonpath_yyparse((void *) &parseresult, escontext) != 0)
if (jsonpath_yyparse(&parseresult, escontext) != 0)
jsonpath_yyerror(NULL, escontext, "invalid input"); /* shouldn't happen */
jsonpath_scanner_finish();

View File

@@ -153,7 +153,7 @@ pg_lock_status(PG_FUNCTION_ARGS)
* out as a result set.
*/
mystatus = (PG_Lock_Status *) palloc(sizeof(PG_Lock_Status));
funcctx->user_fctx = (void *) mystatus;
funcctx->user_fctx = mystatus;
mystatus->lockData = GetLockStatusData();
mystatus->currIdx = 0;

View File

@@ -458,7 +458,7 @@ get_multirange_io_data(FunctionCallInfo fcinfo, Oid mltrngtypid, IOFuncSelector
fmgr_info_cxt(typiofunc, &cache->typioproc,
fcinfo->flinfo->fn_mcxt);
fcinfo->flinfo->fn_extra = (void *) cache;
fcinfo->flinfo->fn_extra = cache;
}
return cache;
@@ -555,7 +555,7 @@ multirange_get_typcache(FunctionCallInfo fcinfo, Oid mltrngtypid)
typcache = lookup_type_cache(mltrngtypid, TYPECACHE_MULTIRANGE_INFO);
if (typcache->rngtype == NULL)
elog(ERROR, "type %u is not a multirange type", mltrngtypid);
fcinfo->flinfo->fn_extra = (void *) typcache;
fcinfo->flinfo->fn_extra = typcache;
}
return typcache;

View File

@@ -270,7 +270,7 @@ ordered_set_startup(FunctionCallInfo fcinfo, bool use_tuples)
&qstate->typAlign);
}
fcinfo->flinfo->fn_extra = (void *) qstate;
fcinfo->flinfo->fn_extra = qstate;
MemoryContextSwitchTo(oldcontext);
}

View File

@@ -92,7 +92,7 @@ pg_partition_tree(PG_FUNCTION_ARGS)
funcctx->tuple_desc = tupdesc;
/* The only state we need is the partition list */
funcctx->user_fctx = (void *) partitions;
funcctx->user_fctx = partitions;
MemoryContextSwitchTo(oldcxt);
}
@@ -219,7 +219,7 @@ pg_partition_ancestors(PG_FUNCTION_ARGS)
ancestors = lcons_oid(relid, ancestors);
/* The only state we need is the ancestors list */
funcctx->user_fctx = (void *) ancestors;
funcctx->user_fctx = ancestors;
MemoryContextSwitchTo(oldcxt);
}

View File

@@ -359,7 +359,7 @@ get_range_io_data(FunctionCallInfo fcinfo, Oid rngtypid, IOFuncSelector func)
fmgr_info_cxt(typiofunc, &cache->typioproc,
fcinfo->flinfo->fn_mcxt);
fcinfo->flinfo->fn_extra = (void *) cache;
fcinfo->flinfo->fn_extra = cache;
}
return cache;
@@ -1710,7 +1710,7 @@ range_get_typcache(FunctionCallInfo fcinfo, Oid rngtypid)
typcache = lookup_type_cache(rngtypid, TYPECACHE_RANGE_INFO);
if (typcache->rngelemtype == NULL)
elog(ERROR, "type %u is not a range type", rngtypid);
fcinfo->flinfo->fn_extra = (void *) typcache;
fcinfo->flinfo->fn_extra = typcache;
}
return typcache;

View File

@@ -1367,7 +1367,7 @@ regexp_matches(PG_FUNCTION_ARGS)
matchctx->nulls = (bool *) palloc(sizeof(bool) * matchctx->npatterns);
MemoryContextSwitchTo(oldcontext);
funcctx->user_fctx = (void *) matchctx;
funcctx->user_fctx = matchctx;
}
funcctx = SRF_PERCALL_SETUP();
@@ -1707,7 +1707,7 @@ regexp_split_to_table(PG_FUNCTION_ARGS)
false, true, true);
MemoryContextSwitchTo(oldcontext);
funcctx->user_fctx = (void *) splitctx;
funcctx->user_fctx = splitctx;
}
funcctx = SRF_PERCALL_SETUP();

View File

@@ -355,7 +355,7 @@ gtsvector_consistent(PG_FUNCTION_ARGS)
chkval.arrb = GETARR(key);
chkval.arre = chkval.arrb + ARRNELEM(key);
PG_RETURN_BOOL(TS_execute(GETQUERY(query),
(void *) &chkval,
&chkval,
TS_EXEC_PHRASE_NO_POS,
checkcondition_arr));
}

View File

@@ -185,7 +185,7 @@ SortAndUniqItems(TSQuery q, int *size)
/* remove duplicates */
while (ptr - res < *size)
{
if (compareQueryOperand((void *) ptr, (void *) prevptr, (void *) operand) != 0)
if (compareQueryOperand(ptr, prevptr, operand) != 0)
{
prevptr++;
*prevptr = *ptr;
@@ -671,7 +671,7 @@ Cover(DocRepresentation *doc, int len, QueryRepresentation *qr, CoverExt *ext)
{
fillQueryRepresentationData(qr, ptr);
if (TS_execute(GETQUERY(qr->query), (void *) qr,
if (TS_execute(GETQUERY(qr->query), qr,
TS_EXEC_EMPTY, checkcondition_QueryOperand))
{
if (WEP_GETPOS(ptr->pos) > ext->q)
@@ -701,7 +701,7 @@ Cover(DocRepresentation *doc, int len, QueryRepresentation *qr, CoverExt *ext)
*/
fillQueryRepresentationData(qr, ptr);
if (TS_execute(GETQUERY(qr->query), (void *) qr,
if (TS_execute(GETQUERY(qr->query), qr,
TS_EXEC_EMPTY, checkcondition_QueryOperand))
{
if (WEP_GETPOS(ptr->pos) < ext->p)

View File

@@ -2452,7 +2452,7 @@ ts_setup_firstcall(FunctionCallInfo fcinfo, FuncCallContext *funcctx,
MemoryContext oldcontext;
StatEntry *node;
funcctx->user_fctx = (void *) stat;
funcctx->user_fctx = stat;
oldcontext = MemoryContextSwitchTo(funcctx->multi_call_memory_ctx);

View File

@@ -1226,7 +1226,7 @@ pg_xml_init(PgXmlStrictness strictness)
errcxt->saved_errcxt = xmlGenericErrorContext;
#endif
xmlSetStructuredErrorFunc((void *) errcxt, xml_errorHandler);
xmlSetStructuredErrorFunc(errcxt, xml_errorHandler);
/*
* Verify that xmlSetStructuredErrorFunc set the context variable we
@@ -1248,7 +1248,7 @@ pg_xml_init(PgXmlStrictness strictness)
new_errcxt = xmlGenericErrorContext;
#endif
if (new_errcxt != (void *) errcxt)
if (new_errcxt != errcxt)
ereport(ERROR,
(errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
errmsg("could not set up XML error handler"),
@@ -1302,7 +1302,7 @@ pg_xml_done(PgXmlErrorContext *errcxt, bool isError)
cur_errcxt = xmlGenericErrorContext;
#endif
if (cur_errcxt != (void *) errcxt)
if (cur_errcxt != errcxt)
elog(WARNING, "libxml error handling state is out of sync with xml.c");
/* Restore the saved handlers */
@@ -2197,7 +2197,7 @@ xml_errorHandler(void *data, PgXmlErrorPtr error)
xmlGenericErrorFunc errFuncSaved = xmlGenericError;
void *errCtxSaved = xmlGenericErrorContext;
xmlSetGenericErrorFunc((void *) errorBuf,
xmlSetGenericErrorFunc(errorBuf,
(xmlGenericErrorFunc) appendStringInfo);
/* Add context information to errorBuf */
@@ -4885,7 +4885,7 @@ XmlTableFetchRow(TableFuncScanState *state)
xtCxt = GetXmlTableBuilderPrivateData(state, "XmlTableFetchRow");
/* Propagate our own error context to libxml2 */
xmlSetStructuredErrorFunc((void *) xtCxt->xmlerrcxt, xml_errorHandler);
xmlSetStructuredErrorFunc(xtCxt->xmlerrcxt, xml_errorHandler);
if (xtCxt->xpathobj == NULL)
{
@@ -4939,7 +4939,7 @@ XmlTableGetValue(TableFuncScanState *state, int colnum,
xtCxt->xpathobj->nodesetval != NULL);
/* Propagate our own error context to libxml2 */
xmlSetStructuredErrorFunc((void *) xtCxt->xmlerrcxt, xml_errorHandler);
xmlSetStructuredErrorFunc(xtCxt->xmlerrcxt, xml_errorHandler);
*isnull = false;
@@ -5082,7 +5082,7 @@ XmlTableDestroyOpaque(TableFuncScanState *state)
xtCxt = GetXmlTableBuilderPrivateData(state, "XmlTableDestroyOpaque");
/* Propagate our own error context to libxml2 */
xmlSetStructuredErrorFunc((void *) xtCxt->xmlerrcxt, xml_errorHandler);
xmlSetStructuredErrorFunc(xtCxt->xmlerrcxt, xml_errorHandler);
if (xtCxt->xpathscomp != NULL)
{