linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] net/mlx5: Add a missing macro undefinition
@ 2020-06-07  5:12 Hu Haowen
  2020-06-07  6:36 ` Leon Romanovsky
  0 siblings, 1 reply; 4+ messages in thread
From: Hu Haowen @ 2020-06-07  5:12 UTC (permalink / raw)
  To: saeedm, leon, davem, kuba; +Cc: netdev, linux-rdma, linux-kernel, Hu Haowen

The macro ODP_CAP_SET_MAX is only used in function handle_hca_cap_odp()
in file main.c, so it should be undefined when there are no more uses
of it.

Signed-off-by: Hu Haowen <xianfengting221@163.com>
---
 drivers/net/ethernet/mellanox/mlx5/core/main.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlx5/core/main.c b/drivers/net/ethernet/mellanox/mlx5/core/main.c
index df46b1fce3a7..1143297eccaa 100644
--- a/drivers/net/ethernet/mellanox/mlx5/core/main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/main.c
@@ -489,6 +489,8 @@ static int handle_hca_cap_odp(struct mlx5_core_dev *dev, void *set_ctx)
 	ODP_CAP_SET_MAX(dev, dc_odp_caps.read);
 	ODP_CAP_SET_MAX(dev, dc_odp_caps.atomic);
 
+#undef ODP_CAP_SET_MAX
+
 	if (!do_set)
 		return 0;
 
-- 
2.25.1



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

* Re: [PATCH] net/mlx5: Add a missing macro undefinition
  2020-06-07  5:12 [PATCH] net/mlx5: Add a missing macro undefinition Hu Haowen
@ 2020-06-07  6:36 ` Leon Romanovsky
  2020-06-07  6:55   ` Hu Haowen
  0 siblings, 1 reply; 4+ messages in thread
From: Leon Romanovsky @ 2020-06-07  6:36 UTC (permalink / raw)
  To: Hu Haowen; +Cc: saeedm, davem, kuba, netdev, linux-rdma, linux-kernel

On Sun, Jun 07, 2020 at 01:12:40PM +0800, Hu Haowen wrote:
> The macro ODP_CAP_SET_MAX is only used in function handle_hca_cap_odp()
> in file main.c, so it should be undefined when there are no more uses
> of it.
>
> Signed-off-by: Hu Haowen <xianfengting221@163.com>
> ---
>  drivers/net/ethernet/mellanox/mlx5/core/main.c | 2 ++
>  1 file changed, 2 insertions(+)

"should be undefined" is s little bit over statement, but overall
the patch is good.

Fixes: fca22e7e595f ("net/mlx5: ODP support for XRC transport is not enabled by default in FW")

Thanks,
Reviewed-by: Leon Romanovsky <leonro@mellanox.com>

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

* Re: [PATCH] net/mlx5: Add a missing macro undefinition
  2020-06-07  6:36 ` Leon Romanovsky
@ 2020-06-07  6:55   ` Hu Haowen
  2020-06-07 23:36     ` David Miller
  0 siblings, 1 reply; 4+ messages in thread
From: Hu Haowen @ 2020-06-07  6:55 UTC (permalink / raw)
  To: Leon Romanovsky; +Cc: saeedm, davem, kuba, netdev, linux-rdma, linux-kernel


On 2020/6/7 2:36 PM, Leon Romanovsky wrote:
> On Sun, Jun 07, 2020 at 01:12:40PM +0800, Hu Haowen wrote:
>> The macro ODP_CAP_SET_MAX is only used in function handle_hca_cap_odp()
>> in file main.c, so it should be undefined when there are no more uses
>> of it.
>>
>> Signed-off-by: Hu Haowen <xianfengting221@163.com>
>> ---
>>   drivers/net/ethernet/mellanox/mlx5/core/main.c | 2 ++
>>   1 file changed, 2 insertions(+)
> "should be undefined" is s little bit over statement, but overall
> the patch is good.


Sorry for my strong tone, but my idea is that every macro which is
defined and used just in a single function, is supposed to be undefined
at the end of its final use, so that you won't get into trouble next
time if you define a macro with the same name as this one.


>
> Fixes: fca22e7e595f ("net/mlx5: ODP support for XRC transport is not enabled by default in FW")
>
> Thanks,
> Reviewed-by: Leon Romanovsky <leonro@mellanox.com>


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

* Re: [PATCH] net/mlx5: Add a missing macro undefinition
  2020-06-07  6:55   ` Hu Haowen
@ 2020-06-07 23:36     ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2020-06-07 23:36 UTC (permalink / raw)
  To: xianfengting221; +Cc: leon, saeedm, kuba, netdev, linux-rdma, linux-kernel

From: Hu Haowen <xianfengting221@163.com>
Date: Sun, 7 Jun 2020 14:55:33 +0800

> 
> On 2020/6/7 2:36 PM, Leon Romanovsky wrote:
>> On Sun, Jun 07, 2020 at 01:12:40PM +0800, Hu Haowen wrote:
>>> The macro ODP_CAP_SET_MAX is only used in function
>>> handle_hca_cap_odp()
>>> in file main.c, so it should be undefined when there are no more uses
>>> of it.
>>>
>>> Signed-off-by: Hu Haowen <xianfengting221@163.com>
>>> ---
>>>   drivers/net/ethernet/mellanox/mlx5/core/main.c | 2 ++
>>>   1 file changed, 2 insertions(+)
>> "should be undefined" is s little bit over statement, but overall
>> the patch is good.
> 
> 
> Sorry for my strong tone, but my idea is that every macro which is
> defined and used just in a single function, is supposed to be
> undefined
> at the end of its final use, so that you won't get into trouble next
> time if you define a macro with the same name as this one.

The compiler would generate an error if that happened, so you would
not get into "trouble".

I fail to see the value in this change at all, sorry.

Really, what's the point?

Does it make the code harder to read?  No.

Does it cause problems if you accidently want to use that macro name
again in the same compilation unit?  No.

So I have yet to hear a valid "why" to make this kind of change and
I'd like to stop this set of cleanups before it gets out of control
and we have these ugly #undef statements all over the tree.

Thank you.

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

end of thread, other threads:[~2020-06-07 23:36 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-07  5:12 [PATCH] net/mlx5: Add a missing macro undefinition Hu Haowen
2020-06-07  6:36 ` Leon Romanovsky
2020-06-07  6:55   ` Hu Haowen
2020-06-07 23:36     ` David Miller

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