+2009-09-16 Ivan Maidanski <ivmai@mail.ru>
+ (ivmai124.diff - superseding diff67 partly)
+
+ * alloc.c (GC_set_fl_marks, GC_clear_fl_marks): Transform loop to
+ suppress compiler "variable might be uninitialized" warnings.
+
2009-09-16 Ivan Maidanski <ivmai@mail.ru>
(ivmai138.diff)
/* Set all mark bits for the free list whose first entry is q */
void GC_set_fl_marks(ptr_t q)
{
- ptr_t p;
- struct hblk * h, * last_h = 0;
- hdr *hhdr; /* gcc "might be uninitialized" warning is bogus. */
+ struct hblk *h, *last_h;
+ hdr *hhdr;
IF_PER_OBJ(size_t sz;)
unsigned bit_no;
- for (p = q; p != 0; p = obj_link(p)){
- h = HBLKPTR(p);
+ if (q != NULL) {
+ h = HBLKPTR(q);
+ last_h = h;
+ hhdr = HDR(h);
+ IF_PER_OBJ(sz = hhdr->hb_sz;)
+
+ for (;;) {
+ bit_no = MARK_BIT_NO((ptr_t)q - (ptr_t)h, sz);
+ if (!mark_bit_from_hdr(hhdr, bit_no)) {
+ set_mark_bit_from_hdr(hhdr, bit_no);
+ ++hhdr -> hb_n_marks;
+ }
+
+ q = obj_link(q);
+ if (q == NULL)
+ break;
+
+ h = HBLKPTR(q);
if (h != last_h) {
last_h = h;
hhdr = HDR(h);
IF_PER_OBJ(sz = hhdr->hb_sz;)
}
- bit_no = MARK_BIT_NO((ptr_t)p - (ptr_t)h, sz);
- if (!mark_bit_from_hdr(hhdr, bit_no)) {
- set_mark_bit_from_hdr(hhdr, bit_no);
- ++hhdr -> hb_n_marks;
- }
+ }
}
}
/* Decrement GC_bytes_found by number of bytes on free list. */
STATIC void GC_clear_fl_marks(ptr_t q)
{
- ptr_t p;
- struct hblk * h, * last_h = 0;
+ struct hblk *h, *last_h;
hdr *hhdr;
size_t sz;
unsigned bit_no;
- for (p = q; p != 0; p = obj_link(p)){
- h = HBLKPTR(p);
- if (h != last_h) {
- last_h = h;
- hhdr = HDR(h);
- sz = hhdr->hb_sz; /* Normally set only once. */
- }
- bit_no = MARK_BIT_NO((ptr_t)p - (ptr_t)h, sz);
+ if (q != NULL) {
+ h = HBLKPTR(q);
+ last_h = h;
+ hhdr = HDR(h);
+ sz = hhdr->hb_sz; /* Normally set only once. */
+
+ for (;;) {
+ bit_no = MARK_BIT_NO((ptr_t)q - (ptr_t)h, sz);
if (mark_bit_from_hdr(hhdr, bit_no)) {
size_t n_marks = hhdr -> hb_n_marks - 1;
clear_mark_bit_from_hdr(hhdr, bit_no);
# endif
}
GC_bytes_found -= sz;
+
+ q = obj_link(q);
+ if (q == NULL)
+ break;
+
+ h = HBLKPTR(q);
+ if (h != last_h) {
+ last_h = h;
+ hhdr = HDR(h);
+ sz = hhdr->hb_sz;
+ }
+ }
}
}