From bab0f6b5b84919a4a676591c4b61267bdd7d1cb6 Mon Sep 17 00:00:00 2001 From: Ivan Maidanski Date: Sat, 9 Nov 2013 11:37:09 +0400 Subject: 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. --- allchblk.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) (limited to 'allchblk.c') diff --git a/allchblk.c b/allchblk.c index 25e11a46..98085b6d 100644 --- a/allchblk.c +++ b/allchblk.c @@ -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) { -- cgit v1.2.1