diff options
author | Ivan Maidanski <ivmai@mail.ru> | 2013-11-09 11:37:09 +0400 |
---|---|---|
committer | Ivan Maidanski <ivmai@mail.ru> | 2013-11-09 15:37:51 +0400 |
commit | bab0f6b5b84919a4a676591c4b61267bdd7d1cb6 (patch) | |
tree | 54bde2c85352b8c0c1d9bcc788344fd15f126e55 /allchblk.c | |
parent | 87cad9093454ec6316c2a649b239ac65d280a3ec (diff) | |
download | bdwgc-bab0f6b5b84919a4a676591c4b61267bdd7d1cb6.tar.gz |
Eliminate GCC warning about uninitialized 'hhdr' in GC_allochblk_nth
* allchblk.c (GC_allochblk_nth): Replace "for" condition with
conditional "return" since otherwise GCC reports
"'hhdr' may be used uninitialized" warning in case of -O0 optimization
level; remove comment about bogus compiler warning; refine comment
for "thishdr" local variable.
Diffstat (limited to 'allchblk.c')
-rw-r--r-- | allchblk.c | 12 |
1 files changed, 5 insertions, 7 deletions
@@ -640,20 +640,18 @@ STATIC struct hblk * GC_allochblk_nth(size_t sz, int kind, unsigned flags, int n, int may_split) { struct hblk *hbp; - hdr * hhdr; /* Header corr. to hbp */ - /* Initialized after loop if hbp !=0 */ - /* Gcc uninitialized use warning is bogus. */ + hdr * hhdr; /* Header corr. to hbp */ struct hblk *thishbp; - hdr * thishdr; /* Header corr. to hbp */ + hdr * thishdr; /* Header corr. to thishbp */ signed_word size_needed; /* number of bytes in requested objects */ signed_word size_avail; /* bytes available in this block */ size_needed = HBLKSIZE * OBJ_SZ_TO_BLOCKS(sz); /* search for a big enough block in free list */ - hbp = GC_hblkfreelist[n]; - for(; 0 != hbp; hbp = hhdr -> hb_next) { - GET_HDR(hbp, hhdr); + for (hbp = GC_hblkfreelist[n];; hbp = hhdr -> hb_next) { + if (NULL == hbp) return NULL; + GET_HDR(hbp, hhdr); /* set hhdr value */ size_avail = hhdr->hb_sz; if (size_avail < size_needed) continue; if (size_avail != size_needed) { |