[OPW,kernel,v2] Coccinelle Script to automate replacement of strict_strtoul()
diff mbox

Message ID 1381863462-31539-1-git-send-email-rashika.kheria@gmail.com
State Rejected
Headers show

Commit Message

Rashika Oct. 15, 2013, 6:57 p.m. UTC
This script automatically replaces the obsolete function strict_strtoul() with kstrtoul().

Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
---

This revision fixes the following issues from the previous revision-
Removal of Unnecessary Cases

 scripts/coccinelle/api/kstrtoul.cocci |   22 ++++++++++++++++++++++
 1 file changed, 22 insertions(+)
 create mode 100644 scripts/coccinelle/api/kstrtoul.cocci

Comments

Greg KH Oct. 15, 2013, 7:12 p.m. UTC | #1
On Wed, Oct 16, 2013 at 12:27:42AM +0530, Rashika Kheria wrote:
> This script automatically replaces the obsolete function strict_strtoul() with kstrtoul().
> 
> Signed-off-by: Rashika Kheria <rashika.kheria@gmail.com>
> ---
> 
> This revision fixes the following issues from the previous revision-
> Removal of Unnecessary Cases
> 
>  scripts/coccinelle/api/kstrtoul.cocci |   22 ++++++++++++++++++++++
>  1 file changed, 22 insertions(+)
>  create mode 100644 scripts/coccinelle/api/kstrtoul.cocci
> 
> diff --git a/scripts/coccinelle/api/kstrtoul.cocci b/scripts/coccinelle/api/kstrtoul.cocci
> new file mode 100644
> index 0000000..6162b29
> --- /dev/null
> +++ b/scripts/coccinelle/api/kstrtoul.cocci
> @@ -0,0 +1,22 @@
> +/// The usage of strict_strtoul() is not preferred, because
> +/// strict_strtoul() is obsolete. Thus, kstrtoul() should be used.
> +/// This Script helps in automating the process of replacement of
> +/// strict_strtoul() with kstrtoul().

It's not just a global search-and-replace for this function, otherwise
it would have been completed by now.  There are some nasty side-affects
that require the code sometimes to be changed in non-trivial ways in
order to properly convert.

No, I don't remember what the corner cases are, but they are present,
look in the archives of the linux-kernel mailing list for details, it
should be there.

So while this script is nice to have, I don't think it's a good idea to
add it to the kernel tree, sorry.

greg k-h
Rashika Oct. 15, 2013, 7:36 p.m. UTC | #2
On Wed, Oct 16, 2013 at 12:42 AM, Greg KH <gregkh@linuxfoundation.org>wrote:

> On Wed, Oct 16, 2013 at 12:27:42AM +0530, Rashika Kheria wrote:
> 
>
> It's not just a global search-and-replace for this function, otherwise
> it would have been completed by now.  There are some nasty side-affects
> that require the code sometimes to be changed in non-trivial ways in
> order to properly convert.
>
> No, I don't remember what the corner cases are, but they are present,
> look in the archives of the linux-kernel mailing list for details, it
> should be there.
>
> So while this script is nice to have, I don't think it's a good idea to
> add it to the kernel tree, sorry.
>
> greg k-h
>
>
> The function strict_strtoul() is defined as kstrtoul() in
include/linux/kernel.h and since there is no implementation for
strict_strtoul(), I thought that I just need to remove calls to this
function and replace it with calls to kstrtoul(). Therefore, I wrote this
script.

I will try and work on some other scripts.

Thanks,

Patch
diff mbox

diff --git a/scripts/coccinelle/api/kstrtoul.cocci b/scripts/coccinelle/api/kstrtoul.cocci
new file mode 100644
index 0000000..6162b29
--- /dev/null
+++ b/scripts/coccinelle/api/kstrtoul.cocci
@@ -0,0 +1,22 @@ 
+/// The usage of strict_strtoul() is not preferred, because
+/// strict_strtoul() is obsolete. Thus, kstrtoul() should be used.
+/// This Script helps in automating the process of replacement of
+/// strict_strtoul() with kstrtoul().
+
+virtual report
+virtual patch
+
+@ kstrtoul depends on report || patch @
+expression E1,E2,E3;
+position p;
+@@
+
+- strict_strtoul@p(E1,E2,E3)
++ kstrtoul(E1,E2,E3)
+
+@ script:python depends on report @
+p << kstrtoul.p;
+@@
+for pos in p:
+	msg = "%s %s: WARNING: Replacing strict_strtoul with kstrtoul" % (pos.file, pos.line)
+	print(msg)