public inbox for gdb-patches@sourceware.org
 help / color / mirror / Atom feed
* [obv] varobj.c: Fix GCC false warning
@ 2010-10-17  8:45 Jan Kratochvil
  2010-10-17 10:02 ` Andreas Schwab
  0 siblings, 1 reply; 3+ messages in thread
From: Jan Kratochvil @ 2010-10-17  8:45 UTC (permalink / raw)
  To: gdb-patches

Hi,

CFLAGS=-O0 ./configure --without-python; make
varobj.c: In function ‘value_get_print_value’:
varobj.c:2578:22: error: ‘str_addr’ may be used uninitialized in this function

Reproducible with FSF GCC 4.4, 4.5, HEAD.

Checked in.


Thanks,
Jan


http://sourceware.org/ml/gdb-cvs/2010-10/msg00100.html

--- src/gdb/ChangeLog	2010/10/15 23:08:04	1.12264
+++ src/gdb/ChangeLog	2010/10/17 08:43:45	1.12265
@@ -1,3 +1,8 @@
+2010-10-17  Jan Kratochvil  <jan.kratochvil@redhat.com>
+
+	Fix GCC false warning.
+	* varobj.c (value_get_print_value) <str_addr>: Initialize it.
+
 2010-10-16  Pierre Muller  <muller@ics.u-strasbg.fr>
 
 	* p-typeprint.c (pascal_type_print_method_args): Fix problem in
--- src/gdb/varobj.c	2010/10/15 18:54:13	1.162
+++ src/gdb/varobj.c	2010/10/17 08:43:46	1.163
@@ -2486,7 +2486,8 @@
   long len = 0;
   char *encoding = NULL;
   struct gdbarch *gdbarch = NULL;
-  CORE_ADDR str_addr;
+  /* Initialize it just to avoid a GCC false warning.  */
+  CORE_ADDR str_addr = 0;
   int string_print = 0;
 
   if (value == NULL)

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [obv] varobj.c: Fix GCC false warning
  2010-10-17  8:45 [obv] varobj.c: Fix GCC false warning Jan Kratochvil
@ 2010-10-17 10:02 ` Andreas Schwab
  2010-10-17 11:54   ` [patch] varobj.c: Reset string_print [Re: [obv] varobj.c: Fix GCC false warning] Jan Kratochvil
  0 siblings, 1 reply; 3+ messages in thread
From: Andreas Schwab @ 2010-10-17 10:02 UTC (permalink / raw)
  To: Jan Kratochvil; +Cc: gdb-patches

Jan Kratochvil <jan.kratochvil@redhat.com> writes:

> --- src/gdb/varobj.c	2010/10/15 18:54:13	1.162
> +++ src/gdb/varobj.c	2010/10/17 08:43:46	1.163
> @@ -2486,7 +2486,8 @@
>    long len = 0;
>    char *encoding = NULL;
>    struct gdbarch *gdbarch = NULL;
> -  CORE_ADDR str_addr;
> +  /* Initialize it just to avoid a GCC false warning.  */
> +  CORE_ADDR str_addr = 0;
>    int string_print = 0;

What happens if string_print is set but gdbpy_extract_lazy_string was
not called?

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [patch] varobj.c: Reset string_print  [Re: [obv] varobj.c: Fix GCC false warning]
  2010-10-17 10:02 ` Andreas Schwab
@ 2010-10-17 11:54   ` Jan Kratochvil
  0 siblings, 0 replies; 3+ messages in thread
From: Jan Kratochvil @ 2010-10-17 11:54 UTC (permalink / raw)
  To: Tom Tromey; +Cc: gdb-patches, Andreas Schwab

On Sun, 17 Oct 2010 12:02:08 +0200, Andreas Schwab wrote:
> What happens if string_print is set but gdbpy_extract_lazy_string was
> not called?

I agree.

BTW this is unrelated to the [obv] fix, in fact GCC warned on a falsely
uninitialized value <! HAVE_PYTHON> and GCC missed a real uninitialized value
<HAVE_PYTHON>.

I guess this patch should fix it.
No regressions on {x86_64,x86_64-m32,i686}-fedora14snapshot-linux-gnu.


Thanks,
Jan


gdb/
2010-10-17  Jan Kratochvil  <jan.kratochvil@redhat.com>

	* varobj.c (value_get_print_value): Reset STRING_PRINT if STR_ADDR is
	not set.

--- a/gdb/varobj.c
+++ b/gdb/varobj.c
@@ -2557,9 +2557,14 @@ value_get_print_value (struct value *value, enum varobj_display_formats format,
 			make_cleanup (xfree, thevalue);
 		      }
 		    else
-		      gdbpy_print_stack ();
+		      {
+			gdbpy_print_stack ();
+			string_print = 0;
+		      }
 		  }
 	      }
+	    else
+	      string_print = 0;
 	    if (replacement)
 	      value = replacement;
 	  }

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2010-10-17 11:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-17  8:45 [obv] varobj.c: Fix GCC false warning Jan Kratochvil
2010-10-17 10:02 ` Andreas Schwab
2010-10-17 11:54   ` [patch] varobj.c: Reset string_print [Re: [obv] varobj.c: Fix GCC false warning] Jan Kratochvil

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).