This is the mail archive of the
gdb-patches@sourceware.org
mailing list for the GDB project.
Re: FYI: another fix for PR 12533
- From: "Ulrich Weigand" <uweigand at de dot ibm dot com>
- To: tromey at redhat dot com (Tom Tromey)
- Cc: gdb-patches at sourceware dot org
- Date: Wed, 4 Jan 2012 13:47:11 +0100 (CET)
- Subject: Re: FYI: another fix for PR 12533
Tom Tromey wrote:
> PR python/12533:
> * python/py-value.c (valpy_dereference, valpy_get_address
> valpy_get_dynamic_type, valpy_lazy_string, valpy_do_cast)
> (valpy_getitem, valpy_call, valpy_binop, valpy_negative)
> (valpy_absolute, valpy_richcompare): Free intermediate values.
I'm now seeing build failures on RHEL5:
/home/kwerner/dailybuild/spu-tc-2012-01-04/gdb-head/src/gdb/python/py-value.c: In function 'valpy_binop':
/home/kwerner/dailybuild/spu-tc-2012-01-04/gdb-head/src/gdb/python/py-value.c:728: warning: 'res_val' may be used uninitialized in this function
> static PyObject *
> valpy_binop (enum valpy_opcode opcode, PyObject *self, PyObject *other)
> {
> - struct value *res_val = NULL; /* Initialize to appease gcc warning. */
> volatile struct gdb_exception except;
> + PyObject *result = NULL;
>
> TRY_CATCH (except, RETURN_MASK_ALL)
> {
> struct value *arg1, *arg2;
> + struct cleanup *cleanup = make_cleanup_value_free_to_mark (value_mark ());
> + struct value *res_val;
>
> /* If the gdb.Value object is the second operand, then it will be passed
> to us as the OTHER argument, and SELF will be an entirely different
> @@ -778,10 +811,15 @@
> res_val = value_binop (arg1, arg2, BINOP_BITWISE_XOR);
> break;
> }
> +
> + if (res_val)
> + result = value_to_value_object (res_val);
> +
> + do_cleanups (cleanup);
> }
> GDB_PY_HANDLE_EXCEPTION (except);
I guess res_val still ought to be NULL initialized here, in the (rather theoretical)
case the switch falls into an unhandled value ...
Bye,
Ulrich
--
Dr. Ulrich Weigand
GNU Toolchain for Linux on System z and Cell BE
Ulrich.Weigand@de.ibm.com