This is the mail archive of the gdb-patches@sourceware.org mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[OB] inf-ptrace.c: 'back_to' uninitialized


Hi,

I got:

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

I check the inf-ptrace.c found that 'back_to' uninitialized.  And it
be use inside "if (! ops_already_pushed)"
  if (! ops_already_pushed)
    {
      /* target_pid_to_str already uses the target.  Also clear possible core
	 file with its process_stratum.  */
      push_target (ops);
      back_to = make_cleanup_unpush_target (ops);
    }
  if (! ops_already_pushed)
    discard_cleanups (back_to);

So I checked in the following code to initialize back_to.

Thanks,
Hui

2010-07-20  Hui Zhu  <teawater@gmail.com>

	* inf-ptrace.c (inf_ptrace_create_inferior): Initialize back_to.
	(inf_ptrace_attach): Ditto.


===================================================================
RCS file: /cvs/src/src/gdb/inf-ptrace.c,v
retrieving revision 1.71
retrieving revision 1.72
diff -u -r1.71 -r1.72
--- src/gdb/inf-ptrace.c	2010/07/19 17:51:23	1.71
+++ src/gdb/inf-ptrace.c	2010/07/20 05:58:53	1.72
@@ -124,7 +124,7 @@
   /* Do not change either targets above or the same target if already present.
      The reason is the target stack is shared across multiple inferiors.  */
   int ops_already_pushed = target_is_pushed (ops);
-  struct cleanup *back_to;
+  struct cleanup *back_to = NULL;

   if (! ops_already_pushed)
     {
@@ -205,7 +205,7 @@
   /* Do not change either targets above or the same target if already present.
      The reason is the target stack is shared across multiple inferiors.  */
   int ops_already_pushed = target_is_pushed (ops);
-  struct cleanup *back_to;
+  struct cleanup *back_to = NULL;

   pid = parse_pid_to_attach (args);


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]