Remove useless casting to same type

This removes some casts where the input already has the same type as
the type specified by the cast.  Their presence could cause risks of
hiding actual type mismatches in the future or silently discarding
qualifiers.  It also improves readability.  Same kind of idea as
7f798aca1d and ef8fe69360.  (This does not change all such
instances, but only those hand-picked by the author.)

Author: Bertrand Drouvot <bertranddrouvot.pg@gmail.com>
Reviewed-by: Nathan Bossart <nathandbossart@gmail.com>
Reviewed-by: Jacob Champion <jacob.champion@enterprisedb.com>
Reviewed-by: Peter Eisentraut <peter@eisentraut.org>
Discussion: https://www.postgresql.org/message-id/flat/aSQy2JawavlVlEB0%40ip-10-97-1-34.eu-west-3.compute.internal
This commit is contained in:
Peter Eisentraut 2025-12-02 10:05:12 +01:00
parent 35988b31db
commit 4f941d432b
41 changed files with 74 additions and 78 deletions

View file

@ -181,8 +181,8 @@ gbt_num_union(GBT_NUMKEY *out, const GistEntryVector *entryvec, const gbtree_nin
cur = (GBT_NUMKEY *) DatumGetPointer((entryvec->vector[0].key));
o.lower = &((GBT_NUMKEY *) out)[0];
o.upper = &((GBT_NUMKEY *) out)[tinfo->size];
o.lower = &out[0];
o.upper = &out[tinfo->size];
memcpy(out, cur, 2 * tinfo->size);

View file

@ -718,16 +718,16 @@ g_cube_internal_consistent(NDBOX *key,
switch (strategy)
{
case RTOverlapStrategyNumber:
retval = (bool) cube_overlap_v0(key, query);
retval = cube_overlap_v0(key, query);
break;
case RTSameStrategyNumber:
case RTContainsStrategyNumber:
case RTOldContainsStrategyNumber:
retval = (bool) cube_contains_v0(key, query);
retval = cube_contains_v0(key, query);
break;
case RTContainedByStrategyNumber:
case RTOldContainedByStrategyNumber:
retval = (bool) cube_overlap_v0(key, query);
retval = cube_overlap_v0(key, query);
break;
default:
retval = false;

View file

@ -327,7 +327,7 @@ GetAt(metastring *s, int pos)
if ((pos < 0) || (pos >= s->length))
return '\0';
return ((char) *(s->str + pos));
return *(s->str + pos);
}

View file

@ -133,7 +133,7 @@ mbuf_create_from_data(uint8 *data, int len)
MBuf *mbuf;
mbuf = palloc(sizeof *mbuf);
mbuf->data = (uint8 *) data;
mbuf->data = data;
mbuf->buf_end = mbuf->data + len;
mbuf->data_end = mbuf->data + len;
mbuf->read_pos = mbuf->data;

View file

@ -172,7 +172,7 @@ index_form_tuple_context(TupleDesc tupleDescriptor,
values,
#endif
isnull,
(char *) tp + hoff,
tp + hoff,
data_size,
&tupmask,
(hasnull ? (bits8 *) tp + sizeof(IndexTupleData) : NULL));

View file

@ -607,11 +607,11 @@ dataBeginPlaceToPageLeaf(GinBtree btree, Buffer buf, GinBtreeStack *stack,
if (append)
elog(DEBUG2, "appended %d new items to block %u; %d bytes (%d to go)",
maxitems, BufferGetBlockNumber(buf), (int) leaf->lsize,
maxitems, BufferGetBlockNumber(buf), leaf->lsize,
items->nitem - items->curitem - maxitems);
else
elog(DEBUG2, "inserted %d new items to block %u; %d bytes (%d to go)",
maxitems, BufferGetBlockNumber(buf), (int) leaf->lsize,
maxitems, BufferGetBlockNumber(buf), leaf->lsize,
items->nitem - items->curitem - maxitems);
}
else
@ -693,11 +693,11 @@ dataBeginPlaceToPageLeaf(GinBtree btree, Buffer buf, GinBtreeStack *stack,
if (append)
elog(DEBUG2, "appended %d items to block %u; split %d/%d (%d to go)",
maxitems, BufferGetBlockNumber(buf), (int) leaf->lsize, (int) leaf->rsize,
maxitems, BufferGetBlockNumber(buf), leaf->lsize, leaf->rsize,
items->nitem - items->curitem - maxitems);
else
elog(DEBUG2, "inserted %d items to block %u; split %d/%d (%d to go)",
maxitems, BufferGetBlockNumber(buf), (int) leaf->lsize, (int) leaf->rsize,
maxitems, BufferGetBlockNumber(buf), leaf->lsize, leaf->rsize,
items->nitem - items->curitem - maxitems);
}

View file

@ -2412,7 +2412,7 @@ _gin_parse_tuple_items(GinTuple *a)
Assert(ndecoded == a->nitems);
return (ItemPointer) items;
return items;
}
/*

View file

@ -590,7 +590,7 @@ hash_xlog_move_page_contents(XLogReaderState *record)
OffsetNumber *unend;
unused = (OffsetNumber *) ptr;
unend = (OffsetNumber *) ((char *) ptr + len);
unend = (OffsetNumber *) (ptr + len);
if ((unend - unused) > 0)
PageIndexMultiDelete(page, unused, unend - unused);
@ -901,7 +901,7 @@ hash_xlog_delete(XLogReaderState *record)
OffsetNumber *unend;
unused = (OffsetNumber *) ptr;
unend = (OffsetNumber *) ((char *) ptr + len);
unend = (OffsetNumber *) (ptr + len);
if ((unend - unused) > 0)
PageIndexMultiDelete(page, unused, unend - unused);

View file

@ -1037,7 +1037,7 @@ save_state_data(const void *data, uint32 len)
records.tail->data = palloc(records.bytes_free);
}
memcpy(((char *) records.tail->data) + records.tail->len, data, len);
memcpy(records.tail->data + records.tail->len, data, len);
records.tail->len += padlen;
records.bytes_free -= padlen;
records.total_len += padlen;

View file

@ -580,7 +580,7 @@ ExecuteGrantStmt(GrantStmt *stmt)
elog(ERROR, "AccessPriv node must specify privilege or columns");
priv = string_to_privilege(privnode->priv_name);
if (priv & ~((AclMode) all_privileges))
if (priv & ~all_privileges)
ereport(ERROR,
(errcode(ERRCODE_INVALID_GRANT_OPERATION),
errmsg(errormsg, privilege_to_string(priv))));
@ -1059,7 +1059,7 @@ ExecAlterDefaultPrivilegesStmt(ParseState *pstate, AlterDefaultPrivilegesStmt *s
elog(ERROR, "AccessPriv node must specify privilege");
priv = string_to_privilege(privnode->priv_name);
if (priv & ~((AclMode) all_privileges))
if (priv & ~all_privileges)
ereport(ERROR,
(errcode(ERRCODE_INVALID_GRANT_OPERATION),
errmsg(errormsg, privilege_to_string(priv))));

View file

@ -6205,7 +6205,7 @@ ATRewriteTable(AlteredTableInfo *tab, Oid OIDNewHeap)
NewColumnValue *ex = lfirst(l);
/* expr already planned */
ex->exprstate = ExecInitExpr((Expr *) ex->expr, NULL);
ex->exprstate = ExecInitExpr(ex->expr, NULL);
}
notnull_attrs = notnull_virtual_attrs = NIL;

View file

@ -4807,7 +4807,7 @@ ExecInitJsonExpr(JsonExpr *jsexpr, ExprState *state,
var->typid = exprType((Node *) argexpr);
var->typmod = exprTypmod((Node *) argexpr);
ExecInitExprRec((Expr *) argexpr, state, &var->value, &var->isnull);
ExecInitExprRec(argexpr, state, &var->value, &var->isnull);
jsestate->args = lappend(jsestate->args, var);
}

View file

@ -3283,7 +3283,7 @@ ExecEvalNextValueExpr(ExprState *state, ExprEvalStep *op)
*op->resvalue = Int32GetDatum((int32) newval);
break;
case INT8OID:
*op->resvalue = Int64GetDatum((int64) newval);
*op->resvalue = Int64GetDatum(newval);
break;
default:
elog(ERROR, "unsupported sequence type %u",

View file

@ -856,7 +856,7 @@ ExecInitPartitionInfo(ModifyTableState *mtstate, EState *estate,
&found_whole_row);
/* We ignore the value of found_whole_row. */
onconfl->oc_WhereClause =
ExecInitQual((List *) clause, &mtstate->ps);
ExecInitQual(clause, &mtstate->ps);
}
}
}

View file

@ -363,7 +363,7 @@ tfuncInitialize(TableFuncScanState *tstate, ExprContext *econtext, Datum doc)
char *ns_uri;
char *ns_name;
value = ExecEvalExpr((ExprState *) expr, econtext, &isnull);
value = ExecEvalExpr(expr, econtext, &isnull);
if (isnull)
ereport(ERROR,
(errcode(ERRCODE_NULL_VALUE_NOT_ALLOWED),

View file

@ -47,8 +47,8 @@ alloc_pool(PlannerInfo *root, int pool_size, int string_length)
/* pool */
new_pool = (Pool *) palloc(sizeof(Pool));
new_pool->size = (int) pool_size;
new_pool->string_length = (int) string_length;
new_pool->size = pool_size;
new_pool->string_length = string_length;
/* all chromosome */
new_pool->data = (Chromosome *) palloc(pool_size * sizeof(Chromosome));

View file

@ -3949,7 +3949,7 @@ make_grouping_rel(PlannerInfo *root, RelOptInfo *input_rel,
* target list and HAVING quals are parallel-safe.
*/
if (input_rel->consider_parallel && target_parallel_safe &&
is_parallel_safe(root, (Node *) havingQual))
is_parallel_safe(root, havingQual))
grouped_rel->consider_parallel = true;
/*
@ -8525,7 +8525,7 @@ create_unique_paths(PlannerInfo *root, RelOptInfo *rel, SpecialJoinInfo *sjinfo)
tle = tlist_member(uniqexpr, newtlist);
if (!tle)
{
tle = makeTargetEntry((Expr *) uniqexpr,
tle = makeTargetEntry(uniqexpr,
nextresno,
NULL,
false);

View file

@ -3865,7 +3865,7 @@ reparameterize_path(PlannerInfo *root, Path *path,
case T_SeqScan:
return create_seqscan_path(root, rel, required_outer, 0);
case T_SampleScan:
return (Path *) create_samplescan_path(root, rel, required_outer);
return create_samplescan_path(root, rel, required_outer);
case T_IndexScan:
case T_IndexOnlyScan:
{

View file

@ -429,7 +429,7 @@ transformStmt(ParseState *pstate, Node *parseTree)
*/
result = makeNode(Query);
result->commandType = CMD_UTILITY;
result->utilityStmt = (Node *) parseTree;
result->utilityStmt = parseTree;
break;
}

View file

@ -327,7 +327,7 @@ transformExprRecurse(ParseState *pstate, Node *expr)
case T_CaseTestExpr:
case T_Var:
{
result = (Node *) expr;
result = expr;
break;
}
@ -4079,7 +4079,7 @@ transformJsonParseArg(ParseState *pstate, Node *jsexpr, JsonFormat *format,
if (*exprtype == UNKNOWNOID || typcategory == TYPCATEGORY_STRING)
{
expr = coerce_to_target_type(pstate, (Node *) expr, *exprtype,
expr = coerce_to_target_type(pstate, expr, *exprtype,
TEXTOID, -1,
COERCION_IMPLICIT,
COERCE_IMPLICIT_CAST, -1);

View file

@ -206,7 +206,7 @@ InternalIpcMemoryCreate(IpcMemoryKey memKey, Size size)
*/
if (shmctl(shmid, IPC_RMID, NULL) < 0)
elog(LOG, "shmctl(%d, %d, 0) failed: %m",
(int) shmid, IPC_RMID);
shmid, IPC_RMID);
}
}

View file

@ -3074,7 +3074,7 @@ InitWalSenderSlot(void)
SpinLockRelease(&walsnd->mutex);
/* don't need the lock anymore */
MyWalSnd = (WalSnd *) walsnd;
MyWalSnd = walsnd;
break;
}

View file

@ -3784,7 +3784,7 @@ rewriteTargetView(Query *parsetree, Relation view)
parsetree->hasSubLinks = checkExprHasSubLink(viewqual);
}
else
AddQual(parsetree, (Node *) viewqual);
AddQual(parsetree, viewqual);
}
/*

View file

@ -785,7 +785,7 @@ dependency_is_compatible_clause(Node *clause, Index relid, AttrNumber *attnum)
* A boolean expression "x" can be interpreted as "x = true", so
* proceed with seeing if it's a suitable Var.
*/
clause_expr = (Node *) clause;
clause_expr = clause;
}
/*
@ -1212,7 +1212,7 @@ dependency_is_compatible_expression(Node *clause, Index relid, List *statlist, N
* A boolean expression "x" can be interpreted as "x = true", so
* proceed with seeing if it's a suitable Var.
*/
clause_expr = (Node *) clause;
clause_expr = clause;
}
/*

View file

@ -2054,13 +2054,13 @@ examine_opclause_args(List *args, Node **exprp, Const **cstp,
if (IsA(rightop, Const))
{
expr = (Node *) leftop;
expr = leftop;
cst = (Const *) rightop;
expronleft = true;
}
else if (IsA(leftop, Const))
{
expr = (Node *) rightop;
expr = rightop;
cst = (Const *) leftop;
expronleft = false;
}

View file

@ -1037,7 +1037,7 @@ statext_mcv_deserialize(bytea *data)
/* pointer to the data part (skip the varlena header) */
raw = (char *) data;
ptr = VARDATA_ANY(raw);
endptr = (char *) raw + VARSIZE_ANY(data);
endptr = raw + VARSIZE_ANY(data);
/* get the header and perform further sanity checks */
memcpy(&mcvlist->magic, ptr, sizeof(uint32));

View file

@ -603,7 +603,7 @@ pgaio_io_wait(PgAioHandle *ioh, uint64 ref_generation)
if (pgaio_io_was_recycled(ioh, ref_generation, &state))
return;
switch ((PgAioHandleState) state)
switch (state)
{
case PGAIO_HS_IDLE:
case PGAIO_HS_HANDED_OUT:
@ -908,7 +908,7 @@ static const char *
pgaio_io_state_get_name(PgAioHandleState s)
{
#define PGAIO_HS_TOSTR_CASE(sym) case PGAIO_HS_##sym: return #sym
switch ((PgAioHandleState) s)
switch (s)
{
PGAIO_HS_TOSTR_CASE(IDLE);
PGAIO_HS_TOSTR_CASE(HANDED_OUT);
@ -933,7 +933,7 @@ pgaio_io_get_state_name(PgAioHandle *ioh)
const char *
pgaio_result_status_string(PgAioResultStatus rs)
{
switch ((PgAioResultStatus) rs)
switch (rs)
{
case PGAIO_RS_UNKNOWN:
return "UNKNOWN";

View file

@ -300,7 +300,7 @@ pgaio_uring_shmem_init(bool first_time)
if (pgaio_uring_caps.mem_init_size > 0)
{
ring_mem_remain = pgaio_uring_ring_shmem_size();
ring_mem_next = (char *) shmem;
ring_mem_next = shmem;
/* align to page boundary, see also pgaio_uring_ring_shmem_size() */
ring_mem_next = (char *) TYPEALIGN(sysconf(_SC_PAGESIZE), ring_mem_next);

View file

@ -1477,7 +1477,7 @@ WaitEventSetWaitBlock(WaitEventSet *set, int cur_timeout,
struct pollfd *cur_pollfd;
/* Sleep */
rc = poll(set->pollfds, set->nevents, (int) cur_timeout);
rc = poll(set->pollfds, set->nevents, cur_timeout);
/* Check return code */
if (rc < 0)

View file

@ -4988,7 +4988,7 @@ predicatelock_twophase_recover(FullTransactionId fxid, uint16 info,
HASH_ENTER, &found);
Assert(sxid != NULL);
Assert(!found);
sxid->myXact = (SERIALIZABLEXACT *) sxact;
sxid->myXact = sxact;
/*
* Update global xmin. Note that this is a special case compared to

View file

@ -244,7 +244,7 @@ InitProcGlobal(void)
MemSet(ptr, 0, requestSize);
procs = (PGPROC *) ptr;
ptr = (char *) ptr + TotalProcs * sizeof(PGPROC);
ptr = ptr + TotalProcs * sizeof(PGPROC);
ProcGlobal->allProcs = procs;
/* XXX allProcCount isn't really all of them; it excludes prepared xacts */
@ -258,13 +258,13 @@ InitProcGlobal(void)
* how hotly they are accessed.
*/
ProcGlobal->xids = (TransactionId *) ptr;
ptr = (char *) ptr + (TotalProcs * sizeof(*ProcGlobal->xids));
ptr = ptr + (TotalProcs * sizeof(*ProcGlobal->xids));
ProcGlobal->subxidStates = (XidCacheStatus *) ptr;
ptr = (char *) ptr + (TotalProcs * sizeof(*ProcGlobal->subxidStates));
ptr = ptr + (TotalProcs * sizeof(*ProcGlobal->subxidStates));
ProcGlobal->statusFlags = (uint8 *) ptr;
ptr = (char *) ptr + (TotalProcs * sizeof(*ProcGlobal->statusFlags));
ptr = ptr + (TotalProcs * sizeof(*ProcGlobal->statusFlags));
/* make sure wer didn't overflow */
Assert((ptr > (char *) procs) && (ptr <= (char *) procs + requestSize));

View file

@ -2257,7 +2257,7 @@ array_set_element(Datum arraydatum,
resultarray = (char *) palloc(arraytyplen);
memcpy(resultarray, DatumGetPointer(arraydatum), arraytyplen);
elt_ptr = (char *) resultarray + indx[0] * elmlen;
elt_ptr = resultarray + indx[0] * elmlen;
ArrayCastAndSet(dataValue, elmlen, elmbyval, elmalign, elt_ptr);
return PointerGetDatum(resultarray);
}
@ -2418,7 +2418,7 @@ array_set_element(Datum arraydatum,
olditemlen = att_addlength_pointer(0, elmlen, elt_ptr);
olditemlen = att_align_nominal(olditemlen, elmalign);
}
lenafter = (int) (olddatasize - lenbefore - olditemlen);
lenafter = olddatasize - lenbefore - olditemlen;
}
if (isNull)

View file

@ -5414,8 +5414,7 @@ setPathObject(JsonbIterator **it, const Datum *path_elems, const bool *path_null
newkey.val.string.len = VARSIZE_ANY_EXHDR(pathelem);
(void) pushJsonbValue(st, WJB_KEY, &newkey);
(void) push_path(st, level, path_elems, path_nulls,
path_len, newval);
push_path(st, level, path_elems, path_nulls, path_len, newval);
/* Result is closed with WJB_END_OBJECT outside of this function */
}
@ -5583,8 +5582,7 @@ setPathArray(JsonbIterator **it, const Datum *path_elems, const bool *path_nulls
if (idx > 0)
push_null_elements(st, idx - nelems);
(void) push_path(st, level, path_elems, path_nulls,
path_len, newval);
push_path(st, level, path_elems, path_nulls, path_len, newval);
/* Result is closed with WJB_END_OBJECT outside of this function */
}

View file

@ -10151,7 +10151,7 @@ get_rule_expr(Node *node, deparse_context *context,
if (needcomma)
appendStringInfoString(buf, ", ");
get_rule_expr((Node *) e, context, true);
get_rule_expr(e, context, true);
appendStringInfo(buf, " AS %s",
quote_identifier(map_xml_name_to_sql_identifier(argname)));
needcomma = true;

View file

@ -2182,7 +2182,7 @@ selectDumpableCast(CastInfo *cast, Archive *fout)
* This would be DUMP_COMPONENT_ACL for from-initdb casts, but they do not
* support ACLs currently.
*/
if (cast->dobj.catId.oid <= (Oid) g_last_builtin_oid)
if (cast->dobj.catId.oid <= g_last_builtin_oid)
cast->dobj.dump = DUMP_COMPONENT_NONE;
else
cast->dobj.dump = fout->dopt->include_everything ?
@ -2214,7 +2214,7 @@ selectDumpableProcLang(ProcLangInfo *plang, Archive *fout)
plang->dobj.dump = DUMP_COMPONENT_NONE;
else
{
if (plang->dobj.catId.oid <= (Oid) g_last_builtin_oid)
if (plang->dobj.catId.oid <= g_last_builtin_oid)
plang->dobj.dump = fout->remoteVersion < 90600 ?
DUMP_COMPONENT_NONE : DUMP_COMPONENT_ACL;
else
@ -2247,7 +2247,7 @@ selectDumpableAccessMethod(AccessMethodInfo *method, Archive *fout)
* This would be DUMP_COMPONENT_ACL for from-initdb access methods, but
* they do not support ACLs currently.
*/
if (method->dobj.catId.oid <= (Oid) g_last_builtin_oid)
if (method->dobj.catId.oid <= g_last_builtin_oid)
method->dobj.dump = DUMP_COMPONENT_NONE;
else
method->dobj.dump = fout->dopt->include_everything ?
@ -2273,7 +2273,7 @@ selectDumpableExtension(ExtensionInfo *extinfo, DumpOptions *dopt)
* change permissions on their member objects, if they wish to, and have
* those changes preserved.
*/
if (extinfo->dobj.catId.oid <= (Oid) g_last_builtin_oid)
if (extinfo->dobj.catId.oid <= g_last_builtin_oid)
extinfo->dobj.dump = extinfo->dobj.dump_contains = DUMP_COMPONENT_ACL;
else
{

View file

@ -277,7 +277,7 @@ sha1_result(uint8 *digest0, pg_sha1_ctx *ctx)
{
uint8 *digest;
digest = (uint8 *) digest0;
digest = digest0;
#ifdef WORDS_BIGENDIAN
memmove(digest, &ctx->h.b8[0], 20);
@ -337,7 +337,7 @@ pg_sha1_update(pg_sha1_ctx *ctx, const uint8 *data, size_t len)
size_t off;
size_t copysiz;
input = (const uint8 *) data;
input = data;
off = 0;
while (off < len)

View file

@ -113,7 +113,7 @@ get_int_item(int lineno, void *var, enum ECPGttype vartype, int value)
*(short *) var = (short) value;
break;
case ECPGt_int:
*(int *) var = (int) value;
*(int *) var = value;
break;
case ECPGt_long:
*(long *) var = (long) value;

View file

@ -54,7 +54,7 @@ quote_postgres(char *arg, bool quote, int lineno)
{
length = strlen(arg);
buffer_len = 2 * length + 1;
res = (char *) ecpg_alloc(buffer_len + 3, lineno);
res = ecpg_alloc(buffer_len + 3, lineno);
if (!res)
return res;
escaped_len = PQescapeString(res + 1, arg, buffer_len);
@ -263,7 +263,7 @@ ecpg_is_type_an_array(int type, const struct statement *stmt, const struct varia
return cache_entry->isarray;
}
array_query = (char *) ecpg_alloc(strlen("select typlen from pg_type where oid= and typelem<>0") + 11, stmt->lineno);
array_query = ecpg_alloc(strlen("select typlen from pg_type where oid= and typelem<>0") + 11, stmt->lineno);
if (array_query == NULL)
return ECPG_ARRAY_ERROR;
@ -391,7 +391,7 @@ ecpg_store_result(const PGresult *results, int act_field,
}
ecpg_log("ecpg_store_result on line %d: allocating memory for %d tuples\n", stmt->lineno, ntuples);
var->value = (char *) ecpg_auto_alloc(len, stmt->lineno);
var->value = ecpg_auto_alloc(len, stmt->lineno);
if (!var->value)
return false;
*((char **) var->pointer) = var->value;
@ -402,7 +402,7 @@ ecpg_store_result(const PGresult *results, int act_field,
{
int len = var->ind_offset * ntuples;
var->ind_value = (char *) ecpg_auto_alloc(len, stmt->lineno);
var->ind_value = ecpg_auto_alloc(len, stmt->lineno);
if (!var->ind_value)
return false;
*((char **) var->ind_pointer) = var->ind_value;
@ -822,7 +822,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
struct ECPGgeneric_bytea *variable =
(struct ECPGgeneric_bytea *) (var->value);
if (!(mallocedval = (char *) ecpg_alloc(variable->len, lineno)))
if (!(mallocedval = ecpg_alloc(variable->len, lineno)))
return false;
memcpy(mallocedval, variable->arr, variable->len);
@ -835,7 +835,7 @@ ecpg_store_input(const int lineno, const bool force_indicator, const struct vari
struct ECPGgeneric_varchar *variable =
(struct ECPGgeneric_varchar *) (var->value);
if (!(newcopy = (char *) ecpg_alloc(variable->len + 1, lineno)))
if (!(newcopy = ecpg_alloc(variable->len + 1, lineno)))
return false;
strncpy(newcopy, variable->arr, variable->len);
@ -1128,9 +1128,7 @@ insert_tobeinserted(int position, int ph_len, struct statement *stmt, char *tobe
{
char *newcopy;
if (!(newcopy = (char *) ecpg_alloc(strlen(stmt->command)
+ strlen(tobeinserted)
+ 1, stmt->lineno)))
if (!(newcopy = ecpg_alloc(strlen(stmt->command) + strlen(tobeinserted) + 1, stmt->lineno)))
{
ecpg_free(tobeinserted);
return false;
@ -1536,7 +1534,7 @@ ecpg_build_params(struct statement *stmt)
int buffersize = sizeof(int) * CHAR_BIT * 10 / 3; /* a rough guess of the
* size we need */
if (!(tobeinserted = (char *) ecpg_alloc(buffersize, stmt->lineno)))
if (!(tobeinserted = ecpg_alloc(buffersize, stmt->lineno)))
{
ecpg_free_params(stmt, false);
return false;

View file

@ -138,14 +138,14 @@ replace_variables(char **text, int lineno)
char *buffer,
*newcopy;
if (!(buffer = (char *) ecpg_alloc(buffersize, lineno)))
if (!(buffer = ecpg_alloc(buffersize, lineno)))
return false;
snprintf(buffer, buffersize, "$%d", counter++);
for (len = 1; (*text)[ptr + len] && isvarchar((*text)[ptr + len]); len++)
/* skip */ ;
if (!(newcopy = (char *) ecpg_alloc(strlen(*text) - len + strlen(buffer) + 1, lineno)))
if (!(newcopy = ecpg_alloc(strlen(*text) - len + strlen(buffer) + 1, lineno)))
{
ecpg_free(buffer);
return false;
@ -302,7 +302,7 @@ deallocate_one(int lineno, enum COMPAT_MODE c, struct connection *con,
char *text;
PGresult *query;
text = (char *) ecpg_alloc(strlen("deallocate \"\" ") + strlen(this->name), this->stmt->lineno);
text = ecpg_alloc(strlen("deallocate \"\" ") + strlen(this->name), this->stmt->lineno);
if (text)
{

View file

@ -62,7 +62,7 @@ initialize_ntdll(void)
return -1;
}
*(pg_funcptr_t *) routines[i].address = address;
*routines[i].address = address;
}
initialized = true;

View file

@ -219,7 +219,7 @@ test_basic(rt_node_class_test_elem *test_info, int shift, bool asc)
TestValueType update = keys[i] + 1;
/* rt_set should report the key found */
EXPECT_TRUE(rt_set(radixtree, keys[i], (TestValueType *) &update));
EXPECT_TRUE(rt_set(radixtree, keys[i], &update));
}
/* delete and re-insert keys */