From e81ec4d61f343419ff897c4083e1316687f9230a Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Tue, 16 Feb 2016 23:34:43 +0300 Subject: [PATCH] Fix 'signed-to-bigger-unsigned value assignment' warning for hb_map (Apply commit 3883587 from 'master' branch.) * include/private/gc_priv.h (hblkhdr): Change type of hb_map from short to unsigned short. * include/private/gc_priv.h (_GC_arrays): Change type of _obj_map from short to unsigned short. * obj_map.c (GC_add_map_entry): Change type of new_map local variable from short to unsigned short. --- include/private/gc_priv.h | 4 ++-- obj_map.c | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/include/private/gc_priv.h b/include/private/gc_priv.h index 66c8bccc..f5f63155 100644 --- a/include/private/gc_priv.h +++ b/include/private/gc_priv.h @@ -920,7 +920,7 @@ struct hblkhdr { # define LARGE_INV_SZ (1 << 16) # else unsigned char hb_large_block; - short * hb_map; /* Essentially a table of remainders */ + unsigned short * hb_map; /* Essentially a table of remainders */ /* mod BYTES_TO_GRANULES(hb_sz), except */ /* for large blocks. See GC_obj_map. */ # endif @@ -1184,7 +1184,7 @@ struct _GC_arrays { /* free list for immutable objects */ # ifdef MARK_BIT_PER_GRANULE # define GC_obj_map GC_arrays._obj_map - short * _obj_map[MAXOBJGRANULES+1]; + unsigned short * _obj_map[MAXOBJGRANULES + 1]; /* If not NULL, then a pointer to a map of valid */ /* object addresses. */ /* _obj_map[sz_in_granules][i] is */ diff --git a/obj_map.c b/obj_map.c index c935bf3f..9fdeb0af 100644 --- a/obj_map.c +++ b/obj_map.c @@ -51,13 +51,13 @@ GC_INNER void GC_register_displacement_inner(size_t offset) GC_INNER GC_bool GC_add_map_entry(size_t granules) { unsigned displ; - short * new_map; + unsigned short * new_map; if (granules > BYTES_TO_GRANULES(MAXOBJBYTES)) granules = 0; if (GC_obj_map[granules] != 0) { return(TRUE); } - new_map = (short *)GC_scratch_alloc(MAP_LEN * sizeof(short)); + new_map = (unsigned short *)GC_scratch_alloc(MAP_LEN * sizeof(short)); if (new_map == 0) return(FALSE); GC_COND_LOG_PRINTF( "Adding block map for size of %u granules (%u bytes)\n", @@ -68,7 +68,7 @@ GC_INNER void GC_register_displacement_inner(size_t offset) } } else { for (displ = 0; displ < BYTES_TO_GRANULES(HBLKSIZE); displ++) { - new_map[displ] = (short)(displ % granules); + new_map[displ] = (unsigned short)(displ % granules); } } GC_obj_map[granules] = new_map; -- 2.40.0