From 8d0530fbf9095bc16fa3465b69aef2c31c4c3c9b Mon Sep 17 00:00:00 2001 From: Peter Eisentraut Date: Thu, 1 Dec 2022 08:36:09 +0100 Subject: [PATCH 2/2] 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. --- src/backend/executor/nodeHashjoin.c | 8 ++++---- src/backend/utils/sort/tuplestore.c | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/backend/executor/nodeHashjoin.c b/src/backend/executor/nodeHashjoin.c index 2718c2113f58..3e1a997f920d 100644 --- a/src/backend/executor/nodeHashjoin.c +++ b/src/backend/executor/nodeHashjoin.c @@ -1227,8 +1227,8 @@ ExecHashJoinSaveTuple(MinimalTuple tuple, uint32 hashvalue, *fileptr = file; } - BufFileWrite(file, (void *) &hashvalue, sizeof(uint32)); - BufFileWrite(file, (void *) tuple, tuple->t_len); + BufFileWrite(file, &hashvalue, sizeof(uint32)); + BufFileWrite(file, tuple, tuple->t_len); } /* @@ -1260,7 +1260,7 @@ ExecHashJoinGetSavedTuple(HashJoinState *hjstate, * we can read them both in one BufFileRead() call without any type * cheating. */ - nread = BufFileRead(file, (void *) header, sizeof(header)); + nread = BufFileRead(file, header, sizeof(header)); if (nread == 0) /* end of file */ { ExecClearTuple(tupleSlot); @@ -1275,7 +1275,7 @@ ExecHashJoinGetSavedTuple(HashJoinState *hjstate, tuple = (MinimalTuple) palloc(header[1]); tuple->t_len = header[1]; nread = BufFileRead(file, - (void *) ((char *) tuple + sizeof(uint32)), + ((char *) tuple + sizeof(uint32)), header[1] - sizeof(uint32)); if (nread != header[1] - sizeof(uint32)) ereport(ERROR, diff --git a/src/backend/utils/sort/tuplestore.c b/src/backend/utils/sort/tuplestore.c index f605ece721eb..cc884ab11649 100644 --- a/src/backend/utils/sort/tuplestore.c +++ b/src/backend/utils/sort/tuplestore.c @@ -1468,7 +1468,7 @@ getlen(Tuplestorestate *state, bool eofOK) unsigned int len; size_t nbytes; - nbytes = BufFileRead(state->myfile, (void *) &len, sizeof(len)); + nbytes = BufFileRead(state->myfile, &len, sizeof(len)); if (nbytes == sizeof(len)) return len; if (nbytes != 0 || !eofOK) @@ -1512,10 +1512,10 @@ writetup_heap(Tuplestorestate *state, void *tup) /* total on-disk footprint: */ unsigned int tuplen = tupbodylen + sizeof(int); - BufFileWrite(state->myfile, (void *) &tuplen, sizeof(tuplen)); - BufFileWrite(state->myfile, (void *) tupbody, tupbodylen); + BufFileWrite(state->myfile, &tuplen, sizeof(tuplen)); + BufFileWrite(state->myfile, tupbody, tupbodylen); if (state->backward) /* need trailing length word? */ - BufFileWrite(state->myfile, (void *) &tuplen, sizeof(tuplen)); + BufFileWrite(state->myfile, &tuplen, sizeof(tuplen)); FREEMEM(state, GetMemoryChunkSpace(tuple)); heap_free_minimal_tuple(tuple); @@ -1533,7 +1533,7 @@ readtup_heap(Tuplestorestate *state, unsigned int len) USEMEM(state, GetMemoryChunkSpace(tuple)); /* read in the tuple proper */ tuple->t_len = tuplen; - nread = BufFileRead(state->myfile, (void *) tupbody, tupbodylen); + nread = BufFileRead(state->myfile, tupbody, tupbodylen); if (nread != (size_t) tupbodylen) ereport(ERROR, (errcode_for_file_access(), @@ -1541,7 +1541,7 @@ readtup_heap(Tuplestorestate *state, unsigned int len) nread, (size_t) tupbodylen))); if (state->backward) /* need trailing length word? */ { - nread = BufFileRead(state->myfile, (void *) &tuplen, sizeof(tuplen)); + nread = BufFileRead(state->myfile, &tuplen, sizeof(tuplen)); if (nread != sizeof(tuplen)) ereport(ERROR, (errcode_for_file_access(), -- 2.38.1