Re: [PATCH 01/16] coccinelle: misc: secs_to_jiffies: Patch expressions too

Markus Elfring
2025-01-29T06:24:46Z

> Teach the script to suggest conversions for timeout patterns where the
> arguments to msecs_to_jiffies() are expressions as well.

I propose to take another look at implementation details for such a script variant
according to the semantic patch language.

…
> +++ b/scripts/coccinelle/misc/secs_to_jiffies.cocci
> @@ -11,12 +11,22 @@
>
> virtual patch
…
> -@depends on patch@ constant C; @@
> +@depends on patch@
> +expression E;
> +@@
>
> -- msecs_to_jiffies(C * MSEC_PER_SEC)
> -+ secs_to_jiffies(C)
> +-msecs_to_jiffies
> ++secs_to_jiffies
> + (E
> +- * \( 1000 \| MSEC_PER_SEC \)
> + )

1. I do not see a need to keep an SmPL rule for the handling of constants
(or literals) after the suggested extension for expressions.

2. I find it nice that you indicate an attempt to make the shown SmPL code
a bit more succinct.
Unfortunately, further constraints should be taken better into account
for the current handling of isomorphisms (and corresponding SmPL disjunctions).
Thus I would find an SmPL rule (like the following) more appropriate.

@adjustment@
expression e;
@@
-msecs_to_jiffies
+secs_to_jiffies
(
(
-e * 1000
|
-e * MSEC_PER_SEC
)
+e
)

3. It seems that you would like to support only a single operation mode so far.
This system aspect can trigger further software development challenges.

Regards,
Markus