Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
* [RFC] Fix build failure in stap-probe.c.
@ 2012-05-02  8:17 Doug Evans
  2012-05-02 18:56 ` Sergio Durigan Junior
  0 siblings, 1 reply; 5+ messages in thread
From: Doug Evans @ 2012-05-02  8:17 UTC (permalink / raw)
  To: sergiodj, tromey, jan.kratochvil; +Cc: gdb-patches

Hi.

I'm getting build failures, gcc is complaining that "opcode" and
"lookahead_opcode" "may be used uninitialized".

cc1: warnings being treated as errors
../../src/gdb/stap-probe.c: In function 'stap_parse_argument_1':
../../src/gdb/stap-probe.c:1558: error: 'lookahead_opcode' may be used uninitialized in this function
../../src/gdb/stap-probe.c:813: note: 'lookahead_opcode' was declared here
../../src/gdb/stap-probe.c:1558: error: 'opcode' may be used uninitialized in this function
../../src/gdb/stap-probe.c:778: note: 'opcode' was declared here
make: *** [stap-probe.o] Error 1

This patch is just RFC.
IIUC the code already watches for valid operators before
calling stap_get_opcode, so stap_get_opcode should "never" return zero.
So I'm wondering if maybe step_get_opcode should be changed
to always succeed and always set the opcode.

Can one of you look at this?


2012-05-02  Doug Evans  <dje@google.com>

	* stap-probe.c (stap_parse_argument_1): Fix "may be used uninitialized"
	build failures.

Index: stap-probe.c
===================================================================
RCS file: /cvs/src/src/gdb/stap-probe.c,v
retrieving revision 1.1
diff -u -p -r1.1 stap-probe.c
--- stap-probe.c	27 Apr 2012 20:47:56 -0000	1.1
+++ stap-probe.c	2 May 2012 08:02:24 -0000
@@ -775,7 +775,8 @@ stap_parse_argument_1 (struct stap_parse
   while (p->arg && *p->arg && *p->arg != ')' && !isspace (*p->arg))
     {
       const char *tmp_exp_buf;
-      enum exp_opcode opcode;
+      /* Initialize to pacify gcc.  */
+      enum exp_opcode opcode = OP_LONG;
       enum stap_operand_prec cur_prec;
 
       if (!stap_is_operator (*p->arg))
@@ -810,7 +811,8 @@ stap_parse_argument_1 (struct stap_parse
 	 right-side, but using the current right-side as a left-side.  */
       while (*p->arg && stap_is_operator (*p->arg))
 	{
-	  enum exp_opcode lookahead_opcode;
+	  /* Initialize to pacify gcc.  */
+	  enum exp_opcode lookahead_opcode = OP_LONG;
 	  enum stap_operand_prec lookahead_prec;
 
 	  /* Saving the current expression buffer position.  The explanation


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

end of thread, other threads:[~2012-05-03 20:27 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-05-02  8:17 [RFC] Fix build failure in stap-probe.c Doug Evans
2012-05-02 18:56 ` Sergio Durigan Junior
2012-05-03 17:53   ` Doug Evans
2012-05-03 20:05     ` Sergio Durigan Junior
2012-05-03 20:27       ` Doug Evans

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