From: Julia Lawall <hidden> Date: 2011-11-06 13:26:58
These patches replace calls to strict_strtoul, etc by the corresponding
calls to kstrtoul. The complete semantic patch that makes these changes is
as follows. This semantic patch checks that the types are as expected,
which was always the case for these files.
// <smpl>
@@
expression a,b;
{int,long} *c;
@@
-strict_strtol
+kstrtol
(a,b,c)
@@
expression a,b;
long long *c;
@@
-strict_strtoll
+kstrtoll
(a,b,c)
@@
typedef ulong;
expression a,b;
{ulong,unsigned long,unsigned int,size_t} *c;
@@
-strict_strtoul
+kstrtoul
(a,b,c)
@@
expression a,b;
unsigned long long *c;
@@
-strict_strtoull
+kstrtoull
(a,b,c)
@@
expression a,b;
u64 *c;
@@
-strict_strtoull
+kstrtou64
(a,b,c)
@@
@@
(
+BAD(
strict_strtoull(...)
+)
|
+BAD(
strict_strtoul(...)
+)
|
+BAD(
strict_strtol(...)
+)
|
+BAD(
strict_strtoll(...)
+)
)
// </smpl>
From: Julia Lawall <hidden> Date: 2011-11-06 13:27:00
From: Julia Lawall <redacted>
Use kstrtoul, etc instead of the now deprecated strict_strtoul, etc.
A semantic patch rule for the kstrtoul case is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression a,b;
{int,long} *c;
@@
-strict_strtoul
+kstrtoul
(a,b,c)
// </smpl>
Signed-off-by: Julia Lawall <redacted>
---
net/batman-adv/bat_sysfs.c | 4 ++--
net/batman-adv/gateway_common.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)
diff -u -p a/net/batman-adv/bat_sysfs.c b/net/batman-adv/bat_sysfs.c
From: Julia Lawall <hidden> Date: 2011-11-06 13:27:01
From: Julia Lawall <redacted>
Use kstrtoul, etc instead of the now deprecated strict_strtoul, etc.
A semantic patch rule for the kstrtoul case is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression a,b;
{int,long} *c;
@@
-strict_strtoul
+kstrtoul
(a,b,c)
// </smpl>
Signed-off-by: Julia Lawall <redacted>
---
net/mac80211/debugfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff -u -p a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
From: Julia Lawall <hidden> Date: 2011-11-06 13:27:05
From: Julia Lawall <redacted>
Use kstrtoul, etc instead of the now deprecated strict_strtoul, etc.
A semantic patch rule for the kstrtoul case is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression a,b;
{int,long} *c;
@@
-strict_strtoul
+kstrtoul
(a,b,c)
// </smpl>
Signed-off-by: Julia Lawall <redacted>
---
net/dns_resolver/dns_key.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff -u -p a/net/dns_resolver/dns_key.c b/net/dns_resolver/dns_key.c
From: Julia Lawall <hidden> Date: 2011-11-06 13:28:37
From: Julia Lawall <redacted>
Use kstrtoul, etc instead of the now deprecated strict_strtoul, etc.
A semantic patch rule for the kstrtoul case is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression a,b;
{int,long} *c;
@@
-strict_strtoul
+kstrtoul
(a,b,c)
// </smpl>
Signed-off-by: Julia Lawall <redacted>
---
net/rfkill/core.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff -u -p a/net/rfkill/core.c b/net/rfkill/core.c
From: Marek Lindner <hidden> Date: 2011-11-06 14:23:17
On Sunday, November 06, 2011 21:26:46 Julia Lawall wrote:
From: Julia Lawall <redacted>
Use kstrtoul, etc instead of the now deprecated strict_strtoul, etc.
Thanks for the patch but we already have a patch lined up to address the
issue. It will be submitted to net-next in the next week or so.
Regards,
Marek
On Sun, Nov 6, 2011 at 3:26 PM, Julia Lawall [off-list ref] wrote:
quoted hunk
From: Julia Lawall <redacted>
Use kstrtoul, etc instead of the now deprecated strict_strtoul, etc.
A semantic patch rule for the kstrtoul case is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression a,b;
{int,long} *c;
@@
-strict_strtoul
+kstrtoul
(a,b,c)
// </smpl>
Signed-off-by: Julia Lawall <redacted>
---
net/mac80211/debugfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff -u -p a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
From: Julia Lawall <hidden> Date: 2011-11-07 11:58:55
On Mon, 7 Nov 2011, Eliad Peller wrote:
On Sun, Nov 6, 2011 at 3:26 PM, Julia Lawall [off-list ref] wrote:
quoted
From: Julia Lawall <redacted>
Use kstrtoul, etc instead of the now deprecated strict_strtoul, etc.
A semantic patch rule for the kstrtoul case is as follows:
(http://coccinelle.lip6.fr/)
// <smpl>
@@
expression a,b;
{int,long} *c;
@@
-strict_strtoul
+kstrtoul
(a,b,c)
// </smpl>
Signed-off-by: Julia Lawall <redacted>
---
net/mac80211/debugfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff -u -p a/net/mac80211/debugfs.c b/net/mac80211/debugfs.c
No, no, no!
In every case see the type or real data and use appropriate function.
kstrtou8() for ports.
This program creates lots of bogus patches in this case.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Sorry, this was not the real rule I used for the strtoul case. Instead I
used the following:
@@
typedef ulong;
expression a,b;
{ulong,unsigned long,unsigned int,size_t} *c;
@@
-strict_strtoul
+kstrtoul
(a,b,c)
But now I have seen that there is a separate function for integers, so I
have made a rule to use that function when the type is unsigned int.
In every case see the type or real data and use appropriate function.
kstrtou8() for ports.
The type of the destination variable in all of these cases is unsigned
long. But maybe that is not enough information to make the
transformation in the right way.
julia
This program creates lots of bogus patches in this case.
--
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
Sorry, this was not the real rule I used for the strtoul case. Instead I
used the following:
@@
typedef ulong;
expression a,b;
{ulong,unsigned long,unsigned int,size_t} *c;
@@
-strict_strtoul
+kstrtoul
(a,b,c)
But now I have seen that there is a separate function for integers, so I
have made a rule to use that function when the type is unsigned int.
quoted
In every case see the type or real data and use appropriate function.
kstrtou8() for ports.
The type of the destination variable in all of these cases is unsigned
long. But maybe that is not enough information to make the
transformation in the right way.
That's because previous functions following libc didn't accept anything
less than unsigned long.
For these conversion, one should literally look at every usecase and
see what types data have for real (not unsigned long) and
make conversion and remove explicit EINVAL checks if necesasry.
In sunrpc case: switch to kstrtou8 + remove "> 255" check.
This program doesn't and won't do that.
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
From: Julia Lawall <hidden> Date: 2011-11-09 06:15:37
In looking through some examples, I see, e.g.:
if (strict_strtoul(buf, 10, &val) < 0)
return -EINVAL;
if (val < 1 || val > 2)
return -EINVAL;
In this case the only valid values are 1 and 2, which are much smaller
than the u8 range. Is it useful to use kstrtou8 anyway? I see that
kstrtou8 returns -ERANGE not -EINVAL when the value is out of bounds. If
kstrtou8 is to be used, should the subsequent if (val < 1 || val > 2) now
return -ERANGE to be consistent?
julia