All of lore.kernel.org
 help / color / mirror / Atom feed
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: cocci@systeme.lip6.fr, Gilles Muller <Gilles.Muller@lip6.fr>,
	Himanshu Jha <himanshujha199640@gmail.com>,
	Julia Lawall <Julia.Lawall@lip6.fr>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Michal Marek <michal.lkml@markovi.net>,
	Nicolas Palix <nicolas.palix@imag.fr>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] Coccinelle: zalloc-simple: Delete function "kmem_cache_alloc" from SmPL rules
Date: Thu, 1 Feb 2018 10:35:57 +0100	[thread overview]
Message-ID: <6bee0e11-59ef-b7b1-886e-7abaa30887f2@users.sourceforge.net> (raw)
In-Reply-To: <CAK7LNAR27r4j4c1FCh_ObpMpBKXgSP6Vq3P=reA-JKoTji6Q1A@mail.gmail.com>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Feb 2018 10:20:47 +0100

The deletion for a call of the function "memset" depends on
the specification that a size determination is passed by
the expression "E1".
The function "kmem_cache_alloc" was specified despite of the technical
detail that this function does not get a parameter passed which would
correspond to such a size information.

Thus remove it from the first two SmPL rules and omit the rule "r4".

Link: https://elixir.free-electrons.com/linux/v4.15/source/tools/testing/radix-tree/linux/slab.h#L14
Link: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/tools/testing/radix-tree/linux/slab.h?id=f26e52e08ab8e56f528ac14aa7929b3477de5616#n14
Fixes: 5e2d9da5b9ba350a4f13bd3b255be046bcf86465 ("Coccinelle: kzalloc-simple: Add all zero allocating functions")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/alloc/zalloc-simple.cocci | 41 +-----------------------
 1 file changed, 1 insertion(+), 40 deletions(-)

diff --git a/scripts/coccinelle/api/alloc/zalloc-simple.cocci b/scripts/coccinelle/api/alloc/zalloc-simple.cocci
index 92b20913055f..3bee6cdd99ea 100644
--- a/scripts/coccinelle/api/alloc/zalloc-simple.cocci
+++ b/scripts/coccinelle/api/alloc/zalloc-simple.cocci
@@ -34,7 +34,7 @@ statement S;
 @@
 
 * x = (T)\(kmalloc(E1, ...)\|vmalloc(E1)\|dma_alloc_coherent(...,E1,...)\|
-  kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|kmem_alloc(E1, ...)\|
+  kmalloc_node(E1, ...)\|kmem_alloc(E1, ...)\|
   devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|pci_alloc_consistent(...,E1,...)\|
   kvmalloc_node(E1,...)\);
   if ((x==NULL) || ...) S
@@ -88,15 +88,6 @@ statement S;
 - x = (T)kmalloc_node(E1,E2,E3);
 + x = (T)kzalloc_node(E1,E2,E3);
 |
-- x = kmem_cache_alloc(E3,E4);
-+ x = kmem_cache_zalloc(E3,E4);
-|
-- x = (T *)kmem_cache_alloc(E3,E4);
-+ x = kmem_cache_zalloc(E3,E4);
-|
-- x = (T)kmem_cache_alloc(E3,E4);
-+ x = (T)kmem_cache_zalloc(E3,E4);
-|
 - x = kmem_alloc(E1,E2);
 + x = kmem_zalloc(E1,E2);
 |
@@ -268,36 +259,6 @@ x << r3.x;
 msg="WARNING: kzalloc_node should be used for %s, instead of kmalloc_node/memset" % (x)
 coccilib.report.print_report(p[0], msg)
 
-//-----------------------------------------------------------------
-@r4 depends on org || report@
-type T, T2;
-expression x;
-expression E1,E2,E3;
-statement S;
-position p;
-@@
-
- x = (T)kmem_cache_alloc@p(E2,E3);
- if ((x==NULL) || ...) S
- memset((T2)x,0,E1);
-
-@script:python depends on org@
-p << r4.p;
-x << r4.x;
-@@
-
-msg="%s" % (x)
-msg_safe=msg.replace("[","@(").replace("]",")")
-coccilib.org.print_todo(p[0], msg_safe)
-
-@script:python depends on report@
-p << r4.p;
-x << r4.x;
-@@
-
-msg="WARNING: kmem_cache_zalloc should be used for %s, instead of kmem_cache_alloc/memset" % (x)
-coccilib.report.print_report(p[0], msg)
-
 //-----------------------------------------------------------------
 @r5 depends on org || report@
 type T, T2;
-- 
2.16.1

WARNING: multiple messages have this Message-ID (diff)
From: SF Markus Elfring <elfring@users.sourceforge.net>
To: cocci@systeme.lip6.fr, Gilles Muller <Gilles.Muller@lip6.fr>,
	Himanshu Jha <himanshujha199640@gmail.com>,
	Julia Lawall <Julia.Lawall@lip6.fr>,
	Masahiro Yamada <yamada.masahiro@socionext.com>,
	Michal Marek <michal.lkml@markovi.net>,
	Nicolas Palix <nicolas.palix@imag.fr>
Cc: LKML <linux-kernel@vger.kernel.org>, kernel-janitors@vger.kernel.org
Subject: [PATCH] Coccinelle: zalloc-simple: Delete function "kmem_cache_alloc" from SmPL rules
Date: Thu, 01 Feb 2018 09:35:57 +0000	[thread overview]
Message-ID: <6bee0e11-59ef-b7b1-886e-7abaa30887f2@users.sourceforge.net> (raw)
In-Reply-To: <CAK7LNAR27r4j4c1FCh_ObpMpBKXgSP6Vq3P=reA-JKoTji6Q1A@mail.gmail.com>

From: Markus Elfring <elfring@users.sourceforge.net>
Date: Thu, 1 Feb 2018 10:20:47 +0100

The deletion for a call of the function "memset" depends on
the specification that a size determination is passed by
the expression "E1".
The function "kmem_cache_alloc" was specified despite of the technical
detail that this function does not get a parameter passed which would
correspond to such a size information.

Thus remove it from the first two SmPL rules and omit the rule "r4".

Link: https://elixir.free-electrons.com/linux/v4.15/source/tools/testing/radix-tree/linux/slab.h#L14
Link: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/tree/tools/testing/radix-tree/linux/slab.h?idò6e52e08ab8e56f528ac14aa7929b3477de5616#n14
Fixes: 5e2d9da5b9ba350a4f13bd3b255be046bcf86465 ("Coccinelle: kzalloc-simple: Add all zero allocating functions")
Signed-off-by: Markus Elfring <elfring@users.sourceforge.net>
---
 scripts/coccinelle/api/alloc/zalloc-simple.cocci | 41 +-----------------------
 1 file changed, 1 insertion(+), 40 deletions(-)

diff --git a/scripts/coccinelle/api/alloc/zalloc-simple.cocci b/scripts/coccinelle/api/alloc/zalloc-simple.cocci
index 92b20913055f..3bee6cdd99ea 100644
--- a/scripts/coccinelle/api/alloc/zalloc-simple.cocci
+++ b/scripts/coccinelle/api/alloc/zalloc-simple.cocci
@@ -34,7 +34,7 @@ statement S;
 @@
 
 * x = (T)\(kmalloc(E1, ...)\|vmalloc(E1)\|dma_alloc_coherent(...,E1,...)\|
-  kmalloc_node(E1, ...)\|kmem_cache_alloc(...)\|kmem_alloc(E1, ...)\|
+  kmalloc_node(E1, ...)\|kmem_alloc(E1, ...)\|
   devm_kmalloc(...,E1,...)\|kvmalloc(E1, ...)\|pci_alloc_consistent(...,E1,...)\|
   kvmalloc_node(E1,...)\);
   if ((x=NULL) || ...) S
@@ -88,15 +88,6 @@ statement S;
 - x = (T)kmalloc_node(E1,E2,E3);
 + x = (T)kzalloc_node(E1,E2,E3);
 |
-- x = kmem_cache_alloc(E3,E4);
-+ x = kmem_cache_zalloc(E3,E4);
-|
-- x = (T *)kmem_cache_alloc(E3,E4);
-+ x = kmem_cache_zalloc(E3,E4);
-|
-- x = (T)kmem_cache_alloc(E3,E4);
-+ x = (T)kmem_cache_zalloc(E3,E4);
-|
 - x = kmem_alloc(E1,E2);
 + x = kmem_zalloc(E1,E2);
 |
@@ -268,36 +259,6 @@ x << r3.x;
 msg="WARNING: kzalloc_node should be used for %s, instead of kmalloc_node/memset" % (x)
 coccilib.report.print_report(p[0], msg)
 
-//-----------------------------------------------------------------
-@r4 depends on org || report@
-type T, T2;
-expression x;
-expression E1,E2,E3;
-statement S;
-position p;
-@@
-
- x = (T)kmem_cache_alloc@p(E2,E3);
- if ((x=NULL) || ...) S
- memset((T2)x,0,E1);
-
-@script:python depends on org@
-p << r4.p;
-x << r4.x;
-@@
-
-msg="%s" % (x)
-msg_safe=msg.replace("[","@(").replace("]",")")
-coccilib.org.print_todo(p[0], msg_safe)
-
-@script:python depends on report@
-p << r4.p;
-x << r4.x;
-@@
-
-msg="WARNING: kmem_cache_zalloc should be used for %s, instead of kmem_cache_alloc/memset" % (x)
-coccilib.report.print_report(p[0], msg)
-
 //-----------------------------------------------------------------
 @r5 depends on org || report@
 type T, T2;
-- 
2.16.1

--
To unsubscribe from this list: send the line "unsubscribe kernel-janitors" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2018-02-01  9:36 UTC|newest]

Thread overview: 79+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-12-26 21:40 [PATCH v2] Coccinelle: kzalloc-simple: Add all zero allocating functions Himanshu Jha
2017-12-26 21:40 ` [Cocci] " Himanshu Jha
2017-12-26 21:52 ` Julia Lawall
2017-12-26 21:52   ` [Cocci] " Julia Lawall
2017-12-29 17:22 ` Masahiro Yamada
2017-12-29 17:22   ` [Cocci] " Masahiro Yamada
2017-12-29 17:49   ` Julia Lawall
2017-12-29 17:49     ` [Cocci] " Julia Lawall
2018-01-02 14:25   ` Rename the SmPL script “kzalloc-….cocci”? SF Markus Elfring
2018-01-02 14:25     ` SF Markus Elfring
2018-01-02 14:28     ` Julia Lawall
2018-01-02 14:28       ` [Cocci] " Julia Lawall
2018-01-02 14:28       ` Julia Lawall
2018-01-02 14:38       ` SF Markus Elfring
2018-01-02 14:38         ` SF Markus Elfring
2018-01-02 14:43         ` Julia Lawall
2018-01-02 14:43           ` [Cocci] " Julia Lawall
2018-01-02 14:43           ` Julia Lawall
2018-01-02 15:00           ` SF Markus Elfring
2018-01-02 15:00             ` SF Markus Elfring
2018-01-08  9:55           ` SF Markus Elfring
2018-01-08  9:55             ` SF Markus Elfring
2018-01-03 11:55       ` [PATCH] Coccinelle: Rename the script for a transformation of memory allocations SF Markus Elfring
2018-01-03 11:55         ` SF Markus Elfring
2018-01-03 12:02         ` Julia Lawall
2018-01-03 12:02           ` [Cocci] " Julia Lawall
2018-01-03 12:02           ` Julia Lawall
2018-01-03 12:13           ` SF Markus Elfring
2018-01-03 12:13             ` SF Markus Elfring
2018-01-03 12:17             ` Julia Lawall
2018-01-03 12:17               ` [Cocci] " Julia Lawall
2018-01-03 12:17               ` Julia Lawall
2018-01-03 12:31               ` SF Markus Elfring
2018-01-03 12:31                 ` SF Markus Elfring
2018-01-03 12:40                 ` Julia Lawall
2018-01-03 12:40                   ` [Cocci] " Julia Lawall
2018-01-03 12:40                   ` Julia Lawall
2018-01-03 12:45                   ` SF Markus Elfring
2018-01-03 12:45                     ` SF Markus Elfring
2018-01-04  8:36                   ` SF Markus Elfring
2018-01-04  8:36                     ` SF Markus Elfring
2018-01-04  8:54                     ` Julia Lawall
2018-01-04  8:54                       ` [Cocci] " Julia Lawall
2018-01-04  8:54                       ` Julia Lawall
2018-01-04  9:43                       ` SF Markus Elfring
2018-01-04  9:43                         ` SF Markus Elfring
2018-01-17 16:47   ` [v2] Coccinelle: zalloc-simple: Safer transformations with SmPL SF Markus Elfring
2018-01-17 16:47     ` SF Markus Elfring
2018-01-19 16:14   ` Coccinelle: zalloc-simple: Checking consequences from the usage of at signs in Python strings SF Markus Elfring
2018-01-19 16:14     ` SF Markus Elfring
2018-01-19 16:18     ` Julia Lawall
2018-01-19 16:18       ` [Cocci] " Julia Lawall
2018-01-19 16:18       ` Julia Lawall
2018-01-19 16:43       ` SF Markus Elfring
2018-01-19 16:43         ` SF Markus Elfring
2018-01-24  8:41       ` SF Markus Elfring
2018-01-24  8:41         ` SF Markus Elfring
2018-01-31 17:28   ` [v2] Coccinelle: zalloc-simple: Delete function “kmem_cache_alloc” from SmPL rules SF Markus Elfring
2018-01-31 17:28     ` [Cocci] " SF Markus Elfring
2018-01-31 17:28     ` [v2] Coccinelle: zalloc-simple: Delete function =?UTF-8?B?4oCca21lbV9jYWNoZV9hbGxvY SF Markus Elfring
2018-01-31 17:38     ` [v2] Coccinelle: zalloc-simple: Delete function “kmem_cache_alloc” from SmPL rules Julia Lawall
2018-01-31 17:38       ` [Cocci] " Julia Lawall
2018-01-31 17:38       ` =?UTF-8?Q?Re=3A_=5Bv2=5D_Coccinelle=3A_zalloc-simple=3A_Delete_function_=E2=80=9Ckmem=5Fcache=5Fallo Julia Lawall
2018-01-31 17:53       ` [v2] Coccinelle: zalloc-simple: Delete function “kmem_cache_alloc” from SmPL rules SF Markus Elfring
2018-01-31 17:53         ` [v2] Coccinelle: zalloc-simple: Delete function =?UTF-8?B?4oCca21lbV9jYWNoZV9hbGxvY SF Markus Elfring
2018-02-01  9:35   ` SF Markus Elfring [this message]
2018-02-01  9:35     ` [PATCH] Coccinelle: zalloc-simple: Delete function "kmem_cache_alloc" from SmPL rules SF Markus Elfring
2018-02-01  9:40     ` Julia Lawall
2018-02-01  9:40       ` [Cocci] " Julia Lawall
2018-02-01  9:40       ` Julia Lawall
2018-02-01 10:17       ` SF Markus Elfring
2018-02-01 10:17         ` SF Markus Elfring
2018-02-01 10:27         ` Julia Lawall
2018-02-01 10:27           ` [Cocci] " Julia Lawall
2018-02-01 10:27           ` Julia Lawall
2018-02-01 11:00           ` SF Markus Elfring
2018-02-01 11:00             ` SF Markus Elfring
2018-02-03  7:22           ` Coccinelle: zalloc-simple: Checking consistency for " SF Markus Elfring
2018-02-03  7:22             ` SF Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6bee0e11-59ef-b7b1-886e-7abaa30887f2@users.sourceforge.net \
    --to=elfring@users.sourceforge.net \
    --cc=Gilles.Muller@lip6.fr \
    --cc=Julia.Lawall@lip6.fr \
    --cc=cocci@systeme.lip6.fr \
    --cc=himanshujha199640@gmail.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=michal.lkml@markovi.net \
    --cc=nicolas.palix@imag.fr \
    --cc=yamada.masahiro@socionext.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.