Results for 2.16.90 20050314 testsuite on sparc-unknown-linux-gnu

Alan Modra amodra@bigpond.net.au
Mon Mar 14 12:29:00 GMT 2005


On Mon, Mar 14, 2005 at 11:24:40AM +0100, Christian Joensson wrote:
> /usr/local/src/trunk/src/ld/ldexp.c: In function 'exp_fold_tree':
> /usr/local/src/trunk/src/ld/ldexp.c:703: warning: 'result$str' is used
> uninitialized in this function
> /usr/local/src/trunk/src/ld/ldexp.c:703: warning: 'result$section' is
> used uninitialized in this function
> /usr/local/src/trunk/src/ld/ldexp.c:703: warning: 'result$value' is
> used uninitialized in this function

These won't cause a problem.

> /usr/local/src/trunk/src/ld/ldexp.c:698: warning: 'result$valid_p' may
> be used uninitialized in this function

But this is a bug.  etree_assign might return a totally uninitialized
result.

> /usr/local/src/trunk/src/gprof/gmon_io.c: In function 'gmon_out_read':
> /usr/local/src/trunk/src/gprof/gmon_io.c:386: warning: 'count' may be
> used uninitialized in this function

And this might be too, but I didn't bother to analyze very deeply.

ld/
	* ldexp.c (exp_fold_tree): Ensure return value is initialized.
	Tidy etree_assert case.
gprof/
	* gmon_io.c (gmon_read_raw_arc): Return 1 for invalid size.

Index: ld/ldexp.c
===================================================================
RCS file: /cvs/src/src/ld/ldexp.c,v
retrieving revision 1.45
diff -u -p -r1.45 ldexp.c
--- ld/ldexp.c	22 Feb 2005 13:00:25 -0000	1.45
+++ ld/ldexp.c	14 Mar 2005 12:20:19 -0000
@@ -699,7 +699,7 @@ exp_fold_tree (etree_type *tree,
 
   if (tree == NULL)
     {
-      result.valid_p = FALSE;
+      memset (&result, 0, sizeof (result));
       return result;
     }
 
@@ -711,7 +711,7 @@ exp_fold_tree (etree_type *tree,
 
     case etree_rel:
       if (allocation_done != lang_final_phase_enum)
-	result.valid_p = FALSE;
+	memset (&result, 0, sizeof (result));
       else
 	result = new_rel ((tree->rel.value
 			   + tree->rel.section->output_section->vma
@@ -724,12 +724,8 @@ exp_fold_tree (etree_type *tree,
       result = exp_fold_tree (tree->assert_s.child,
 			      current_section,
 			      allocation_done, dot, dotp);
-      if (result.valid_p)
-	{
-	  if (! result.value)
-	    einfo ("%X%P: %s\n", tree->assert_s.message);
-	  return result;
-	}
+      if (result.valid_p && !result.value)
+	einfo ("%X%P: %s\n", tree->assert_s.message);
       break;
 
     case etree_unary:
@@ -787,6 +783,8 @@ exp_fold_tree (etree_type *tree,
 		    }
 		}
 	    }
+	  else
+	    memset (&result, 0, sizeof (result));
 	}
       else
 	{
@@ -839,6 +837,7 @@ exp_fold_tree (etree_type *tree,
 
     default:
       FAIL ();
+      memset (&result, 0, sizeof (result));
       break;
     }
 
Index: gprof/gmon_io.c
===================================================================
RCS file: /cvs/src/src/gprof/gmon_io.c,v
retrieving revision 1.20
diff -u -p -r1.20 gmon_io.c
--- gprof/gmon_io.c	3 Mar 2005 12:05:12 -0000	1.20
+++ gprof/gmon_io.c	14 Mar 2005 12:20:19 -0000
@@ -256,6 +256,9 @@ gmon_read_raw_arc (FILE *ifp, bfd_vma *f
       *cnt = cnt64;
       break;
 #endif
+
+    default:
+      return 1;
     }
   return 0;
 }

-- 
Alan Modra
IBM OzLabs - Linux Technology Centre



More information about the Binutils mailing list