gc.c: Cast int literal "1" to bits_t

... because shifting by more than 31 bits has undefined behavior
(depending upon platform). Coverity Scan found this issue.
This commit is contained in:
Yusuke Endoh 2020-07-08 09:58:48 +09:00
Родитель b06a4dc6f1
Коммит ecfc09d053
1 изменённых файлов: 1 добавлений и 1 удалений

2
gc.c
Просмотреть файл

@ -4199,7 +4199,7 @@ gc_page_sweep(rb_objspace_t *objspace, rb_heap_t *heap, struct heap_page *sweep_
/* create guard : fill 1 out-of-range */ /* create guard : fill 1 out-of-range */
bits[BITMAP_INDEX(p)] |= BITMAP_BIT(p)-1; bits[BITMAP_INDEX(p)] |= BITMAP_BIT(p)-1;
bits[BITMAP_INDEX(p) + sweep_page->total_slots / BITS_BITLENGTH] |= ~((1 << ((NUM_IN_PAGE(p) + sweep_page->total_slots) % BITS_BITLENGTH)) - 1); bits[BITMAP_INDEX(p) + sweep_page->total_slots / BITS_BITLENGTH] |= ~(((bits_t)1 << ((NUM_IN_PAGE(p) + sweep_page->total_slots) % BITS_BITLENGTH)) - 1);
for (i=0; i < HEAP_PAGE_BITMAP_LIMIT; i++) { for (i=0; i < HEAP_PAGE_BITMAP_LIMIT; i++) {
bitset = ~bits[i]; bitset = ~bits[i];