Skip to content

Commit

Permalink
Eliminate 'incompatible pointer type passed to GC_grow_table' gcc war…
Browse files Browse the repository at this point in the history
…ning

(fix of commit 642a4d1)

* allchblk.c (GC_dump_regions): Change type of i local variable from
unsigned to size_t.
* alloc.c [GC_ASSERTIONS] (GC_add_to_heap): Likewise.
* alloc.c [!NO_DEBUGGING] (GC_print_heap_sects): Likewise.
* blacklst.c (total_stack_black_listed): Likewise.
* checksums.c (GC_check_dirty): Likewise.
* alloc.c (GC_add_to_heap): Remove casts to size_t.
* extra/MacOS.c (perform_final_collection): Change type of
last_fo_entries local variable from word to size_t.
* include/private/gc_priv.h (GC_arrays._n_heap_sects,
GC_arrays._fo_entries): Change type from word to size_t.
  • Loading branch information
ivmai committed Jul 10, 2024
1 parent 69f6232 commit 32b9d86
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 12 deletions.
2 changes: 1 addition & 1 deletion allchblk.c
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ STATIC int GC_hblk_fl_from_blocks(size_t blocks_needed)

GC_API void GC_CALL GC_dump_regions(void)
{
unsigned i;
size_t i;

for (i = 0; i < GC_n_heap_sects; ++i) {
ptr_t start = GC_heap_sects[i].hs_start;
Expand Down
10 changes: 5 additions & 5 deletions alloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -1403,7 +1403,7 @@ STATIC void GC_add_to_heap(struct hblk *h, size_t sz)
size_t old_capacity = 0;
void *old_heap_sects = NULL;
# ifdef GC_ASSERTIONS
unsigned i;
size_t i;
# endif

GC_ASSERT(I_HOLD_LOCK());
Expand All @@ -1417,14 +1417,14 @@ STATIC void GC_add_to_heap(struct hblk *h, size_t sz)
# ifndef INITIAL_HEAP_SECTS
# define INITIAL_HEAP_SECTS 32
# endif
size_t new_capacity = GC_n_heap_sects > 0 ?
(size_t)GC_n_heap_sects * 2 : INITIAL_HEAP_SECTS;
size_t new_capacity = GC_n_heap_sects > 0
? GC_n_heap_sects * 2 : INITIAL_HEAP_SECTS;
void *new_heap_sects =
GC_scratch_alloc(new_capacity * sizeof(struct HeapSect));

if (NULL == new_heap_sects) {
/* Retry with smaller yet sufficient capacity. */
new_capacity = (size_t)GC_n_heap_sects + INITIAL_HEAP_SECTS;
new_capacity = GC_n_heap_sects + INITIAL_HEAP_SECTS;
new_heap_sects =
GC_scratch_alloc(new_capacity * sizeof(struct HeapSect));
if (NULL == new_heap_sects)
Expand Down Expand Up @@ -1521,7 +1521,7 @@ STATIC void GC_add_to_heap(struct hblk *h, size_t sz)
#if !defined(NO_DEBUGGING)
void GC_print_heap_sects(void)
{
unsigned i;
size_t i;

GC_printf("Total heap size: %lu" IF_USE_MUNMAP(" (%lu unmapped)") "\n",
(unsigned long)GC_heapsize /*, */
Expand Down
2 changes: 1 addition & 1 deletion blacklst.c
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ STATIC word GC_number_stack_black_listed(struct hblk *start,
/* Return the total number of (stack) black-listed bytes. */
static word total_stack_black_listed(void)
{
unsigned i;
size_t i;
word total = 0;

for (i = 0; i < GC_n_heap_sects; i++) {
Expand Down
4 changes: 2 additions & 2 deletions checksums.c
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ STATIC GC_bool GC_was_faulted(struct hblk *h)
STATIC word GC_checksum(struct hblk *h)
{
word *p;
word *lim = (word *)(h+1);
word *lim = (word *)(h + 1);
word result = 0;

for (p = (word *)h; ADDR_LT((ptr_t)p, (ptr_t)lim); p++) {
Expand Down Expand Up @@ -138,7 +138,7 @@ STATIC void GC_check_blocks(void)
void GC_check_dirty(void)
{
int index;
unsigned i;
size_t i;

GC_check_blocks();
GC_n_dirty_errors = 0;
Expand Down
2 changes: 1 addition & 1 deletion extra/MacOS.c
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ Ptr GC_MacTemporaryNewPtr(size_t size, Boolean clearMemory)
static void perform_final_collection(void)
{
unsigned i;
word last_fo_entries = 0;
size_t last_fo_entries = 0;

/* adjust the stack bottom, because CFM calls us from another stack
location. */
Expand Down
4 changes: 2 additions & 2 deletions include/private/gc_priv.h
Original file line number Diff line number Diff line change
Expand Up @@ -1533,7 +1533,7 @@ struct _GC_arrays {
# define GC_capacity_heap_sects GC_arrays._capacity_heap_sects
size_t _capacity_heap_sects;
# define GC_n_heap_sects GC_arrays._n_heap_sects
word _n_heap_sects; /* Number of separately added heap sections. */
size_t _n_heap_sects; /* number of separately added heap sections */
# ifdef ANY_MSWIN
# define GC_n_heap_bases GC_arrays._n_heap_bases
size_t _n_heap_bases; /* see GC_heap_bases[] */
Expand All @@ -1547,7 +1547,7 @@ struct _GC_arrays {
ptr_t *_gcjobjfreelist;
# endif
# define GC_fo_entries GC_arrays._fo_entries
word _fo_entries;
size_t _fo_entries;
# ifndef GC_NO_FINALIZATION
# define GC_dl_hashtbl GC_arrays._dl_hashtbl
# define GC_fnlz_roots GC_arrays._fnlz_roots
Expand Down

0 comments on commit 32b9d86

Please sign in to comment.