diff mbox

[3/8] Initialize 'ra' to zero to avoid uninitialized use.

Message ID 1465678115-58170-4-git-send-email-jhb@FreeBSD.org
State New
Headers show

Commit Message

John Baldwin June 11, 2016, 8:48 p.m. UTC
If the instruction in this case does not include an RA field, then 'ra'
is used uninitialized.  Use the same idiom used elsewhere in this file of
initializing ra to zero before check for an RA field.

gdb/ChangeLog:

	* rs6000-tdep.c (ppc_process_record_op31): Initialize ra.
---
 gdb/ChangeLog     | 4 ++++
 gdb/rs6000-tdep.c | 1 +
 2 files changed, 5 insertions(+)

Comments

Yao Qi June 13, 2016, 11:04 a.m. UTC | #1
On Sat, Jun 11, 2016 at 9:48 PM, John Baldwin <jhb@freebsd.org> wrote:
> If the instruction in this case does not include an RA field, then 'ra'
> is used uninitialized.  Use the same idiom used elsewhere in this file of
> initializing ra to zero before check for an RA field.
>
> gdb/ChangeLog:
>
>         * rs6000-tdep.c (ppc_process_record_op31): Initialize ra.

Patch is good to me.
diff mbox

Patch

diff --git a/gdb/ChangeLog b/gdb/ChangeLog
index 335476b..38fcb30 100644
--- a/gdb/ChangeLog
+++ b/gdb/ChangeLog
@@ -1,3 +1,7 @@ 
+2016-06-11  John Baldwin  <jhb@FreeBSD.org>
+
+	* rs6000-tdep.c (ppc_process_record_op31): Initialize ra.
+
 2016-06-10  Tom Tromey  <tom@tromey.com>
 
 	* gdbtypes.c (arch_type, arch_integer_type, arch_character_type)
diff --git a/gdb/rs6000-tdep.c b/gdb/rs6000-tdep.c
index 645fe92..1ed1354 100644
--- a/gdb/rs6000-tdep.c
+++ b/gdb/rs6000-tdep.c
@@ -4631,6 +4631,7 @@  ppc_process_record_op31 (struct gdbarch *gdbarch, struct regcache *regcache,
 	  || at_dcsz == 0)
 	at_dcsz = 128; /* Assume 128-byte cache line size (POWER8)  */
 
+      ra = 0;
       if (PPC_RA (insn) != 0)
 	regcache_raw_read_unsigned (regcache,
 				    tdep->ppc_gp0_regnum + PPC_RA (insn), &ra);