mirror of
https://git.postgresql.org/git/postgresql.git
synced 2025-01-06 15:24:56 +08: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:
parent
388e80132c
commit
5f2f99c9c6
@ -2961,10 +2961,10 @@ hashagg_spill_tuple(AggState *aggstate, HashAggSpill *spill,
|
||||
|
||||
tape = spill->partitions[partition];
|
||||
|
||||
LogicalTapeWrite(tape, (void *) &hash, sizeof(uint32));
|
||||
LogicalTapeWrite(tape, &hash, sizeof(uint32));
|
||||
total_written += sizeof(uint32);
|
||||
|
||||
LogicalTapeWrite(tape, (void *) tuple, tuple->t_len);
|
||||
LogicalTapeWrite(tape, tuple, tuple->t_len);
|
||||
total_written += tuple->t_len;
|
||||
|
||||
if (shouldFree)
|
||||
@ -3029,7 +3029,7 @@ hashagg_batch_read(HashAggBatch *batch, uint32 *hashp)
|
||||
tuple->t_len = t_len;
|
||||
|
||||
nread = LogicalTapeRead(tape,
|
||||
(void *) ((char *) tuple + sizeof(uint32)),
|
||||
(char *) tuple + sizeof(uint32),
|
||||
t_len - sizeof(uint32));
|
||||
if (nread != t_len - sizeof(uint32))
|
||||
ereport(ERROR,
|
||||
|
@ -607,7 +607,7 @@ BufFileRead(BufFile *file, void *ptr, size_t size)
|
||||
memcpy(ptr, file->buffer.data + file->pos, nthistime);
|
||||
|
||||
file->pos += nthistime;
|
||||
ptr = (void *) ((char *) ptr + nthistime);
|
||||
ptr = (char *) ptr + nthistime;
|
||||
size -= nthistime;
|
||||
nread += nthistime;
|
||||
}
|
||||
@ -655,7 +655,7 @@ BufFileWrite(BufFile *file, void *ptr, size_t size)
|
||||
file->pos += nthistime;
|
||||
if (file->nbytes < file->pos)
|
||||
file->nbytes = file->pos;
|
||||
ptr = (void *) ((char *) ptr + nthistime);
|
||||
ptr = (char *) ptr + nthistime;
|
||||
size -= nthistime;
|
||||
}
|
||||
}
|
||||
|
@ -319,7 +319,7 @@ ltsReadFillBuffer(LogicalTape *lt)
|
||||
datablocknum += lt->offsetBlockNumber;
|
||||
|
||||
/* Read the block */
|
||||
ltsReadBlock(lt->tapeSet, datablocknum, (void *) thisbuf);
|
||||
ltsReadBlock(lt->tapeSet, datablocknum, thisbuf);
|
||||
if (!lt->frozen)
|
||||
ltsReleaseBlock(lt->tapeSet, datablocknum);
|
||||
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. */
|
||||
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 */
|
||||
TapeBlockGetTrailer(lt->buffer)->prev = lt->curBlockNumber;
|
||||
@ -826,7 +826,7 @@ LogicalTapeWrite(LogicalTape *lt, void *ptr, size_t size)
|
||||
lt->pos += nthistime;
|
||||
if (lt->nbytes < lt->pos)
|
||||
lt->nbytes = lt->pos;
|
||||
ptr = (void *) ((char *) ptr + nthistime);
|
||||
ptr = (char *) ptr + nthistime;
|
||||
size -= nthistime;
|
||||
}
|
||||
}
|
||||
@ -888,7 +888,7 @@ LogicalTapeRewindForRead(LogicalTape *lt, size_t buffer_size)
|
||||
lt->buffer_size - 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;
|
||||
}
|
||||
@ -953,7 +953,7 @@ LogicalTapeRead(LogicalTape *lt, void *ptr, size_t size)
|
||||
memcpy(ptr, lt->buffer + lt->pos, nthistime);
|
||||
|
||||
lt->pos += nthistime;
|
||||
ptr = (void *) ((char *) ptr + nthistime);
|
||||
ptr = (char *) ptr + nthistime;
|
||||
size -= nthistime;
|
||||
nread += nthistime;
|
||||
}
|
||||
@ -1004,7 +1004,7 @@ LogicalTapeFreeze(LogicalTape *lt, TapeShare *share)
|
||||
lt->buffer_size - 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->frozen = true;
|
||||
@ -1031,7 +1031,7 @@ LogicalTapeFreeze(LogicalTape *lt, TapeShare *share)
|
||||
|
||||
if (lt->firstBlockNumber == -1L)
|
||||
lt->nextBlockNumber = -1L;
|
||||
ltsReadBlock(lt->tapeSet, lt->curBlockNumber, (void *) lt->buffer);
|
||||
ltsReadBlock(lt->tapeSet, lt->curBlockNumber, lt->buffer);
|
||||
if (TapeBlockIsLast(lt->buffer))
|
||||
lt->nextBlockNumber = -1L;
|
||||
else
|
||||
@ -1098,7 +1098,7 @@ LogicalTapeBackspace(LogicalTape *lt, size_t size)
|
||||
return seekpos;
|
||||
}
|
||||
|
||||
ltsReadBlock(lt->tapeSet, prev, (void *) lt->buffer);
|
||||
ltsReadBlock(lt->tapeSet, prev, lt->buffer);
|
||||
|
||||
if (TapeBlockGetTrailer(lt->buffer)->next != lt->curBlockNumber)
|
||||
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)
|
||||
{
|
||||
ltsReadBlock(lt->tapeSet, blocknum, (void *) lt->buffer);
|
||||
ltsReadBlock(lt->tapeSet, blocknum, lt->buffer);
|
||||
lt->curBlockNumber = blocknum;
|
||||
lt->nbytes = TapeBlockPayloadSize;
|
||||
lt->nextBlockNumber = TapeBlockGetTrailer(lt->buffer)->next;
|
||||
|
@ -2908,7 +2908,7 @@ markrunend(LogicalTape *tape)
|
||||
{
|
||||
unsigned int len = 0;
|
||||
|
||||
LogicalTapeWrite(tape, (void *) &len, sizeof(len));
|
||||
LogicalTapeWrite(tape, &len, sizeof(len));
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -1002,10 +1002,10 @@ writetup_heap(Tuplesortstate *state, LogicalTape *tape, SortTuple *stup)
|
||||
/* total on-disk footprint: */
|
||||
unsigned int tuplen = tupbodylen + sizeof(int);
|
||||
|
||||
LogicalTapeWrite(tape, (void *) &tuplen, sizeof(tuplen));
|
||||
LogicalTapeWrite(tape, (void *) tupbody, tupbodylen);
|
||||
LogicalTapeWrite(tape, &tuplen, sizeof(tuplen));
|
||||
LogicalTapeWrite(tape, tupbody, tupbodylen);
|
||||
if (base->sortopt & TUPLESORT_RANDOMACCESS) /* need trailing length word? */
|
||||
LogicalTapeWrite(tape, (void *) &tuplen, sizeof(tuplen));
|
||||
LogicalTapeWrite(tape, &tuplen, sizeof(tuplen));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1475,10 +1475,10 @@ writetup_index(Tuplesortstate *state, LogicalTape *tape, SortTuple *stup)
|
||||
unsigned int tuplen;
|
||||
|
||||
tuplen = IndexTupleSize(tuple) + sizeof(tuplen);
|
||||
LogicalTapeWrite(tape, (void *) &tuplen, sizeof(tuplen));
|
||||
LogicalTapeWrite(tape, (void *) tuple, IndexTupleSize(tuple));
|
||||
LogicalTapeWrite(tape, &tuplen, sizeof(tuplen));
|
||||
LogicalTapeWrite(tape, tuple, IndexTupleSize(tuple));
|
||||
if (base->sortopt & TUPLESORT_RANDOMACCESS) /* need trailing length word? */
|
||||
LogicalTapeWrite(tape, (void *) &tuplen, sizeof(tuplen));
|
||||
LogicalTapeWrite(tape, &tuplen, sizeof(tuplen));
|
||||
}
|
||||
|
||||
static void
|
||||
@ -1564,10 +1564,10 @@ writetup_datum(Tuplesortstate *state, LogicalTape *tape, SortTuple *stup)
|
||||
|
||||
writtenlen = tuplen + sizeof(unsigned int);
|
||||
|
||||
LogicalTapeWrite(tape, (void *) &writtenlen, sizeof(writtenlen));
|
||||
LogicalTapeWrite(tape, &writtenlen, sizeof(writtenlen));
|
||||
LogicalTapeWrite(tape, waddr, tuplen);
|
||||
if (base->sortopt & TUPLESORT_RANDOMACCESS) /* need trailing length word? */
|
||||
LogicalTapeWrite(tape, (void *) &writtenlen, sizeof(writtenlen));
|
||||
LogicalTapeWrite(tape, &writtenlen, sizeof(writtenlen));
|
||||
}
|
||||
|
||||
static void
|
||||
|
Loading…
Reference in New Issue
Block a user