diff mbox

[libibverbs,3/9] ibv_cmd_post_send(): initialize reserved field in struct ibv_kern_send_wr

Message ID 8034db9803f8383339322394a7e52404aed83f96.1412163687.git.ydroneaud@opteya.com (mailing list archive)
State Rejected
Headers show

Commit Message

Yann Droneaud Oct. 1, 2014, 11:49 a.m. UTC
Properly initialize data structure exchanged with kernel uverbs
layer:
- may remove valgrind spurious warnings;
- may allow to use the field later for future expansion.

Link: http://marc.info/?i=cover.1412163687.git.ydroneaud@opteya.com
Fixes: eb0663777c24 ('Add support for new datapath kernel commands')
Signed-off-by: Yann Droneaud <ydroneaud@opteya.com>
---
 src/cmd.c | 10 ++++++++++
 1 file changed, 10 insertions(+)
diff mbox

Patch

diff --git a/src/cmd.c b/src/cmd.c
index d057494260ee..8d8f7e8294e5 100644
--- a/src/cmd.c
+++ b/src/cmd.c
@@ -999,6 +999,9 @@  int ibv_cmd_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
 			tmp->wr.ud.ah 	       = i->wr.ud.ah->handle;
 			tmp->wr.ud.remote_qpn  = i->wr.ud.remote_qpn;
 			tmp->wr.ud.remote_qkey = i->wr.ud.remote_qkey;
+			memset(&tmp->wr.ud.reserved, 0,
+			       sizeof(tmp->wr.ud.reserved)
+			       + (sizeof(tmp->wr) - sizeof(tmp->wr.ud)));
 		} else {
 			switch (i->opcode) {
 			case IBV_WR_RDMA_WRITE:
@@ -1007,6 +1010,9 @@  int ibv_cmd_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
 				tmp->wr.rdma.remote_addr =
 					i->wr.rdma.remote_addr;
 				tmp->wr.rdma.rkey = i->wr.rdma.rkey;
+				memset(&tmp->wr.rdma.reserved, 0,
+				       sizeof(tmp->wr.rdma.reserved)
+				       + (sizeof(tmp->wr) - sizeof(tmp->wr.rdma)));
 				break;
 			case IBV_WR_ATOMIC_CMP_AND_SWP:
 			case IBV_WR_ATOMIC_FETCH_AND_ADD:
@@ -1016,8 +1022,12 @@  int ibv_cmd_post_send(struct ibv_qp *ibqp, struct ibv_send_wr *wr,
 					i->wr.atomic.compare_add;
 				tmp->wr.atomic.swap = i->wr.atomic.swap;
 				tmp->wr.atomic.rkey = i->wr.atomic.rkey;
+				memset(&tmp->wr.atomic.reserved, 0,
+				       sizeof(tmp->wr.atomic.reserved)
+				       + (sizeof(tmp->wr) - sizeof(tmp->wr.atomic)));
 				break;
 			default:
+				memset(&tmp->wr, 0, sizeof(tmp->wr));
 				break;
 			}
 		}