* [PATCH] IB/core: fix duplicated code for different branches
@ 2017-08-13 0:52 Gustavo A. R. Silva
2017-08-13 6:31 ` Leon Romanovsky
0 siblings, 1 reply; 3+ messages in thread
From: Gustavo A. R. Silva @ 2017-08-13 0:52 UTC (permalink / raw)
To: Doug Ledford, Sean Hefty, Hal Rosenstock
Cc: linux-rdma, linux-kernel, Gustavo A. R. Silva
Refactor code to avoid identical code for different branches.
This issue was detected with the help of Coccinelle.
Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
---
drivers/infiniband/core/cm.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
index 2b4d613..b46262f 100644
--- a/drivers/infiniband/core/cm.c
+++ b/drivers/infiniband/core/cm.c
@@ -590,8 +590,6 @@ static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv)
link = &(*link)->rb_right;
else if (be64_lt(service_id, cur_cm_id_priv->id.service_id))
link = &(*link)->rb_left;
- else if (be64_gt(service_id, cur_cm_id_priv->id.service_id))
- link = &(*link)->rb_right;
else
link = &(*link)->rb_right;
}
@@ -619,8 +617,6 @@ static struct cm_id_private * cm_find_listen(struct ib_device *device,
node = node->rb_right;
else if (be64_lt(service_id, cm_id_priv->id.service_id))
node = node->rb_left;
- else if (be64_gt(service_id, cm_id_priv->id.service_id))
- node = node->rb_right;
else
node = node->rb_right;
}
--
2.5.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] IB/core: fix duplicated code for different branches
2017-08-13 0:52 [PATCH] IB/core: fix duplicated code for different branches Gustavo A. R. Silva
@ 2017-08-13 6:31 ` Leon Romanovsky
2017-08-17 23:52 ` Gustavo A. R. Silva
0 siblings, 1 reply; 3+ messages in thread
From: Leon Romanovsky @ 2017-08-13 6:31 UTC (permalink / raw)
To: Gustavo A. R. Silva
Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, linux-rdma,
linux-kernel
[-- Attachment #1: Type: text/plain, Size: 1482 bytes --]
On Sat, Aug 12, 2017 at 07:52:35PM -0500, Gustavo A. R. Silva wrote:
> Refactor code to avoid identical code for different branches.
>
> This issue was detected with the help of Coccinelle.
>
> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
> ---
> drivers/infiniband/core/cm.c | 4 ----
> 1 file changed, 4 deletions(-)
I see that you used the same commit message and title for many patches,
it will be better to have description on what exactly you are removing
and why there is no bug in that code.
>
> diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
> index 2b4d613..b46262f 100644
> --- a/drivers/infiniband/core/cm.c
> +++ b/drivers/infiniband/core/cm.c
> @@ -590,8 +590,6 @@ static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv)
> link = &(*link)->rb_right;
> else if (be64_lt(service_id, cur_cm_id_priv->id.service_id))
> link = &(*link)->rb_left;
> - else if (be64_gt(service_id, cur_cm_id_priv->id.service_id))
> - link = &(*link)->rb_right;
> else
> link = &(*link)->rb_right;
> }
> @@ -619,8 +617,6 @@ static struct cm_id_private * cm_find_listen(struct ib_device *device,
> node = node->rb_right;
> else if (be64_lt(service_id, cm_id_priv->id.service_id))
> node = node->rb_left;
> - else if (be64_gt(service_id, cm_id_priv->id.service_id))
> - node = node->rb_right;
You should remove be64_gt() too.
> else
> node = node->rb_right;
> }
> --
> 2.5.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] IB/core: fix duplicated code for different branches
2017-08-13 6:31 ` Leon Romanovsky
@ 2017-08-17 23:52 ` Gustavo A. R. Silva
0 siblings, 0 replies; 3+ messages in thread
From: Gustavo A. R. Silva @ 2017-08-17 23:52 UTC (permalink / raw)
To: Leon Romanovsky
Cc: Doug Ledford, Sean Hefty, Hal Rosenstock, linux-rdma,
linux-kernel
Hi Leon,
On 08/13/2017 01:31 AM, Leon Romanovsky wrote:
> On Sat, Aug 12, 2017 at 07:52:35PM -0500, Gustavo A. R. Silva wrote:
>> Refactor code to avoid identical code for different branches.
>>
>> This issue was detected with the help of Coccinelle.
>>
>> Signed-off-by: Gustavo A. R. Silva <gustavo@embeddedor.com>
>> ---
>> drivers/infiniband/core/cm.c | 4 ----
>> 1 file changed, 4 deletions(-)
>
> I see that you used the same commit message and title for many patches,
> it will be better to have description on what exactly you are removing
> and why there is no bug in that code.
>
Thank you for the suggestion.
I will add a note saying that it is up to the maintainer to verify
whether the code is applicable or not.
The intention of the patch is to point out a duplication of code found
by a Coccinelle script. I'm also working on similar issues reported by
Coverity. It was tested only by compilation as I don't have the proper
hardware to test it on.
>
>>
>> diff --git a/drivers/infiniband/core/cm.c b/drivers/infiniband/core/cm.c
>> index 2b4d613..b46262f 100644
>> --- a/drivers/infiniband/core/cm.c
>> +++ b/drivers/infiniband/core/cm.c
>> @@ -590,8 +590,6 @@ static struct cm_id_private * cm_insert_listen(struct cm_id_private *cm_id_priv)
>> link = &(*link)->rb_right;
>> else if (be64_lt(service_id, cur_cm_id_priv->id.service_id))
>> link = &(*link)->rb_left;
>> - else if (be64_gt(service_id, cur_cm_id_priv->id.service_id))
>> - link = &(*link)->rb_right;
>> else
>> link = &(*link)->rb_right;
>> }
>> @@ -619,8 +617,6 @@ static struct cm_id_private * cm_find_listen(struct ib_device *device,
>> node = node->rb_right;
>> else if (be64_lt(service_id, cm_id_priv->id.service_id))
>> node = node->rb_left;
>> - else if (be64_gt(service_id, cm_id_priv->id.service_id))
>> - node = node->rb_right;
>
> You should remove be64_gt() too.
>
Thank you for pointing it out.
>> else
>> node = node->rb_right;
>> }
>> --
>> 2.5.0
>>
--
Gustavo A. R. Silva
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2017-08-17 23:52 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2017-08-13 0:52 [PATCH] IB/core: fix duplicated code for different branches Gustavo A. R. Silva
2017-08-13 6:31 ` Leon Romanovsky
2017-08-17 23:52 ` Gustavo A. R. Silva
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox