[PATCH v2 1/3] coccinelle: misc: secs_to_jiffies: Patch expressions too

Easwar Hariharan posted 3 patches 1 year ago
There is a newer version of this series
[PATCH v2 1/3] coccinelle: misc: secs_to_jiffies: Patch expressions too
Posted by Easwar Hariharan 1 year ago
Teach the script to suggest conversions for timeout patterns where the
arguments to msecs_to_jiffies() are expressions as well.

Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
---
 scripts/coccinelle/misc/secs_to_jiffies.cocci | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/scripts/coccinelle/misc/secs_to_jiffies.cocci b/scripts/coccinelle/misc/secs_to_jiffies.cocci
index 8bbb2884ea5db939c63fd4513cf5ca8c977aa8cb..416f348174ca659b544441f5f68f04a41d1ad4a3 100644
--- a/scripts/coccinelle/misc/secs_to_jiffies.cocci
+++ b/scripts/coccinelle/misc/secs_to_jiffies.cocci
@@ -20,3 +20,13 @@ virtual patch
 
 - msecs_to_jiffies(C * MSEC_PER_SEC)
 + secs_to_jiffies(C)
+
+@depends on patch@ expression E; @@
+
+- msecs_to_jiffies(E * 1000)
++ secs_to_jiffies(E)
+
+@depends on patch@ expression E; @@
+
+- msecs_to_jiffies(E * MSEC_PER_SEC)
++ secs_to_jiffies(E)

-- 
2.43.0
Re: [cocci] [PATCH v2 1/3] coccinelle: misc: secs_to_jiffies: Patch expressions too
Posted by Markus Elfring 1 year ago
> Teach the script to suggest conversions for timeout patterns where the
> arguments to msecs_to_jiffies() are expressions as well.
How do you imagine that the shown SmPL code fits ever to patch reviews?

Examples:
* https://lore.kernel.org/cocci/80cae791-663c-4589-b67e-d4d1049fcd98@web.de/
  https://sympa.inria.fr/sympa/arc/cocci/2025-02/msg00002.html
  https://lkml.org/lkml/2025/2/3/151

* https://lore.kernel.org/cocci/e06cb7f5-7aa3-464c-a8a1-2c7b9b6a29eb@web.de/
  https://sympa.inria.fr/sympa/arc/cocci/2025-01/msg00122.html
  https://lkml.org/lkml/2025/1/30/307


Regards,
Markus
Re: [cocci] [PATCH v2 1/3] coccinelle: misc: secs_to_jiffies: Patch expressions too
Posted by Easwar Hariharan 1 year ago
On 2/3/2025 11:56 PM, Markus Elfring wrote:
>> Teach the script to suggest conversions for timeout patterns where the
>> arguments to msecs_to_jiffies() are expressions as well.
> How do you imagine that the shown SmPL code fits ever to patch reviews?

By the simple fact of accomplishing the same result despite differences in
code style, as explicitly called out in the changelog.

- Easwar (he/him)
Re: [cocci] [v2 1/3] coccinelle: misc: secs_to_jiffies: Patch expressions too
Posted by Markus Elfring 1 year ago
>> How do you imagine that the shown SmPL code fits ever to patch reviews?
>
> By the simple fact of accomplishing the same result despite differences in
> code style, as explicitly called out in the changelog.
Do any other contributors care more for the mentioned software development concerns?

How do you think about helping to improve affected implementation details?

Regards,
Markus