Eliminate warning and simplify expression in GC_init_explicit_typing
authorIvan Maidanski <ivmai@mail.ru>
Tue, 23 Oct 2012 05:04:57 +0000 (09:04 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Tue, 23 Oct 2012 12:06:50 +0000 (16:06 +0400)
* typd_mlc.c (GC_init_explicit_typing): Cast -1 argument of
WORDS_TO_BYTES() to word (instead of casting its result) to avoid
"overflow in signed shift operation" warning (issued by some static
code analysis tools).
* typd_mlc.c (GC_init_explicit_typing): Simplify expression for
computing GC_bm_table elements (remove redundant right shift of
unsigned -1 before left shift for the same amount of bits).

typd_mlc.c

index 827cc4f..e1d3b2a 100644 (file)
@@ -361,7 +361,7 @@ STATIC void GC_init_explicit_typing(void)
       GC_eobjfreelist = (ptr_t *)GC_new_free_list_inner();
       GC_explicit_kind = GC_new_kind_inner(
                             (void **)GC_eobjfreelist,
-                            (((word)WORDS_TO_BYTES(-1)) | GC_DS_PER_OBJECT),
+                            (WORDS_TO_BYTES((word)-1) | GC_DS_PER_OBJECT),
                             TRUE, TRUE);
                 /* Descriptors are in the last word of the object. */
       GC_typed_mark_proc_index = GC_new_proc_inner(GC_typed_mark_proc);
@@ -373,9 +373,7 @@ STATIC void GC_init_explicit_typing(void)
                             GC_MAKE_PROC(GC_array_mark_proc_index, 0),
                             FALSE, TRUE);
       for (i = 0; i < WORDSZ/2; i++) {
-          GC_descr d = (((word)(-1)) >> (WORDSZ - i)) << (WORDSZ - i);
-          d |= GC_DS_BITMAP;
-          GC_bm_table[i] = d;
+          GC_bm_table[i] = (((word)-1) << (WORDSZ - i)) | GC_DS_BITMAP;
       }
     UNLOCK();
 }