This is the mail archive of the
gdb-patches@sources.redhat.com
mailing list for the GDB project.
[patch] Fix misc -Wuninitialized -Werror
- To: GDB Patches <gdb-patches at sourceware dot cygnus dot com>
- Subject: [patch] Fix misc -Wuninitialized -Werror
- From: Andrew Cagney <ac131313 at cygnus dot com>
- Date: Fri, 23 Mar 2001 17:47:01 -0500
FYI,
fork-child.c:fork_inferior() took a little to figure it out. Turns out
that GCC doesn't like:
declare local_variable;
vfork ();
reference to local_variable;
If you dig a little you'll find that the other variables referenced
after the vfork() have already been made static.
As for jv-*.c, it was either initialize the variable or rewrite the
function :-/
enjoy,
Andrew
2001-03-23 Andrew Cagney <ac131313@redhat.com>
* fork-child.c (fork_inferior): Make ``argv'', ``exec_file'' and
``shell_file'' static locals.
* jv-lang.c (java_link_class_type): Initialize ``field'' and
``method''.
* jv-valprint.c (java_value_print): Initialize ``next_element''.
Index: fork-child.c
===================================================================
RCS file: /cvs/src/src/gdb/fork-child.c,v
retrieving revision 1.9
diff -p -r1.9 fork-child.c
*** fork-child.c 2001/03/06 08:21:07 1.9
--- fork-child.c 2001/03/23 20:42:59
*************** breakup_args (char *scratch, char **argv
*** 95,104 ****
ENV is the environment vector to pass. SHELL_FILE is the shell file,
or NULL if we should pick one. Errors reported with error(). */
void
! fork_inferior (char *exec_file, char *allargs, char **env,
void (*traceme_fun) (void), void (*init_trace_fun) (int),
! void (*pre_trace_fun) (void), char *shell_file)
{
int pid;
char *shell_command;
--- 95,107 ----
ENV is the environment vector to pass. SHELL_FILE is the shell file,
or NULL if we should pick one. Errors reported with error(). */
+ /* This function is NOT-REENTRANT. Some of the variables have been
+ made static to ensure that they survive the vfork() call. */
+
void
! fork_inferior (char *exec_file_arg, char *allargs, char **env,
void (*traceme_fun) (void), void (*init_trace_fun) (int),
! void (*pre_trace_fun) (void), char *shell_file_arg)
{
int pid;
char *shell_command;
*************** fork_inferior (char *exec_file, char *al
*** 109,120 ****
/* This is set to the result of setpgrp, which if vforked, will be visible
to you in the parent process. It's only used by humans for debugging. */
static int debug_setpgrp = 657473;
char **save_our_env;
int shell = 0;
! char **argv;
/* If no exec file handed to us, get it from the exec-file command -- with
a good, common error message if none is specified. */
if (exec_file == 0)
exec_file = get_exec_file (1);
--- 112,126 ----
/* This is set to the result of setpgrp, which if vforked, will be visible
to you in the parent process. It's only used by humans for debugging. */
static int debug_setpgrp = 657473;
+ static char *shell_file;
+ static char *exec_file;
char **save_our_env;
int shell = 0;
! static char **argv;
/* If no exec file handed to us, get it from the exec-file command -- with
a good, common error message if none is specified. */
+ exec_file = exec_file_arg;
if (exec_file == 0)
exec_file = get_exec_file (1);
*************** fork_inferior (char *exec_file, char *al
*** 122,127 ****
--- 128,134 ----
* If 0, we'll just do a fork/exec, no shell, so don't
* bother figuring out what shell.
*/
+ shell_file = shell_file_arg;
if (STARTUP_WITH_SHELL)
{
/* Figure out what shell to start up the user program under. */
Index: jv-lang.c
===================================================================
RCS file: /cvs/src/src/gdb/jv-lang.c,v
retrieving revision 1.6
diff -p -r1.6 jv-lang.c
*** jv-lang.c 2001/03/06 08:21:09 1.6
--- jv-lang.c 2001/03/23 20:43:01
*************** java_link_class_type (struct type *type,
*** 346,352 ****
int type_is_object = 0;
struct fn_field *fn_fields;
struct fn_fieldlist *fn_fieldlists;
! value_ptr fields, field, method, methods;
int i, j;
struct objfile *objfile = get_dynamics_objfile ();
struct type *tsuper;
--- 346,354 ----
int type_is_object = 0;
struct fn_field *fn_fields;
struct fn_fieldlist *fn_fieldlists;
! value_ptr fields, methods;
! struct value *method = NULL;
! struct value *field = NULL;
int i, j;
struct objfile *objfile = get_dynamics_objfile ();
struct type *tsuper;
Index: jv-valprint.c
===================================================================
RCS file: /cvs/src/src/gdb/jv-valprint.c,v
retrieving revision 1.6
diff -p -r1.6 jv-valprint.c
*** jv-valprint.c 2001/03/06 08:21:09 1.6
--- jv-valprint.c 2001/03/23 20:43:01
*************** java_value_print (value_ptr val, struct
*** 90,96 ****
if (el_type == NULL)
{
! CORE_ADDR element, next_element;
address += JAVA_OBJECT_SIZE + 4; /* Skip object header and length. */
--- 90,97 ----
if (el_type == NULL)
{
! CORE_ADDR element;
! CORE_ADDR next_element = -1; /* dummy initial value */
address += JAVA_OBJECT_SIZE + 4; /* Skip object header and length. */