1
0
mirror of https://github.com/postgres/postgres.git synced 2025-05-05 09:19:17 +03:00

Add casts to simplehash.h to silence C++ warnings.

Casting the result of palloc etc. to the intended type is more per
project style anyway.

(The fact that cpluspluscheck doesn't notice these problems is
because it doesn't expand any macros, which seems like a troubling
shortcoming.  Don't have a good idea about improving that.)

Back-patch to v13, which is as far as the patch applies cleanly;
doesn't seem worth working harder.

David Geier

Discussion: https://postgr.es/m/aa5d88a3-71f4-3455-11cf-82de0372c941@gmail.com
This commit is contained in:
Tom Lane 2022-11-03 10:47:31 -04:00
parent 058c7b5dd4
commit eeb5461e76

View File

@ -437,9 +437,9 @@ SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
uint64 size; uint64 size;
#ifdef SH_RAW_ALLOCATOR #ifdef SH_RAW_ALLOCATOR
tb = SH_RAW_ALLOCATOR(sizeof(SH_TYPE)); tb = (SH_TYPE *) SH_RAW_ALLOCATOR(sizeof(SH_TYPE));
#else #else
tb = MemoryContextAllocZero(ctx, sizeof(SH_TYPE)); tb = (SH_TYPE *) MemoryContextAllocZero(ctx, sizeof(SH_TYPE));
tb->ctx = ctx; tb->ctx = ctx;
#endif #endif
tb->private_data = private_data; tb->private_data = private_data;
@ -449,7 +449,7 @@ SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
SH_COMPUTE_PARAMETERS(tb, size); SH_COMPUTE_PARAMETERS(tb, size);
tb->data = SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size); tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
return tb; return tb;
} }
@ -494,7 +494,7 @@ SH_GROW(SH_TYPE * tb, uint64 newsize)
/* compute parameters for new table */ /* compute parameters for new table */
SH_COMPUTE_PARAMETERS(tb, newsize); SH_COMPUTE_PARAMETERS(tb, newsize);
tb->data = SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size); tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
newdata = tb->data; newdata = tb->data;
@ -1060,7 +1060,7 @@ SH_STAT(SH_TYPE * tb)
double fillfactor; double fillfactor;
uint32 i; uint32 i;
uint32 *collisions = palloc0(tb->size * sizeof(uint32)); uint32 *collisions = (uint32 *) palloc0(tb->size * sizeof(uint32));
uint32 total_collisions = 0; uint32 total_collisions = 0;
uint32 max_collisions = 0; uint32 max_collisions = 0;
double avg_collisions; double avg_collisions;