]> granicus.if.org Git - gc/commitdiff
Eliminate GCC warning about uninitialized 'hhdr' in GC_allochblk_nth
authorIvan Maidanski <ivmai@mail.ru>
Sat, 9 Nov 2013 07:37:09 +0000 (11:37 +0400)
committerIvan Maidanski <ivmai@mail.ru>
Sat, 9 Nov 2013 11:37:51 +0000 (15:37 +0400)
* 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

index 25e11a46fc06b9e360e7c7a70c9072fb67c7e0a6..98085b6dd4e6304237f5dc3dad10a93cccc7ecff 100644 (file)
@@ -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) {