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]

[RFC] Fix build failure in stap-probe.c.


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


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