From a3b0b6f953ecd51c98bc84efd043a4aad786801b Mon Sep 17 00:00:00 2001 From: Rikard Falkeborn Date: Mon, 8 Apr 2019 21:14:32 +0200 Subject: coccinelle: kstrdup: Fix typo in warning messages Replace 'kstrdep' with 'kstrdup' in warning messages. Signed-off-by: Rikard Falkeborn Acked-by: Julia Lawall Signed-off-by: Masahiro Yamada --- scripts/coccinelle/api/kstrdup.cocci | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'scripts/coccinelle') diff --git a/scripts/coccinelle/api/kstrdup.cocci b/scripts/coccinelle/api/kstrdup.cocci index 09cba54ed0cf..6d13d54a6ee6 100644 --- a/scripts/coccinelle/api/kstrdup.cocci +++ b/scripts/coccinelle/api/kstrdup.cocci @@ -76,7 +76,7 @@ p1 << r1.p1; p2 << r1.p2; @@ -cocci.print_main("WARNING opportunity for kstrdep",p1) +cocci.print_main("WARNING opportunity for kstrdup",p1) cocci.print_secs("strcpy",p2) @script:python depends on org@ @@ -84,7 +84,7 @@ p1 << r2.p1; p2 << r2.p2; @@ -cocci.print_main("WARNING opportunity for kstrdep",p1) +cocci.print_main("WARNING opportunity for kstrdup",p1) cocci.print_secs("memcpy",p2) @script:python depends on report@ @@ -92,7 +92,7 @@ p1 << r1.p1; p2 << r1.p2; @@ -msg = "WARNING opportunity for kstrdep (strcpy on line %s)" % (p2[0].line) +msg = "WARNING opportunity for kstrdup (strcpy on line %s)" % (p2[0].line) coccilib.report.print_report(p1[0], msg) @script:python depends on report@ @@ -100,5 +100,5 @@ p1 << r2.p1; p2 << r2.p2; @@ -msg = "WARNING opportunity for kstrdep (memcpy on line %s)" % (p2[0].line) +msg = "WARNING opportunity for kstrdup (memcpy on line %s)" % (p2[0].line) coccilib.report.print_report(p1[0], msg) -- cgit v1.2.3 From 30a70e806d938ed9fd9bfd2074c4458e63efc3ed Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Tue, 7 May 2019 11:20:48 +0200 Subject: coccinelle: put_device: Adjust a message construction The Linux coding style tolerates long string literals so that the provided information can be easier found also by search tools like grep. Thus simplify a message construction in a SmPL rule by concatenating text with two plus operators less. Signed-off-by: Markus Elfring Signed-off-by: Masahiro Yamada --- scripts/coccinelle/free/put_device.cocci | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'scripts/coccinelle') diff --git a/scripts/coccinelle/free/put_device.cocci b/scripts/coccinelle/free/put_device.cocci index c9f071b0a0ab..3ebebc064f10 100644 --- a/scripts/coccinelle/free/put_device.cocci +++ b/scripts/coccinelle/free/put_device.cocci @@ -42,11 +42,10 @@ p1 << search.p1; p2 << search.p2; @@ -coccilib.report.print_report(p2[0], "ERROR: missing put_device; " - + "call of_find_device_by_node on line " - + p1[0].line - + ", but without a corresponding object release " - + "within this function.") +coccilib.report.print_report(p2[0], + "ERROR: missing put_device; call of_find_device_by_node on line " + + p1[0].line + + ", but without a corresponding object release within this function.") @script:python depends on org@ p1 << search.p1; -- cgit v1.2.3 From f58c17c202e7aec9623754a7ec0b0669e043b838 Mon Sep 17 00:00:00 2001 From: Markus Elfring Date: Wed, 8 May 2019 13:50:49 +0200 Subject: coccinelle: put_device: Add a cast to an expression for an assignment Extend a when constraint in a SmPL rule so that an additional cast is optionally excluded from source code searches for an expression in assignments. Signed-off-by: Markus Elfring Suggested-by: Julia Lawall Link: https://lore.kernel.org/lkml/alpine.DEB.2.21.1902160934400.3212@hadrien/ Link: https://systeme.lip6.fr/pipermail/cocci/2019-February/005592.html Acked-by: Julia Lawall Signed-off-by: Masahiro Yamada --- scripts/coccinelle/free/put_device.cocci | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts/coccinelle') diff --git a/scripts/coccinelle/free/put_device.cocci b/scripts/coccinelle/free/put_device.cocci index 3ebebc064f10..120921366e84 100644 --- a/scripts/coccinelle/free/put_device.cocci +++ b/scripts/coccinelle/free/put_device.cocci @@ -24,7 +24,7 @@ if (id == NULL || ...) { ... return ...; } when != of_dev_put(id) when != if (id) { ... put_device(&id->dev) ... } when != e1 = (T)id - when != e1 = &id->dev + when != e1 = (T)(&id->dev) when != e1 = get_device(&id->dev) when != e1 = (T1)platform_get_drvdata(id) ( -- cgit v1.2.3 From 0c4ab18fc33bba70299f51fac83e32397cf9a04b Mon Sep 17 00:00:00 2001 From: Kirill Smelkov Date: Sun, 23 Jun 2019 07:28:53 +0000 Subject: coccinelle: api/stream_open: treat all wait_.*() calls as blocking Previously steam_open.cocci was treating only wait_event_.* - e.g. wait_event_interruptible - as a blocking operation. However e.g. wait_for_completion_interruptible is also blocking, and so from this point of view it would be more logical to treat all wait_.* as a blocking point. The logic of this change actually came up for real when drivers/pci/switch/switchtec.c changed from using wait_event_interruptible to wait_for_completion_interruptible: https://lore.kernel.org/linux-pci/20190413170056.GA11293@deco.navytux.spb.ru/ https://lore.kernel.org/linux-pci/20190415145456.GA15280@deco.navytux.spb.ru/ https://lore.kernel.org/linux-pci/20190415154102.GB17661@deco.navytux.spb.ru/ For a driver that uses nonseekable_open with read/write having stream semantic and read also calling e.g. wait_for_completion_interruptible, running stream_open.cocci before this patch would produce: WARNING: _fops: .read() and .write() have stream semantic; safe to change nonseekable_open -> stream_open. while after this patch it will report: ERROR: _fops: .read() can deadlock .write(); change nonseekable_open -> stream_open to fix. Signed-off-by: Kirill Smelkov Acked-by: Julia Lawall Signed-off-by: Masahiro Yamada --- scripts/coccinelle/api/stream_open.cocci | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'scripts/coccinelle') diff --git a/scripts/coccinelle/api/stream_open.cocci b/scripts/coccinelle/api/stream_open.cocci index 350145da7669..12ce18fa6b74 100644 --- a/scripts/coccinelle/api/stream_open.cocci +++ b/scripts/coccinelle/api/stream_open.cocci @@ -35,11 +35,11 @@ type loff_t; // a function that blocks @ blocks @ identifier block_f; -identifier wait_event =~ "^wait_event_.*"; +identifier wait =~ "^wait_.*"; @@ block_f(...) { ... when exists - wait_event(...) + wait(...) ... when exists } @@ -49,12 +49,12 @@ identifier wait_event =~ "^wait_event_.*"; // XXX currently reader_blocks supports only direct and 1-level indirect cases. @ reader_blocks_direct @ identifier stream_reader.readstream; -identifier wait_event =~ "^wait_event_.*"; +identifier wait =~ "^wait_.*"; @@ readstream(...) { ... when exists - wait_event(...) + wait(...) ... when exists } -- cgit v1.2.3