1
0
mirror of https://github.com/postgres/postgres.git synced 2025-11-22 12:22:45 +03:00

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 7f798aca1d.

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:
Peter Eisentraut
2025-02-12 08:50:13 +01:00
parent 506183bce7
commit 827b4060a8
20 changed files with 44 additions and 48 deletions

View File

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

View File

@@ -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

View File

@@ -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)
{
/*

View File

@@ -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

View File

@@ -794,7 +794,7 @@ restart:
readOff = ReadPageInternal(state, targetPagePtr,
pageHeaderSize + len);
memcpy(buffer, (char *) contdata, len);
memcpy(buffer, contdata, len);
buffer += len;
gotlen += len;