linux-rdma.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH for libibmad] mad_rpc(): Fail with EINVAL if max_retries <= 0
@ 2013-08-18  8:37 Bart Van Assche
       [not found] ` <521087B7.9090208-HInyCGIudOg@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Bart Van Assche @ 2013-08-18  8:37 UTC (permalink / raw)
  To: Ira Weiny; +Cc: linux-rdma

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

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH for libibmad] mad_rpc(): Fail with EINVAL if max_retries <= 0
       [not found] ` <521087B7.9090208-HInyCGIudOg@public.gmane.org>
@ 2013-08-19  6:24   ` Ira Weiny
  0 siblings, 0 replies; 2+ messages in thread
From: Ira Weiny @ 2013-08-19  6:24 UTC (permalink / raw)
  To: Bart Van Assche; +Cc: linux-rdma

On Sun, 18 Aug 2013 10:37:11 +0200
Bart Van Assche <bvanassche-HInyCGIudOg@public.gmane.org> wrote:

> 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>

Thanks Applied,
Ira

> ---
>  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
> 


-- 
Ira Weiny <ira.weiny-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
--
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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2013-08-19  6:24 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-08-18  8:37 [PATCH for libibmad] mad_rpc(): Fail with EINVAL if max_retries <= 0 Bart Van Assche
     [not found] ` <521087B7.9090208-HInyCGIudOg@public.gmane.org>
2013-08-19  6:24   ` Ira Weiny

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).