diff mbox

[RFA] Fix uninitialised variable warning error in gdb/stack.c

Message ID 5114EB2A.9040007@linaro.org
State New
Headers show

Commit Message

Matthew Gretton-Dann Feb. 8, 2013, 12:10 p.m. UTC
All,

When compiling GDB with GCC 4.5 and earlier I am getting the following 
uninitialized variable warning:

/work/sources/gdb/stack.c: In function 'return_command':
/work/sources/gdb/stack.c:2281: error: 'rv_conv' may be used uninitialized 
in this function
make[1]: *** [stack.o] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory `/work/builds/common/gdb'

The attached patch fixes this issue by initializing rv_conv when it is 
declared.  The value used to initialise rv_conv is chosen so that if the 
code changes in the future and rv_conv really should be uninitialized then 
the gdb_assert around line 2385 will trigger.

OK for trunk?  Tested on x86_64-none-linux-gnu

gdb/ChangeLog:

2013-02-08  Matthew Gretton-Dann  <matthew.gretton-dann@linaro.org>

	* stack.c (return_command): Work around uninitialized variable
	warning.

Thanks,

Matt

Comments

Pierre Muller Feb. 8, 2013, 12:52 p.m. UTC | #1
Hi Matt,

  I stumbled over the same error...
But didn't get the time to fix it myself.

  Such kind of small fixes that restore a successful
compilation broken by a commit can be considered as obvious fixes.

  I would have committed the change as such and
would have simply sent the patch after committing with [OBVIOUS] in front.

  So, this means that I can also give you 
an approval for that obvious change!

Pierre Muller

> -----Message d'origine-----
> De : gdb-patches-owner@sourceware.org [mailto:gdb-patches-
> owner@sourceware.org] De la part de Matthew Gretton-Dann
> Envoyé : vendredi 8 février 2013 13:10
> À : gdb-patches@sourceware.org
> Cc : Patch Tracking
> Objet : [RFA] Fix uninitialised variable warning error in gdb/stack.c
> 
> All,
> 
> When compiling GDB with GCC 4.5 and earlier I am getting the following
> uninitialized variable warning:
> 
> /work/sources/gdb/stack.c: In function 'return_command':
> /work/sources/gdb/stack.c:2281: error: 'rv_conv' may be used uninitialized
> in this function
> make[1]: *** [stack.o] Error 1
> make[1]: *** Waiting for unfinished jobs....
> make[1]: Leaving directory `/work/builds/common/gdb'
> 
> The attached patch fixes this issue by initializing rv_conv when it is
> declared.  The value used to initialise rv_conv is chosen so that if the
> code changes in the future and rv_conv really should be uninitialized then
> the gdb_assert around line 2385 will trigger.
> 
> OK for trunk?  Tested on x86_64-none-linux-gnu
> 
> gdb/ChangeLog:
> 
> 2013-02-08  Matthew Gretton-Dann  <matthew.gretton-dann@linaro.org>
> 
> 	* stack.c (return_command): Work around uninitialized variable
> 	warning.
> 
> Thanks,
> 
> Matt
> 
> --
> Matthew Gretton-Dann
> Toolchain Working Group, Linaro
diff mbox

Patch

diff --git a/gdb/stack.c b/gdb/stack.c
index 9f4aafc..147d815 100644
--- a/gdb/stack.c
+++ b/gdb/stack.c
@@ -2278,7 +2278,8 @@  down_command (char *count_exp, int from_tty)
 void
 return_command (char *retval_exp, int from_tty)
 {
-  enum return_value_convention rv_conv;
+  /* Initialize it just to avoid a GCC false warning.  */
+  enum return_value_convention rv_conv = RETURN_VALUE_STRUCT_CONVENTION;
   struct frame_info *thisframe;
   struct gdbarch *gdbarch;
   struct symbol *thisfun;