diff mbox

[rdma-core] librdmacm: Remove unneeded condition

Message ID 20171102135134.5728-1-yuval.shaia@oracle.com (mailing list archive)
State Changes Requested
Headers show

Commit Message

Yuval Shaia Nov. 2, 2017, 1:51 p.m. UTC
The check makes no difference - remove it.

Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
---
 librdmacm/cma.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Bart Van Assche Nov. 2, 2017, 3:10 p.m. UTC | #1
On Thu, 2017-11-02 at 15:51 +0200, Yuval Shaia wrote:
> The check makes no difference - remove it.

> 

> Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>

> ---

>  librdmacm/cma.c | 4 ++--

>  1 file changed, 2 insertions(+), 2 deletions(-)

> 

> diff --git a/librdmacm/cma.c b/librdmacm/cma.c

> index 7aaf45f2..6eebe71b 100644

> --- a/librdmacm/cma.c

> +++ b/librdmacm/cma.c

> @@ -880,8 +880,8 @@ static int rdma_resolve_addr2(struct rdma_cm_id *id, struct sockaddr *src_addr,

>  	CMA_INIT_CMD(&cmd, sizeof cmd, RESOLVE_ADDR);

>  	id_priv = container_of(id, struct cma_id_private, id);

>  	cmd.id = id_priv->handle;

> -	if ((cmd.src_size = src_len))

> -		memcpy(&cmd.src_addr, src_addr, src_len);

> +	cmd.src_size = src_len;

> +	memcpy(&cmd.src_addr, src_addr, src_len);

>  	memcpy(&cmd.dst_addr, dst_addr, dst_len);

>  	cmd.dst_size = dst_len;

>  	cmd.timeout_ms = timeout_ms;


Shouldn't the description have been "Passing zero as third argument to
memcpy() is allowed so the if-test is not necessary. Hence leave it out"?

Bart.
Leon Romanovsky Nov. 2, 2017, 3:12 p.m. UTC | #2
On Thu, Nov 02, 2017 at 03:51:34PM +0200, Yuval Shaia wrote:
> The check makes no difference - remove it.
>
> Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
> ---
>  librdmacm/cma.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/librdmacm/cma.c b/librdmacm/cma.c
> index 7aaf45f2..6eebe71b 100644
> --- a/librdmacm/cma.c
> +++ b/librdmacm/cma.c
> @@ -880,8 +880,8 @@ static int rdma_resolve_addr2(struct rdma_cm_id *id, struct sockaddr *src_addr,
>  	CMA_INIT_CMD(&cmd, sizeof cmd, RESOLVE_ADDR);
>  	id_priv = container_of(id, struct cma_id_private, id);
>  	cmd.id = id_priv->handle;
> -	if ((cmd.src_size = src_len))

Isn't this "=" should be "=="?

> -		memcpy(&cmd.src_addr, src_addr, src_len);
> +	cmd.src_size = src_len;
> +	memcpy(&cmd.src_addr, src_addr, src_len);
>  	memcpy(&cmd.dst_addr, dst_addr, dst_len);
>  	cmd.dst_size = dst_len;
>  	cmd.timeout_ms = timeout_ms;
> --
> 2.13.6
>
> --
> 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
Jason Gunthorpe Nov. 2, 2017, 4:45 p.m. UTC | #3
On Thu, Nov 02, 2017 at 03:10:27PM +0000, Bart Van Assche wrote:
> On Thu, 2017-11-02 at 15:51 +0200, Yuval Shaia wrote:
> > The check makes no difference - remove it.
> 
> Shouldn't the description have been "Passing zero as third argument to
> memcpy() is allowed so the if-test is not necessary. Hence leave it out"?

+1

Jason
--
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
Yuval Shaia Nov. 2, 2017, 6:03 p.m. UTC | #4
On Thu, Nov 02, 2017 at 05:12:52PM +0200, Leon Romanovsky wrote:
> On Thu, Nov 02, 2017 at 03:51:34PM +0200, Yuval Shaia wrote:
> > The check makes no difference - remove it.
> >
> > Signed-off-by: Yuval Shaia <yuval.shaia@oracle.com>
> > ---
> >  librdmacm/cma.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/librdmacm/cma.c b/librdmacm/cma.c
> > index 7aaf45f2..6eebe71b 100644
> > --- a/librdmacm/cma.c
> > +++ b/librdmacm/cma.c
> > @@ -880,8 +880,8 @@ static int rdma_resolve_addr2(struct rdma_cm_id *id, struct sockaddr *src_addr,
> >  	CMA_INIT_CMD(&cmd, sizeof cmd, RESOLVE_ADDR);
> >  	id_priv = container_of(id, struct cma_id_private, id);
> >  	cmd.id = id_priv->handle;
> > -	if ((cmd.src_size = src_len))
> 
> Isn't this "=" should be "=="?

No chance as cmd was just initialized.

> 
> > -		memcpy(&cmd.src_addr, src_addr, src_len);
> > +	cmd.src_size = src_len;
> > +	memcpy(&cmd.src_addr, src_addr, src_len);
> >  	memcpy(&cmd.dst_addr, dst_addr, dst_len);
> >  	cmd.dst_size = dst_len;
> >  	cmd.timeout_ms = timeout_ms;
> > --
> > 2.13.6
> >
> > --
> > 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


--
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
Leon Romanovsky Nov. 5, 2017, 7:26 a.m. UTC | #5
On Thu, Nov 02, 2017 at 10:45:28AM -0600, Jason Gunthorpe wrote:
> On Thu, Nov 02, 2017 at 03:10:27PM +0000, Bart Van Assche wrote:
> > On Thu, 2017-11-02 at 15:51 +0200, Yuval Shaia wrote:
> > > The check makes no difference - remove it.
> >
> > Shouldn't the description have been "Passing zero as third argument to
> > memcpy() is allowed so the if-test is not necessary. Hence leave it out"?
>
> +1

Yuval ?

Thanks

>
> Jason
> --
> 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
Yuval Shaia Nov. 5, 2017, 9:30 a.m. UTC | #6
On Sun, Nov 05, 2017 at 09:26:58AM +0200, Leon Romanovsky wrote:
> On Thu, Nov 02, 2017 at 10:45:28AM -0600, Jason Gunthorpe wrote:
> > On Thu, Nov 02, 2017 at 03:10:27PM +0000, Bart Van Assche wrote:
> > > On Thu, 2017-11-02 at 15:51 +0200, Yuval Shaia wrote:
> > > > The check makes no difference - remove it.
> > >
> > > Shouldn't the description have been "Passing zero as third argument to
> > > memcpy() is allowed so the if-test is not necessary. Hence leave it out"?
> >
> > +1
> 
> Yuval ?

Thanks Leon,
Just post new pull request with the revised commit message.
If still v1 is needed here for review then i'll post it.

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


--
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
Leon Romanovsky Nov. 5, 2017, 1:27 p.m. UTC | #7
On Sun, Nov 05, 2017 at 11:30:15AM +0200, Yuval Shaia wrote:
> On Sun, Nov 05, 2017 at 09:26:58AM +0200, Leon Romanovsky wrote:
> > On Thu, Nov 02, 2017 at 10:45:28AM -0600, Jason Gunthorpe wrote:
> > > On Thu, Nov 02, 2017 at 03:10:27PM +0000, Bart Van Assche wrote:
> > > > On Thu, 2017-11-02 at 15:51 +0200, Yuval Shaia wrote:
> > > > > The check makes no difference - remove it.
> > > >
> > > > Shouldn't the description have been "Passing zero as third argument to
> > > > memcpy() is allowed so the if-test is not necessary. Hence leave it out"?
> > >
> > > +1
> >
> > Yuval ?
>
> Thanks Leon,
> Just post new pull request with the revised commit message.
> If still v1 is needed here for review then i'll post it.

Thanks, applied.

>
> >
> > Thanks
> >
> > >
> > > Jason
> > > --
> > > 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/librdmacm/cma.c b/librdmacm/cma.c
index 7aaf45f2..6eebe71b 100644
--- a/librdmacm/cma.c
+++ b/librdmacm/cma.c
@@ -880,8 +880,8 @@  static int rdma_resolve_addr2(struct rdma_cm_id *id, struct sockaddr *src_addr,
 	CMA_INIT_CMD(&cmd, sizeof cmd, RESOLVE_ADDR);
 	id_priv = container_of(id, struct cma_id_private, id);
 	cmd.id = id_priv->handle;
-	if ((cmd.src_size = src_len))
-		memcpy(&cmd.src_addr, src_addr, src_len);
+	cmd.src_size = src_len;
+	memcpy(&cmd.src_addr, src_addr, src_len);
 	memcpy(&cmd.dst_addr, dst_addr, dst_len);
 	cmd.dst_size = dst_len;
 	cmd.timeout_ms = timeout_ms;