diff mbox

[hsa] Fix issue spotted by valgrind

Message ID 55BB4D46.7070908@suse.cz
State New
Headers show

Commit Message

Martin Liška July 31, 2015, 10:26 a.m. UTC
Hello.

Following small patch removes write of uninitialized memory to BRIG insn stream.

Martin
diff mbox

Patch

From 533041ecb00f69226ba44c45c6c69d349e05413d Mon Sep 17 00:00:00 2001
From: mliska <mliska@suse.cz>
Date: Fri, 31 Jul 2015 12:08:34 +0200
Subject: [PATCH 2/2] HSA: fix write of uninitialized memory.

gcc/ChangeLog:

2015-07-31  Martin Liska  <mliska@suse.cz>

	* hsa-brig.c (emit_comment_insn): Memset to zero.
	(emit_queue_insn): Likewise.
---
 gcc/hsa-brig.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/gcc/hsa-brig.c b/gcc/hsa-brig.c
index 27c41a5..ab928a1 100644
--- a/gcc/hsa-brig.c
+++ b/gcc/hsa-brig.c
@@ -1461,6 +1461,8 @@  static void
 emit_comment_insn (hsa_insn_comment *insn)
 {
   struct BrigDirectiveComment repr;
+  memset (&repr, 0, sizeof (repr));
+
   repr.base.byteCount = htole16 (sizeof (repr));
   repr.base.kind = htole16 (insn->opcode);
   repr.name = brig_emit_string (insn->comment, '\0', false);
@@ -1474,6 +1476,8 @@  static void
 emit_queue_insn (hsa_insn_queue *insn)
 {
   BrigInstQueue repr;
+  memset (&repr, 0, sizeof (repr));
+
   auto_vec<BrigOperandOffset32_t, HSA_BRIG_INT_STORAGE_OPERANDS>
     operand_offsets;
   uint32_t byteCount, operand_count = insn->operands.length ();
-- 
2.4.6