PATCH: Initialize tmp_obstack

H. J. Lu hjl@lucon.org
Sat Dec 2 18:27:00 GMT 2006


Gcc 4.1 warns

cc1: warnings being treated as errors
/export/gnu/src/gdb/gdb/gdb/p-valprint.c: In function
‘pascal_object_print_value_fields’:
/export/gnu/src/gdb/gdb/gdb/p-valprint.c:756: warning:
‘tmp_obstack.alloc_failed’ may be used uninitialized in this function

This patch fixes those.

H.J.
----
2006-12-02  H.J. Lu  <hongjiu.lu@intel.com>

	* cp-valprint.c (cp_print_value_fields): Initialize tmp_obstack.
	(cp_print_value): Likewise
	* p-valprint.c (pascal_object_print_value_fields): Likewise
	(pascal_object_print_value): Likewise

--- gdb/cp-valprint.c.init	2005-12-17 14:33:59.000000000 -0800
+++ gdb/cp-valprint.c	2006-12-02 10:23:21.000000000 -0800
@@ -265,7 +265,7 @@ cp_print_value_fields (struct type *type
 		       struct type **dont_print_vb,int dont_print_statmem)
 {
   int i, len, n_baseclasses;
-  struct obstack tmp_obstack;
+  struct obstack tmp_obstack = { 0 };
   char *last_dont_print = obstack_next_free (&dont_print_statmem_obstack);
   int fields_seen = 0;
 
@@ -524,7 +524,7 @@ cp_print_value (struct type *type, struc
 		struct ui_file *stream, int format, int recurse,
 		enum val_prettyprint pretty, struct type **dont_print_vb)
 {
-  struct obstack tmp_obstack;
+  struct obstack tmp_obstack = { 0 };
   struct type **last_dont_print
     = (struct type **) obstack_next_free (&dont_print_vb_obstack);
   int i, n_baseclasses = TYPE_N_BASECLASSES (type);
--- gdb/p-valprint.c.init	2006-12-02 09:50:54.000000000 -0800
+++ gdb/p-valprint.c	2006-12-02 10:22:35.000000000 -0800
@@ -753,7 +753,7 @@ pascal_object_print_value_fields (struct
 				  int dont_print_statmem)
 {
   int i, len, n_baseclasses;
-  struct obstack tmp_obstack;
+  struct obstack tmp_obstack = { 0 };
   char *last_dont_print = obstack_next_free (&dont_print_statmem_obstack);
 
   CHECK_TYPEDEF (type);
@@ -922,7 +922,7 @@ pascal_object_print_value (struct type *
 			   enum val_prettyprint pretty,
 			   struct type **dont_print_vb)
 {
-  struct obstack tmp_obstack;
+  struct obstack tmp_obstack = { 0 };
   struct type **last_dont_print
   = (struct type **) obstack_next_free (&dont_print_vb_obstack);
   int i, n_baseclasses = TYPE_N_BASECLASSES (type);



More information about the Gdb-patches mailing list