coccinelle: misc: secs_to_jiffies: Implement context and report modes
A message that is not in the archive (sent off-list or not yet received): [email protected]
Quoted 79 lines · Easwar Hariharan
As requested by Ricardo and Jakub, implement report and context modes for the
secs_to_jiffiesCoccinelle script. While here, add the option to look for opportunities to usesecs_to_jiffies()in headers.Cc Andrew Morton <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Ricardo Ribalda <[email protected]>Signed-off-by Easwar Hariharan <[email protected]>--- scripts/coccinelle/misc/secs_to_jiffies.cocci | 49 +++++++++++++++++-- 1 file changed, 44 insertions(+), 5 deletions(-)scripts/coccinelle/misc/secs_to_jiffies.cocci +34
-5@@ -7,26 +7,65 @@ // Confidence: High // Copyright: (C) 2024 Easwar Hariharan, Microsoft // Keywords: secs, seconds, jiffies -// +// Options: --include-headers virtual patch +virtual report +virtual context -@depends on patch@ constant C; @@ +@pconst depends on patch@ constant C; @@ - msecs_to_jiffies(C * 1000) + secs_to_jiffies(C) -@depends on patch@ constant C; @@ +@pconstms depends on patch@ constant C; @@ - msecs_to_jiffies(C * MSEC_PER_SEC) + secs_to_jiffies(C) -@depends on patch@ expression E; @@ +@pexpr depends on patch@ expression E; @@ - msecs_to_jiffies(E * 1000) + secs_to_jiffies(E) -@depends on patch@ expression E; @@ +@pexprms depends on patch@ expression E; @@ - msecs_to_jiffies(E * MSEC_PER_SEC) + secs_to_jiffies(E) + +@r depends on report && !patch@ +constant C; +expression E; +position p; +@@ + +( + msecs_to_jiffies(C@p * 1000) +| + msecs_to_jiffies(C@p * MSEC_PER_SEC) +| + msecs_to_jiffies(E@p * 1000) +| + msecs_to_jiffies(E@p * MSEC_PER_SEC) +) + +@c depends on context && !patch@ +constant C; +expression E; +@@ + +( +* msecs_to_jiffies(C * 1000) +| +* msecs_to_jiffies(C * MSEC_PER_SEC) +|
scripts/coccinelle/misc/secs_to_jiffies.cocci line 71
Quoted 10 lines
scripts/coccinelle/misc/secs_to_jiffies.cocci +10
-0+* msecs_to_jiffies(E * 1000) +| +* msecs_to_jiffies(E * MSEC_PER_SEC) +) + +@script:python depends on report@ +p << r.p; +@@ + +coccilib.report.print_report(p[0], "WARNING opportunity for secs_to_jiffies()")
Sorry, I was testing sending this to myself before sending to the list, I've added the mailing lists now.
Thanks,
Easwar (he/him)
Ricardo Ribalda
Tested-byQuoted 9 lines · Easwar Hariharan
Quoted 7 lines · Easwar Hariharan
As requested by Ricardo and Jakub, implement report and context modes for the
secs_to_jiffiesCoccinelle script. While here, add the option to look for opportunities to usesecs_to_jiffies()in headers.Cc Andrew Morton <[email protected]>Cc Jakub Kicinski <[email protected]>Cc Ricardo Ribalda <[email protected]>
With this patch I can run coccicheck MODE=report with no error.
Thanks!
Quoted 88 lines
Quoted 72 lines
Signed-off-by Easwar Hariharan <[email protected]>--- scripts/coccinelle/misc/secs_to_jiffies.cocci | 49 +++++++++++++++++-- 1 file changed, 44 insertions(+), 5 deletions(-)scripts/coccinelle/misc/secs_to_jiffies.cocci +34
-5@@ -7,26 +7,65 @@ // Confidence: High // Copyright: (C) 2024 Easwar Hariharan, Microsoft // Keywords: secs, seconds, jiffies -// +// Options: --include-headers virtual patch +virtual report +virtual context -@depends on patch@ constant C; @@ +@pconst depends on patch@ constant C; @@ - msecs_to_jiffies(C * 1000) + secs_to_jiffies(C) -@depends on patch@ constant C; @@ +@pconstms depends on patch@ constant C; @@ - msecs_to_jiffies(C * MSEC_PER_SEC) + secs_to_jiffies(C) -@depends on patch@ expression E; @@ +@pexpr depends on patch@ expression E; @@ - msecs_to_jiffies(E * 1000) + secs_to_jiffies(E) -@depends on patch@ expression E; @@ +@pexprms depends on patch@ expression E; @@ - msecs_to_jiffies(E * MSEC_PER_SEC) + secs_to_jiffies(E) + +@r depends on report && !patch@ +constant C; +expression E; +position p; +@@ + +( + msecs_to_jiffies(C@p * 1000) +| + msecs_to_jiffies(C@p * MSEC_PER_SEC) +| + msecs_to_jiffies(E@p * 1000) +| + msecs_to_jiffies(E@p * MSEC_PER_SEC) +) + +@c depends on context && !patch@ +constant C; +expression E; +@@ + +( +* msecs_to_jiffies(C * 1000) +| +* msecs_to_jiffies(C * MSEC_PER_SEC) +|scripts/coccinelle/misc/secs_to_jiffies.cocci line 71
Quoted 10 lines
scripts/coccinelle/misc/secs_to_jiffies.cocci +10
-0+* msecs_to_jiffies(E * 1000) +| +* msecs_to_jiffies(E * MSEC_PER_SEC) +) + +@script:python depends on report@ +p << r.p; +@@ + +coccilib.report.print_report(p[0], "WARNING opportunity for secs_to_jiffies()")Sorry, I was testing sending this to myself before sending to the list, I've added the mailing lists now.
Thanks,
Easwar (he/him)
Signature · 1 line
Ricardo Ribalda
Quoted 2 lines
Quoted 2 lines
---
scripts/coccinelle/misc/secs_to_jiffies.cocci| 49 +++++++++++++++++--
…
Did you overlook the addition of patch version descriptions?
https://lore.kernel.org/all/?q=%22This+looks+like+a+new+version+of+a+previously+submitted+patch%22
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.15#n310
Will any information from previous patch review approaches trigger more desirable effects also for such an SmPL script variant?
Quoted 15 lines
Quoted 15 lines
-@depends on patch@ constant C; @@
+@pconst depends on patch@ constant C; @@-
msecs_to_jiffies(C * 1000)
+secs_to_jiffies(C)-@depends on patch@ constant C; @@
+@pconstms depends on patch@ constant C; @@-
msecs_to_jiffies(C * MSEC_PER_SEC)
+secs_to_jiffies(C)-@depends on patch@ expression E; @@
+@pexpr depends on patch@ expression E; @@
Quoted 8 lines
Quoted 8 lines
-
msecs_to_jiffies(E * 1000)
+secs_to_jiffies(E)-@depends on patch@ expression E; @@
+@pexprms depends on patch@ expression E; @@-
msecs_to_jiffies(E * MSEC_PER_SEC)
+secs_to_jiffies(E)
Please reduce duplicate code for such SmPL rules.
Quoted 1 line
Quoted 1 line
+@r depends on report && !patch@
…
Please reconsider the condition selection once more.
SmPL code can probably be shared between the operation modes “orq” and “report”. Would you get further development ideas from previous contributions?
Regards,
Markus