Initialize HASHCTL differently, to suppress Coverity warning

Coverity complained that the hash_create() call might access
hash_table_ctl->hctl. That's a false alarm, hash_create() only
accesses that field when passed the HASH_SHARED_MEM flag. Try to
silence it by using a plain local variable instead of a const. That's
how the HASHCTL is initialized in all the other hash_create() calls.
This commit is contained in:
Heikki Linnakangas 2024-08-11 20:21:16 +03:00
parent b2be5cb2ab
commit f011e82c2c
1 changed files with 5 additions and 7 deletions

View File

@ -362,17 +362,15 @@ XLogPrefetcher *
XLogPrefetcherAllocate(XLogReaderState *reader)
{
XLogPrefetcher *prefetcher;
const HASHCTL hash_table_ctl = {
.keysize = sizeof(RelFileLocator),
.entrysize = sizeof(XLogPrefetcherFilter)
};
HASHCTL ctl;
prefetcher = palloc0(sizeof(XLogPrefetcher));
prefetcher->reader = reader;
ctl.keysize = sizeof(RelFileLocator);
ctl.entrysize = sizeof(XLogPrefetcherFilter);
prefetcher->filter_table = hash_create("XLogPrefetcherFilterTable", 1024,
&hash_table_ctl,
HASH_ELEM | HASH_BLOBS);
&ctl, HASH_ELEM | HASH_BLOBS);
dlist_init(&prefetcher->filter_queue);
SharedStats->wal_distance = 0;