This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
[commit] Fix compile error (Re: [RFA] Async mode fixes.)
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: vladimir at codesourcery dot com (Vladimir Prus)
- Cc: gdb-patches at sources dot redhat dot com
- Date: Mon, 17 Mar 2008 15:10:32 +0100 (CET)
- Subject: [commit] Fix compile error (Re: [RFA] Async mode fixes.)
Vladimir Prus wrote:
> + long time_at_cmd_start;
[snip]
> + if (target_can_async_p ())
> + {
> + time_at_cmd_start = get_run_time ();
[snip]
> + if (target_can_async_p () && target_executing)
> + {
> + arg1 =
> + (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
> + arg2 =
> + (struct continuation_arg *) xmalloc (sizeof (struct continuation_arg));
> + arg1->next = arg2;
> + arg2->next = NULL;
> + arg1->data.longint = time_at_cmd_start;
this breaks compilation with:
/home/uweigand/fsf/gdb-head/gdb/top.c: In function `execute_command':
/home/uweigand/fsf/gdb-head/gdb/top.c:415: warning: 'time_at_cmd_start' might be used uninitialized in this function
and the compiler error seems somewhat justified as the compiler cannot
know that target_can_async_p () always returns the same value ...
Fixed by adding a dummy initializer, as already done for space_at_cmd_start.
Committed to mainline.
Bye,
Ulrich
ChangeLog:
* top.c (execute_command): Fix uninitialized variable error.
Index: gdb/top.c
===================================================================
RCS file: /cvs/src/src/gdb/top.c,v
retrieving revision 1.133
diff -u -p -r1.133 top.c
--- gdb/top.c 14 Mar 2008 18:57:43 -0000 1.133
+++ gdb/top.c 17 Mar 2008 13:54:19 -0000
@@ -412,7 +412,7 @@ execute_command (char *p, int from_tty)
char *line;
struct continuation_arg *arg1;
struct continuation_arg *arg2;
- long time_at_cmd_start;
+ long time_at_cmd_start = 0;
#ifdef HAVE_SBRK
long space_at_cmd_start = 0;
#endif
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com