Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

coccinelle: misc: secs_to_jiffies: implement context and report modes

As requested by Ricardo and Jakub, implement report and context modes for
the secs_to_jiffies Coccinelle script. While here, add the option to look
for opportunities to use secs_to_jiffies() in headers.

Link: https://lkml.kernel.org/r/20250703225145.152288-1-eahariha@linux.microsoft.com
Signed-off-by: Easwar Hariharan <eahariha@linux.microsoft.com>
Closes: https://lore.kernel.org/all/20250129-secs_to_jiffles-v1-1-35a5e16b9f03@chromium.org/
Closes: https://lore.kernel.org/all/20250221162107.409ae333@kernel.org/
Tested-by: Ricardo Ribalda <ribalda@chromium.org>
Cc: Julia Lawall <julia.lawall@inria.fr>
Cc: Nicolas Palix <nicolas.palix@imag.fr>
Cc: Jakub Kicinski <kuba@kernel.org>
Cc: Ricardo Ribalda <ribalda@chromium.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>

authored by

Easwar Hariharan and committed by
Andrew Morton
249e7ced ee13240c

+44 -5
+44 -5
scripts/coccinelle/misc/secs_to_jiffies.cocci
··· 7 7 // Confidence: High 8 8 // Copyright: (C) 2024 Easwar Hariharan, Microsoft 9 9 // Keywords: secs, seconds, jiffies 10 - // 10 + // Options: --include-headers 11 11 12 12 virtual patch 13 + virtual report 14 + virtual context 13 15 14 - @depends on patch@ constant C; @@ 16 + @pconst depends on patch@ constant C; @@ 15 17 16 18 - msecs_to_jiffies(C * 1000) 17 19 + secs_to_jiffies(C) 18 20 19 - @depends on patch@ constant C; @@ 21 + @pconstms depends on patch@ constant C; @@ 20 22 21 23 - msecs_to_jiffies(C * MSEC_PER_SEC) 22 24 + secs_to_jiffies(C) 23 25 24 - @depends on patch@ expression E; @@ 26 + @pexpr depends on patch@ expression E; @@ 25 27 26 28 - msecs_to_jiffies(E * 1000) 27 29 + secs_to_jiffies(E) 28 30 29 - @depends on patch@ expression E; @@ 31 + @pexprms depends on patch@ expression E; @@ 30 32 31 33 - msecs_to_jiffies(E * MSEC_PER_SEC) 32 34 + secs_to_jiffies(E) 35 + 36 + @r depends on report && !patch@ 37 + constant C; 38 + expression E; 39 + position p; 40 + @@ 41 + 42 + ( 43 + msecs_to_jiffies(C@p * 1000) 44 + | 45 + msecs_to_jiffies(C@p * MSEC_PER_SEC) 46 + | 47 + msecs_to_jiffies(E@p * 1000) 48 + | 49 + msecs_to_jiffies(E@p * MSEC_PER_SEC) 50 + ) 51 + 52 + @c depends on context && !patch@ 53 + constant C; 54 + expression E; 55 + @@ 56 + 57 + ( 58 + * msecs_to_jiffies(C * 1000) 59 + | 60 + * msecs_to_jiffies(C * MSEC_PER_SEC) 61 + | 62 + * msecs_to_jiffies(E * 1000) 63 + | 64 + * msecs_to_jiffies(E * MSEC_PER_SEC) 65 + ) 66 + 67 + @script:python depends on report@ 68 + p << r.p; 69 + @@ 70 + 71 + coccilib.report.print_report(p[0], "WARNING opportunity for secs_to_jiffies()")