Skip to content

Commit 07c29ca

Browse files
committed
Remove unnecessary casts
Some code carefully cast all data buffer arguments for BufFileWrite() and BufFileRead() to void *, even though the arguments are already void * (and AFAICT were never anything else). Remove this unnecessary clutter. Discussion: https://www.postgresql.org/message-id/flat/11dda853-bb5b-59ba-a746-e168b1ce4bdb%40enterprisedb.com
1 parent 2d4f1ba commit 07c29ca

File tree

2 files changed

+10
-10
lines changed

2 files changed

+10
-10
lines changed

src/backend/executor/nodeHashjoin.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1227,8 +1227,8 @@ ExecHashJoinSaveTuple(MinimalTuple tuple, uint32 hashvalue,
12271227
*fileptr = file;
12281228
}
12291229

1230-
BufFileWrite(file, (void *) &hashvalue, sizeof(uint32));
1231-
BufFileWrite(file, (void *) tuple, tuple->t_len);
1230+
BufFileWrite(file, &hashvalue, sizeof(uint32));
1231+
BufFileWrite(file, tuple, tuple->t_len);
12321232
}
12331233

12341234
/*
@@ -1260,7 +1260,7 @@ ExecHashJoinGetSavedTuple(HashJoinState *hjstate,
12601260
* we can read them both in one BufFileRead() call without any type
12611261
* cheating.
12621262
*/
1263-
nread = BufFileRead(file, (void *) header, sizeof(header));
1263+
nread = BufFileRead(file, header, sizeof(header));
12641264
if (nread == 0) /* end of file */
12651265
{
12661266
ExecClearTuple(tupleSlot);
@@ -1275,7 +1275,7 @@ ExecHashJoinGetSavedTuple(HashJoinState *hjstate,
12751275
tuple = (MinimalTuple) palloc(header[1]);
12761276
tuple->t_len = header[1];
12771277
nread = BufFileRead(file,
1278-
(void *) ((char *) tuple + sizeof(uint32)),
1278+
((char *) tuple + sizeof(uint32)),
12791279
header[1] - sizeof(uint32));
12801280
if (nread != header[1] - sizeof(uint32))
12811281
ereport(ERROR,

src/backend/utils/sort/tuplestore.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1468,7 +1468,7 @@ getlen(Tuplestorestate *state, bool eofOK)
14681468
unsigned int len;
14691469
size_t nbytes;
14701470

1471-
nbytes = BufFileRead(state->myfile, (void *) &len, sizeof(len));
1471+
nbytes = BufFileRead(state->myfile, &len, sizeof(len));
14721472
if (nbytes == sizeof(len))
14731473
return len;
14741474
if (nbytes != 0 || !eofOK)
@@ -1512,10 +1512,10 @@ writetup_heap(Tuplestorestate *state, void *tup)
15121512
/* total on-disk footprint: */
15131513
unsigned int tuplen = tupbodylen + sizeof(int);
15141514

1515-
BufFileWrite(state->myfile, (void *) &tuplen, sizeof(tuplen));
1516-
BufFileWrite(state->myfile, (void *) tupbody, tupbodylen);
1515+
BufFileWrite(state->myfile, &tuplen, sizeof(tuplen));
1516+
BufFileWrite(state->myfile, tupbody, tupbodylen);
15171517
if (state->backward) /* need trailing length word? */
1518-
BufFileWrite(state->myfile, (void *) &tuplen, sizeof(tuplen));
1518+
BufFileWrite(state->myfile, &tuplen, sizeof(tuplen));
15191519

15201520
FREEMEM(state, GetMemoryChunkSpace(tuple));
15211521
heap_free_minimal_tuple(tuple);
@@ -1533,15 +1533,15 @@ readtup_heap(Tuplestorestate *state, unsigned int len)
15331533
USEMEM(state, GetMemoryChunkSpace(tuple));
15341534
/* read in the tuple proper */
15351535
tuple->t_len = tuplen;
1536-
nread = BufFileRead(state->myfile, (void *) tupbody, tupbodylen);
1536+
nread = BufFileRead(state->myfile, tupbody, tupbodylen);
15371537
if (nread != (size_t) tupbodylen)
15381538
ereport(ERROR,
15391539
(errcode_for_file_access(),
15401540
errmsg("could not read from tuplestore temporary file: read only %zu of %zu bytes",
15411541
nread, (size_t) tupbodylen)));
15421542
if (state->backward) /* need trailing length word? */
15431543
{
1544-
nread = BufFileRead(state->myfile, (void *) &tuplen, sizeof(tuplen));
1544+
nread = BufFileRead(state->myfile, &tuplen, sizeof(tuplen));
15451545
if (nread != sizeof(tuplen))
15461546
ereport(ERROR,
15471547
(errcode_for_file_access(),

0 commit comments

Comments
 (0)