Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFA] Fix compilation failure in parse_escape
@ 2009-04-15 18:48 Eli Zaretskii
  2009-04-15 19:18 ` Tom Tromey
  0 siblings, 1 reply; 3+ messages in thread
From: Eli Zaretskii @ 2009-04-15 18:48 UTC (permalink / raw)
  To: gdb-patches

Today's snapshot fails to compile:

  gcc -g -O2   -I. -I.././gdb -I.././gdb/common -I.././gdb/config -DLOCALEDIR="\"/usr/local/share/locale\"" -DHAVE_CONFIG_H -I.././gdb/../include/opcode -I.././gdb/../readline/.. -I../bfd -I.././gdb/../bfd -I.././gdb/../include -I../libdecnumber -I.././gdb/../libdecnumber  -I.././gdb/gnulib -Ignulib  -DMI_OUT=1 -DTUI=1  -Wall -Wdeclaration-after-statement -Wpointer-arith -Wformat-nonliteral -Wno-pointer-sign -Wno-unused -Wno-switch -Wno-char-subscripts -Werror -c -o utils.o -MT utils.o -MMD -MP -MF .deps/utils.Tpo utils.c
  cc1: warnings being treated as errors
  utils.c: In function 'parse_escape':
  utils.c:1621: warning: 'target_char' may be used uninitialized in this function
  make[2]: *** [utils.o] Error 1

I think this happens because host_char_to_target sets its target_c
argument only under certain conditions.  Is the following patch the
right fix?

2009-04-15  Eli Zaretskii  <eliz@gnu.org>

	* utils.c (parse_escape): Initialize target_char to pacify GCC.

Index: gdb/utils.c
===================================================================
RCS file: /cvs/src/src/gdb/utils.c,v
retrieving revision 1.208
diff -u -r1.208 utils.c
--- gdb/utils.c	20 Mar 2009 23:04:34 -0000	1.208
+++ gdb/utils.c	15 Apr 2009 18:45:02 -0000
@@ -1618,7 +1618,7 @@
 int
 parse_escape (char **string_ptr)
 {
-  int target_char;
+  int target_char = -2;
   int c = *(*string_ptr)++;
   switch (c)
     {


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

* Re: [RFA] Fix compilation failure in parse_escape
  2009-04-15 18:48 [RFA] Fix compilation failure in parse_escape Eli Zaretskii
@ 2009-04-15 19:18 ` Tom Tromey
  2009-04-15 20:42   ` Eli Zaretskii
  0 siblings, 1 reply; 3+ messages in thread
From: Tom Tromey @ 2009-04-15 19:18 UTC (permalink / raw)
  To: Eli Zaretskii; +Cc: gdb-patches

>>>>> "Eli" == Eli Zaretskii <eliz@gnu.org> writes:

Eli> I think this happens because host_char_to_target sets its target_c
Eli> argument only under certain conditions.  Is the following patch the
Eli> right fix?

Eli> 2009-04-15  Eli Zaretskii  <eliz@gnu.org>
Eli> 	* utils.c (parse_escape): Initialize target_char to pacify GCC.

Any value (not just -2) is ok here because it will always be overwritten.
Add a comment explaining that the initialization is to avoid a
warning -- we do this in other places.  Ok with that.

thanks,
Tom


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

* Re: [RFA] Fix compilation failure in parse_escape
  2009-04-15 19:18 ` Tom Tromey
@ 2009-04-15 20:42   ` Eli Zaretskii
  0 siblings, 0 replies; 3+ messages in thread
From: Eli Zaretskii @ 2009-04-15 20:42 UTC (permalink / raw)
  To: tromey; +Cc: gdb-patches

> Cc: gdb-patches@sourceware.org
> From: Tom Tromey <tromey@redhat.com>
> Date: Wed, 15 Apr 2009 13:17:50 -0600
> 
> Eli> 2009-04-15  Eli Zaretskii  <eliz@gnu.org>
> Eli> 	* utils.c (parse_escape): Initialize target_char to pacify GCC.
> 
> Any value (not just -2) is ok here because it will always be overwritten.
> Add a comment explaining that the initialization is to avoid a
> warning -- we do this in other places.  Ok with that.

Committed, thanks.


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

end of thread, other threads:[~2009-04-15 20:42 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-04-15 18:48 [RFA] Fix compilation failure in parse_escape Eli Zaretskii
2009-04-15 19:18 ` Tom Tromey
2009-04-15 20:42   ` Eli Zaretskii

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox