From 9a78b5217717054e4e1cbb6fbdb293d25de467e3 Mon Sep 17 00:00:00 2001 From: "Michael S. Tsirkin" Date: Wed, 25 May 2005 20:18:32 +0000 Subject: [PATCH] Fix uninitialized AH attributes in pingpong examples Some address handle attributes (notably static rate flow control) were uninitialized. Fix this by initializing all fields to 0 using designated initializers. Signed-off-by: Michael S. Tsirkin Signed-off-by: Roland Dreier --- examples/pingpong.c | 28 +++++++++++++++------------- examples/ud-pingpong.c | 14 +++++++------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/examples/pingpong.c b/examples/pingpong.c index f7f6bd1..0862d6e 100644 --- a/examples/pingpong.c +++ b/examples/pingpong.c @@ -360,19 +360,21 @@ static int pp_post_send(struct pingpong_context *ctx) static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn, struct pingpong_dest *dest) { - struct ibv_qp_attr attr; - - attr.qp_state = IBV_QPS_RTR; - attr.path_mtu = IBV_MTU_1024; - attr.dest_qp_num = dest->qpn; - attr.rq_psn = dest->psn; - attr.max_dest_rd_atomic = 1; - attr.min_rnr_timer = 12; - attr.ah_attr.is_global = 0; - attr.ah_attr.dlid = dest->lid; - attr.ah_attr.sl = 0; - attr.ah_attr.src_path_bits = 0; - attr.ah_attr.port_num = port; + struct ibv_qp_attr attr = { + .qp_state = IBV_QPS_RTR, + .path_mtu = IBV_MTU_1024, + .dest_qp_num = dest->qpn, + .rq_psn = dest->psn, + .max_dest_rd_atomic = 1, + .min_rnr_timer = 12, + .ah_attr = { + .is_global = 0, + .dlid = dest->lid, + .sl = 0, + .src_path_bits = 0, + .port_num = port + } + }; if (ibv_modify_qp(ctx->qp, &attr, IBV_QP_STATE | IBV_QP_AV | diff --git a/examples/ud-pingpong.c b/examples/ud-pingpong.c index 09c3295..4936d30 100644 --- a/examples/ud-pingpong.c +++ b/examples/ud-pingpong.c @@ -370,7 +370,13 @@ static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn, struct pingpong_dest *dest) { struct ibv_qp_attr attr; - struct ibv_ah_attr ah_attr; + struct ibv_ah_attr ah_attr = { + .is_global = 0, + .dlid = dest->lid, + .sl = 0, + .src_path_bits = 0, + .port_num = port + }; attr.qp_state = IBV_QPS_RTR; @@ -389,12 +395,6 @@ static int pp_connect_ctx(struct pingpong_context *ctx, int port, int my_psn, return 1; } - ah_attr.is_global = 0; - ah_attr.dlid = dest->lid; - ah_attr.sl = 0; - ah_attr.src_path_bits = 0; - ah_attr.port_num = port; - ctx->ah = ibv_create_ah(ctx->pd, &ah_attr); if (!ctx->ah) { fprintf(stderr, "Failed to create AH\n"); -- 2.46.0