1
0
mirror of https://github.com/postgres/postgres.git synced 2025-04-25 21:42:33 +03:00

Remove unnecessary casts

Some code carefully cast all data buffer arguments for data write and
read function calls to void *, even though the respective arguments
are already void *.  Remove this unnecessary clutter.

Discussion: https://www.postgresql.org/message-id/flat/11dda853-bb5b-59ba-a746-e168b1ce4bdb%40enterprisedb.com
This commit is contained in:
Peter Eisentraut 2022-12-30 10:02:59 +01:00
parent 388e80132c
commit 5f2f99c9c6
5 changed files with 23 additions and 23 deletions

View File

@ -2961,10 +2961,10 @@ hashagg_spill_tuple(AggState *aggstate, HashAggSpill *spill,
tape = spill->partitions[partition]; tape = spill->partitions[partition];
LogicalTapeWrite(tape, (void *) &hash, sizeof(uint32)); LogicalTapeWrite(tape, &hash, sizeof(uint32));
total_written += sizeof(uint32); total_written += sizeof(uint32);
LogicalTapeWrite(tape, (void *) tuple, tuple->t_len); LogicalTapeWrite(tape, tuple, tuple->t_len);
total_written += tuple->t_len; total_written += tuple->t_len;
if (shouldFree) if (shouldFree)
@ -3029,7 +3029,7 @@ hashagg_batch_read(HashAggBatch *batch, uint32 *hashp)
tuple->t_len = t_len; tuple->t_len = t_len;
nread = LogicalTapeRead(tape, nread = LogicalTapeRead(tape,
(void *) ((char *) tuple + sizeof(uint32)), (char *) tuple + sizeof(uint32),
t_len - sizeof(uint32)); t_len - sizeof(uint32));
if (nread != t_len - sizeof(uint32)) if (nread != t_len - sizeof(uint32))
ereport(ERROR, ereport(ERROR,

View File

@ -607,7 +607,7 @@ BufFileRead(BufFile *file, void *ptr, size_t size)
memcpy(ptr, file->buffer.data + file->pos, nthistime); memcpy(ptr, file->buffer.data + file->pos, nthistime);
file->pos += nthistime; file->pos += nthistime;
ptr = (void *) ((char *) ptr + nthistime); ptr = (char *) ptr + nthistime;
size -= nthistime; size -= nthistime;
nread += nthistime; nread += nthistime;
} }
@ -655,7 +655,7 @@ BufFileWrite(BufFile *file, void *ptr, size_t size)
file->pos += nthistime; file->pos += nthistime;
if (file->nbytes < file->pos) if (file->nbytes < file->pos)
file->nbytes = file->pos; file->nbytes = file->pos;
ptr = (void *) ((char *) ptr + nthistime); ptr = (char *) ptr + nthistime;
size -= nthistime; size -= nthistime;
} }
} }

View File

@ -319,7 +319,7 @@ ltsReadFillBuffer(LogicalTape *lt)
datablocknum += lt->offsetBlockNumber; datablocknum += lt->offsetBlockNumber;
/* Read the block */ /* Read the block */
ltsReadBlock(lt->tapeSet, datablocknum, (void *) thisbuf); ltsReadBlock(lt->tapeSet, datablocknum, thisbuf);
if (!lt->frozen) if (!lt->frozen)
ltsReleaseBlock(lt->tapeSet, datablocknum); ltsReleaseBlock(lt->tapeSet, datablocknum);
lt->curBlockNumber = lt->nextBlockNumber; lt->curBlockNumber = lt->nextBlockNumber;
@ -806,7 +806,7 @@ LogicalTapeWrite(LogicalTape *lt, void *ptr, size_t size)
/* set the next-pointer and dump the current block. */ /* set the next-pointer and dump the current block. */
TapeBlockGetTrailer(lt->buffer)->next = nextBlockNumber; TapeBlockGetTrailer(lt->buffer)->next = nextBlockNumber;
ltsWriteBlock(lt->tapeSet, lt->curBlockNumber, (void *) lt->buffer); ltsWriteBlock(lt->tapeSet, lt->curBlockNumber, lt->buffer);
/* initialize the prev-pointer of the next block */ /* initialize the prev-pointer of the next block */
TapeBlockGetTrailer(lt->buffer)->prev = lt->curBlockNumber; TapeBlockGetTrailer(lt->buffer)->prev = lt->curBlockNumber;
@ -826,7 +826,7 @@ LogicalTapeWrite(LogicalTape *lt, void *ptr, size_t size)
lt->pos += nthistime; lt->pos += nthistime;
if (lt->nbytes < lt->pos) if (lt->nbytes < lt->pos)
lt->nbytes = lt->pos; lt->nbytes = lt->pos;
ptr = (void *) ((char *) ptr + nthistime); ptr = (char *) ptr + nthistime;
size -= nthistime; size -= nthistime;
} }
} }
@ -888,7 +888,7 @@ LogicalTapeRewindForRead(LogicalTape *lt, size_t buffer_size)
lt->buffer_size - lt->nbytes); lt->buffer_size - lt->nbytes);
TapeBlockSetNBytes(lt->buffer, lt->nbytes); TapeBlockSetNBytes(lt->buffer, lt->nbytes);
ltsWriteBlock(lt->tapeSet, lt->curBlockNumber, (void *) lt->buffer); ltsWriteBlock(lt->tapeSet, lt->curBlockNumber, lt->buffer);
} }
lt->writing = false; lt->writing = false;
} }
@ -953,7 +953,7 @@ LogicalTapeRead(LogicalTape *lt, void *ptr, size_t size)
memcpy(ptr, lt->buffer + lt->pos, nthistime); memcpy(ptr, lt->buffer + lt->pos, nthistime);
lt->pos += nthistime; lt->pos += nthistime;
ptr = (void *) ((char *) ptr + nthistime); ptr = (char *) ptr + nthistime;
size -= nthistime; size -= nthistime;
nread += nthistime; nread += nthistime;
} }
@ -1004,7 +1004,7 @@ LogicalTapeFreeze(LogicalTape *lt, TapeShare *share)
lt->buffer_size - lt->nbytes); lt->buffer_size - lt->nbytes);
TapeBlockSetNBytes(lt->buffer, lt->nbytes); TapeBlockSetNBytes(lt->buffer, lt->nbytes);
ltsWriteBlock(lt->tapeSet, lt->curBlockNumber, (void *) lt->buffer); ltsWriteBlock(lt->tapeSet, lt->curBlockNumber, lt->buffer);
} }
lt->writing = false; lt->writing = false;
lt->frozen = true; lt->frozen = true;
@ -1031,7 +1031,7 @@ LogicalTapeFreeze(LogicalTape *lt, TapeShare *share)
if (lt->firstBlockNumber == -1L) if (lt->firstBlockNumber == -1L)
lt->nextBlockNumber = -1L; lt->nextBlockNumber = -1L;
ltsReadBlock(lt->tapeSet, lt->curBlockNumber, (void *) lt->buffer); ltsReadBlock(lt->tapeSet, lt->curBlockNumber, lt->buffer);
if (TapeBlockIsLast(lt->buffer)) if (TapeBlockIsLast(lt->buffer))
lt->nextBlockNumber = -1L; lt->nextBlockNumber = -1L;
else else
@ -1098,7 +1098,7 @@ LogicalTapeBackspace(LogicalTape *lt, size_t size)
return seekpos; return seekpos;
} }
ltsReadBlock(lt->tapeSet, prev, (void *) lt->buffer); ltsReadBlock(lt->tapeSet, prev, lt->buffer);
if (TapeBlockGetTrailer(lt->buffer)->next != lt->curBlockNumber) if (TapeBlockGetTrailer(lt->buffer)->next != lt->curBlockNumber)
elog(ERROR, "broken tape, next of block %ld is %ld, expected %ld", elog(ERROR, "broken tape, next of block %ld is %ld, expected %ld",
@ -1142,7 +1142,7 @@ LogicalTapeSeek(LogicalTape *lt, long blocknum, int offset)
if (blocknum != lt->curBlockNumber) if (blocknum != lt->curBlockNumber)
{ {
ltsReadBlock(lt->tapeSet, blocknum, (void *) lt->buffer); ltsReadBlock(lt->tapeSet, blocknum, lt->buffer);
lt->curBlockNumber = blocknum; lt->curBlockNumber = blocknum;
lt->nbytes = TapeBlockPayloadSize; lt->nbytes = TapeBlockPayloadSize;
lt->nextBlockNumber = TapeBlockGetTrailer(lt->buffer)->next; lt->nextBlockNumber = TapeBlockGetTrailer(lt->buffer)->next;

View File

@ -2908,7 +2908,7 @@ markrunend(LogicalTape *tape)
{ {
unsigned int len = 0; unsigned int len = 0;
LogicalTapeWrite(tape, (void *) &len, sizeof(len)); LogicalTapeWrite(tape, &len, sizeof(len));
} }
/* /*

View File

@ -1002,10 +1002,10 @@ writetup_heap(Tuplesortstate *state, LogicalTape *tape, SortTuple *stup)
/* total on-disk footprint: */ /* total on-disk footprint: */
unsigned int tuplen = tupbodylen + sizeof(int); unsigned int tuplen = tupbodylen + sizeof(int);
LogicalTapeWrite(tape, (void *) &tuplen, sizeof(tuplen)); LogicalTapeWrite(tape, &tuplen, sizeof(tuplen));
LogicalTapeWrite(tape, (void *) tupbody, tupbodylen); LogicalTapeWrite(tape, tupbody, tupbodylen);
if (base->sortopt & TUPLESORT_RANDOMACCESS) /* need trailing length word? */ if (base->sortopt & TUPLESORT_RANDOMACCESS) /* need trailing length word? */
LogicalTapeWrite(tape, (void *) &tuplen, sizeof(tuplen)); LogicalTapeWrite(tape, &tuplen, sizeof(tuplen));
} }
static void static void
@ -1475,10 +1475,10 @@ writetup_index(Tuplesortstate *state, LogicalTape *tape, SortTuple *stup)
unsigned int tuplen; unsigned int tuplen;
tuplen = IndexTupleSize(tuple) + sizeof(tuplen); tuplen = IndexTupleSize(tuple) + sizeof(tuplen);
LogicalTapeWrite(tape, (void *) &tuplen, sizeof(tuplen)); LogicalTapeWrite(tape, &tuplen, sizeof(tuplen));
LogicalTapeWrite(tape, (void *) tuple, IndexTupleSize(tuple)); LogicalTapeWrite(tape, tuple, IndexTupleSize(tuple));
if (base->sortopt & TUPLESORT_RANDOMACCESS) /* need trailing length word? */ if (base->sortopt & TUPLESORT_RANDOMACCESS) /* need trailing length word? */
LogicalTapeWrite(tape, (void *) &tuplen, sizeof(tuplen)); LogicalTapeWrite(tape, &tuplen, sizeof(tuplen));
} }
static void static void
@ -1564,10 +1564,10 @@ writetup_datum(Tuplesortstate *state, LogicalTape *tape, SortTuple *stup)
writtenlen = tuplen + sizeof(unsigned int); writtenlen = tuplen + sizeof(unsigned int);
LogicalTapeWrite(tape, (void *) &writtenlen, sizeof(writtenlen)); LogicalTapeWrite(tape, &writtenlen, sizeof(writtenlen));
LogicalTapeWrite(tape, waddr, tuplen); LogicalTapeWrite(tape, waddr, tuplen);
if (base->sortopt & TUPLESORT_RANDOMACCESS) /* need trailing length word? */ if (base->sortopt & TUPLESORT_RANDOMACCESS) /* need trailing length word? */
LogicalTapeWrite(tape, (void *) &writtenlen, sizeof(writtenlen)); LogicalTapeWrite(tape, &writtenlen, sizeof(writtenlen));
} }
static void static void