All of lore.kernel.org
 help / color / mirror / Atom feed
From: Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org>
To: Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
Cc: linux-rdma <linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>
Subject: [PATCH for libibmad] mad_rpc(): Fail with EINVAL if max_retries <= 0
Date: Sun, 18 Aug 2013 10:37:11 +0200	[thread overview]
Message-ID: <521087B7.9090208@acm.org> (raw)

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 <bvanassche-HInyCGIudOg@public.gmane.org>
---
 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

             reply	other threads:[~2013-08-18  8:37 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-08-18  8:37 Bart Van Assche [this message]
     [not found] ` <521087B7.9090208-HInyCGIudOg@public.gmane.org>
2013-08-19  6:24   ` [PATCH for libibmad] mad_rpc(): Fail with EINVAL if max_retries <= 0 Ira Weiny

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=521087B7.9090208@acm.org \
    --to=bvanassche-hinycgiudog@public.gmane.org \
    --cc=ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    --cc=linux-rdma-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.