diff mbox

[09/28] mlx5: Fix gcc 6.4 uninitialized variable warning

Message ID 1473109698-31408-10-git-send-email-jgunthorpe@obsidianresearch.com (mailing list archive)
State Superseded
Headers show

Commit Message

Jason Gunthorpe Sept. 5, 2016, 9:07 p.m. UTC
gcc 6.4 remarks:

../providers/mlx5/cq.c:647:10: warning: 'wc_byte_len' may be used uninitialized in this function [-Wmaybe-uninitialized]
    err = mlx5_copy_to_send_wqe(mqp, wqe_ctr, cqe,
           lazy ? wc_byte_len : wc->byte_len);

The path is because handle_good_req_lazy does not set its wc_byte_len
outputs under certain case conditions.

Perhaps it is possible that the hardware never produces a completion
with opcodes and scatter flags that could trigger this, but gcc is not
wrong, so zero the field rather than hide the warning.

Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
---
 libmlx5/src/cq.c | 3 +++
 1 file changed, 3 insertions(+)

Comments

Yishai Hadas Sept. 14, 2016, 3:39 p.m. UTC | #1
On 9/6/2016 12:07 AM, Jason Gunthorpe wrote:
> gcc 6.4 remarks:
>
> ../providers/mlx5/cq.c:647:10: warning: 'wc_byte_len' may be used uninitialized in this function [-Wmaybe-uninitialized]
>     err = mlx5_copy_to_send_wqe(mqp, wqe_ctr, cqe,
>            lazy ? wc_byte_len : wc->byte_len);
> The path is because handle_good_req_lazy does not set its wc_byte_len
> outputs under certain case conditions.

wc_byte_len defined as uint32_t uninitialized_var(wc_byte_len) to 
prevent this warning, isn't this macro applicable ?

> Perhaps it is possible that the hardware never produces a completion
> with opcodes and scatter flags that could trigger this,
It can't happen, no real functional issue.

> Signed-off-by: Jason Gunthorpe <jgunthorpe@obsidianresearch.com>
> ---
>  libmlx5/src/cq.c | 3 +++
>  1 file changed, 3 insertions(+)
>
> diff --git a/libmlx5/src/cq.c b/libmlx5/src/cq.c
> index 88097037eea0..163205bddeb8 100644
> --- a/libmlx5/src/cq.c
> +++ b/libmlx5/src/cq.c
> @@ -235,7 +235,10 @@ static inline void handle_good_req_lazy(struct mlx5_cqe64 *cqe, uint32_t *pwc_by
>  		break;
>  	case MLX5_OPCODE_UMR:
>  		*umr_opcode = wq->wr_data[idx];
> +		*pwc_byte_len = 0;

This case is a data path flow, need to prevent adding non applicable code.

>  		break;
> +	default:
> +		*pwc_byte_len = 0;
>  	}
>  }
>
>

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/libmlx5/src/cq.c b/libmlx5/src/cq.c
index 88097037eea0..163205bddeb8 100644
--- a/libmlx5/src/cq.c
+++ b/libmlx5/src/cq.c
@@ -235,7 +235,10 @@  static inline void handle_good_req_lazy(struct mlx5_cqe64 *cqe, uint32_t *pwc_by
 		break;
 	case MLX5_OPCODE_UMR:
 		*umr_opcode = wq->wr_data[idx];
+		*pwc_byte_len = 0;
 		break;
+	default:
+		*pwc_byte_len = 0;
 	}
 }