2019-05-13 09:16:15

by Markus Elfring

[permalink] [raw]
Subject: [PATCH 5/5] Coccinelle: put_device: Merge two SmPL when constraints into one

From: Markus Elfring <[email protected]>
Date: Mon, 13 May 2019 09:55:22 +0200

A single parameter was repeated for a function call in two SmPL
when constraints.
Combine the exclusion specifications into a disjunction for the semantic
patch language so that this argument is referenced only once there.

Signed-off-by: Markus Elfring <[email protected]>
---
scripts/coccinelle/free/put_device.cocci | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/scripts/coccinelle/free/put_device.cocci b/scripts/coccinelle/free/put_device.cocci
index 28b0be53fb3f..975cabb97d01 100644
--- a/scripts/coccinelle/free/put_device.cocci
+++ b/scripts/coccinelle/free/put_device.cocci
@@ -22,8 +22,7 @@ id = of_find_device_by_node@p1(x)
if (id == NULL || ...) { ... return ...; }
... when != put_device(&id->dev)
when != id = (T6)(e)
- when != platform_device_put(id)
- when != of_dev_put(id)
+ when != \( platform_device_put \| of_dev_put \) (id)
when != if (id) { ... put_device(&id->dev) ... }
when != e1 = \( (T) \( id \| (&id->dev) \) \| get_device(&id->dev) \| (T1)platform_get_drvdata(id) \)
(
--
2.21.0


2019-05-13 10:22:23

by Julia Lawall

[permalink] [raw]
Subject: Re: [PATCH 5/5] Coccinelle: put_device: Merge two SmPL when constraints into one



On Mon, 13 May 2019, Markus Elfring wrote:

> From: Markus Elfring <[email protected]>
> Date: Mon, 13 May 2019 09:55:22 +0200
>
> A single parameter was repeated for a function call in two SmPL
> when constraints.
> Combine the exclusion specifications into a disjunction for the semantic
> patch language so that this argument is referenced only once there.
>
> Signed-off-by: Markus Elfring <[email protected]>

NACK. This hurts readability and gives no practical benefit.

julia

> ---
> scripts/coccinelle/free/put_device.cocci | 3 +--
> 1 file changed, 1 insertion(+), 2 deletions(-)
>
> diff --git a/scripts/coccinelle/free/put_device.cocci b/scripts/coccinelle/free/put_device.cocci
> index 28b0be53fb3f..975cabb97d01 100644
> --- a/scripts/coccinelle/free/put_device.cocci
> +++ b/scripts/coccinelle/free/put_device.cocci
> @@ -22,8 +22,7 @@ id = of_find_device_by_node@p1(x)
> if (id == NULL || ...) { ... return ...; }
> ... when != put_device(&id->dev)
> when != id = (T6)(e)
> - when != platform_device_put(id)
> - when != of_dev_put(id)
> + when != \( platform_device_put \| of_dev_put \) (id)
> when != if (id) { ... put_device(&id->dev) ... }
> when != e1 = \( (T) \( id \| (&id->dev) \) \| get_device(&id->dev) \| (T1)platform_get_drvdata(id) \)
> (
> --
> 2.21.0
>
>

2019-05-13 13:46:02

by Markus Elfring

[permalink] [raw]
Subject: Re: [5/5] Coccinelle: put_device: Merge two SmPL when constraints into one

>> Combine the exclusion specifications into a disjunction for the semantic
>> patch language so that this argument is referenced only once there.

> NACK. This hurts readability

I suggest to reconsider such readability concerns once more.
Can corresponding software limitations be adjusted any further?


> and gives no practical benefit.

I guess that you know better which aspects can matter also here
for software fine-tuning.


>> +++ b/scripts/coccinelle/free/put_device.cocci
>> @@ -22,8 +22,7 @@ id = of_find_device_by_node@p1(x)
>> if (id == NULL || ...) { ... return ...; }
>> ... when != put_device(&id->dev)
>> when != id = (T6)(e)
>> - when != platform_device_put(id)
>> - when != of_dev_put(id)
>> + when != \( platform_device_put \| of_dev_put \) (id)

Can the reduction of a bit of duplicate SmPL code result in nicer
run time characteristics?

Regards,
Markus