Skip to contentSkip to conversation

mad_rpc(): Fail with EINVAL if max_retries <= 0

PATCH Applied Bart Van Assche 2 participants 2 messages Aug 18, 2013 – Aug 19, 2013 1 message not in the archive InfiniBand

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mad_rpc(): Fail with EINVAL if max_retries <= 0

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]

---
 src/rpc.c |    7 +++++++
 1 file changed, 7 insertions(+)
src/rpc.c +7 -0
index 08b6c19..8d961f2 100644
@@ -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);
 
Signature · 6 lines
1.7.10.4

--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Applied
#2 lore raw
In reply to a message not in the archive
Quoted 6 lines · On Sun, 18 Aug 2013 10:37:11 +0200 Bart Van Assche…

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]

Thanks Applied,
Ira

Quoted 25 lines
---
 src/rpc.c |    7 +++++++
 1 file changed, 7 insertions(+)
src/rpc.c +7 -0
index 08b6c19..8d961f2 100644
@@ -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);
 
Signature · 1 line
1.7.10.4
Signature · 5 lines
Ira Weiny <[email protected]>
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html