From mboxrd@z Thu Jan 1 00:00:00 1970 From: Bart Van Assche Subject: [PATCH for libibmad] mad_rpc(): Fail with EINVAL if max_retries <= 0 Date: Sun, 18 Aug 2013 10:37:11 +0200 Message-ID: <521087B7.9090208@acm.org> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Return-path: Sender: linux-rdma-owner-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: Ira Weiny Cc: linux-rdma List-Id: linux-rdma@vger.kernel.org Set errno to EINVAL instead of an undefined value if max_retries <= 0. This patch avoids that the following compiler warning is triggered: src/rpc.c:187:8: warning: 'status' may be used uninitialized in this function [-Wmaybe-uninitialized] Signed-off-by: Bart Van Assche --- src/rpc.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/rpc.c b/src/rpc.c index 08b6c19..8d961f2 100644 --- a/src/rpc.c +++ b/src/rpc.c @@ -144,6 +144,13 @@ _do_madrpc(int port_id, void *sndbuf, void *rcvbuf, int agentid, int len, save_mad = 0; } + if (max_retries <= 0) { + errno = EINVAL; + *p_error = EINVAL; + ERRS("max_retries %d <= 0", max_retries); + return -1; + } + trid = (uint32_t) mad_get_field64(umad_get_mad(sndbuf), 0, IB_MAD_TRID_F); -- 1.7.10.4 -- To unsubscribe from this list: send the line "unsubscribe linux-rdma" in the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org More majordomo info at http://vger.kernel.org/majordomo-info.html