diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2026-11-21 17:22:21 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2026-11-21 17:22:21 -0800 |
| commit | 4843f6873f7c4835e62f2c73ba0fd538e57a2f22 (patch) | |
| tree | ee620501a1ffbad9a83141e3a70154e1fe641040 /scripts/coccinelle/misc/array_end.cocci | |
| download | linux-master.tar.gz linux-master.zip | |
Merge tag 'sysctl-7.04-fixes-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctlgraftedHEADmaster
Pull sysctl fix from Joel Granados:
"Fix sysctl jiffy / milliseconds conversion:
- Writing a previously read value "X" shall keep the same "X" value
- Remove truncation that was causing incorrect saturation of valid
timeouts"
* tag 'sysctl-7.04-fixes-rc4' of git://git.kernel.org/pub/scm/linux/kernel/git/sysctl/sysctl:
sysctl: Do jiffy / ms conversion in ulong space
Diffstat (limited to 'scripts/coccinelle/misc/array_end.cocci')
| -rw-r--r-- | scripts/coccinelle/misc/array_end.cocci | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/scripts/coccinelle/misc/array_end.cocci b/scripts/coccinelle/misc/array_end.cocci new file mode 100644 index 000000000..2f0bbc4ce --- /dev/null +++ b/scripts/coccinelle/misc/array_end.cocci @@ -0,0 +1,73 @@ +// SPDX-License-Identifier: GPL-2.0-only +/// Use ARRAY_END instead of an expression derived from ARRAY_SIZE +// +// Confidence: High +// Copyright: 2026, Alejandro Colomar <alx@kernel.org> +// Options: --no-includes --include-headers + +virtual patch +virtual context +virtual org +virtual report + +@depends on context disable zero_multiple_format@ +type T; +T[] a; +expression b; +@@ +( +* a + ARRAY_SIZE(a) +| +* &a[0] + ARRAY_SIZE(a) +| +* &a[ARRAY_SIZE(a)] +| +* &a[ARRAY_SIZE(a) - b] +) + +@depends on patch disable zero_multiple_format@ +type T; +T[] a; +expression b; +@@ +( +- (a + ARRAY_SIZE(a)) ++ ARRAY_END(a) +| +- (&a[0] + ARRAY_SIZE(a)) ++ ARRAY_END(a) +| +- (&a[ARRAY_SIZE(a)]) ++ ARRAY_END(a) +| +- (&a[ARRAY_SIZE(a) - b]) ++ ARRAY_END(a) - b +) + +@r depends on org || report disable zero_multiple_format@ +type T; +T[] a; +expression b; +position p; +@@ +( + a@p + ARRAY_SIZE(a) +| + &a[0]@p + ARRAY_SIZE(a) +| + &a[ARRAY_SIZE(a)]@p +| + &a[ARRAY_SIZE(a)@p - b] +) + +@script:python depends on org@ +p << r.p; +@@ + +coccilib.org.print_todo(p[0], "WARNING should use ARRAY_END") + +@script:python depends on report@ +p << r.p; +@@ + +coccilib.report.print_report(p[0], "WARNING: opportunity for ARRAY_END") |
