Skip to content

Commit 5f2f99c

Browse files
committed
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
1 parent 388e801 commit 5f2f99c

File tree

5 files changed

+23
-23
lines changed

5 files changed

+23
-23
lines changed

src/backend/executor/nodeAgg.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2961,10 +2961,10 @@ hashagg_spill_tuple(AggState *aggstate, HashAggSpill *spill,
29612961

29622962
tape = spill->partitions[partition];
29632963

2964-
LogicalTapeWrite(tape, (void *) &hash, sizeof(uint32));
2964+
LogicalTapeWrite(tape, &hash, sizeof(uint32));
29652965
total_written += sizeof(uint32);
29662966

2967-
LogicalTapeWrite(tape, (void *) tuple, tuple->t_len);
2967+
LogicalTapeWrite(tape, tuple, tuple->t_len);
29682968
total_written += tuple->t_len;
29692969

29702970
if (shouldFree)
@@ -3029,7 +3029,7 @@ hashagg_batch_read(HashAggBatch *batch, uint32 *hashp)
30293029
tuple->t_len = t_len;
30303030

30313031
nread = LogicalTapeRead(tape,
3032-
(void *) ((char *) tuple + sizeof(uint32)),
3032+
(char *) tuple + sizeof(uint32),
30333033
t_len - sizeof(uint32));
30343034
if (nread != t_len - sizeof(uint32))
30353035
ereport(ERROR,

src/backend/storage/file/buffile.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,7 +607,7 @@ BufFileRead(BufFile *file, void *ptr, size_t size)
607607
memcpy(ptr, file->buffer.data + file->pos, nthistime);
608608

609609
file->pos += nthistime;
610-
ptr = (void *) ((char *) ptr + nthistime);
610+
ptr = (char *) ptr + nthistime;
611611
size -= nthistime;
612612
nread += nthistime;
613613
}
@@ -655,7 +655,7 @@ BufFileWrite(BufFile *file, void *ptr, size_t size)
655655
file->pos += nthistime;
656656
if (file->nbytes < file->pos)
657657
file->nbytes = file->pos;
658-
ptr = (void *) ((char *) ptr + nthistime);
658+
ptr = (char *) ptr + nthistime;
659659
size -= nthistime;
660660
}
661661
}

src/backend/utils/sort/logtape.c

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ ltsReadFillBuffer(LogicalTape *lt)
319319
datablocknum += lt->offsetBlockNumber;
320320

321321
/* Read the block */
322-
ltsReadBlock(lt->tapeSet, datablocknum, (void *) thisbuf);
322+
ltsReadBlock(lt->tapeSet, datablocknum, thisbuf);
323323
if (!lt->frozen)
324324
ltsReleaseBlock(lt->tapeSet, datablocknum);
325325
lt->curBlockNumber = lt->nextBlockNumber;
@@ -806,7 +806,7 @@ LogicalTapeWrite(LogicalTape *lt, void *ptr, size_t size)
806806

807807
/* set the next-pointer and dump the current block. */
808808
TapeBlockGetTrailer(lt->buffer)->next = nextBlockNumber;
809-
ltsWriteBlock(lt->tapeSet, lt->curBlockNumber, (void *) lt->buffer);
809+
ltsWriteBlock(lt->tapeSet, lt->curBlockNumber, lt->buffer);
810810

811811
/* initialize the prev-pointer of the next block */
812812
TapeBlockGetTrailer(lt->buffer)->prev = lt->curBlockNumber;
@@ -826,7 +826,7 @@ LogicalTapeWrite(LogicalTape *lt, void *ptr, size_t size)
826826
lt->pos += nthistime;
827827
if (lt->nbytes < lt->pos)
828828
lt->nbytes = lt->pos;
829-
ptr = (void *) ((char *) ptr + nthistime);
829+
ptr = (char *) ptr + nthistime;
830830
size -= nthistime;
831831
}
832832
}
@@ -888,7 +888,7 @@ LogicalTapeRewindForRead(LogicalTape *lt, size_t buffer_size)
888888
lt->buffer_size - lt->nbytes);
889889

890890
TapeBlockSetNBytes(lt->buffer, lt->nbytes);
891-
ltsWriteBlock(lt->tapeSet, lt->curBlockNumber, (void *) lt->buffer);
891+
ltsWriteBlock(lt->tapeSet, lt->curBlockNumber, lt->buffer);
892892
}
893893
lt->writing = false;
894894
}
@@ -953,7 +953,7 @@ LogicalTapeRead(LogicalTape *lt, void *ptr, size_t size)
953953
memcpy(ptr, lt->buffer + lt->pos, nthistime);
954954

955955
lt->pos += nthistime;
956-
ptr = (void *) ((char *) ptr + nthistime);
956+
ptr = (char *) ptr + nthistime;
957957
size -= nthistime;
958958
nread += nthistime;
959959
}
@@ -1004,7 +1004,7 @@ LogicalTapeFreeze(LogicalTape *lt, TapeShare *share)
10041004
lt->buffer_size - lt->nbytes);
10051005

10061006
TapeBlockSetNBytes(lt->buffer, lt->nbytes);
1007-
ltsWriteBlock(lt->tapeSet, lt->curBlockNumber, (void *) lt->buffer);
1007+
ltsWriteBlock(lt->tapeSet, lt->curBlockNumber, lt->buffer);
10081008
}
10091009
lt->writing = false;
10101010
lt->frozen = true;
@@ -1031,7 +1031,7 @@ LogicalTapeFreeze(LogicalTape *lt, TapeShare *share)
10311031

10321032
if (lt->firstBlockNumber == -1L)
10331033
lt->nextBlockNumber = -1L;
1034-
ltsReadBlock(lt->tapeSet, lt->curBlockNumber, (void *) lt->buffer);
1034+
ltsReadBlock(lt->tapeSet, lt->curBlockNumber, lt->buffer);
10351035
if (TapeBlockIsLast(lt->buffer))
10361036
lt->nextBlockNumber = -1L;
10371037
else
@@ -1098,7 +1098,7 @@ LogicalTapeBackspace(LogicalTape *lt, size_t size)
10981098
return seekpos;
10991099
}
11001100

1101-
ltsReadBlock(lt->tapeSet, prev, (void *) lt->buffer);
1101+
ltsReadBlock(lt->tapeSet, prev, lt->buffer);
11021102

11031103
if (TapeBlockGetTrailer(lt->buffer)->next != lt->curBlockNumber)
11041104
elog(ERROR, "broken tape, next of block %ld is %ld, expected %ld",
@@ -1142,7 +1142,7 @@ LogicalTapeSeek(LogicalTape *lt, long blocknum, int offset)
11421142

11431143
if (blocknum != lt->curBlockNumber)
11441144
{
1145-
ltsReadBlock(lt->tapeSet, blocknum, (void *) lt->buffer);
1145+
ltsReadBlock(lt->tapeSet, blocknum, lt->buffer);
11461146
lt->curBlockNumber = blocknum;
11471147
lt->nbytes = TapeBlockPayloadSize;
11481148
lt->nextBlockNumber = TapeBlockGetTrailer(lt->buffer)->next;

src/backend/utils/sort/tuplesort.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2908,7 +2908,7 @@ markrunend(LogicalTape *tape)
29082908
{
29092909
unsigned int len = 0;
29102910

2911-
LogicalTapeWrite(tape, (void *) &len, sizeof(len));
2911+
LogicalTapeWrite(tape, &len, sizeof(len));
29122912
}
29132913

29142914
/*

src/backend/utils/sort/tuplesortvariants.c

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1002,10 +1002,10 @@ writetup_heap(Tuplesortstate *state, LogicalTape *tape, SortTuple *stup)
10021002
/* total on-disk footprint: */
10031003
unsigned int tuplen = tupbodylen + sizeof(int);
10041004

1005-
LogicalTapeWrite(tape, (void *) &tuplen, sizeof(tuplen));
1006-
LogicalTapeWrite(tape, (void *) tupbody, tupbodylen);
1005+
LogicalTapeWrite(tape, &tuplen, sizeof(tuplen));
1006+
LogicalTapeWrite(tape, tupbody, tupbodylen);
10071007
if (base->sortopt & TUPLESORT_RANDOMACCESS) /* need trailing length word? */
1008-
LogicalTapeWrite(tape, (void *) &tuplen, sizeof(tuplen));
1008+
LogicalTapeWrite(tape, &tuplen, sizeof(tuplen));
10091009
}
10101010

10111011
static void
@@ -1475,10 +1475,10 @@ writetup_index(Tuplesortstate *state, LogicalTape *tape, SortTuple *stup)
14751475
unsigned int tuplen;
14761476

14771477
tuplen = IndexTupleSize(tuple) + sizeof(tuplen);
1478-
LogicalTapeWrite(tape, (void *) &tuplen, sizeof(tuplen));
1479-
LogicalTapeWrite(tape, (void *) tuple, IndexTupleSize(tuple));
1478+
LogicalTapeWrite(tape, &tuplen, sizeof(tuplen));
1479+
LogicalTapeWrite(tape, tuple, IndexTupleSize(tuple));
14801480
if (base->sortopt & TUPLESORT_RANDOMACCESS) /* need trailing length word? */
1481-
LogicalTapeWrite(tape, (void *) &tuplen, sizeof(tuplen));
1481+
LogicalTapeWrite(tape, &tuplen, sizeof(tuplen));
14821482
}
14831483

14841484
static void
@@ -1564,10 +1564,10 @@ writetup_datum(Tuplesortstate *state, LogicalTape *tape, SortTuple *stup)
15641564

15651565
writtenlen = tuplen + sizeof(unsigned int);
15661566

1567-
LogicalTapeWrite(tape, (void *) &writtenlen, sizeof(writtenlen));
1567+
LogicalTapeWrite(tape, &writtenlen, sizeof(writtenlen));
15681568
LogicalTapeWrite(tape, waddr, tuplen);
15691569
if (base->sortopt & TUPLESORT_RANDOMACCESS) /* need trailing length word? */
1570-
LogicalTapeWrite(tape, (void *) &writtenlen, sizeof(writtenlen));
1570+
LogicalTapeWrite(tape, &writtenlen, sizeof(writtenlen));
15711571
}
15721572

15731573
static void

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy