I have found that in some corners of the code some calls to standard C
functions are decorated with casts to (void *) for no reason, and this
code pattern then gets copied around. I have gone through and cleaned
this up a bit, in the attached patches.
The involved functions are: repalloc, memcpy, memset, memmove, memcmp,
qsort, bsearch
Also hash_search(), for which there was a historical reason (the
argument used to be char *), but not anymore.From b4f050d23761187e05576cfbe8277b593d9c19fb Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Thu, 2 Feb 2023 23:02:34 +0100
Subject: [PATCH 1/8] Remove useless casts to (void *) (hash_search)
Some of these appear to be leftovers from when hash_search took a char
* argument (changed in 5999e78fc45dcb91784b64b6e9ae43f4e4f68ca2).
---
contrib/postgres_fdw/shippable.c | 6 +--
src/backend/access/gist/gistbuild.c | 4 +-
src/backend/access/gist/gistbuildbuffers.c | 2 +-
src/backend/access/transam/xlogutils.c | 6 +--
src/backend/catalog/storage.c | 4 +-
src/backend/optimizer/util/predtest.c | 2 +-
src/backend/parser/parse_oper.c | 6 +--
src/backend/replication/logical/relation.c | 6 +--
.../replication/logical/reorderbuffer.c | 16 +++---
src/backend/replication/pgoutput/pgoutput.c | 2 +-
src/backend/storage/buffer/buf_table.c | 6 +--
src/backend/storage/buffer/bufmgr.c | 8 +--
src/backend/storage/buffer/localbuf.c | 12 ++---
src/backend/storage/lmgr/lock.c | 50 +++++++++----------
src/backend/storage/smgr/smgr.c | 6 +--
src/backend/storage/sync/sync.c | 4 +-
src/backend/tsearch/ts_typanalyze.c | 4 +-
src/backend/utils/adt/array_typanalyze.c | 4 +-
src/backend/utils/adt/ri_triggers.c | 8 +--
src/backend/utils/cache/attoptcache.c | 6 +--
src/backend/utils/cache/relcache.c | 12 ++---
src/backend/utils/cache/relfilenumbermap.c | 6 +--
src/backend/utils/cache/spccache.c | 6 +--
src/backend/utils/cache/ts_cache.c | 12 ++---
src/backend/utils/cache/typcache.c | 8 +--
src/backend/utils/time/combocid.c | 2 +-
src/pl/plpgsql/src/pl_comp.c | 6 +--
src/pl/plpgsql/src/pl_exec.c | 2 +-
28 files changed, 108 insertions(+), 108 deletions(-)
diff --git a/contrib/postgres_fdw/shippable.c b/contrib/postgres_fdw/shippable.c
index 1b47a30dbf..a500b90390 100644
--- a/contrib/postgres_fdw/shippable.c
+++ b/contrib/postgres_fdw/shippable.c
@@ -77,7 +77,7 @@ InvalidateShippableCacheCallback(Datum arg, int cacheid,
uint32 hashvalue)
while ((entry = (ShippableCacheEntry *) hash_seq_search(&status)) !=
NULL)
{
if (hash_search(ShippableCacheHash,
- (void *) &entry->key,
+ &entry->key,
HASH_REMOVE,
NULL) == NULL)
elog(ERROR, "hash table corrupted");
@@ -184,7 +184,7 @@ is_shippable(Oid objectId, Oid classId, PgFdwRelationInfo
*fpinfo)
/* See if we already cached the result. */
entry = (ShippableCacheEntry *)
hash_search(ShippableCacheHash,
- (void *) &key,
+ &key,
HASH_FIND,
NULL);
@@ -200,7 +200,7 @@ is_shippable(Oid objectId, Oid classId, PgFdwRelationInfo
*fpinfo)
*/
entry = (ShippableCacheEntry *)
hash_search(ShippableCacheHash,
- (void *) &key,
+ &key,
HASH_ENTER,
NULL);
diff --git a/src/backend/access/gist/gistbuild.c
b/src/backend/access/gist/gistbuild.c
index d21a308d41..7a6d93bb87 100644
--- a/src/backend/access/gist/gistbuild.c
+++ b/src/backend/access/gist/gistbuild.c
@@ -1587,7 +1587,7 @@ gistMemorizeParent(GISTBuildState *buildstate,
BlockNumber child, BlockNumber pa
bool found;
entry = (ParentMapEntry *) hash_search(buildstate->parentMap,
-
(const void *) &child,
+
&child,
HASH_ENTER,
&found);
entry->parentblkno = parent;
@@ -1625,7 +1625,7 @@ gistGetParent(GISTBuildState *buildstate, BlockNumber
child)
/* Find node buffer in hash table */
entry = (ParentMapEntry *) hash_search(buildstate->parentMap,
-
(const void *) &child,
+
&child,
HASH_FIND,
&found);
if (!found)
diff --git a/src/backend/access/gist/gistbuildbuffers.c
b/src/backend/access/gist/gistbuildbuffers.c
index 3399a6ae68..95cbed4337 100644
--- a/src/backend/access/gist/gistbuildbuffers.c
+++ b/src/backend/access/gist/gistbuildbuffers.c
@@ -122,7 +122,7 @@ gistGetNodeBuffer(GISTBuildBuffers *gfbb, GISTSTATE
*giststate,
/* Find node buffer in hash table */
nodeBuffer = (GISTNodeBuffer *) hash_search(gfbb->nodeBuffersTab,
-
(const void *) &nodeBlocknum,
+
&nodeBlocknum,
HASH_ENTER,
&found);
if (!found)
diff --git a/src/backend/access/transam/xlogutils.c
b/src/backend/access/transam/xlogutils.c
index 87ca9dfef1..2c28956b1a 100644
--- a/src/backend/access/transam/xlogutils.c
+++ b/src/backend/access/transam/xlogutils.c
@@ -151,7 +151,7 @@ log_invalid_page(RelFileLocator locator, ForkNumber forkno,
BlockNumber blkno,
key.forkno = forkno;
key.blkno = blkno;
hentry = (xl_invalid_page *)
- hash_search(invalid_page_tab, (void *) &key, HASH_ENTER,
&found);
+ hash_search(invalid_page_tab, &key, HASH_ENTER, &found);
if (!found)
{
@@ -193,7 +193,7 @@ forget_invalid_pages(RelFileLocator locator, ForkNumber
forkno,
}
if (hash_search(invalid_page_tab,
- (void *) &hentry->key,
+ &hentry->key,
HASH_REMOVE, NULL) ==
NULL)
elog(ERROR, "hash table corrupted");
}
@@ -226,7 +226,7 @@ forget_invalid_pages_db(Oid dbid)
}
if (hash_search(invalid_page_tab,
- (void *) &hentry->key,
+ &hentry->key,
HASH_REMOVE, NULL) ==
NULL)
elog(ERROR, "hash table corrupted");
}
diff --git a/src/backend/catalog/storage.c b/src/backend/catalog/storage.c
index 039ada94c4..af1491aa1d 100644
--- a/src/backend/catalog/storage.c
+++ b/src/backend/catalog/storage.c
@@ -603,7 +603,7 @@ SerializePendingSyncs(Size maxSize, char *startAddress)
/* remove deleted rnodes */
for (delete = pendingDeletes; delete != NULL; delete = delete->next)
if (delete->atCommit)
- (void) hash_search(tmphash, (void *) &delete->rlocator,
+ (void) hash_search(tmphash, &delete->rlocator,
HASH_REMOVE, NULL);
hash_seq_init(&scan, tmphash);
@@ -748,7 +748,7 @@ smgrDoPendingSyncs(bool isCommit, bool isParallelWorker)
/* Skip syncing nodes that smgrDoPendingDeletes() will delete. */
for (pending = pendingDeletes; pending != NULL; pending = pending->next)
if (pending->atCommit)
- (void) hash_search(pendingSyncHash, (void *)
&pending->rlocator,
+ (void) hash_search(pendingSyncHash, &pending->rlocator,
HASH_REMOVE, NULL);
hash_seq_init(&scan, pendingSyncHash);
diff --git a/src/backend/optimizer/util/predtest.c
b/src/backend/optimizer/util/predtest.c
index f6e12856dd..237c883874 100644
--- a/src/backend/optimizer/util/predtest.c
+++ b/src/backend/optimizer/util/predtest.c
@@ -2040,7 +2040,7 @@ lookup_proof_cache(Oid pred_op, Oid clause_op, bool
refute_it)
key.pred_op = pred_op;
key.clause_op = clause_op;
cache_entry = (OprProofCacheEntry *) hash_search(OprProofCacheHash,
-
(void *) &key,
+
&key,
HASH_ENTER, &cfound);
if (!cfound)
{
diff --git a/src/backend/parser/parse_oper.c b/src/backend/parser/parse_oper.c
index 8801f30898..bdc8f8e26a 100644
--- a/src/backend/parser/parse_oper.c
+++ b/src/backend/parser/parse_oper.c
@@ -1017,7 +1017,7 @@ find_oper_cache_entry(OprCacheKey *key)
/* Look for an existing entry */
oprentry = (OprCacheEntry *) hash_search(OprCacheHash,
-
(void *) key,
+
key,
HASH_FIND, NULL);
if (oprentry == NULL)
return InvalidOid;
@@ -1038,7 +1038,7 @@ make_oper_cache_entry(OprCacheKey *key, Oid opr_oid)
Assert(OprCacheHash != NULL);
oprentry = (OprCacheEntry *) hash_search(OprCacheHash,
-
(void *) key,
+
key,
HASH_ENTER, NULL);
oprentry->opr_oid = opr_oid;
}
@@ -1060,7 +1060,7 @@ InvalidateOprCacheCallBack(Datum arg, int cacheid, uint32
hashvalue)
while ((hentry = (OprCacheEntry *) hash_seq_search(&status)) != NULL)
{
if (hash_search(OprCacheHash,
- (void *) &hentry->key,
+ &hentry->key,
HASH_REMOVE, NULL) == NULL)
elog(ERROR, "hash table corrupted");
}
diff --git a/src/backend/replication/logical/relation.c
b/src/backend/replication/logical/relation.c
index ca88ae171c..9f139c64db 100644
--- a/src/backend/replication/logical/relation.c
+++ b/src/backend/replication/logical/relation.c
@@ -167,7 +167,7 @@ logicalrep_relmap_update(LogicalRepRelation *remoterel)
/*
* HASH_ENTER returns the existing entry if present or creates a new
one.
*/
- entry = hash_search(LogicalRepRelMap, (void *) &remoterel->remoteid,
+ entry = hash_search(LogicalRepRelMap, &remoterel->remoteid,
HASH_ENTER, &found);
if (found)
@@ -326,7 +326,7 @@ logicalrep_rel_open(LogicalRepRelId remoteid, LOCKMODE
lockmode)
logicalrep_relmap_init();
/* Search for existing entry. */
- entry = hash_search(LogicalRepRelMap, (void *) &remoteid,
+ entry = hash_search(LogicalRepRelMap, &remoteid,
HASH_FIND, &found);
if (!found)
@@ -598,7 +598,7 @@ logicalrep_partition_open(LogicalRepRelMapEntry *root,
/* Search for existing entry. */
part_entry = (LogicalRepPartMapEntry *) hash_search(LogicalRepPartMap,
-
(void *) &partOid,
+
&partOid,
HASH_ENTER, &found);
entry = &part_entry->relmapentry;
diff --git a/src/backend/replication/logical/reorderbuffer.c
b/src/backend/replication/logical/reorderbuffer.c
index efe057b4de..02319d5c2f 100644
--- a/src/backend/replication/logical/reorderbuffer.c
+++ b/src/backend/replication/logical/reorderbuffer.c
@@ -657,7 +657,7 @@ ReorderBufferTXNByXid(ReorderBuffer *rb, TransactionId xid,
bool create,
/* search the lookup table */
ent = (ReorderBufferTXNByIdEnt *)
hash_search(rb->by_txn,
- (void *) &xid,
+ &xid,
create ? HASH_ENTER : HASH_FIND,
&found);
if (found)
@@ -1582,7 +1582,7 @@ ReorderBufferCleanupTXN(ReorderBuffer *rb,
ReorderBufferTXN *txn)
/* now remove reference from buffer */
hash_search(rb->by_txn,
- (void *) &txn->xid,
+ &txn->xid,
HASH_REMOVE,
&found);
Assert(found);
@@ -1763,7 +1763,7 @@ ReorderBufferBuildTupleCidHash(ReorderBuffer *rb,
ReorderBufferTXN *txn)
ent = (ReorderBufferTupleCidEnt *)
hash_search(txn->tuplecid_hash,
- (void *) &key,
+ &key,
HASH_ENTER,
&found);
if (!found)
@@ -4654,7 +4654,7 @@ ReorderBufferToastAppendChunk(ReorderBuffer *rb,
ReorderBufferTXN *txn,
ent = (ReorderBufferToastEnt *)
hash_search(txn->toast_hash,
- (void *) &chunk_id,
+ &chunk_id,
HASH_ENTER,
&found);
@@ -4811,7 +4811,7 @@ ReorderBufferToastReplace(ReorderBuffer *rb,
ReorderBufferTXN *txn,
*/
ent = (ReorderBufferToastEnt *)
hash_search(txn->toast_hash,
- (void *)
&toast_pointer.va_valueid,
+ &toast_pointer.va_valueid,
HASH_FIND,
NULL);
if (ent == NULL)
@@ -5054,7 +5054,7 @@ ApplyLogicalMappingFile(HTAB *tuplecid_data, Oid relid,
const char *fname)
ent = (ReorderBufferTupleCidEnt *)
hash_search(tuplecid_data,
- (void *) &key,
+ &key,
HASH_FIND,
NULL);
@@ -5068,7 +5068,7 @@ ApplyLogicalMappingFile(HTAB *tuplecid_data, Oid relid,
const char *fname)
new_ent = (ReorderBufferTupleCidEnt *)
hash_search(tuplecid_data,
- (void *) &key,
+ &key,
HASH_ENTER,
&found);
@@ -5250,7 +5250,7 @@ ResolveCminCmaxDuringDecoding(HTAB *tuplecid_data,
restart:
ent = (ReorderBufferTupleCidEnt *)
hash_search(tuplecid_data,
- (void *) &key,
+ &key,
HASH_FIND,
NULL);
diff --git a/src/backend/replication/pgoutput/pgoutput.c
b/src/backend/replication/pgoutput/pgoutput.c
index 1a80d67bb9..e4938d8888 100644
--- a/src/backend/replication/pgoutput/pgoutput.c
+++ b/src/backend/replication/pgoutput/pgoutput.c
@@ -2026,7 +2026,7 @@ get_rel_sync_entry(PGOutputData *data, Relation relation)
/* Find cached relation info, creating if not found */
entry = (RelationSyncEntry *) hash_search(RelationSyncCache,
-
(void *) &relid,
+
&relid,
HASH_ENTER, &found);
Assert(entry != NULL);
diff --git a/src/backend/storage/buffer/buf_table.c
b/src/backend/storage/buffer/buf_table.c
index e61546a5ff..2b96639a5a 100644
--- a/src/backend/storage/buffer/buf_table.c
+++ b/src/backend/storage/buffer/buf_table.c
@@ -94,7 +94,7 @@ BufTableLookup(BufferTag *tagPtr, uint32 hashcode)
result = (BufferLookupEnt *)
hash_search_with_hash_value(SharedBufHash,
- (void
*) tagPtr,
+ tagPtr,
hashcode,
HASH_FIND,
NULL);
@@ -126,7 +126,7 @@ BufTableInsert(BufferTag *tagPtr, uint32 hashcode, int
buf_id)
result = (BufferLookupEnt *)
hash_search_with_hash_value(SharedBufHash,
- (void
*) tagPtr,
+ tagPtr,
hashcode,
HASH_ENTER,
&found);
@@ -152,7 +152,7 @@ BufTableDelete(BufferTag *tagPtr, uint32 hashcode)
result = (BufferLookupEnt *)
hash_search_with_hash_value(SharedBufHash,
- (void
*) tagPtr,
+ tagPtr,
hashcode,
HASH_REMOVE,
NULL);
diff --git a/src/backend/storage/buffer/bufmgr.c
b/src/backend/storage/buffer/bufmgr.c
index 800a4248c9..cbde861789 100644
--- a/src/backend/storage/buffer/bufmgr.c
+++ b/src/backend/storage/buffer/bufmgr.c
@@ -262,7 +262,7 @@ ReservePrivateRefCountEntry(void)
/* enter victim array entry into hashtable */
hashent = hash_search(PrivateRefCountHash,
- (void *)
&(ReservedRefCountEntry->buffer),
+
&(ReservedRefCountEntry->buffer),
HASH_ENTER,
&found);
Assert(!found);
@@ -337,7 +337,7 @@ GetPrivateRefCountEntry(Buffer buffer, bool do_move)
return NULL;
res = hash_search(PrivateRefCountHash,
- (void *) &buffer,
+ &buffer,
HASH_FIND,
NULL);
@@ -369,7 +369,7 @@ GetPrivateRefCountEntry(Buffer buffer, bool do_move)
/* delete from hashtable */
hash_search(PrivateRefCountHash,
- (void *) &buffer,
+ &buffer,
HASH_REMOVE,
&found);
Assert(found);
@@ -431,7 +431,7 @@ ForgetPrivateRefCountEntry(PrivateRefCountEntry *ref)
Buffer buffer = ref->buffer;
hash_search(PrivateRefCountHash,
- (void *) &buffer,
+ &buffer,
HASH_REMOVE,
&found);
Assert(found);
diff --git a/src/backend/storage/buffer/localbuf.c
b/src/backend/storage/buffer/localbuf.c
index 8372acc383..0229a2eca1 100644
--- a/src/backend/storage/buffer/localbuf.c
+++ b/src/backend/storage/buffer/localbuf.c
@@ -76,7 +76,7 @@ PrefetchLocalBuffer(SMgrRelation smgr, ForkNumber forkNum,
/* See if the desired buffer already exists */
hresult = (LocalBufferLookupEnt *)
- hash_search(LocalBufHash, (void *) &newTag, HASH_FIND, NULL);
+ hash_search(LocalBufHash, &newTag, HASH_FIND, NULL);
if (hresult)
{
@@ -125,7 +125,7 @@ LocalBufferAlloc(SMgrRelation smgr, ForkNumber forkNum,
BlockNumber blockNum,
/* See if the desired buffer already exists */
hresult = (LocalBufferLookupEnt *)
- hash_search(LocalBufHash, (void *) &newTag, HASH_FIND, NULL);
+ hash_search(LocalBufHash, &newTag, HASH_FIND, NULL);
if (hresult)
{
@@ -248,7 +248,7 @@ LocalBufferAlloc(SMgrRelation smgr, ForkNumber forkNum,
BlockNumber blockNum,
if (buf_state & BM_TAG_VALID)
{
hresult = (LocalBufferLookupEnt *)
- hash_search(LocalBufHash, (void *) &bufHdr->tag,
+ hash_search(LocalBufHash, &bufHdr->tag,
HASH_REMOVE, NULL);
if (!hresult) /* shouldn't happen */
elog(ERROR, "local buffer hash table corrupted");
@@ -259,7 +259,7 @@ LocalBufferAlloc(SMgrRelation smgr, ForkNumber forkNum,
BlockNumber blockNum,
}
hresult = (LocalBufferLookupEnt *)
- hash_search(LocalBufHash, (void *) &newTag, HASH_ENTER, &found);
+ hash_search(LocalBufHash, &newTag, HASH_ENTER, &found);
if (found) /* shouldn't happen */
elog(ERROR, "local buffer hash table corrupted");
hresult->id = b;
@@ -351,7 +351,7 @@ DropRelationLocalBuffers(RelFileLocator rlocator,
ForkNumber forkNum,
/* Remove entry from hashtable */
hresult = (LocalBufferLookupEnt *)
- hash_search(LocalBufHash, (void *) &bufHdr->tag,
+ hash_search(LocalBufHash, &bufHdr->tag,
HASH_REMOVE, NULL);
if (!hresult) /* shouldn't happen */
elog(ERROR, "local buffer hash table
corrupted");
@@ -396,7 +396,7 @@ DropRelationAllLocalBuffers(RelFileLocator rlocator)
LocalRefCount[i]);
/* Remove entry from hashtable */
hresult = (LocalBufferLookupEnt *)
- hash_search(LocalBufHash, (void *) &bufHdr->tag,
+ hash_search(LocalBufHash, &bufHdr->tag,
HASH_REMOVE, NULL);
if (!hresult) /* shouldn't happen */
elog(ERROR, "local buffer hash table
corrupted");
diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c
index 49d62a0dc7..a87372f33f 100644
--- a/src/backend/storage/lmgr/lock.c
+++ b/src/backend/storage/lmgr/lock.c
@@ -608,7 +608,7 @@ LockHeldByMe(const LOCKTAG *locktag, LOCKMODE lockmode)
localtag.mode = lockmode;
locallock = (LOCALLOCK *) hash_search(LockMethodLocalHash,
-
(void *) &localtag,
+
&localtag,
HASH_FIND, NULL);
return (locallock && locallock->nLocks > 0);
@@ -663,7 +663,7 @@ LockHasWaiters(const LOCKTAG *locktag, LOCKMODE lockmode,
bool sessionLock)
localtag.mode = lockmode;
locallock = (LOCALLOCK *) hash_search(LockMethodLocalHash,
-
(void *) &localtag,
+
&localtag,
HASH_FIND, NULL);
/*
@@ -825,7 +825,7 @@ LockAcquireExtended(const LOCKTAG *locktag,
localtag.mode = lockmode;
locallock = (LOCALLOCK *) hash_search(LockMethodLocalHash,
-
(void *) &localtag,
+
&localtag,
HASH_ENTER, &found);
/*
@@ -1061,7 +1061,7 @@ LockAcquireExtended(const LOCKTAG *locktag,
dlist_delete(&proclock->lockLink);
dlist_delete(&proclock->procLink);
if
(!hash_search_with_hash_value(LockMethodProcLockHash,
-
(void *) &(proclock->tag),
+
&(proclock->tag),
proclock_hashcode,
HASH_REMOVE,
NULL))
@@ -1180,7 +1180,7 @@ SetupLockInTable(LockMethod lockMethodTable, PGPROC *proc,
* Find or create a lock with this tag.
*/
lock = (LOCK *) hash_search_with_hash_value(LockMethodLockHash,
-
(const void *) locktag,
+
locktag,
hashcode,
HASH_ENTER_NULL,
&found);
@@ -1222,7 +1222,7 @@ SetupLockInTable(LockMethod lockMethodTable, PGPROC *proc,
* Find or create a proclock entry with this tag
*/
proclock = (PROCLOCK *)
hash_search_with_hash_value(LockMethodProcLockHash,
-
(void *) &proclocktag,
+
&proclocktag,
proclock_hashcode,
HASH_ENTER_NULL,
&found);
@@ -1239,7 +1239,7 @@ SetupLockInTable(LockMethod lockMethodTable, PGPROC *proc,
*/
Assert(dlist_is_empty(&(lock->procLocks)));
if (!hash_search_with_hash_value(LockMethodLockHash,
-
(void *) &(lock->tag),
+
&(lock->tag),
hashcode,
HASH_REMOVE,
NULL))
@@ -1391,7 +1391,7 @@ RemoveLocalLock(LOCALLOCK *locallock)
}
if (!hash_search(LockMethodLocalHash,
- (void *) &(locallock->tag),
+ &(locallock->tag),
HASH_REMOVE, NULL))
elog(WARNING, "locallock table corrupted");
@@ -1644,7 +1644,7 @@ CleanUpLock(LOCK *lock, PROCLOCK *proclock,
dlist_delete(&proclock->procLink);
proclock_hashcode = ProcLockHashCode(&proclock->tag, hashcode);
if (!hash_search_with_hash_value(LockMethodProcLockHash,
-
(void *) &(proclock->tag),
+
&(proclock->tag),
proclock_hashcode,
HASH_REMOVE,
NULL))
@@ -1660,7 +1660,7 @@ CleanUpLock(LOCK *lock, PROCLOCK *proclock,
LOCK_PRINT("CleanUpLock: deleting", lock, 0);
Assert(dlist_is_empty(&lock->procLocks));
if (!hash_search_with_hash_value(LockMethodLockHash,
-
(void *) &(lock->tag),
+
&(lock->tag),
hashcode,
HASH_REMOVE,
NULL))
@@ -1998,7 +1998,7 @@ LockRelease(const LOCKTAG *locktag, LOCKMODE lockmode,
bool sessionLock)
localtag.mode = lockmode;
locallock = (LOCALLOCK *) hash_search(LockMethodLocalHash,
-
(void *) &localtag,
+
&localtag,
HASH_FIND, NULL);
/*
@@ -2112,7 +2112,7 @@ LockRelease(const LOCKTAG *locktag, LOCKMODE lockmode,
bool sessionLock)
Assert(EligibleForRelationFastPath(locktag, lockmode));
lock = (LOCK *) hash_search_with_hash_value(LockMethodLockHash,
-
(const void *) locktag,
+
locktag,
locallock->hashcode,
HASH_FIND,
NULL);
@@ -2123,7 +2123,7 @@ LockRelease(const LOCKTAG *locktag, LOCKMODE lockmode,
bool sessionLock)
proclocktag.myLock = lock;
proclocktag.myProc = MyProc;
locallock->proclock = (PROCLOCK *)
hash_search(LockMethodProcLockHash,
-
(void *) &proclocktag,
+
&proclocktag,
HASH_FIND,
NULL);
if (!locallock->proclock)
@@ -2851,7 +2851,7 @@ FastPathGetRelationLockEntry(LOCALLOCK *locallock)
LWLockAcquire(partitionLock, LW_SHARED);
lock = (LOCK *) hash_search_with_hash_value(LockMethodLockHash,
-
(void *) locktag,
+
locktag,
locallock->hashcode,
HASH_FIND,
NULL);
@@ -2864,7 +2864,7 @@ FastPathGetRelationLockEntry(LOCALLOCK *locallock)
proclock_hashcode = ProcLockHashCode(&proclocktag,
locallock->hashcode);
proclock = (PROCLOCK *)
hash_search_with_hash_value(LockMethodProcLockHash,
-
(void *) &proclocktag,
+
&proclocktag,
proclock_hashcode,
HASH_FIND,
NULL);
@@ -3028,7 +3028,7 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE
lockmode, int *countp)
LWLockAcquire(partitionLock, LW_SHARED);
lock = (LOCK *) hash_search_with_hash_value(LockMethodLockHash,
-
(const void *) locktag,
+
locktag,
hashcode,
HASH_FIND,
NULL);
@@ -3125,7 +3125,7 @@ LockRefindAndRelease(LockMethod lockMethodTable, PGPROC
*proc,
* Re-find the lock object (it had better be there).
*/
lock = (LOCK *) hash_search_with_hash_value(LockMethodLockHash,
-
(void *) locktag,
+
locktag,
hashcode,
HASH_FIND,
NULL);
@@ -3141,7 +3141,7 @@ LockRefindAndRelease(LockMethod lockMethodTable, PGPROC
*proc,
proclock_hashcode = ProcLockHashCode(&proclocktag, hashcode);
proclock = (PROCLOCK *)
hash_search_with_hash_value(LockMethodProcLockHash,
-
(void *) &proclocktag,
+
&proclocktag,
proclock_hashcode,
HASH_FIND,
NULL);
@@ -3255,7 +3255,7 @@ CheckForSessionAndXactLocks(void)
/* Otherwise, find or make an entry in lockhtab */
hentry = (PerLockTagEntry *) hash_search(lockhtab,
-
(void *) &locallock->tag.lock,
+
&locallock->tag.lock,
HASH_ENTER, &found);
if (!found) /* initialize, if newly
created */
hentry->sessLock = hentry->xactLock = false;
@@ -3555,8 +3555,8 @@ PostPrepare_Locks(TransactionId xid)
* given lock with my own proc.
*/
if (!hash_update_hash_key(LockMethodProcLockHash,
- (void
*) proclock,
- (void
*) &proclocktag))
+
proclock,
+
&proclocktag))
elog(PANIC, "duplicate entry found while
reassigning a prepared transaction's locks");
/* Re-link into the new proc's proclock list */
@@ -4202,7 +4202,7 @@ lock_twophase_recover(TransactionId xid, uint16 info,
* Find or create a lock with this tag.
*/
lock = (LOCK *) hash_search_with_hash_value(LockMethodLockHash,
-
(void *) locktag,
+
locktag,
hashcode,
HASH_ENTER_NULL,
&found);
@@ -4250,7 +4250,7 @@ lock_twophase_recover(TransactionId xid, uint16 info,
* Find or create a proclock entry with this tag
*/
proclock = (PROCLOCK *)
hash_search_with_hash_value(LockMethodProcLockHash,
-
(void *) &proclocktag,
+
&proclocktag,
proclock_hashcode,
HASH_ENTER_NULL,
&found);
@@ -4267,7 +4267,7 @@ lock_twophase_recover(TransactionId xid, uint16 info,
*/
Assert(dlist_is_empty(&lock->procLocks));
if (!hash_search_with_hash_value(LockMethodLockHash,
-
(void *) &(lock->tag),
+
&(lock->tag),
hashcode,
HASH_REMOVE,
NULL))
@@ -4679,7 +4679,7 @@ LockWaiterCount(const LOCKTAG *locktag)
LWLockAcquire(partitionLock, LW_EXCLUSIVE);
lock = (LOCK *) hash_search_with_hash_value(LockMethodLockHash,
-
(const void *) locktag,
+
locktag,
hashcode,
HASH_FIND,
&found);
diff --git a/src/backend/storage/smgr/smgr.c b/src/backend/storage/smgr/smgr.c
index 80eb6311e7..b2bd749d77 100644
--- a/src/backend/storage/smgr/smgr.c
+++ b/src/backend/storage/smgr/smgr.c
@@ -165,7 +165,7 @@ smgropen(RelFileLocator rlocator, BackendId backend)
brlocator.locator = rlocator;
brlocator.backend = backend;
reln = (SMgrRelation) hash_search(SMgrRelationHash,
- (void
*) &brlocator,
+
&brlocator,
HASH_ENTER, &found);
/* Initialize it if not present before */
@@ -267,7 +267,7 @@ smgrclose(SMgrRelation reln)
dlist_delete(&reln->node);
if (hash_search(SMgrRelationHash,
- (void *) &(reln->smgr_rlocator),
+ &(reln->smgr_rlocator),
HASH_REMOVE, NULL) == NULL)
elog(ERROR, "SMgrRelation hashtable corrupted");
@@ -352,7 +352,7 @@ smgrcloserellocator(RelFileLocatorBackend rlocator)
return;
reln = (SMgrRelation) hash_search(SMgrRelationHash,
- (void
*) &rlocator,
+
&rlocator,
HASH_FIND, NULL);
if (reln != NULL)
smgrclose(reln);
diff --git a/src/backend/storage/sync/sync.c b/src/backend/storage/sync/sync.c
index 7135150b16..768d1dbfc4 100644
--- a/src/backend/storage/sync/sync.c
+++ b/src/backend/storage/sync/sync.c
@@ -501,7 +501,7 @@ RememberSyncRequest(const FileTag *ftag, SyncRequestType
type)
/* Cancel previously entered request */
entry = (PendingFsyncEntry *) hash_search(pendingOps,
-
(void *) ftag,
+
ftag,
HASH_FIND,
NULL);
if (entry != NULL)
@@ -557,7 +557,7 @@ RememberSyncRequest(const FileTag *ftag, SyncRequestType
type)
Assert(type == SYNC_REQUEST);
entry = (PendingFsyncEntry *) hash_search(pendingOps,
-
(void *) ftag,
+
ftag,
HASH_ENTER,
&found);
/* if new entry, or was previously canceled, initialize it */
diff --git a/src/backend/tsearch/ts_typanalyze.c
b/src/backend/tsearch/ts_typanalyze.c
index ae4b5d10f2..75ecd72efe 100644
--- a/src/backend/tsearch/ts_typanalyze.c
+++ b/src/backend/tsearch/ts_typanalyze.c
@@ -254,7 +254,7 @@ compute_tsvector_stats(VacAttrStats *stats,
/* Lookup current lexeme in hashtable, adding it if new
*/
item = (TrackItem *) hash_search(lexemes_tab,
-
(const void *) &hash_key,
+
&hash_key,
HASH_ENTER, &found);
if (found)
@@ -464,7 +464,7 @@ prune_lexemes_hashtable(HTAB *lexemes_tab, int b_current)
{
char *lexeme = item->key.lexeme;
- if (hash_search(lexemes_tab, (const void *) &item->key,
+ if (hash_search(lexemes_tab, &item->key,
HASH_REMOVE, NULL) ==
NULL)
elog(ERROR, "hash table corrupted");
pfree(lexeme);
diff --git a/src/backend/utils/adt/array_typanalyze.c
b/src/backend/utils/adt/array_typanalyze.c
index 5841d7d6fc..52e160d6bb 100644
--- a/src/backend/utils/adt/array_typanalyze.c
+++ b/src/backend/utils/adt/array_typanalyze.c
@@ -362,7 +362,7 @@ compute_array_stats(VacAttrStats *stats,
AnalyzeAttrFetchFunc fetchfunc,
/* Lookup current element in hashtable, adding it if
new */
elem_value = elem_values[j];
item = (TrackItem *) hash_search(elements_tab,
-
(const void *) &elem_value,
+
&elem_value,
HASH_ENTER, &found);
if (found)
@@ -690,7 +690,7 @@ prune_element_hashtable(HTAB *elements_tab, int b_current)
{
Datum value = item->key;
- if (hash_search(elements_tab, (const void *) &item->key,
+ if (hash_search(elements_tab, &item->key,
HASH_REMOVE, NULL) ==
NULL)
elog(ERROR, "hash table corrupted");
/* We should free memory if element is not passed by
value */
diff --git a/src/backend/utils/adt/ri_triggers.c
b/src/backend/utils/adt/ri_triggers.c
index 995571ae04..375b17b9f3 100644
--- a/src/backend/utils/adt/ri_triggers.c
+++ b/src/backend/utils/adt/ri_triggers.c
@@ -2129,7 +2129,7 @@ ri_LoadConstraintInfo(Oid constraintOid)
* Find or create a hash entry. If we find a valid one, just return it.
*/
riinfo = (RI_ConstraintInfo *) hash_search(ri_constraint_cache,
-
(void *) &constraintOid,
+
&constraintOid,
HASH_ENTER, &found);
if (!found)
riinfo->valid = false;
@@ -2724,7 +2724,7 @@ ri_FetchPreparedPlan(RI_QueryKey *key)
* Lookup for the key
*/
entry = (RI_QueryHashEntry *) hash_search(ri_query_cache,
-
(void *) key,
+
key,
HASH_FIND, NULL);
if (entry == NULL)
return NULL;
@@ -2777,7 +2777,7 @@ ri_HashPreparedPlan(RI_QueryKey *key, SPIPlanPtr plan)
* invalid by ri_FetchPreparedPlan.
*/
entry = (RI_QueryHashEntry *) hash_search(ri_query_cache,
-
(void *) key,
+
key,
HASH_ENTER, &found);
Assert(!found || entry->plan == NULL);
entry->plan = plan;
@@ -2927,7 +2927,7 @@ ri_HashCompareOp(Oid eq_opr, Oid typeid)
key.eq_opr = eq_opr;
key.typeid = typeid;
entry = (RI_CompareHashEntry *) hash_search(ri_compare_cache,
-
(void *) &key,
+
&key,
HASH_ENTER, &found);
if (!found)
entry->valid = false;
diff --git a/src/backend/utils/cache/attoptcache.c
b/src/backend/utils/cache/attoptcache.c
index 28a99f0fc4..6769d4765b 100644
--- a/src/backend/utils/cache/attoptcache.c
+++ b/src/backend/utils/cache/attoptcache.c
@@ -63,7 +63,7 @@ InvalidateAttoptCacheCallback(Datum arg, int cacheid, uint32
hashvalue)
if (attopt->opts)
pfree(attopt->opts);
if (hash_search(AttoptCacheHash,
- (void *) &attopt->key,
+ &attopt->key,
HASH_REMOVE,
NULL) == NULL)
elog(ERROR, "hash table corrupted");
@@ -116,7 +116,7 @@ get_attribute_options(Oid attrelid, int attnum)
key.attnum = attnum;
attopt =
(AttoptCacheEntry *) hash_search(AttoptCacheHash,
-
(void *) &key,
+
&key,
HASH_FIND,
NULL);
@@ -163,7 +163,7 @@ get_attribute_options(Oid attrelid, int attnum)
* pg_attribute, since the read could cause a cache flush.
*/
attopt = (AttoptCacheEntry *) hash_search(AttoptCacheHash,
-
(void *) &key,
+
&key,
HASH_ENTER,
NULL);
attopt->opts = opts;
diff --git a/src/backend/utils/cache/relcache.c
b/src/backend/utils/cache/relcache.c
index d171cfcf2f..dfda0ab7d6 100644
--- a/src/backend/utils/cache/relcache.c
+++ b/src/backend/utils/cache/relcache.c
@@ -210,7 +210,7 @@ static int EOXactTupleDescArrayLen = 0;
do { \
RelIdCacheEnt *hentry; bool found; \
hentry = (RelIdCacheEnt *) hash_search(RelationIdCache, \
-
(void *) &((RELATION)->rd_id), \
+
&((RELATION)->rd_id), \
HASH_ENTER, &found); \
if (found) \
{ \
@@ -232,7 +232,7 @@ do { \
do { \
RelIdCacheEnt *hentry; \
hentry = (RelIdCacheEnt *) hash_search(RelationIdCache, \
-
(void *) &(ID), \
+
&(ID), \
HASH_FIND, NULL); \
if (hentry) \
RELATION = hentry->reldesc; \
@@ -244,7 +244,7 @@ do { \
do { \
RelIdCacheEnt *hentry; \
hentry = (RelIdCacheEnt *) hash_search(RelationIdCache, \
-
(void *) &((RELATION)->rd_id), \
+
&((RELATION)->rd_id), \
HASH_REMOVE, NULL); \
if (hentry == NULL) \
elog(WARNING, "failed to delete relcache entry for OID %u", \
@@ -1663,7 +1663,7 @@ LookupOpclassInfo(Oid operatorClassOid,
}
opcentry = (OpClassCacheEnt *) hash_search(OpClassCache,
-
(void *) &operatorClassOid,
+
&operatorClassOid,
HASH_ENTER, &found);
if (!found)
@@ -3210,7 +3210,7 @@ AtEOXact_RelationCache(bool isCommit)
for (i = 0; i < eoxact_list_len; i++)
{
idhentry = (RelIdCacheEnt *)
hash_search(RelationIdCache,
-
(void *) &eoxact_list[i],
+
&eoxact_list[i],
HASH_FIND,
NULL);
if (idhentry != NULL)
@@ -3359,7 +3359,7 @@ AtEOSubXact_RelationCache(bool isCommit, SubTransactionId
mySubid,
for (i = 0; i < eoxact_list_len; i++)
{
idhentry = (RelIdCacheEnt *)
hash_search(RelationIdCache,
-
(void *) &eoxact_list[i],
+
&eoxact_list[i],
HASH_FIND,
NULL);
if (idhentry != NULL)
diff --git a/src/backend/utils/cache/relfilenumbermap.c
b/src/backend/utils/cache/relfilenumbermap.c
index 57c3254795..220f33d43f 100644
--- a/src/backend/utils/cache/relfilenumbermap.c
+++ b/src/backend/utils/cache/relfilenumbermap.c
@@ -72,7 +72,7 @@ RelfilenumberMapInvalidateCallback(Datum arg, Oid relid)
entry->relid == relid) /* individual flushed relation
*/
{
if (hash_search(RelfilenumberMapHash,
- (void *) &entry->key,
+ &entry->key,
HASH_REMOVE,
NULL) == NULL)
elog(ERROR, "hash table corrupted");
@@ -164,7 +164,7 @@ RelidByRelfilenumber(Oid reltablespace, RelFileNumber
relfilenumber)
* since querying invalid values isn't supposed to be a frequent thing,
* but it's basically free.
*/
- entry = hash_search(RelfilenumberMapHash, (void *) &key, HASH_FIND,
&found);
+ entry = hash_search(RelfilenumberMapHash, &key, HASH_FIND, &found);
if (found)
return entry->relid;
@@ -235,7 +235,7 @@ RelidByRelfilenumber(Oid reltablespace, RelFileNumber
relfilenumber)
* caused cache invalidations to be executed which would have deleted a
* new entry if we had entered it above.
*/
- entry = hash_search(RelfilenumberMapHash, (void *) &key, HASH_ENTER,
&found);
+ entry = hash_search(RelfilenumberMapHash, &key, HASH_ENTER, &found);
if (found)
elog(ERROR, "corrupted hashtable");
entry->relid = relid;
diff --git a/src/backend/utils/cache/spccache.c
b/src/backend/utils/cache/spccache.c
index aabe6ba64b..136fd737d3 100644
--- a/src/backend/utils/cache/spccache.c
+++ b/src/backend/utils/cache/spccache.c
@@ -63,7 +63,7 @@ InvalidateTableSpaceCacheCallback(Datum arg, int cacheid,
uint32 hashvalue)
if (spc->opts)
pfree(spc->opts);
if (hash_search(TableSpaceCacheHash,
- (void *) &spc->oid,
+ &spc->oid,
HASH_REMOVE,
NULL) == NULL)
elog(ERROR, "hash table corrupted");
@@ -121,7 +121,7 @@ get_tablespace(Oid spcid)
if (!TableSpaceCacheHash)
InitializeTableSpaceCache();
spc = (TableSpaceCacheEntry *) hash_search(TableSpaceCacheHash,
-
(void *) &spcid,
+
&spcid,
HASH_FIND,
NULL);
if (spc)
@@ -163,7 +163,7 @@ get_tablespace(Oid spcid)
* flush.
*/
spc = (TableSpaceCacheEntry *) hash_search(TableSpaceCacheHash,
-
(void *) &spcid,
+
&spcid,
HASH_ENTER,
NULL);
spc->opts = opts;
diff --git a/src/backend/utils/cache/ts_cache.c
b/src/backend/utils/cache/ts_cache.c
index 519fa9fa73..3f256f9bf9 100644
--- a/src/backend/utils/cache/ts_cache.c
+++ b/src/backend/utils/cache/ts_cache.c
@@ -139,7 +139,7 @@ lookup_ts_parser_cache(Oid prsId)
/* Try to look up an existing entry */
entry = (TSParserCacheEntry *) hash_search(TSParserCacheHash,
-
(void *) &prsId,
+
&prsId,
HASH_FIND, NULL);
if (entry == NULL || !entry->isvalid)
{
@@ -173,7 +173,7 @@ lookup_ts_parser_cache(Oid prsId)
/* Now make the cache entry */
entry = (TSParserCacheEntry *)
hash_search(TSParserCacheHash,
- (void *) &prsId,
+ &prsId,
HASH_ENTER, &found);
Assert(!found); /* it wasn't there a moment ago
*/
}
@@ -238,7 +238,7 @@ lookup_ts_dictionary_cache(Oid dictId)
/* Try to look up an existing entry */
entry = (TSDictionaryCacheEntry *) hash_search(TSDictionaryCacheHash,
-
(void *) &dictId,
+
&dictId,
HASH_FIND, NULL);
if (entry == NULL || !entry->isvalid)
{
@@ -288,7 +288,7 @@ lookup_ts_dictionary_cache(Oid dictId)
/* Now make the cache entry */
entry = (TSDictionaryCacheEntry *)
hash_search(TSDictionaryCacheHash,
- (void *) &dictId,
+ &dictId,
HASH_ENTER, &found);
Assert(!found); /* it wasn't there a moment ago
*/
@@ -401,7 +401,7 @@ lookup_ts_config_cache(Oid cfgId)
/* Try to look up an existing entry */
entry = (TSConfigCacheEntry *) hash_search(TSConfigCacheHash,
-
(void *) &cfgId,
+
&cfgId,
HASH_FIND, NULL);
if (entry == NULL || !entry->isvalid)
{
@@ -441,7 +441,7 @@ lookup_ts_config_cache(Oid cfgId)
/* Now make the cache entry */
entry = (TSConfigCacheEntry *)
hash_search(TSConfigCacheHash,
- (void *) &cfgId,
+ &cfgId,
HASH_ENTER, &found);
Assert(!found); /* it wasn't there a moment ago
*/
}
diff --git a/src/backend/utils/cache/typcache.c
b/src/backend/utils/cache/typcache.c
index 4a3e0fdb7f..ed6360ce2b 100644
--- a/src/backend/utils/cache/typcache.c
+++ b/src/backend/utils/cache/typcache.c
@@ -364,7 +364,7 @@ lookup_type_cache(Oid type_id, int flags)
/* Try to look up an existing entry */
typentry = (TypeCacheEntry *) hash_search(TypeCacheHash,
-
(void *) &type_id,
+
&type_id,
HASH_FIND, NULL);
if (typentry == NULL)
{
@@ -392,7 +392,7 @@ lookup_type_cache(Oid type_id, int flags)
/* Now make the typcache entry */
typentry = (TypeCacheEntry *) hash_search(TypeCacheHash,
-
(void *) &type_id,
+
&type_id,
HASH_ENTER, &found);
Assert(!found); /* it wasn't there a moment ago
*/
@@ -1974,7 +1974,7 @@ assign_record_type_typmod(TupleDesc tupDesc)
* the allocations succeed before we create the new entry.
*/
recentry = (RecordCacheEntry *) hash_search(RecordCacheHash,
-
(void *) &tupDesc,
+
&tupDesc,
HASH_FIND, &found);
if (found && recentry->tupdesc != NULL)
{
@@ -2012,7 +2012,7 @@ assign_record_type_typmod(TupleDesc tupDesc)
/* Fully initialized; create the hash table entry */
recentry = (RecordCacheEntry *) hash_search(RecordCacheHash,
-
(void *) &tupDesc,
+
&tupDesc,
HASH_ENTER, NULL);
recentry->tupdesc = entDesc;
diff --git a/src/backend/utils/time/combocid.c
b/src/backend/utils/time/combocid.c
index c7124d284f..0e94bc93f7 100644
--- a/src/backend/utils/time/combocid.c
+++ b/src/backend/utils/time/combocid.c
@@ -253,7 +253,7 @@ GetComboCommandId(CommandId cmin, CommandId cmax)
key.cmin = cmin;
key.cmax = cmax;
entry = (ComboCidEntry) hash_search(comboHash,
-
(void *) &key,
+
&key,
HASH_ENTER,
&found);
diff --git a/src/pl/plpgsql/src/pl_comp.c b/src/pl/plpgsql/src/pl_comp.c
index 8ce4186240..7db912fd18 100644
--- a/src/pl/plpgsql/src/pl_comp.c
+++ b/src/pl/plpgsql/src/pl_comp.c
@@ -2627,7 +2627,7 @@ plpgsql_HashTableLookup(PLpgSQL_func_hashkey *func_key)
plpgsql_HashEnt *hentry;
hentry = (plpgsql_HashEnt *) hash_search(plpgsql_HashTable,
-
(void *) func_key,
+
func_key,
HASH_FIND,
NULL);
if (hentry)
@@ -2644,7 +2644,7 @@ plpgsql_HashTableInsert(PLpgSQL_function *function,
bool found;
hentry = (plpgsql_HashEnt *) hash_search(plpgsql_HashTable,
-
(void *) func_key,
+
func_key,
HASH_ENTER,
&found);
if (found)
@@ -2665,7 +2665,7 @@ plpgsql_HashTableDelete(PLpgSQL_function *function)
return;
hentry = (plpgsql_HashEnt *) hash_search(plpgsql_HashTable,
-
(void *) function->fn_hashkey,
+
function->fn_hashkey,
HASH_REMOVE,
NULL);
if (hentry == NULL)
diff --git a/src/pl/plpgsql/src/pl_exec.c b/src/pl/plpgsql/src/pl_exec.c
index 37da624388..70a002a0f6 100644
--- a/src/pl/plpgsql/src/pl_exec.c
+++ b/src/pl/plpgsql/src/pl_exec.c
@@ -7775,7 +7775,7 @@ get_cast_hashentry(PLpgSQL_execstate *estate,
cast_key.srctypmod = srctypmod;
cast_key.dsttypmod = dsttypmod;
cast_entry = (plpgsql_CastHashEntry *) hash_search(estate->cast_hash,
-
(void *) &cast_key,
+
&cast_key,
HASH_ENTER, &found);
if (!found) /* initialize if new
entry */
cast_entry->cast_cexpr = NULL;
--
2.39.1
From 597d41490d8eda8e3d9361ae39788813828712fc Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Thu, 2 Feb 2023 23:02:35 +0100
Subject: [PATCH 2/8] Remove useless casts to (void *) (repalloc)
---
contrib/ltree/ltxtquery_io.c | 2 +-
src/backend/access/gist/gistutil.c | 2 +-
src/backend/tsearch/spell.c | 4 ++--
src/backend/tsearch/ts_parse.c | 6 +++---
src/backend/tsearch/ts_utils.c | 2 +-
src/backend/utils/adt/tsgistidx.c | 2 +-
src/backend/utils/adt/tsquery.c | 2 +-
src/backend/utils/adt/tsquery_cleanup.c | 2 +-
src/backend/utils/adt/tsvector.c | 4 ++--
9 files changed, 13 insertions(+), 13 deletions(-)
diff --git a/contrib/ltree/ltxtquery_io.c b/contrib/ltree/ltxtquery_io.c
index d9910e6c99..82d617f1ae 100644
--- a/contrib/ltree/ltxtquery_io.c
+++ b/contrib/ltree/ltxtquery_io.c
@@ -195,7 +195,7 @@ pushval_asis(QPRS_STATE *state, int type, char *strval, int
lenval, uint16 flag)
int32 tmp = state->curop - state->op;
state->lenop *= 2;
- state->op = (char *) repalloc((void *) state->op, state->lenop);
+ state->op = (char *) repalloc(state->op, state->lenop);
state->curop = state->op + tmp;
}
memcpy((void *) state->curop, (void *) strval, lenval);
diff --git a/src/backend/access/gist/gistutil.c
b/src/backend/access/gist/gistutil.c
index 56451fede1..b4d843a0ff 100644
--- a/src/backend/access/gist/gistutil.c
+++ b/src/backend/access/gist/gistutil.c
@@ -113,7 +113,7 @@ gistextractpage(Page page, int *len /* out */ )
IndexTuple *
gistjoinvector(IndexTuple *itvec, int *len, IndexTuple *additvec, int addlen)
{
- itvec = (IndexTuple *) repalloc((void *) itvec, sizeof(IndexTuple) *
((*len) + addlen));
+ itvec = (IndexTuple *) repalloc(itvec, sizeof(IndexTuple) * ((*len) +
addlen));
memmove(&itvec[*len], additvec, sizeof(IndexTuple) * addlen);
*len += addlen;
return itvec;
diff --git a/src/backend/tsearch/spell.c b/src/backend/tsearch/spell.c
index 83838ab438..c8dfed6178 100644
--- a/src/backend/tsearch/spell.c
+++ b/src/backend/tsearch/spell.c
@@ -695,7 +695,7 @@ NIAddAffix(IspellDict *Conf, const char *flag, char
flagflags, const char *mask,
if (Conf->maffixes)
{
Conf->maffixes *= 2;
- Conf->Affix = (AFFIX *) repalloc((void *) Conf->Affix,
Conf->maffixes * sizeof(AFFIX));
+ Conf->Affix = (AFFIX *) repalloc(Conf->Affix,
Conf->maffixes * sizeof(AFFIX));
}
else
{
@@ -1116,7 +1116,7 @@ addCompoundAffixFlagValue(IspellDict *Conf, char *s,
uint32 val)
{
Conf->mCompoundAffixFlag *= 2;
Conf->CompoundAffixFlags = (CompoundAffixFlag *)
- repalloc((void *) Conf->CompoundAffixFlags,
+ repalloc(Conf->CompoundAffixFlags,
Conf->mCompoundAffixFlag *
sizeof(CompoundAffixFlag));
}
else
diff --git a/src/backend/tsearch/ts_parse.c b/src/backend/tsearch/ts_parse.c
index 9b6d934958..25d9852778 100644
--- a/src/backend/tsearch/ts_parse.c
+++ b/src/backend/tsearch/ts_parse.c
@@ -410,7 +410,7 @@ parsetext(Oid cfgId, ParsedText *prs, char *buf, int buflen)
if (prs->curwords == prs->lenwords)
{
prs->lenwords *= 2;
- prs->words = (ParsedWord *)
repalloc((void *) prs->words, prs->lenwords * sizeof(ParsedWord));
+ prs->words = (ParsedWord *)
repalloc(prs->words, prs->lenwords * sizeof(ParsedWord));
}
if (ptr->flags & TSL_ADDPOS)
@@ -442,7 +442,7 @@ hladdword(HeadlineParsedText *prs, char *buf, int buflen,
int type)
if (prs->curwords >= prs->lenwords)
{
prs->lenwords *= 2;
- prs->words = (HeadlineWordEntry *) repalloc((void *)
prs->words, prs->lenwords * sizeof(HeadlineWordEntry));
+ prs->words = (HeadlineWordEntry *) repalloc(prs->words,
prs->lenwords * sizeof(HeadlineWordEntry));
}
memset(&(prs->words[prs->curwords]), 0, sizeof(HeadlineWordEntry));
prs->words[prs->curwords].type = (uint8) type;
@@ -470,7 +470,7 @@ hlfinditem(HeadlineParsedText *prs, TSQuery query, int32
pos, char *buf, int buf
while (prs->curwords + query->size >= prs->lenwords)
{
prs->lenwords *= 2;
- prs->words = (HeadlineWordEntry *) repalloc((void *)
prs->words, prs->lenwords * sizeof(HeadlineWordEntry));
+ prs->words = (HeadlineWordEntry *) repalloc(prs->words,
prs->lenwords * sizeof(HeadlineWordEntry));
}
word = &(prs->words[prs->curwords - 1]);
diff --git a/src/backend/tsearch/ts_utils.c b/src/backend/tsearch/ts_utils.c
index bb954184d3..c46867d074 100644
--- a/src/backend/tsearch/ts_utils.c
+++ b/src/backend/tsearch/ts_utils.c
@@ -109,7 +109,7 @@ readstoplist(const char *fname, StopList *s, char
*(*wordop) (const char *))
else
{
reallen *= 2;
- stop = (char **) repalloc((void *) stop,
+ stop = (char **) repalloc(stop,
sizeof(char *) * reallen);
}
}
diff --git a/src/backend/utils/adt/tsgistidx.c
b/src/backend/utils/adt/tsgistidx.c
index f0411bf48f..a360b26ee2 100644
--- a/src/backend/utils/adt/tsgistidx.c
+++ b/src/backend/utils/adt/tsgistidx.c
@@ -204,7 +204,7 @@ gtsvector_compress(PG_FUNCTION_ARGS)
* val->size
*/
len = CALCGTSIZE(ARRKEY, len);
- res = (SignTSVector *) repalloc((void *) res, len);
+ res = (SignTSVector *) repalloc(res, len);
SET_VARSIZE(res, len);
}
diff --git a/src/backend/utils/adt/tsquery.c b/src/backend/utils/adt/tsquery.c
index 25150c6d16..e22a2c20a0 100644
--- a/src/backend/utils/adt/tsquery.c
+++ b/src/backend/utils/adt/tsquery.c
@@ -602,7 +602,7 @@ pushValue(TSQueryParserState state, char *strval, int
lenval, int16 weight, bool
int used = state->curop - state->op;
state->lenop *= 2;
- state->op = (char *) repalloc((void *) state->op, state->lenop);
+ state->op = (char *) repalloc(state->op, state->lenop);
state->curop = state->op + used;
}
memcpy((void *) state->curop, (void *) strval, lenval);
diff --git a/src/backend/utils/adt/tsquery_cleanup.c
b/src/backend/utils/adt/tsquery_cleanup.c
index 59b3e859c3..7b9210c321 100644
--- a/src/backend/utils/adt/tsquery_cleanup.c
+++ b/src/backend/utils/adt/tsquery_cleanup.c
@@ -67,7 +67,7 @@ plainnode(PLAINTREE *state, NODE *node)
if (state->cur == state->len)
{
state->len *= 2;
- state->ptr = (QueryItem *) repalloc((void *) state->ptr,
state->len * sizeof(QueryItem));
+ state->ptr = (QueryItem *) repalloc(state->ptr, state->len *
sizeof(QueryItem));
}
memcpy((void *) &(state->ptr[state->cur]), (void *) node->valnode,
sizeof(QueryItem));
if (node->valnode->type == QI_VAL)
diff --git a/src/backend/utils/adt/tsvector.c b/src/backend/utils/adt/tsvector.c
index c7e20ce4ec..77673864a2 100644
--- a/src/backend/utils/adt/tsvector.c
+++ b/src/backend/utils/adt/tsvector.c
@@ -232,14 +232,14 @@ tsvectorin(PG_FUNCTION_ARGS)
{
arrlen *= 2;
arr = (WordEntryIN *)
- repalloc((void *) arr, sizeof(WordEntryIN) *
arrlen);
+ repalloc(arr, sizeof(WordEntryIN) * arrlen);
}
while ((cur - tmpbuf) + toklen >= buflen)
{
int dist = cur - tmpbuf;
buflen *= 2;
- tmpbuf = (char *) repalloc((void *) tmpbuf, buflen);
+ tmpbuf = (char *) repalloc(tmpbuf, buflen);
cur = tmpbuf + dist;
}
arr[len].entry.len = toklen;
--
2.39.1
From 5104fe8d3c2569d74ef77626684d9a38372d36f8 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Thu, 2 Feb 2023 23:02:34 +0100
Subject: [PATCH 3/8] Remove useless casts to (void *) (memcpy)
---
contrib/btree_gist/btree_bit.c | 2 +-
contrib/btree_gist/btree_interval.c | 4 ++--
contrib/btree_gist/btree_utils_num.c | 6 +++---
contrib/btree_gist/btree_uuid.c | 4 ++--
contrib/ltree/ltxtquery_io.c | 4 ++--
contrib/pg_trgm/trgm_gist.c | 2 +-
doc/src/sgml/xfunc.sgml | 4 ++--
src/backend/access/gist/gistproc.c | 4 ++--
src/backend/storage/ipc/procarray.c | 4 ++--
src/backend/utils/adt/tsgistidx.c | 2 +-
src/backend/utils/adt/tsquery.c | 4 ++--
src/backend/utils/adt/tsquery_cleanup.c | 2 +-
src/backend/utils/adt/tsvector.c | 2 +-
src/tutorial/funcs.c | 4 ++--
14 files changed, 24 insertions(+), 24 deletions(-)
diff --git a/contrib/btree_gist/btree_bit.c b/contrib/btree_gist/btree_bit.c
index 5b246bcde4..6790f22b4b 100644
--- a/contrib/btree_gist/btree_bit.c
+++ b/contrib/btree_gist/btree_bit.c
@@ -84,7 +84,7 @@ gbt_bit_xfrm(bytea *leaf)
while (sz < padded_sz)
((char *) out)[sz++] = 0;
SET_VARSIZE(out, padded_sz);
- memcpy((void *) VARDATA(out), (void *) VARBITS(leaf),
VARBITBYTES(leaf));
+ memcpy(VARDATA(out), VARBITS(leaf), VARBITBYTES(leaf));
return out;
}
diff --git a/contrib/btree_gist/btree_interval.c
b/contrib/btree_gist/btree_interval.c
index 2c98b330cd..b0afdf02bb 100644
--- a/contrib/btree_gist/btree_interval.c
+++ b/contrib/btree_gist/btree_interval.c
@@ -157,8 +157,8 @@ gbt_intv_compress(PG_FUNCTION_ARGS)
{
Interval *key = DatumGetIntervalP(entry->key);
- memcpy((void *) r, (void *) key, INTERVALSIZE);
- memcpy((void *) (r + INTERVALSIZE), (void *) key,
INTERVALSIZE);
+ memcpy(r, key, INTERVALSIZE);
+ memcpy(r + INTERVALSIZE, key, INTERVALSIZE);
}
else
{
diff --git a/contrib/btree_gist/btree_utils_num.c
b/contrib/btree_gist/btree_utils_num.c
index 05c154afa3..cfbecbea65 100644
--- a/contrib/btree_gist/btree_utils_num.c
+++ b/contrib/btree_gist/btree_utils_num.c
@@ -87,8 +87,8 @@ gbt_num_compress(GISTENTRY *entry, const gbtree_ninfo *tinfo)
Assert(tinfo->indexsize >= 2 * tinfo->size);
- memcpy((void *) &r[0], leaf, tinfo->size);
- memcpy((void *) &r[tinfo->size], leaf, tinfo->size);
+ memcpy(&r[0], leaf, tinfo->size);
+ memcpy(&r[tinfo->size], leaf, tinfo->size);
retval = palloc(sizeof(GISTENTRY));
gistentryinit(*retval, PointerGetDatum(r), entry->rel,
entry->page,
entry->offset, false);
@@ -184,7 +184,7 @@ gbt_num_union(GBT_NUMKEY *out, const GistEntryVector
*entryvec, const gbtree_nin
o.lower = &((GBT_NUMKEY *) out)[0];
o.upper = &((GBT_NUMKEY *) out)[tinfo->size];
- memcpy((void *) out, (void *) cur, 2 * tinfo->size);
+ memcpy(out, cur, 2 * tinfo->size);
for (i = 1; i < numranges; i++)
{
diff --git a/contrib/btree_gist/btree_uuid.c b/contrib/btree_gist/btree_uuid.c
index b81875979a..fe8c679cbe 100644
--- a/contrib/btree_gist/btree_uuid.c
+++ b/contrib/btree_gist/btree_uuid.c
@@ -110,8 +110,8 @@ gbt_uuid_compress(PG_FUNCTION_ARGS)
retval = palloc(sizeof(GISTENTRY));
- memcpy((void *) r, (void *) key, UUID_LEN);
- memcpy((void *) (r + UUID_LEN), (void *) key, UUID_LEN);
+ memcpy(r, key, UUID_LEN);
+ memcpy(r + UUID_LEN, key, UUID_LEN);
gistentryinit(*retval, PointerGetDatum(r),
entry->rel, entry->page,
entry->offset, false);
diff --git a/contrib/ltree/ltxtquery_io.c b/contrib/ltree/ltxtquery_io.c
index 82d617f1ae..0d29e15630 100644
--- a/contrib/ltree/ltxtquery_io.c
+++ b/contrib/ltree/ltxtquery_io.c
@@ -198,7 +198,7 @@ pushval_asis(QPRS_STATE *state, int type, char *strval, int
lenval, uint16 flag)
state->op = (char *) repalloc(state->op, state->lenop);
state->curop = state->op + tmp;
}
- memcpy((void *) state->curop, (void *) strval, lenval);
+ memcpy(state->curop, strval, lenval);
state->curop += lenval;
*(state->curop) = '\0';
state->curop++;
@@ -391,7 +391,7 @@ queryin(char *buf, struct Node *escontext)
}
/* set user-friendly operand view */
- memcpy((void *) GETOPERAND(query), (void *) state.op, state.sumlen);
+ memcpy(GETOPERAND(query), state.op, state.sumlen);
pfree(state.op);
/* set left operand's position for every operator */
diff --git a/contrib/pg_trgm/trgm_gist.c b/contrib/pg_trgm/trgm_gist.c
index ef5d8cca78..68ebf1767b 100644
--- a/contrib/pg_trgm/trgm_gist.c
+++ b/contrib/pg_trgm/trgm_gist.c
@@ -755,7 +755,7 @@ fillcache(CACHESIGN *item, TRGM *key, BITVECP sign, int
siglen)
else if (ISALLTRUE(key))
item->allistrue = true;
else
- memcpy((void *) item->sign, (void *) GETSIGN(key), siglen);
+ memcpy(item->sign, GETSIGN(key), siglen);
}
#define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
diff --git a/doc/src/sgml/xfunc.sgml b/doc/src/sgml/xfunc.sgml
index 52e5aa17bf..e2a5496c34 100644
--- a/doc/src/sgml/xfunc.sgml
+++ b/doc/src/sgml/xfunc.sgml
@@ -2456,8 +2456,8 @@ <title>Version 1 Calling Conventions</title>
* VARDATA is a pointer to the data region of the new struct. The source
* could be a short datum, so retrieve its data through VARDATA_ANY.
*/
- memcpy((void *) VARDATA(new_t), /* destination */
- (void *) VARDATA_ANY(t), /* source */
+ memcpy(VARDATA(new_t), /* destination */
+ VARDATA_ANY(t), /* source */
VARSIZE_ANY_EXHDR(t)); /* how many bytes */
PG_RETURN_TEXT_P(new_t);
}
diff --git a/src/backend/access/gist/gistproc.c
b/src/backend/access/gist/gistproc.c
index eb9178d456..4881034069 100644
--- a/src/backend/access/gist/gistproc.c
+++ b/src/backend/access/gist/gistproc.c
@@ -173,7 +173,7 @@ gist_box_union(PG_FUNCTION_ARGS)
numranges = entryvec->n;
pageunion = (BOX *) palloc(sizeof(BOX));
cur = DatumGetBoxP(entryvec->vector[0].key);
- memcpy((void *) pageunion, (void *) cur, sizeof(BOX));
+ memcpy(pageunion, cur, sizeof(BOX));
for (i = 1; i < numranges; i++)
{
@@ -1043,7 +1043,7 @@ gist_poly_compress(PG_FUNCTION_ARGS)
BOX *r;
r = (BOX *) palloc(sizeof(BOX));
- memcpy((void *) r, (void *) &(in->boundbox), sizeof(BOX));
+ memcpy(r, &(in->boundbox), sizeof(BOX));
retval = (GISTENTRY *) palloc(sizeof(GISTENTRY));
gistentryinit(*retval, PointerGetDatum(r),
diff --git a/src/backend/storage/ipc/procarray.c
b/src/backend/storage/ipc/procarray.c
index 4340bf9641..a7071b2fce 100644
--- a/src/backend/storage/ipc/procarray.c
+++ b/src/backend/storage/ipc/procarray.c
@@ -2394,7 +2394,7 @@ GetSnapshotData(Snapshot snapshot)
pg_read_barrier(); /*
pairs with GetNewTransactionId */
memcpy(snapshot->subxip +
subcount,
- (void *)
proc->subxids.xids,
+ proc->subxids.xids,
nsubxids *
sizeof(TransactionId));
subcount += nsubxids;
}
@@ -2846,7 +2846,7 @@ GetRunningTransactionData(void)
/* barrier not really required, as XidGenLock
is held, but ... */
pg_read_barrier(); /* pairs with
GetNewTransactionId */
- memcpy(&xids[count], (void *)
proc->subxids.xids,
+ memcpy(&xids[count], proc->subxids.xids,
nsubxids * sizeof(TransactionId));
count += nsubxids;
subcount += nsubxids;
diff --git a/src/backend/utils/adt/tsgistidx.c
b/src/backend/utils/adt/tsgistidx.c
index a360b26ee2..e27e08d996 100644
--- a/src/backend/utils/adt/tsgistidx.c
+++ b/src/backend/utils/adt/tsgistidx.c
@@ -577,7 +577,7 @@ fillcache(CACHESIGN *item, SignTSVector *key, int siglen)
else if (ISALLTRUE(key))
item->allistrue = true;
else
- memcpy((void *) item->sign, (void *) GETSIGN(key), siglen);
+ memcpy(item->sign, GETSIGN(key), siglen);
}
#define WISH_F(a,b,c) (double)( -(double)(((a)-(b))*((a)-(b))*((a)-(b)))*(c) )
diff --git a/src/backend/utils/adt/tsquery.c b/src/backend/utils/adt/tsquery.c
index e22a2c20a0..67ad876a27 100644
--- a/src/backend/utils/adt/tsquery.c
+++ b/src/backend/utils/adt/tsquery.c
@@ -605,7 +605,7 @@ pushValue(TSQueryParserState state, char *strval, int
lenval, int16 weight, bool
state->op = (char *) repalloc(state->op, state->lenop);
state->curop = state->op + used;
}
- memcpy((void *) state->curop, (void *) strval, lenval);
+ memcpy(state->curop, strval, lenval);
state->curop += lenval;
*(state->curop) = '\0';
state->curop++;
@@ -924,7 +924,7 @@ parse_tsquery(char *buf,
}
/* Copy all the operand strings to TSQuery */
- memcpy((void *) GETOPERAND(query), (void *) state.op, state.sumlen);
+ memcpy(GETOPERAND(query), state.op, state.sumlen);
pfree(state.op);
/*
diff --git a/src/backend/utils/adt/tsquery_cleanup.c
b/src/backend/utils/adt/tsquery_cleanup.c
index 7b9210c321..dc31665770 100644
--- a/src/backend/utils/adt/tsquery_cleanup.c
+++ b/src/backend/utils/adt/tsquery_cleanup.c
@@ -69,7 +69,7 @@ plainnode(PLAINTREE *state, NODE *node)
state->len *= 2;
state->ptr = (QueryItem *) repalloc(state->ptr, state->len *
sizeof(QueryItem));
}
- memcpy((void *) &(state->ptr[state->cur]), (void *) node->valnode,
sizeof(QueryItem));
+ memcpy(&(state->ptr[state->cur]), node->valnode, sizeof(QueryItem));
if (node->valnode->type == QI_VAL)
state->cur++;
else if (node->valnode->qoperator.oper == OP_NOT)
diff --git a/src/backend/utils/adt/tsvector.c b/src/backend/utils/adt/tsvector.c
index 77673864a2..e5b05960e3 100644
--- a/src/backend/utils/adt/tsvector.c
+++ b/src/backend/utils/adt/tsvector.c
@@ -244,7 +244,7 @@ tsvectorin(PG_FUNCTION_ARGS)
}
arr[len].entry.len = toklen;
arr[len].entry.pos = cur - tmpbuf;
- memcpy((void *) cur, (void *) token, toklen);
+ memcpy(cur, token, toklen);
cur += toklen;
if (poslen != 0)
diff --git a/src/tutorial/funcs.c b/src/tutorial/funcs.c
index cdd155ebbd..ceffb56835 100644
--- a/src/tutorial/funcs.c
+++ b/src/tutorial/funcs.c
@@ -78,8 +78,8 @@ copytext(PG_FUNCTION_ARGS)
* VARDATA is a pointer to the data region of the new struct. The
source
* could be a short datum, so retrieve its data through VARDATA_ANY.
*/
- memcpy((void *) VARDATA(new_t), /* destination */
- (void *) VARDATA_ANY(t), /* source */
+ memcpy(VARDATA(new_t), /* destination */
+ VARDATA_ANY(t), /* source */
VARSIZE_ANY_EXHDR(t)); /* how many bytes */
PG_RETURN_TEXT_P(new_t);
}
--
2.39.1
From ac0833f8a98d4561c0378fbf98345307b578bcbf Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Thu, 2 Feb 2023 23:02:34 +0100
Subject: [PATCH 4/8] Remove useless casts to (void *) (memset)
---
contrib/hstore/hstore_gist.c | 4 ++--
contrib/intarray/_intbig_gist.c | 4 ++--
contrib/ltree/_ltree_gist.c | 4 ++--
contrib/pg_trgm/trgm_gist.c | 6 +++---
src/backend/tsearch/ts_utils.c | 3 +--
src/backend/utils/adt/tsgistidx.c | 6 +++---
src/bin/pg_dump/parallel.c | 2 +-
7 files changed, 14 insertions(+), 15 deletions(-)
diff --git a/contrib/hstore/hstore_gist.c b/contrib/hstore/hstore_gist.c
index 5d8b806d30..d31da564fe 100644
--- a/contrib/hstore/hstore_gist.c
+++ b/contrib/hstore/hstore_gist.c
@@ -465,7 +465,7 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_l) || ISALLTRUE(_j))
{
if (!ISALLTRUE(datum_l))
- memset((void *) union_l, 0xff, siglen);
+ memset(union_l, 0xff, siglen);
}
else
{
@@ -481,7 +481,7 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_r) || ISALLTRUE(_j))
{
if (!ISALLTRUE(datum_r))
- memset((void *) union_r, 0xff, siglen);
+ memset(union_r, 0xff, siglen);
}
else
{
diff --git a/contrib/intarray/_intbig_gist.c b/contrib/intarray/_intbig_gist.c
index dadc18646a..f8fca44ea5 100644
--- a/contrib/intarray/_intbig_gist.c
+++ b/contrib/intarray/_intbig_gist.c
@@ -424,7 +424,7 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_l) || ISALLTRUE(_j))
{
if (!ISALLTRUE(datum_l))
- memset((void *) union_l, 0xff, siglen);
+ memset(union_l, 0xff, siglen);
}
else
{
@@ -440,7 +440,7 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_r) || ISALLTRUE(_j))
{
if (!ISALLTRUE(datum_r))
- memset((void *) union_r, 0xff, siglen);
+ memset(union_r, 0xff, siglen);
}
else
{
diff --git a/contrib/ltree/_ltree_gist.c b/contrib/ltree/_ltree_gist.c
index 385a10283b..4d9ee53f08 100644
--- a/contrib/ltree/_ltree_gist.c
+++ b/contrib/ltree/_ltree_gist.c
@@ -348,7 +348,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
if (LTG_ISALLTRUE(datum_l) || LTG_ISALLTRUE(_j))
{
if (!LTG_ISALLTRUE(datum_l))
- memset((void *) union_l, 0xff, siglen);
+ memset(union_l, 0xff, siglen);
}
else
{
@@ -364,7 +364,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
if (LTG_ISALLTRUE(datum_r) || LTG_ISALLTRUE(_j))
{
if (!LTG_ISALLTRUE(datum_r))
- memset((void *) union_r, 0xff, siglen);
+ memset(union_r, 0xff, siglen);
}
else
{
diff --git a/contrib/pg_trgm/trgm_gist.c b/contrib/pg_trgm/trgm_gist.c
index 68ebf1767b..ed2b010b93 100644
--- a/contrib/pg_trgm/trgm_gist.c
+++ b/contrib/pg_trgm/trgm_gist.c
@@ -102,7 +102,7 @@ makesign(BITVECP sign, TRGM *a, int siglen)
trgm *ptr = GETARR(a);
int32 tmp = 0;
- MemSet((void *) sign, 0, siglen);
+ MemSet(sign, 0, siglen);
SETBIT(sign, SIGLENBIT(siglen)); /* set last unused bit */
for (k = 0; k < len; k++)
{
@@ -921,7 +921,7 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_l) || cache[j].allistrue)
{
if (!ISALLTRUE(datum_l))
- memset((void *) GETSIGN(datum_l), 0xff,
siglen);
+ memset(GETSIGN(datum_l), 0xff, siglen);
}
else
{
@@ -937,7 +937,7 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_r) || cache[j].allistrue)
{
if (!ISALLTRUE(datum_r))
- memset((void *) GETSIGN(datum_r), 0xff,
siglen);
+ memset(GETSIGN(datum_r), 0xff, siglen);
}
else
{
diff --git a/src/backend/tsearch/ts_utils.c b/src/backend/tsearch/ts_utils.c
index c46867d074..7c4c2a9112 100644
--- a/src/backend/tsearch/ts_utils.c
+++ b/src/backend/tsearch/ts_utils.c
@@ -109,8 +109,7 @@ readstoplist(const char *fname, StopList *s, char
*(*wordop) (const char *))
else
{
reallen *= 2;
- stop = (char **) repalloc(stop,
-
sizeof(char *) * reallen);
+ stop = (char **) repalloc(stop,
sizeof(char *) * reallen);
}
}
diff --git a/src/backend/utils/adt/tsgistidx.c
b/src/backend/utils/adt/tsgistidx.c
index e27e08d996..ca4563290f 100644
--- a/src/backend/utils/adt/tsgistidx.c
+++ b/src/backend/utils/adt/tsgistidx.c
@@ -143,7 +143,7 @@ makesign(BITVECP sign, SignTSVector *a, int siglen)
len = ARRNELEM(a);
int32 *ptr = GETARR(a);
- MemSet((void *) sign, 0, siglen);
+ MemSet(sign, 0, siglen);
for (k = 0; k < len; k++)
HASH(sign, ptr[k], siglen);
}
@@ -755,7 +755,7 @@ gtsvector_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_l) || cache[j].allistrue)
{
if (!ISALLTRUE(datum_l))
- memset((void *) GETSIGN(datum_l), 0xff,
siglen);
+ memset(GETSIGN(datum_l), 0xff, siglen);
}
else
{
@@ -771,7 +771,7 @@ gtsvector_picksplit(PG_FUNCTION_ARGS)
if (ISALLTRUE(datum_r) || cache[j].allistrue)
{
if (!ISALLTRUE(datum_r))
- memset((void *) GETSIGN(datum_r), 0xff,
siglen);
+ memset(GETSIGN(datum_r), 0xff, siglen);
}
else
{
diff --git a/src/bin/pg_dump/parallel.c b/src/bin/pg_dump/parallel.c
index 9bfb95557a..da0723ad38 100644
--- a/src/bin/pg_dump/parallel.c
+++ b/src/bin/pg_dump/parallel.c
@@ -1736,7 +1736,7 @@ pgpipe(int handles[2])
return -1;
}
- memset((void *) &serv_addr, 0, sizeof(serv_addr));
+ memset(&serv_addr, 0, sizeof(serv_addr));
serv_addr.sin_family = AF_INET;
serv_addr.sin_port = pg_hton16(0);
serv_addr.sin_addr.s_addr = pg_hton32(INADDR_LOOPBACK);
--
2.39.1
From 7da5b5474a65d5a5a3fd104a624f3e9048f973dd Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Thu, 2 Feb 2023 23:02:35 +0100
Subject: [PATCH 5/8] Remove useless casts to (void *) (memmove)
---
contrib/intarray/_int_gist.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/contrib/intarray/_int_gist.c b/contrib/intarray/_int_gist.c
index 331fa25fcf..2d72e7dafb 100644
--- a/contrib/intarray/_int_gist.c
+++ b/contrib/intarray/_int_gist.c
@@ -243,7 +243,7 @@ g_int_compress(PG_FUNCTION_ARGS)
/*
* shunt everything down to start at the right place
*/
- memmove((void *) &dr[0], (void *) &dr[2 * j], 2 * (len
- j) * sizeof(int32));
+ memmove(&dr[0], &dr[2 * j], 2 * (len - j) *
sizeof(int32));
}
/*
@@ -260,7 +260,7 @@ g_int_compress(PG_FUNCTION_ARGS)
min = ((int64) dr[i] - (int64) dr[i -
1]);
cand = i;
}
- memmove((void *) &dr[cand - 1], (void *) &dr[cand + 1],
(len - cand - 1) * sizeof(int32));
+ memmove(&dr[cand - 1], &dr[cand + 1], (len - cand - 1)
* sizeof(int32));
len -= 2;
}
--
2.39.1
From 122a9bc37bb9e095665e3b44095f0394983a647a Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Thu, 2 Feb 2023 23:02:35 +0100
Subject: [PATCH 6/8] Remove useless casts to (void *) (memcmp)
---
contrib/citext/citext.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/citext/citext.c b/contrib/citext/citext.c
index 976c578e1c..26af935a70 100644
--- a/contrib/citext/citext.c
+++ b/contrib/citext/citext.c
@@ -80,7 +80,7 @@ internal_citext_pattern_cmp(text *left, text *right, Oid
collid)
llen = strlen(lcstr);
rlen = strlen(rcstr);
- result = memcmp((void *) lcstr, (void *) rcstr, Min(llen, rlen));
+ result = memcmp(lcstr, rcstr, Min(llen, rlen));
if (result == 0)
{
if (llen < rlen)
--
2.39.1
From 2b7d664f2f7d475f84ead47eafde28157fcaf061 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Thu, 2 Feb 2023 23:02:35 +0100
Subject: [PATCH 7/8] Remove useless casts to (void *) (qsort)
---
contrib/btree_gist/btree_utils_num.c | 2 +-
contrib/btree_gist/btree_utils_var.c | 4 ++--
contrib/hstore/hstore_gist.c | 2 +-
contrib/hstore/hstore_io.c | 2 +-
contrib/intarray/_int_gist.c | 2 +-
contrib/intarray/_int_tool.c | 2 +-
contrib/intarray/_intbig_gist.c | 2 +-
contrib/ltree/_ltree_gist.c | 2 +-
contrib/ltree/ltree_gist.c | 2 +-
contrib/pg_surgery/heap_surgery.c | 2 +-
contrib/pg_trgm/trgm_gist.c | 2 +-
contrib/pg_trgm/trgm_op.c | 4 ++--
src/backend/access/brin/brin_minmax_multi.c | 6 +++---
src/backend/access/gin/ginutil.c | 2 +-
src/backend/access/nbtree/nbtutils.c | 4 ++--
src/backend/catalog/dependency.c | 6 +++---
src/backend/catalog/pg_shdepend.c | 2 +-
src/backend/commands/analyze.c | 8 ++++----
src/backend/commands/collationcmds.c | 2 +-
src/backend/executor/nodeTidscan.c | 2 +-
src/backend/nodes/tidbitmap.c | 8 ++++----
src/backend/partitioning/partbounds.c | 4 ++--
src/backend/statistics/extended_stats.c | 2 +-
src/backend/statistics/mcv.c | 4 ++--
src/backend/statistics/mvdistinct.c | 2 +-
src/backend/tsearch/spell.c | 8 ++++----
src/backend/tsearch/to_tsany.c | 2 +-
src/backend/utils/adt/tsgistidx.c | 2 +-
src/backend/utils/adt/tsquery_gist.c | 2 +-
src/backend/utils/adt/tsquery_util.c | 2 +-
src/backend/utils/adt/tsrank.c | 4 ++--
src/backend/utils/adt/tsvector.c | 10 +++++-----
src/bin/pg_dump/pg_backup_archiver.c | 2 +-
src/bin/pg_dump/pg_dump_sort.c | 2 +-
src/bin/pg_upgrade/function.c | 2 +-
src/bin/pgbench/pgbench.c | 2 +-
36 files changed, 59 insertions(+), 59 deletions(-)
diff --git a/contrib/btree_gist/btree_utils_num.c
b/contrib/btree_gist/btree_utils_num.c
index cfbecbea65..346ee837d7 100644
--- a/contrib/btree_gist/btree_utils_num.c
+++ b/contrib/btree_gist/btree_utils_num.c
@@ -360,7 +360,7 @@ gbt_num_picksplit(const GistEntryVector *entryvec,
GIST_SPLITVEC *v,
arr[i].t = (GBT_NUMKEY *)
DatumGetPointer((entryvec->vector[i].key));
arr[i].i = i;
}
- qsort_arg((void *) &arr[FirstOffsetNumber], maxoff - FirstOffsetNumber
+ 1, sizeof(Nsrt), (qsort_arg_comparator) tinfo->f_cmp, (void *) flinfo);
+ qsort_arg(&arr[FirstOffsetNumber], maxoff - FirstOffsetNumber + 1,
sizeof(Nsrt), (qsort_arg_comparator) tinfo->f_cmp, flinfo);
/* We do simply create two parts */
diff --git a/contrib/btree_gist/btree_utils_var.c
b/contrib/btree_gist/btree_utils_var.c
index 3ef82d0e20..0c0e952f73 100644
--- a/contrib/btree_gist/btree_utils_var.c
+++ b/contrib/btree_gist/btree_utils_var.c
@@ -502,11 +502,11 @@ gbt_var_picksplit(const GistEntryVector *entryvec,
GIST_SPLITVEC *v,
varg.tinfo = tinfo;
varg.collation = collation;
varg.flinfo = flinfo;
- qsort_arg((void *) &arr[FirstOffsetNumber],
+ qsort_arg(&arr[FirstOffsetNumber],
maxoff - FirstOffsetNumber + 1,
sizeof(Vsrt),
gbt_vsrt_cmp,
- (void *) &varg);
+ &varg);
/* We do simply create two parts */
diff --git a/contrib/hstore/hstore_gist.c b/contrib/hstore/hstore_gist.c
index d31da564fe..3df00493e8 100644
--- a/contrib/hstore/hstore_gist.c
+++ b/contrib/hstore/hstore_gist.c
@@ -436,7 +436,7 @@ ghstore_picksplit(PG_FUNCTION_ARGS)
size_beta = hemdist(datum_r, _j, siglen);
costvector[j - 1].cost = abs(size_alpha - size_beta);
}
- qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
+ qsort(costvector, maxoff, sizeof(SPLITCOST), comparecost);
union_l = GETSIGN(datum_l);
union_r = GETSIGN(datum_r);
diff --git a/contrib/hstore/hstore_io.c b/contrib/hstore/hstore_io.c
index ae09cede8c..cec7df71a2 100644
--- a/contrib/hstore/hstore_io.c
+++ b/contrib/hstore/hstore_io.c
@@ -365,7 +365,7 @@ hstoreUniquePairs(Pairs *a, int32 l, int32 *buflen)
return l;
}
- qsort((void *) a, l, sizeof(Pairs), comparePairs);
+ qsort(a, l, sizeof(Pairs), comparePairs);
/*
* We can't use qunique here because we have some clean-up code to run
on
diff --git a/contrib/intarray/_int_gist.c b/contrib/intarray/_int_gist.c
index 2d72e7dafb..7a48ce624d 100644
--- a/contrib/intarray/_int_gist.c
+++ b/contrib/intarray/_int_gist.c
@@ -542,7 +542,7 @@ g_int_picksplit(PG_FUNCTION_ARGS)
pfree(union_d);
costvector[i - 1].cost = fabsf((size_alpha - size_l) -
(size_beta - size_r));
}
- qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
+ qsort(costvector, maxoff, sizeof(SPLITCOST), comparecost);
/*
* Now split up the regions between the two seeds. An important
property
diff --git a/contrib/intarray/_int_tool.c b/contrib/intarray/_int_tool.c
index 5ab6eb81e8..68f624e085 100644
--- a/contrib/intarray/_int_tool.c
+++ b/contrib/intarray/_int_tool.c
@@ -212,7 +212,7 @@ isort(int32 *a, int len)
{
bool r = false;
- qsort_arg(a, len, sizeof(int32), isort_cmp, (void *) &r);
+ qsort_arg(a, len, sizeof(int32), isort_cmp, &r);
return r;
}
diff --git a/contrib/intarray/_intbig_gist.c b/contrib/intarray/_intbig_gist.c
index f8fca44ea5..bfba5eef1d 100644
--- a/contrib/intarray/_intbig_gist.c
+++ b/contrib/intarray/_intbig_gist.c
@@ -395,7 +395,7 @@ g_intbig_picksplit(PG_FUNCTION_ARGS)
size_beta = hemdist(datum_r, _j, siglen);
costvector[j - 1].cost = abs(size_alpha - size_beta);
}
- qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
+ qsort(costvector, maxoff, sizeof(SPLITCOST), comparecost);
union_l = GETSIGN(datum_l);
union_r = GETSIGN(datum_r);
diff --git a/contrib/ltree/_ltree_gist.c b/contrib/ltree/_ltree_gist.c
index 4d9ee53f08..e89a39a5b5 100644
--- a/contrib/ltree/_ltree_gist.c
+++ b/contrib/ltree/_ltree_gist.c
@@ -319,7 +319,7 @@ _ltree_picksplit(PG_FUNCTION_ARGS)
size_beta = hemdist(datum_r, _j, siglen);
costvector[j - 1].cost = abs(size_alpha - size_beta);
}
- qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
+ qsort(costvector, maxoff, sizeof(SPLITCOST), comparecost);
union_l = LTG_SIGN(datum_l);
union_r = LTG_SIGN(datum_r);
diff --git a/contrib/ltree/ltree_gist.c b/contrib/ltree/ltree_gist.c
index 5d2db6c62b..3cba2269d8 100644
--- a/contrib/ltree/ltree_gist.c
+++ b/contrib/ltree/ltree_gist.c
@@ -328,7 +328,7 @@ ltree_picksplit(PG_FUNCTION_ARGS)
array[j].r = LTG_GETLNODE(lu, siglen);
}
- qsort((void *) &array[FirstOffsetNumber], maxoff - FirstOffsetNumber +
1,
+ qsort(&array[FirstOffsetNumber], maxoff - FirstOffsetNumber + 1,
sizeof(RIX), treekey_cmp);
lu_l = lu_r = ru_l = ru_r = NULL;
diff --git a/contrib/pg_surgery/heap_surgery.c
b/contrib/pg_surgery/heap_surgery.c
index 61b184597a..88a40ab7d3 100644
--- a/contrib/pg_surgery/heap_surgery.c
+++ b/contrib/pg_surgery/heap_surgery.c
@@ -131,7 +131,7 @@ heap_force_common(FunctionCallInfo fcinfo,
HeapTupleForceOption heap_force_opt)
* array.
*/
if (ntids > 1)
- qsort((void *) tids, ntids, sizeof(ItemPointerData), tidcmp);
+ qsort(tids, ntids, sizeof(ItemPointerData), tidcmp);
curr_start_ptr = next_start_ptr = 0;
nblocks = RelationGetNumberOfBlocks(rel);
diff --git a/contrib/pg_trgm/trgm_gist.c b/contrib/pg_trgm/trgm_gist.c
index ed2b010b93..9ef2e38560 100644
--- a/contrib/pg_trgm/trgm_gist.c
+++ b/contrib/pg_trgm/trgm_gist.c
@@ -872,7 +872,7 @@ gtrgm_picksplit(PG_FUNCTION_ARGS)
size_beta = hemdistcache(&(cache[seed_2]), &(cache[j]), siglen);
costvector[j - 1].cost = abs(size_alpha - size_beta);
}
- qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
+ qsort(costvector, maxoff, sizeof(SPLITCOST), comparecost);
for (k = 0; k < maxoff; k++)
{
diff --git a/contrib/pg_trgm/trgm_op.c b/contrib/pg_trgm/trgm_op.c
index 2c644bc148..49d4497b4f 100644
--- a/contrib/pg_trgm/trgm_op.c
+++ b/contrib/pg_trgm/trgm_op.c
@@ -376,7 +376,7 @@ generate_trgm(char *str, int slen)
*/
if (len > 1)
{
- qsort((void *) GETARR(trg), len, sizeof(trgm), comp_trgm);
+ qsort(GETARR(trg), len, sizeof(trgm), comp_trgm);
len = qunique(GETARR(trg), len, sizeof(trgm), comp_trgm);
}
@@ -929,7 +929,7 @@ generate_wildcard_trgm(const char *str, int slen)
*/
if (len > 1)
{
- qsort((void *) GETARR(trg), len, sizeof(trgm), comp_trgm);
+ qsort(GETARR(trg), len, sizeof(trgm), comp_trgm);
len = qunique(GETARR(trg), len, sizeof(trgm), comp_trgm);
}
diff --git a/src/backend/access/brin/brin_minmax_multi.c
b/src/backend/access/brin/brin_minmax_multi.c
index ac670fd02d..0ace6035be 100644
--- a/src/backend/access/brin/brin_minmax_multi.c
+++ b/src/backend/access/brin/brin_minmax_multi.c
@@ -543,7 +543,7 @@ range_deduplicate_values(Ranges *range)
*/
qsort_arg(&range->values[start],
range->nvalues, sizeof(Datum),
- compare_values, (void *) &cxt);
+ compare_values, &cxt);
n = 1;
for (i = 1; i < range->nvalues; i++)
@@ -1197,7 +1197,7 @@ sort_expanded_ranges(FmgrInfo *cmp, Oid colloid,
* some of the points) and do merge sort.
*/
qsort_arg(eranges, neranges, sizeof(ExpandedRange),
- compare_expanded_ranges, (void *) &cxt);
+ compare_expanded_ranges, &cxt);
/*
* Deduplicate the ranges - simply compare each range to the preceding
@@ -1535,7 +1535,7 @@ reduce_expanded_ranges(ExpandedRange *eranges, int
neranges,
* sorted result.
*/
qsort_arg(values, nvalues, sizeof(Datum),
- compare_values, (void *) &cxt);
+ compare_values, &cxt);
/* We have nvalues boundary values, which means nvalues/2 ranges. */
for (i = 0; i < (nvalues / 2); i++)
diff --git a/src/backend/access/gin/ginutil.c b/src/backend/access/gin/ginutil.c
index e7cc452a8a..f05128ecf5 100644
--- a/src/backend/access/gin/ginutil.c
+++ b/src/backend/access/gin/ginutil.c
@@ -560,7 +560,7 @@ ginExtractEntries(GinState *ginstate, OffsetNumber attnum,
arg.collation = ginstate->supportCollation[attnum - 1];
arg.haveDups = false;
qsort_arg(keydata, *nentries, sizeof(keyEntryData),
- cmpEntries, (void *) &arg);
+ cmpEntries, &arg);
if (arg.haveDups)
{
diff --git a/src/backend/access/nbtree/nbtutils.c
b/src/backend/access/nbtree/nbtutils.c
index 8003583c0a..7da499c4dd 100644
--- a/src/backend/access/nbtree/nbtutils.c
+++ b/src/backend/access/nbtree/nbtutils.c
@@ -488,8 +488,8 @@ _bt_sort_array_elements(IndexScanDesc scan, ScanKey skey,
fmgr_info(cmp_proc, &cxt.flinfo);
cxt.collation = skey->sk_collation;
cxt.reverse = reverse;
- qsort_arg((void *) elems, nelems, sizeof(Datum),
- _bt_compare_array_elements, (void *) &cxt);
+ qsort_arg(elems, nelems, sizeof(Datum),
+ _bt_compare_array_elements, &cxt);
/* Now scan the sorted elements and remove duplicates */
return qunique_arg(elems, nelems, sizeof(Datum),
diff --git a/src/backend/catalog/dependency.c b/src/backend/catalog/dependency.c
index 7acf654bf8..f8a136ba0a 100644
--- a/src/backend/catalog/dependency.c
+++ b/src/backend/catalog/dependency.c
@@ -967,7 +967,7 @@ findDependentObjects(const ObjectAddress *object,
* first within ObjectAddressAndFlags.
*/
if (numDependentObjects > 1)
- qsort((void *) dependentObjects, numDependentObjects,
+ qsort(dependentObjects, numDependentObjects,
sizeof(ObjectAddressAndFlags),
object_address_comparator);
@@ -2442,7 +2442,7 @@ eliminate_duplicate_dependencies(ObjectAddresses *addrs)
return; /* nothing to do */
/* Sort the refs so that duplicates are adjacent */
- qsort((void *) addrs->refs, addrs->numrefs, sizeof(ObjectAddress),
+ qsort(addrs->refs, addrs->numrefs, sizeof(ObjectAddress),
object_address_comparator);
/* Remove dups */
@@ -2809,7 +2809,7 @@ void
sort_object_addresses(ObjectAddresses *addrs)
{
if (addrs->numrefs > 1)
- qsort((void *) addrs->refs, addrs->numrefs,
+ qsort(addrs->refs, addrs->numrefs,
sizeof(ObjectAddress),
object_address_comparator);
}
diff --git a/src/backend/catalog/pg_shdepend.c
b/src/backend/catalog/pg_shdepend.c
index 1ce0ba94e3..64d326f073 100644
--- a/src/backend/catalog/pg_shdepend.c
+++ b/src/backend/catalog/pg_shdepend.c
@@ -762,7 +762,7 @@ checkSharedDependencies(Oid classId, Oid objectId,
* Sort and report local and shared objects.
*/
if (numobjects > 1)
- qsort((void *) objects, numobjects,
+ qsort(objects, numobjects,
sizeof(ShDependObjectInfo),
shared_dependency_comparator);
for (int i = 0; i < numobjects; i++)
diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c
index c86e690980..65750958bb 100644
--- a/src/backend/commands/analyze.c
+++ b/src/backend/commands/analyze.c
@@ -1304,7 +1304,7 @@ acquire_sample_rows(Relation onerel, int elevel,
* tuples are already sorted.
*/
if (numrows == targrows)
- qsort_interruptible((void *) rows, numrows, sizeof(HeapTuple),
+ qsort_interruptible(rows, numrows, sizeof(HeapTuple),
compare_rows, NULL);
/*
@@ -2479,8 +2479,8 @@ compute_scalar_stats(VacAttrStatsP stats,
/* Sort the collected values */
cxt.ssup = &ssup;
cxt.tupnoLink = tupnoLink;
- qsort_interruptible((void *) values, values_cnt,
sizeof(ScalarItem),
- compare_scalars, (void
*) &cxt);
+ qsort_interruptible(values, values_cnt, sizeof(ScalarItem),
+ compare_scalars, &cxt);
/*
* Now scan the values in order, find the most common ones, and
also
@@ -2724,7 +2724,7 @@ compute_scalar_stats(VacAttrStatsP stats,
deltafrac;
/* Sort the MCV items into position order to speed next
loop */
- qsort_interruptible((void *) track, num_mcv,
sizeof(ScalarMCVItem),
+ qsort_interruptible(track, num_mcv,
sizeof(ScalarMCVItem),
compare_mcvs,
NULL);
/*
diff --git a/src/backend/commands/collationcmds.c
b/src/backend/commands/collationcmds.c
index 6a4311cc63..eb62d285ea 100644
--- a/src/backend/commands/collationcmds.c
+++ b/src/backend/commands/collationcmds.c
@@ -878,7 +878,7 @@ pg_import_system_collations(PG_FUNCTION_ARGS)
* created such a pg_collation entry above, and that one will
win.)
*/
if (naliases > 1)
- qsort((void *) aliases, naliases,
sizeof(CollAliasData), cmpaliases);
+ qsort(aliases, naliases, sizeof(CollAliasData),
cmpaliases);
/* Now add aliases, ignoring any that match pre-existing
entries */
for (i = 0; i < naliases; i++)
diff --git a/src/backend/executor/nodeTidscan.c
b/src/backend/executor/nodeTidscan.c
index fe6a964ee1..862bd0330b 100644
--- a/src/backend/executor/nodeTidscan.c
+++ b/src/backend/executor/nodeTidscan.c
@@ -266,7 +266,7 @@ TidListEval(TidScanState *tidstate)
/* CurrentOfExpr could never appear OR'd with something else */
Assert(!tidstate->tss_isCurrentOf);
- qsort((void *) tidList, numTids, sizeof(ItemPointerData),
+ qsort(tidList, numTids, sizeof(ItemPointerData),
itemptr_comparator);
numTids = qunique(tidList, numTids, sizeof(ItemPointerData),
itemptr_comparator);
diff --git a/src/backend/nodes/tidbitmap.c b/src/backend/nodes/tidbitmap.c
index 8c640ce16a..29a1858441 100644
--- a/src/backend/nodes/tidbitmap.c
+++ b/src/backend/nodes/tidbitmap.c
@@ -853,11 +853,11 @@ tbm_prepare_shared_iterate(TIDBitmap *tbm)
if (ptbase != NULL)
pg_atomic_init_u32(&ptbase->refcount, 0);
if (npages > 1)
- qsort_arg((void *) (ptpages->index), npages,
sizeof(int),
- tbm_shared_comparator, (void *)
ptbase->ptentry);
+ qsort_arg(ptpages->index, npages, sizeof(int),
+ tbm_shared_comparator,
ptbase->ptentry);
if (nchunks > 1)
- qsort_arg((void *) (ptchunks->index), nchunks,
sizeof(int),
- tbm_shared_comparator, (void *)
ptbase->ptentry);
+ qsort_arg(ptchunks->index, nchunks, sizeof(int),
+ tbm_shared_comparator,
ptbase->ptentry);
}
/*
diff --git a/src/backend/partitioning/partbounds.c
b/src/backend/partitioning/partbounds.c
index ed880c496a..a69c1d1e77 100644
--- a/src/backend/partitioning/partbounds.c
+++ b/src/backend/partitioning/partbounds.c
@@ -531,7 +531,7 @@ create_list_bounds(PartitionBoundSpec **boundspecs, int
nparts,
Assert(j == ndatums);
qsort_arg(all_values, ndatums, sizeof(PartitionListValue),
- qsort_partition_list_value_cmp, (void *) key);
+ qsort_partition_list_value_cmp, key);
boundinfo->ndatums = ndatums;
boundinfo->datums = (Datum **) palloc0(ndatums * sizeof(Datum *));
@@ -737,7 +737,7 @@ create_range_bounds(PartitionBoundSpec **boundspecs, int
nparts,
qsort_arg(all_bounds, ndatums,
sizeof(PartitionRangeBound *),
qsort_partition_rbound_cmp,
- (void *) key);
+ key);
/* Save distinct bounds from all_bounds into rbounds. */
rbounds = (PartitionRangeBound **)
diff --git a/src/backend/statistics/extended_stats.c
b/src/backend/statistics/extended_stats.c
index bdc21bb457..572d9b4464 100644
--- a/src/backend/statistics/extended_stats.c
+++ b/src/backend/statistics/extended_stats.c
@@ -1129,7 +1129,7 @@ build_sorted_items(StatsBuildData *data, int *nitems,
}
/* do the sort, using the multi-sort */
- qsort_interruptible((void *) items, nrows, sizeof(SortItem),
+ qsort_interruptible(items, nrows, sizeof(SortItem),
multi_sort_compare, mss);
return items;
diff --git a/src/backend/statistics/mcv.c b/src/backend/statistics/mcv.c
index 2d2a87d3a6..e21e0e87e4 100644
--- a/src/backend/statistics/mcv.c
+++ b/src/backend/statistics/mcv.c
@@ -457,7 +457,7 @@ build_distinct_groups(int numrows, SortItem *items,
MultiSortSupport mss,
Assert(j + 1 == ngroups);
/* Sort the distinct groups by frequency (in descending order). */
- qsort_interruptible((void *) groups, ngroups, sizeof(SortItem),
+ qsort_interruptible(groups, ngroups, sizeof(SortItem),
compare_sort_item_count, NULL);
*ndistinct = ngroups;
@@ -528,7 +528,7 @@ build_column_frequencies(SortItem *groups, int ngroups,
}
/* sort the values, deduplicate */
- qsort_interruptible((void *) result[dim], ngroups,
sizeof(SortItem),
+ qsort_interruptible(result[dim], ngroups, sizeof(SortItem),
sort_item_compare,
ssup);
/*
diff --git a/src/backend/statistics/mvdistinct.c
b/src/backend/statistics/mvdistinct.c
index 13301a3157..df5cc3e13a 100644
--- a/src/backend/statistics/mvdistinct.c
+++ b/src/backend/statistics/mvdistinct.c
@@ -489,7 +489,7 @@ ndistinct_for_combination(double totalrows, StatsBuildData
*data,
}
/* We can sort the array now ... */
- qsort_interruptible((void *) items, numrows, sizeof(SortItem),
+ qsort_interruptible(items, numrows, sizeof(SortItem),
multi_sort_compare, mss);
/* ... and count the number of distinct combinations */
diff --git a/src/backend/tsearch/spell.c b/src/backend/tsearch/spell.c
index c8dfed6178..cc04b87164 100644
--- a/src/backend/tsearch/spell.c
+++ b/src/backend/tsearch/spell.c
@@ -1305,7 +1305,7 @@ NIImportOOAffixes(IspellDict *Conf, const char *filename)
tsearch_readline_end(&trst);
if (Conf->nCompoundAffixFlag > 1)
- qsort((void *) Conf->CompoundAffixFlags,
Conf->nCompoundAffixFlag,
+ qsort(Conf->CompoundAffixFlags, Conf->nCompoundAffixFlag,
sizeof(CompoundAffixFlag), cmpcmdflag);
if (!tsearch_readline_begin(&trst, filename))
@@ -1789,7 +1789,7 @@ NISortDictionary(IspellDict *Conf)
else
{
/* Count the number of different flags used in the dictionary */
- qsort((void *) Conf->Spell, Conf->nspell, sizeof(SPELL *),
+ qsort(Conf->Spell, Conf->nspell, sizeof(SPELL *),
cmpspellaffix);
naffix = 0;
@@ -1827,7 +1827,7 @@ NISortDictionary(IspellDict *Conf)
}
/* Start build a prefix tree */
- qsort((void *) Conf->Spell, Conf->nspell, sizeof(SPELL *), cmpspell);
+ qsort(Conf->Spell, Conf->nspell, sizeof(SPELL *), cmpspell);
Conf->Dictionary = mkSPNode(Conf, 0, Conf->nspell, 0);
}
@@ -2001,7 +2001,7 @@ NISortAffixes(IspellDict *Conf)
/* Store compound affixes in the Conf->CompoundAffix array */
if (Conf->naffixes > 1)
- qsort((void *) Conf->Affix, Conf->naffixes, sizeof(AFFIX),
cmpaffix);
+ qsort(Conf->Affix, Conf->naffixes, sizeof(AFFIX), cmpaffix);
Conf->CompoundAffix = ptr = (CMPDAffix *) palloc(sizeof(CMPDAffix) *
Conf->naffixes);
ptr->affix = NULL;
diff --git a/src/backend/tsearch/to_tsany.c b/src/backend/tsearch/to_tsany.c
index f9a87e43ab..3b6d41f9e8 100644
--- a/src/backend/tsearch/to_tsany.c
+++ b/src/backend/tsearch/to_tsany.c
@@ -97,7 +97,7 @@ uniqueWORD(ParsedWord *a, int32 l)
/*
* Sort words with its positions
*/
- qsort((void *) a, l, sizeof(ParsedWord), compareWORD);
+ qsort(a, l, sizeof(ParsedWord), compareWORD);
/*
* Initialize first word and its first position
diff --git a/src/backend/utils/adt/tsgistidx.c
b/src/backend/utils/adt/tsgistidx.c
index ca4563290f..f0cd2866ff 100644
--- a/src/backend/utils/adt/tsgistidx.c
+++ b/src/backend/utils/adt/tsgistidx.c
@@ -704,7 +704,7 @@ gtsvector_picksplit(PG_FUNCTION_ARGS)
size_beta = hemdistcache(&(cache[seed_2]), &(cache[j]), siglen);
costvector[j - 1].cost = abs(size_alpha - size_beta);
}
- qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
+ qsort(costvector, maxoff, sizeof(SPLITCOST), comparecost);
for (k = 0; k < maxoff; k++)
{
diff --git a/src/backend/utils/adt/tsquery_gist.c
b/src/backend/utils/adt/tsquery_gist.c
index b7941ffaca..7c99348d44 100644
--- a/src/backend/utils/adt/tsquery_gist.c
+++ b/src/backend/utils/adt/tsquery_gist.c
@@ -222,7 +222,7 @@ gtsquery_picksplit(PG_FUNCTION_ARGS)
size_beta = hemdist(GETENTRY(entryvec, seed_2),
GETENTRY(entryvec, j));
costvector[j - 1].cost = abs(size_alpha - size_beta);
}
- qsort((void *) costvector, maxoff, sizeof(SPLITCOST), comparecost);
+ qsort(costvector, maxoff, sizeof(SPLITCOST), comparecost);
for (k = 0; k < maxoff; k++)
{
diff --git a/src/backend/utils/adt/tsquery_util.c
b/src/backend/utils/adt/tsquery_util.c
index f266b9f067..7b6970a6f8 100644
--- a/src/backend/utils/adt/tsquery_util.c
+++ b/src/backend/utils/adt/tsquery_util.c
@@ -173,7 +173,7 @@ QTNSort(QTNode *in)
for (i = 0; i < in->nchild; i++)
QTNSort(in->child[i]);
if (in->nchild > 1 && in->valnode->qoperator.oper != OP_PHRASE)
- qsort((void *) in->child, in->nchild, sizeof(QTNode *), cmpQTN);
+ qsort(in->child, in->nchild, sizeof(QTNode *), cmpQTN);
}
/*
diff --git a/src/backend/utils/adt/tsrank.c b/src/backend/utils/adt/tsrank.c
index 1ae555f7f7..e5b850ea8e 100644
--- a/src/backend/utils/adt/tsrank.c
+++ b/src/backend/utils/adt/tsrank.c
@@ -176,7 +176,7 @@ SortAndUniqItems(TSQuery q, int *size)
if (*size < 2)
return res;
- qsort_arg(res, *size, sizeof(QueryOperand *), compareQueryOperand,
(void *) operand);
+ qsort_arg(res, *size, sizeof(QueryOperand *), compareQueryOperand,
operand);
ptr = res + 1;
prevptr = res;
@@ -804,7 +804,7 @@ get_docrep(TSVector txt, QueryRepresentation *qr, int
*doclen)
/*
* Sort representation in ascending order by pos and entry
*/
- qsort((void *) doc, cur, sizeof(DocRepresentation),
compareDocR);
+ qsort(doc, cur, sizeof(DocRepresentation), compareDocR);
/*
* Join QueryItem per WordEntry and it's position
diff --git a/src/backend/utils/adt/tsvector.c b/src/backend/utils/adt/tsvector.c
index e5b05960e3..03db27194a 100644
--- a/src/backend/utils/adt/tsvector.c
+++ b/src/backend/utils/adt/tsvector.c
@@ -58,7 +58,7 @@ uniquePos(WordEntryPos *a, int l)
if (l <= 1)
return l;
- qsort((void *) a, l, sizeof(WordEntryPos), compareWordEntryPos);
+ qsort(a, l, sizeof(WordEntryPos), compareWordEntryPos);
res = a;
ptr = a + 1;
@@ -107,8 +107,8 @@ uniqueentry(WordEntryIN *a, int l, char *buf, int
*outbuflen)
Assert(l >= 1);
if (l > 1)
- qsort_arg((void *) a, l, sizeof(WordEntryIN), compareentry,
- (void *) buf);
+ qsort_arg(a, l, sizeof(WordEntryIN), compareentry,
+ buf);
buflen = 0;
res = a;
@@ -552,8 +552,8 @@ tsvectorrecv(PG_FUNCTION_ARGS)
SET_VARSIZE(vec, hdrlen + datalen);
if (needSort)
- qsort_arg((void *) ARRPTR(vec), vec->size, sizeof(WordEntry),
- compareentry, (void *) STRPTR(vec));
+ qsort_arg(ARRPTR(vec), vec->size, sizeof(WordEntry),
+ compareentry, STRPTR(vec));
PG_RETURN_TSVECTOR(vec);
}
diff --git a/src/bin/pg_dump/pg_backup_archiver.c
b/src/bin/pg_dump/pg_backup_archiver.c
index cb4386f871..71d3bc25fb 100644
--- a/src/bin/pg_dump/pg_backup_archiver.c
+++ b/src/bin/pg_dump/pg_backup_archiver.c
@@ -2363,7 +2363,7 @@ WriteDataChunks(ArchiveHandle *AH, ParallelState *pstate)
}
if (ntes > 1)
- qsort((void *) tes, ntes, sizeof(TocEntry *),
+ qsort(tes, ntes, sizeof(TocEntry *),
TocEntrySizeCompare);
for (int i = 0; i < ntes; i++)
diff --git a/src/bin/pg_dump/pg_dump_sort.c b/src/bin/pg_dump/pg_dump_sort.c
index f963b9a449..8266c117a3 100644
--- a/src/bin/pg_dump/pg_dump_sort.c
+++ b/src/bin/pg_dump/pg_dump_sort.c
@@ -186,7 +186,7 @@ void
sortDumpableObjectsByTypeName(DumpableObject **objs, int numObjs)
{
if (numObjs > 1)
- qsort((void *) objs, numObjs, sizeof(DumpableObject *),
+ qsort(objs, numObjs, sizeof(DumpableObject *),
DOTypeNameCompare);
}
diff --git a/src/bin/pg_upgrade/function.c b/src/bin/pg_upgrade/function.c
index 9ad75446ee..dc8800c7cd 100644
--- a/src/bin/pg_upgrade/function.c
+++ b/src/bin/pg_upgrade/function.c
@@ -136,7 +136,7 @@ check_loadable_libraries(void)
* consistent order, which is important for reproducible behavior if one
* library depends on another.
*/
- qsort((void *) os_info.libraries, os_info.num_libraries,
+ qsort(os_info.libraries, os_info.num_libraries,
sizeof(LibraryInfo), library_name_compare);
for (libnum = 0; libnum < os_info.num_libraries; libnum++)
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index 9c12ffaea9..d2d6431a28 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -1604,7 +1604,7 @@ lookupVariable(Variables *variables, char *name)
/* Sort if we have to */
if (!variables->vars_sorted)
{
- qsort((void *) variables->vars, variables->nvars,
sizeof(Variable),
+ qsort(variables->vars, variables->nvars, sizeof(Variable),
compareVariableNames);
variables->vars_sorted = true;
}
--
2.39.1
From 5ccd209c0fd26625597757cecc5c7acc0f2b7b18 Mon Sep 17 00:00:00 2001
From: Peter Eisentraut <pe...@eisentraut.org>
Date: Thu, 2 Feb 2023 23:02:35 +0100
Subject: [PATCH 8/8] Remove useless casts to (void *) (bsearch)
---
src/backend/commands/vacuum.c | 4 ++--
src/backend/tsearch/spell.c | 2 +-
src/bin/pgbench/pgbench.c | 4 ++--
3 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 7b1a4b127e..aa79d9de4d 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -2384,8 +2384,8 @@ vac_tid_reaped(ItemPointer itemptr, void *state)
if (item < litem || item > ritem)
return false;
- res = (ItemPointer) bsearch((void *) itemptr,
- (void *)
dead_items->items,
+ res = (ItemPointer) bsearch(itemptr,
+
dead_items->items,
dead_items->num_items,
sizeof(ItemPointerData),
vac_cmp_itemptr);
diff --git a/src/backend/tsearch/spell.c b/src/backend/tsearch/spell.c
index cc04b87164..8d48cad251 100644
--- a/src/backend/tsearch/spell.c
+++ b/src/backend/tsearch/spell.c
@@ -1158,7 +1158,7 @@ getCompoundAffixFlagValue(IspellDict *Conf, char *s)
setCompoundAffixFlagValue(Conf, &key, sflag, 0);
found = (CompoundAffixFlag *)
- bsearch(&key, (void *) Conf->CompoundAffixFlags,
+ bsearch(&key, Conf->CompoundAffixFlags,
Conf->nCompoundAffixFlag,
sizeof(CompoundAffixFlag),
cmpcmdflag);
if (found != NULL)
diff --git a/src/bin/pgbench/pgbench.c b/src/bin/pgbench/pgbench.c
index d2d6431a28..508ed218e8 100644
--- a/src/bin/pgbench/pgbench.c
+++ b/src/bin/pgbench/pgbench.c
@@ -1611,8 +1611,8 @@ lookupVariable(Variables *variables, char *name)
/* Now we can search */
key.name = name;
- return (Variable *) bsearch((void *) &key,
- (void *)
variables->vars,
+ return (Variable *) bsearch(&key,
+ variables->vars,
variables->nvars,
sizeof(Variable),
compareVariableNames);
--
2.39.1