Skip to contentSkip to conversation

Staging: lustre: lproc_ptlrpc: Replace simple_strtol with simple_stroul

PATCH Superseded Shivani Bhardwaj 2 participants 7 messages Oct 15, 2015 Staging

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Staging: lustre: lproc_ptlrpc: Replace simple_strtol with simple_stroul

The variable inst is a __u32 type and hence the function used should be simple_strtoul.
Semantic patch used:

@@ type T;
T e;@@
e=
- simple_strtol
+ simple_strtoul
(...)

---
 drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +1 -1
index ec44b3c..415817c 100644
@@ -1251,7 +1251,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
 		*ptr = 0;
 		do_reconn = 0;
 		ptr += strlen("::");
-		inst = simple_strtol(ptr, &endptr, 10);
+		inst = simple_strtoul(ptr, &endptr, 10);
 		if (*endptr) {
 			CERROR("config: wrong instance # %s\n", ptr);
 		} else if (inst != imp->imp_connect_data.ocd_instance) {
Signature · 1 line
2.1.0
#1 lore raw
Quoted 10 lines · Shivani Bhardwaj

The variable inst is a __u32 type and hence the function used should be simple_strtoul.
Semantic patch used:

@@ type T;
T e;@@
e=
- simple_strtol
+ simple_strtoul
(...)

The semantic patch is not really helpful here. Certainly you don't want to replace all calls to simple_strtol by simple_strtoul. I guess that something around the call should have type __u32.

julia

Quoted 29 lines
---
 drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +1 -1
index ec44b3c..415817c 100644
@@ -1251,7 +1251,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
 		*ptr = 0;
 		do_reconn = 0;
 		ptr += strlen("::");
-		inst = simple_strtol(ptr, &endptr, 10);
+		inst = simple_strtoul(ptr, &endptr, 10);
 		if (*endptr) {
 			CERROR("config: wrong instance # %s\n", ptr);
 		} else if (inst != imp->imp_connect_data.ocd_instance) {
Signature · 8 lines
2.1.0

-- 
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151015201311.GA45040%40ubuntu.
For more options, visit https://groups.google.com/d/optout.
#2 lore raw
Quoted 13 lines · Julia Lawall
Quoted 10 lines · Shivani Bhardwaj

The variable inst is a __u32 type and hence the function used should be simple_strtoul.
Semantic patch used:

@@ type T;
T e;@@
e=
- simple_strtol
+ simple_strtoul
(...)

Quoted 6 lines

The semantic patch is not really helpful here. Certainly you don't want to replace all calls to simple_strtol by simple_strtoul. I guess that something around the call should have type __u32.

julia

@@ __u32 T;
T e;@@
e=
- simple_strtol
+ simple_strtoul
(...)

Like this?

Quoted 29 lines
Quoted 29 lines
---
 drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +1 -2
index ec44b3c..415817c 100644
@@ -1251,7 +1251,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
              *ptr = 0;
              do_reconn = 0;
              ptr += strlen("::");
-             inst = simple_strtol(ptr, &endptr, 10);
+             inst = simple_strtoul(ptr, &endptr, 10);
              if (*endptr) {
                      CERROR("config: wrong instance # %s\n", ptr);
              } else if (inst != imp->imp_connect_data.ocd_instance) {
--

2.1.0

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151015201311.GA45040%40ubuntu.
For more options, visit https://groups.google.com/d/optout.

#3 lore raw
Quoted 20 lines · Shivani Bhardwaj
Quoted 13 lines · Julia Lawall
Quoted 10 lines · Shivani Bhardwaj

The variable inst is a __u32 type and hence the function used should be simple_strtoul.
Semantic patch used:

@@ type T;
T e;@@
e=
- simple_strtol
+ simple_strtoul
(...)

Quoted 6 lines

The semantic patch is not really helpful here. Certainly you don't want to replace all calls to simple_strtol by simple_strtoul. I guess that something around the call should have type __u32.

julia

Quoted 8 lines

@@ __u32 T;
T e;@@
e=
- simple_strtol
+ simple_strtoul
(...)

Like this?

No. You want e to have type __u32. So it would be

__u32 e;

You don't need T at all. In some other semantic patches there has been T, but that was a metavariable to hold any possible type. Here you want to specify a specific type.

julia

Quoted 38 lines
Quoted 30 lines
Quoted 30 lines
---
 drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +1 -2
index ec44b3c..415817c 100644
@@ -1251,7 +1251,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
              *ptr = 0;
              do_reconn = 0;
              ptr += strlen("::");
-             inst = simple_strtol(ptr, &endptr, 10);
+             inst = simple_strtoul(ptr, &endptr, 10);
              if (*endptr) {
                      CERROR("config: wrong instance # %s\n", ptr);
              } else if (inst != imp->imp_connect_data.ocd_instance) {
--

2.1.0

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151015201311.GA45040%40ubuntu.
For more options, visit https://groups.google.com/d/optout.

Signature · 5 lines
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/CAKHNQQGPX%3DKu867t8UWX59hqta6e8EidrLX7H%3DM%2BGfc_%2BGL%2B1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.
#4 lore raw
Quoted 35 lines · Julia Lawall
Quoted 20 lines · Shivani Bhardwaj
Quoted 13 lines · Julia Lawall
Quoted 10 lines · Shivani Bhardwaj

The variable inst is a __u32 type and hence the function used should be simple_strtoul.
Semantic patch used:

@@ type T;
T e;@@
e=
- simple_strtol
+ simple_strtoul
(...)

Quoted 6 lines

The semantic patch is not really helpful here. Certainly you don't want to replace all calls to simple_strtol by simple_strtoul. I guess that something around the call should have type __u32.

julia

Quoted 8 lines

@@ __u32 T;
T e;@@
e=
- simple_strtol
+ simple_strtoul
(...)

Like this?

No. You want e to have type __u32. So it would be

Quoted 8 lines

__u32 e;

You don't need T at all. In some other semantic patches there has been T, but that was a metavariable to hold any possible type. Here you want to specify a specific type.

julia

All right. Thank you. I'm sending new version.

Quoted 38 lines
Quoted 38 lines
Quoted 23 lines
Quoted 23 lines
---
 drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +1 -2
index ec44b3c..415817c 100644
@@ -1251,7 +1251,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
              *ptr = 0;
              do_reconn = 0;
              ptr += strlen("::");
-             inst = simple_strtol(ptr, &endptr, 10);
+             inst = simple_strtoul(ptr, &endptr, 10);
              if (*endptr) {
                      CERROR("config: wrong instance # %s\n", ptr);
              } else if (inst != imp->imp_connect_data.ocd_instance) {
--

2.1.0

Quoted 7 lines
Quoted 7 lines

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151015201311.GA45040%40ubuntu.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/CAKHNQQGPX%3DKu867t8UWX59hqta6e8EidrLX7H%3DM%2BGfc_%2BGL%2B1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

#5 lore raw
Quoted 36 lines · Shivani Bhardwaj
Quoted 35 lines · Julia Lawall
Quoted 20 lines · Shivani Bhardwaj
Quoted 13 lines · Julia Lawall
Quoted 10 lines · Shivani Bhardwaj

The variable inst is a __u32 type and hence the function used should be simple_strtoul.
Semantic patch used:

@@ type T;
T e;@@
e=
- simple_strtol
+ simple_strtoul
(...)

Quoted 6 lines

The semantic patch is not really helpful here. Certainly you don't want to replace all calls to simple_strtol by simple_strtoul. I guess that something around the call should have type __u32.

julia

Quoted 8 lines

@@ __u32 T;
T e;@@
e=
- simple_strtol
+ simple_strtoul
(...)

Like this?

No. You want e to have type __u32. So it would be

Quoted 8 lines
Quoted 8 lines

__u32 e;

You don't need T at all. In some other semantic patches there has been T, but that was a metavariable to hold any possible type. Here you want to specify a specific type.

julia

It shows parse error for __u32, works fine for int. What should I do?

Quoted 40 lines

All right. Thank you. I'm sending new version.

Quoted 38 lines
Quoted 38 lines
Quoted 23 lines
Quoted 23 lines
---
 drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +1 -2
index ec44b3c..415817c 100644
@@ -1251,7 +1251,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
              *ptr = 0;
              do_reconn = 0;
              ptr += strlen("::");
-             inst = simple_strtol(ptr, &endptr, 10);
+             inst = simple_strtoul(ptr, &endptr, 10);
              if (*endptr) {
                      CERROR("config: wrong instance # %s\n", ptr);
              } else if (inst != imp->imp_connect_data.ocd_instance) {
--

2.1.0

Quoted 7 lines
Quoted 7 lines

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151015201311.GA45040%40ubuntu.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/CAKHNQQGPX%3DKu867t8UWX59hqta6e8EidrLX7H%3DM%2BGfc_%2BGL%2B1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

#6 lore raw
Quoted 39 lines · Shivani Bhardwaj
Quoted 38 lines · Shivani Bhardwaj
Quoted 37 lines · Julia Lawall
Quoted 20 lines · Shivani Bhardwaj
Quoted 13 lines · Julia Lawall
Quoted 10 lines · Shivani Bhardwaj

The variable inst is a __u32 type and hence the function used should be simple_strtoul.
Semantic patch used:

@@ type T;
T e;@@
e=
- simple_strtol
+ simple_strtoul
(...)

Quoted 6 lines

The semantic patch is not really helpful here. Certainly you don't want to replace all calls to simple_strtol by simple_strtoul. I guess that something around the call should have type __u32.

julia

Quoted 8 lines

@@ __u32 T;
T e;@@
e=
- simple_strtol
+ simple_strtoul
(...)

Like this?

No. You want e to have type __u32. So it would be

__u32 e;

Quoted 8 lines
Quoted 6 lines
Quoted 6 lines

You don't need T at all. In some other semantic patches there has been T, but that was a metavariable to hold any possible type. Here you want to specify a specific type.

julia

It shows parse error for __u32, works fine for int. What should I do?

__u32 is not known as a type to Coccinelle.

Put typedef __u32; just on the line before.

julia

Quoted 48 lines
Quoted 40 lines

All right. Thank you. I'm sending new version.

Quoted 38 lines
Quoted 38 lines
Quoted 23 lines
Quoted 23 lines
---
 drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/staging/lustre/lustre/ptlrpc/lproc_ptlrpc.c +1 -2
index ec44b3c..415817c 100644
@@ -1251,7 +1251,7 @@ int lprocfs_wr_import(struct file *file, const char __user *buffer,
              *ptr = 0;
              do_reconn = 0;
              ptr += strlen("::");
-             inst = simple_strtol(ptr, &endptr, 10);
+             inst = simple_strtoul(ptr, &endptr, 10);
              if (*endptr) {
                      CERROR("config: wrong instance # %s\n", ptr);
              } else if (inst != imp->imp_connect_data.ocd_instance) {
--

2.1.0

Quoted 7 lines
Quoted 7 lines

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/20151015201311.GA45040%40ubuntu.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/CAKHNQQGPX%3DKu867t8UWX59hqta6e8EidrLX7H%3DM%2BGfc_%2BGL%2B1A%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Signature · 5 lines
You received this message because you are subscribed to the Google Groups "outreachy-kernel" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit https://groups.google.com/d/msgid/outreachy-kernel/CAKHNQQH9iKJL02m5p%2BKjH0-H947u5ncpV5GbPm_-g_o6KLEqcg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.