Skip to content

Commit eeb5461

Browse files
committed
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
1 parent 058c7b5 commit eeb5461

File tree

1 file changed

+5
-5
lines changed

1 file changed

+5
-5
lines changed

src/include/lib/simplehash.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -437,9 +437,9 @@ SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
437437
uint64 size;
438438

439439
#ifdef SH_RAW_ALLOCATOR
440-
tb = SH_RAW_ALLOCATOR(sizeof(SH_TYPE));
440+
tb = (SH_TYPE *) SH_RAW_ALLOCATOR(sizeof(SH_TYPE));
441441
#else
442-
tb = MemoryContextAllocZero(ctx, sizeof(SH_TYPE));
442+
tb = (SH_TYPE *) MemoryContextAllocZero(ctx, sizeof(SH_TYPE));
443443
tb->ctx = ctx;
444444
#endif
445445
tb->private_data = private_data;
@@ -449,7 +449,7 @@ SH_CREATE(MemoryContext ctx, uint32 nelements, void *private_data)
449449

450450
SH_COMPUTE_PARAMETERS(tb, size);
451451

452-
tb->data = SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
452+
tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
453453

454454
return tb;
455455
}
@@ -494,7 +494,7 @@ SH_GROW(SH_TYPE * tb, uint64 newsize)
494494
/* compute parameters for new table */
495495
SH_COMPUTE_PARAMETERS(tb, newsize);
496496

497-
tb->data = SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
497+
tb->data = (SH_ELEMENT_TYPE *) SH_ALLOCATE(tb, sizeof(SH_ELEMENT_TYPE) * tb->size);
498498

499499
newdata = tb->data;
500500

@@ -1060,7 +1060,7 @@ SH_STAT(SH_TYPE * tb)
10601060
double fillfactor;
10611061
uint32 i;
10621062

1063-
uint32 *collisions = palloc0(tb->size * sizeof(uint32));
1063+
uint32 *collisions = (uint32 *) palloc0(tb->size * sizeof(uint32));
10641064
uint32 total_collisions = 0;
10651065
uint32 max_collisions = 0;
10661066
double avg_collisions;

0 commit comments

Comments
 (0)