Remove unnecessary (char *) casts [mem]
Remove (char *) casts around memory functions such as memcmp(), memcpy(), or memset() where the cast is useless. Since these functions don't take char * arguments anyway, these casts are at best complicated casts to (void *), about which see commit 7f798aca1d5. Reviewed-by: Dagfinn Ilmari Mannsåker <ilmari@ilmari.org> Discussion: https://www.postgresql.org/message-id/flat/fd1fcedb-3492-4fc8-9e3e-74b97f2db6c7%40eisentraut.org
This commit is contained in:
parent
506183bce7
commit
827b4060a8
@ -228,7 +228,7 @@ gtrgm_consistent(PG_FUNCTION_ARGS)
|
||||
if (cache == NULL ||
|
||||
cache->strategy != strategy ||
|
||||
VARSIZE(cache->query) != querysize ||
|
||||
memcmp((char *) cache->query, (char *) query, querysize) != 0)
|
||||
memcmp(cache->query, query, querysize) != 0)
|
||||
{
|
||||
gtrgm_consistent_cache *newcache;
|
||||
TrgmPackedGraph *graph = NULL;
|
||||
@ -284,12 +284,12 @@ gtrgm_consistent(PG_FUNCTION_ARGS)
|
||||
newcache->strategy = strategy;
|
||||
newcache->query = (text *)
|
||||
((char *) newcache + MAXALIGN(sizeof(gtrgm_consistent_cache)));
|
||||
memcpy((char *) newcache->query, (char *) query, querysize);
|
||||
memcpy(newcache->query, query, querysize);
|
||||
if (qtrg)
|
||||
{
|
||||
newcache->trigrams = (TRGM *)
|
||||
((char *) newcache->query + MAXALIGN(querysize));
|
||||
memcpy((char *) newcache->trigrams, (char *) qtrg, qtrgsize);
|
||||
memcpy((char *) newcache->trigrams, qtrg, qtrgsize);
|
||||
/* release qtrg in case it was made in fn_mcxt */
|
||||
pfree(qtrg);
|
||||
}
|
||||
|
@ -278,8 +278,8 @@ xpath_string(PG_FUNCTION_ARGS)
|
||||
/* We could try casting to string using the libxml function? */
|
||||
|
||||
xpath = (xmlChar *) palloc(pathsize + 9);
|
||||
memcpy((char *) xpath, "string(", 7);
|
||||
memcpy((char *) (xpath + 7), VARDATA_ANY(xpathsupp), pathsize);
|
||||
memcpy(xpath, "string(", 7);
|
||||
memcpy(xpath + 7, VARDATA_ANY(xpathsupp), pathsize);
|
||||
xpath[pathsize + 7] = ')';
|
||||
xpath[pathsize + 8] = '\0';
|
||||
|
||||
|
@ -787,7 +787,7 @@ heap_copytuple(HeapTuple tuple)
|
||||
newTuple->t_self = tuple->t_self;
|
||||
newTuple->t_tableOid = tuple->t_tableOid;
|
||||
newTuple->t_data = (HeapTupleHeader) ((char *) newTuple + HEAPTUPLESIZE);
|
||||
memcpy((char *) newTuple->t_data, (char *) tuple->t_data, tuple->t_len);
|
||||
memcpy(newTuple->t_data, tuple->t_data, tuple->t_len);
|
||||
return newTuple;
|
||||
}
|
||||
|
||||
@ -813,7 +813,7 @@ heap_copytuple_with_tuple(HeapTuple src, HeapTuple dest)
|
||||
dest->t_self = src->t_self;
|
||||
dest->t_tableOid = src->t_tableOid;
|
||||
dest->t_data = (HeapTupleHeader) palloc(src->t_len);
|
||||
memcpy((char *) dest->t_data, (char *) src->t_data, src->t_len);
|
||||
memcpy(dest->t_data, src->t_data, src->t_len);
|
||||
}
|
||||
|
||||
/*
|
||||
@ -1097,7 +1097,7 @@ heap_copy_tuple_as_datum(HeapTuple tuple, TupleDesc tupleDesc)
|
||||
* the given tuple came from disk, rather than from heap_form_tuple).
|
||||
*/
|
||||
td = (HeapTupleHeader) palloc(tuple->t_len);
|
||||
memcpy((char *) td, (char *) tuple->t_data, tuple->t_len);
|
||||
memcpy(td, tuple->t_data, tuple->t_len);
|
||||
|
||||
HeapTupleHeaderSetDatumLength(td, tuple->t_len);
|
||||
HeapTupleHeaderSetTypeId(td, tupleDesc->tdtypeid);
|
||||
|
@ -480,11 +480,11 @@ heap_xlog_insert(XLogReaderState *record)
|
||||
|
||||
newlen = datalen - SizeOfHeapHeader;
|
||||
Assert(datalen > SizeOfHeapHeader && newlen <= MaxHeapTupleSize);
|
||||
memcpy((char *) &xlhdr, data, SizeOfHeapHeader);
|
||||
memcpy(&xlhdr, data, SizeOfHeapHeader);
|
||||
data += SizeOfHeapHeader;
|
||||
|
||||
htup = &tbuf.hdr;
|
||||
MemSet((char *) htup, 0, SizeofHeapTupleHeader);
|
||||
MemSet(htup, 0, SizeofHeapTupleHeader);
|
||||
/* PG73FORMAT: get bitmap [+ padding] [+ oid] + data */
|
||||
memcpy((char *) htup + SizeofHeapTupleHeader,
|
||||
data,
|
||||
@ -625,10 +625,10 @@ heap_xlog_multi_insert(XLogReaderState *record)
|
||||
newlen = xlhdr->datalen;
|
||||
Assert(newlen <= MaxHeapTupleSize);
|
||||
htup = &tbuf.hdr;
|
||||
MemSet((char *) htup, 0, SizeofHeapTupleHeader);
|
||||
MemSet(htup, 0, SizeofHeapTupleHeader);
|
||||
/* PG73FORMAT: get bitmap [+ padding] [+ oid] + data */
|
||||
memcpy((char *) htup + SizeofHeapTupleHeader,
|
||||
(char *) tupdata,
|
||||
tupdata,
|
||||
newlen);
|
||||
tupdata += newlen;
|
||||
|
||||
@ -854,14 +854,14 @@ heap_xlog_update(XLogReaderState *record, bool hot_update)
|
||||
recdata += sizeof(uint16);
|
||||
}
|
||||
|
||||
memcpy((char *) &xlhdr, recdata, SizeOfHeapHeader);
|
||||
memcpy(&xlhdr, recdata, SizeOfHeapHeader);
|
||||
recdata += SizeOfHeapHeader;
|
||||
|
||||
tuplen = recdata_end - recdata;
|
||||
Assert(tuplen <= MaxHeapTupleSize);
|
||||
|
||||
htup = &tbuf.hdr;
|
||||
MemSet((char *) htup, 0, SizeofHeapTupleHeader);
|
||||
MemSet(htup, 0, SizeofHeapTupleHeader);
|
||||
|
||||
/*
|
||||
* Reconstruct the new tuple using the prefix and/or suffix from the
|
||||
|
@ -75,7 +75,7 @@ toast_tuple_init(ToastTupleContext *ttc)
|
||||
{
|
||||
if (ttc->ttc_isnull[i] ||
|
||||
!VARATT_IS_EXTERNAL_ONDISK(new_value) ||
|
||||
memcmp((char *) old_value, (char *) new_value,
|
||||
memcmp(old_value, new_value,
|
||||
VARSIZE_EXTERNAL(old_value)) != 0)
|
||||
{
|
||||
/*
|
||||
|
@ -2089,7 +2089,7 @@ AdvanceXLInsertBuffer(XLogRecPtr upto, TimeLineID tli, bool opportunistic)
|
||||
* Be sure to re-zero the buffer so that bytes beyond what we've
|
||||
* written will look like zeroes and not valid XLOG records...
|
||||
*/
|
||||
MemSet((char *) NewPage, 0, XLOG_BLCKSZ);
|
||||
MemSet(NewPage, 0, XLOG_BLCKSZ);
|
||||
|
||||
/*
|
||||
* Fill the new page's header
|
||||
|
@ -794,7 +794,7 @@ restart:
|
||||
readOff = ReadPageInternal(state, targetPagePtr,
|
||||
pageHeaderSize + len);
|
||||
|
||||
memcpy(buffer, (char *) contdata, len);
|
||||
memcpy(buffer, contdata, len);
|
||||
buffer += len;
|
||||
gotlen += len;
|
||||
|
||||
|
@ -463,8 +463,8 @@ boot_openrel(char *relname)
|
||||
{
|
||||
if (attrtypes[i] == NULL)
|
||||
attrtypes[i] = AllocateAttribute();
|
||||
memmove((char *) attrtypes[i],
|
||||
(char *) TupleDescAttr(boot_reldesc->rd_att, i),
|
||||
memmove(attrtypes[i],
|
||||
TupleDescAttr(boot_reldesc->rd_att, i),
|
||||
ATTRIBUTE_FIXED_PART_SIZE);
|
||||
|
||||
{
|
||||
|
@ -641,7 +641,7 @@ secure_open_gssapi(Port *port)
|
||||
return -1;
|
||||
}
|
||||
|
||||
memcpy(PqGSSSendBuffer, (char *) &netlen, sizeof(uint32));
|
||||
memcpy(PqGSSSendBuffer, &netlen, sizeof(uint32));
|
||||
PqGSSSendLength += sizeof(uint32);
|
||||
|
||||
memcpy(PqGSSSendBuffer + PqGSSSendLength, output.value, output.length);
|
||||
|
@ -1177,9 +1177,7 @@ DecodeMultiInsert(LogicalDecodingContext *ctx, XLogRecordBuffer *buf)
|
||||
|
||||
memset(header, 0, SizeofHeapTupleHeader);
|
||||
|
||||
memcpy((char *) tuple->t_data + SizeofHeapTupleHeader,
|
||||
(char *) data,
|
||||
datalen);
|
||||
memcpy((char *) tuple->t_data + SizeofHeapTupleHeader, data, datalen);
|
||||
header->t_infomask = xlhdr->t_infomask;
|
||||
header->t_infomask2 = xlhdr->t_infomask2;
|
||||
header->t_hoff = xlhdr->t_hoff;
|
||||
@ -1265,9 +1263,7 @@ DecodeXLogTuple(char *data, Size len, HeapTuple tuple)
|
||||
tuple->t_tableOid = InvalidOid;
|
||||
|
||||
/* data is not stored aligned, copy to aligned storage */
|
||||
memcpy((char *) &xlhdr,
|
||||
data,
|
||||
SizeOfHeapHeader);
|
||||
memcpy(&xlhdr, data, SizeOfHeapHeader);
|
||||
|
||||
memset(header, 0, SizeofHeapTupleHeader);
|
||||
|
||||
|
@ -2221,7 +2221,7 @@ ExtendBufferedRelShared(BufferManagerRelation bmr,
|
||||
buf_block = BufHdrGetBlock(GetBufferDescriptor(buffers[i] - 1));
|
||||
|
||||
/* new buffers are zero-filled */
|
||||
MemSet((char *) buf_block, 0, BLCKSZ);
|
||||
MemSet(buf_block, 0, BLCKSZ);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -338,7 +338,7 @@ ExtendBufferedRelLocal(BufferManagerRelation bmr,
|
||||
buf_block = LocalBufHdrGetBlock(buf_hdr);
|
||||
|
||||
/* new buffers are zero-filled */
|
||||
MemSet((char *) buf_block, 0, BLCKSZ);
|
||||
MemSet(buf_block, 0, BLCKSZ);
|
||||
}
|
||||
|
||||
first_block = smgrnblocks(bmr.smgr, fork);
|
||||
|
@ -910,7 +910,7 @@ InitFileAccess(void)
|
||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||
errmsg("out of memory")));
|
||||
|
||||
MemSet((char *) &(VfdCache[0]), 0, sizeof(Vfd));
|
||||
MemSet(&(VfdCache[0]), 0, sizeof(Vfd));
|
||||
VfdCache->fd = VFD_CLOSED;
|
||||
|
||||
SizeVfdCache = 1;
|
||||
@ -1447,7 +1447,7 @@ AllocateVfd(void)
|
||||
*/
|
||||
for (i = SizeVfdCache; i < newCacheSize; i++)
|
||||
{
|
||||
MemSet((char *) &(VfdCache[i]), 0, sizeof(Vfd));
|
||||
MemSet(&(VfdCache[i]), 0, sizeof(Vfd));
|
||||
VfdCache[i].nextFree = i + 1;
|
||||
VfdCache[i].fd = VFD_CLOSED;
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ PageRestoreTempPage(Page tempPage, Page oldPage)
|
||||
Size pageSize;
|
||||
|
||||
pageSize = PageGetPageSize(tempPage);
|
||||
memcpy((char *) oldPage, (char *) tempPage, pageSize);
|
||||
memcpy(oldPage, tempPage, pageSize);
|
||||
|
||||
pfree(tempPage);
|
||||
}
|
||||
@ -1094,8 +1094,8 @@ PageIndexTupleDelete(Page page, OffsetNumber offnum)
|
||||
((char *) &phdr->pd_linp[offidx + 1] - (char *) phdr);
|
||||
|
||||
if (nbytes > 0)
|
||||
memmove((char *) &(phdr->pd_linp[offidx]),
|
||||
(char *) &(phdr->pd_linp[offidx + 1]),
|
||||
memmove(&(phdr->pd_linp[offidx]),
|
||||
&(phdr->pd_linp[offidx + 1]),
|
||||
nbytes);
|
||||
|
||||
/*
|
||||
@ -1516,7 +1516,7 @@ PageSetChecksumCopy(Page page, BlockNumber blkno)
|
||||
PG_IO_ALIGN_SIZE,
|
||||
0);
|
||||
|
||||
memcpy(pageCopy, (char *) page, BLCKSZ);
|
||||
memcpy(pageCopy, page, BLCKSZ);
|
||||
((PageHeader) pageCopy)->pd_checksum = pg_checksum_page(pageCopy, blkno);
|
||||
return pageCopy;
|
||||
}
|
||||
|
@ -4991,8 +4991,8 @@ ShowUsage(const char *title)
|
||||
|
||||
getrusage(RUSAGE_SELF, &r);
|
||||
gettimeofday(&elapse_t, NULL);
|
||||
memcpy((char *) &user, (char *) &r.ru_utime, sizeof(user));
|
||||
memcpy((char *) &sys, (char *) &r.ru_stime, sizeof(sys));
|
||||
memcpy(&user, &r.ru_utime, sizeof(user));
|
||||
memcpy(&sys, &r.ru_stime, sizeof(sys));
|
||||
if (elapse_t.tv_usec < Save_t.tv_usec)
|
||||
{
|
||||
elapse_t.tv_sec--;
|
||||
|
@ -597,7 +597,7 @@ pgstat_report_activity(BackendState state, const char *cmd_str)
|
||||
|
||||
if (cmd_str != NULL)
|
||||
{
|
||||
memcpy((char *) beentry->st_activity_raw, cmd_str, len);
|
||||
memcpy(beentry->st_activity_raw, cmd_str, len);
|
||||
beentry->st_activity_raw[len] = '\0';
|
||||
beentry->st_activity_start_timestamp = start_timestamp;
|
||||
}
|
||||
@ -670,7 +670,7 @@ pgstat_report_appname(const char *appname)
|
||||
*/
|
||||
PGSTAT_BEGIN_WRITE_ACTIVITY(beentry);
|
||||
|
||||
memcpy((char *) beentry->st_appname, appname, len);
|
||||
memcpy(beentry->st_appname, appname, len);
|
||||
beentry->st_appname[len] = '\0';
|
||||
|
||||
PGSTAT_END_WRITE_ACTIVITY(beentry);
|
||||
|
@ -1035,7 +1035,7 @@ ECPG_informix_reset_sqlca(void)
|
||||
if (sqlca == NULL)
|
||||
return;
|
||||
|
||||
memcpy((char *) sqlca, (char *) &sqlca_init, sizeof(struct sqlca_t));
|
||||
memcpy(sqlca, &sqlca_init, sizeof(struct sqlca_t));
|
||||
}
|
||||
|
||||
int
|
||||
|
@ -66,7 +66,7 @@ static FILE *debugstream = NULL;
|
||||
void
|
||||
ecpg_init_sqlca(struct sqlca_t *sqlca)
|
||||
{
|
||||
memcpy((char *) sqlca, (char *) &sqlca_init, sizeof(struct sqlca_t));
|
||||
memcpy(sqlca, &sqlca_init, sizeof(struct sqlca_t));
|
||||
}
|
||||
|
||||
bool
|
||||
@ -316,10 +316,10 @@ ECPGset_noind_null(enum ECPGttype type, void *ptr)
|
||||
*((long long *) ptr) = LONG_LONG_MIN;
|
||||
break;
|
||||
case ECPGt_float:
|
||||
memset((char *) ptr, 0xff, sizeof(float));
|
||||
memset(ptr, 0xff, sizeof(float));
|
||||
break;
|
||||
case ECPGt_double:
|
||||
memset((char *) ptr, 0xff, sizeof(double));
|
||||
memset(ptr, 0xff, sizeof(double));
|
||||
break;
|
||||
case ECPGt_varchar:
|
||||
*(((struct ECPGgeneric_varchar *) ptr)->arr) = 0x00;
|
||||
@ -329,18 +329,18 @@ ECPGset_noind_null(enum ECPGttype type, void *ptr)
|
||||
((struct ECPGgeneric_bytea *) ptr)->len = 0;
|
||||
break;
|
||||
case ECPGt_decimal:
|
||||
memset((char *) ptr, 0, sizeof(decimal));
|
||||
memset(ptr, 0, sizeof(decimal));
|
||||
((decimal *) ptr)->sign = NUMERIC_NULL;
|
||||
break;
|
||||
case ECPGt_numeric:
|
||||
memset((char *) ptr, 0, sizeof(numeric));
|
||||
memset(ptr, 0, sizeof(numeric));
|
||||
((numeric *) ptr)->sign = NUMERIC_NULL;
|
||||
break;
|
||||
case ECPGt_interval:
|
||||
memset((char *) ptr, 0xff, sizeof(interval));
|
||||
memset(ptr, 0xff, sizeof(interval));
|
||||
break;
|
||||
case ECPGt_timestamp:
|
||||
memset((char *) ptr, 0xff, sizeof(timestamp));
|
||||
memset(ptr, 0xff, sizeof(timestamp));
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
@ -870,7 +870,7 @@ lo_initialize(PGconn *conn)
|
||||
libpq_append_conn_error(conn, "out of memory");
|
||||
return -1;
|
||||
}
|
||||
MemSet((char *) lobjfuncs, 0, sizeof(PGlobjfuncs));
|
||||
MemSet(lobjfuncs, 0, sizeof(PGlobjfuncs));
|
||||
|
||||
/*
|
||||
* Execute the query to get all the functions at once. (Not all of them
|
||||
|
@ -698,7 +698,7 @@ pqsecure_open_gss(PGconn *conn)
|
||||
/* Queue the token for writing */
|
||||
netlen = pg_hton32(output.length);
|
||||
|
||||
memcpy(PqGSSSendBuffer, (char *) &netlen, sizeof(uint32));
|
||||
memcpy(PqGSSSendBuffer, &netlen, sizeof(uint32));
|
||||
PqGSSSendLength += sizeof(uint32);
|
||||
|
||||
memcpy(PqGSSSendBuffer + PqGSSSendLength, output.value, output.length);
|
||||
|
Loading…
x
Reference in New Issue
Block a user