Commit 76e2d16b authored by Linus Torvalds's avatar Linus Torvalds
Browse files
Pull coccinelle updates from Julia Lawall:
 "There are two new semantic patches:

   - minmax: To use min and max instead of ? :

   - swap: To use swap when possible

  Some other semantic patches have been updated to better conform to
  Linux kernel developer expectations or to make the explanation message
  more clear.

  Finally, there is a fix for the coccicheck script"

* 'for-5.14' of git://git.kernel.org/pub/scm/linux/kernel/git/jlawall/linux:
  coccinelle: api: remove kobj_to_dev.cocci script
  scripts: coccicheck: fix troubles on non-English builds
  coccinelle: misc: minmax: suppress patch generation for err returns
  drop unneeded *s
  coccinelle: irqf_oneshot: reduce the severity due to false positives
  coccinelle: misc: add swap script
  coccinelle: misc: update uninitialized_var.cocci documentation
  coccinelle: misc: restrict patch mode in flexible_array.cocci
  coccinelle: misc: add minmax script
parents 8e4f3e15 5e523446
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -87,7 +87,7 @@ else
    fi

    # Use only one thread per core by default if hyperthreading is enabled
    THREADS_PER_CORE=$(lscpu | grep "Thread(s) per core: " | tr -cd "[:digit:]")
    THREADS_PER_CORE=$(LANG=C lscpu | grep "Thread(s) per core: " | tr -cd "[:digit:]")
    if [ -z "$J" ]; then
        NPROC=$(getconf _NPROCESSORS_ONLN)
	if [ $THREADS_PER_CORE -gt 1 -a $NPROC -gt 4 ] ; then
+0 −45
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
///
/// Use kobj_to_dev() instead of container_of()
///
// Confidence: High
// Copyright: (C) 2020 Denis Efremov ISPRAS
// Options: --no-includes --include-headers
//
// Keywords: kobj_to_dev, container_of
//

virtual context
virtual report
virtual org
virtual patch


@r depends on !patch@
expression ptr;
symbol kobj;
position p;
@@

* container_of(ptr, struct device, kobj)@p


@depends on patch@
expression ptr;
@@

- container_of(ptr, struct device, kobj)
+ kobj_to_dev(ptr)


@script:python depends on report@
p << r.p;
@@

coccilib.report.print_report(p[0], "WARNING opportunity for kobj_to_dev()")

@script:python depends on org@
p << r.p;
@@

coccilib.org.print_todo(p[0], "WARNING opportunity for kobj_to_dev()")
+6 −6
Original line number Diff line number Diff line
@@ -22,9 +22,9 @@ position p1;
@@

(
* kfree@p1(E)
 kfree@p1(E)
|
* kfree_sensitive@p1(E)
 kfree_sensitive@p1(E)
)

@print expression@
@@ -66,9 +66,9 @@ position ok;

while (1) { ...
(
* kfree@ok(E)
 kfree@ok(E)
|
* kfree_sensitive@ok(E)
 kfree_sensitive@ok(E)
)
  ... when != break;
      when != goto l;
@@ -84,9 +84,9 @@ position free.p1!=loop.ok,p2!={print.p,sz.p};
@@

(
* kfree@p1(E,...)
 kfree@p1(E,...)
|
* kfree_sensitive@p1(E,...)
 kfree_sensitive@p1(E,...)
)
...
(
+21 −2
Original line number Diff line number Diff line
@@ -51,21 +51,40 @@ position p : script:python() { relevant(p) };
  };
)

@only_field depends on patch@
identifier name, array;
type T;
position q;
@@

(
  struct name {@q
    T array[0];
  };
|
  struct {@q
    T array[0];
  };
)

@depends on patch@
identifier name, array;
type T;
position p : script:python() { relevant(p) };
// position @q with rule "only_field" simplifies
// handling of bitfields, arrays, etc.
position q != only_field.q;
@@

(
  struct name {
  struct name {@q
    ...
    T array@p[
-       0
    ];
  };
|
  struct {
  struct {@q
    ...
    T array@p[
-       0
+2 −2
Original line number Diff line number Diff line
@@ -103,11 +103,11 @@ devm_request_threaded_irq@p(dev, irq, NULL, ...)
@script:python depends on org@
p << match.p;
@@
msg = "ERROR: Threaded IRQ with no primary handler requested without IRQF_ONESHOT"
msg = "WARNING: Threaded IRQ with no primary handler requested without IRQF_ONESHOT (unless it is nested IRQ)"
coccilib.org.print_todo(p[0],msg)

@script:python depends on report@
p << match.p;
@@
msg = "ERROR: Threaded IRQ with no primary handler requested without IRQF_ONESHOT"
msg = "WARNING: Threaded IRQ with no primary handler requested without IRQF_ONESHOT (unless it is nested IRQ)"
coccilib.report.print_report(p[0],msg)
Loading