All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Btrfs: replace simple_strtoull() with kstrtoull() in btrfs_ioctl_resize()
@ 2013-01-06  3:53 Jeff Liu
  2013-01-07 16:03 ` David Sterba
  0 siblings, 1 reply; 3+ messages in thread
From: Jeff Liu @ 2013-01-06  3:53 UTC (permalink / raw)
  To: linux-btrfs

simple_strtoull() is obsolete, use kstrtoull() instead.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
---
 fs/btrfs/ioctl.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 8fcf9a5..b147424 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1331,11 +1331,16 @@ static noinline int btrfs_ioctl_resize(struct btrfs_root *root,
 	sizestr = vol_args->name;
 	devstr = strchr(sizestr, ':');
 	if (devstr) {
-		char *end;
 		sizestr = devstr + 1;
 		*devstr = '\0';
 		devstr = vol_args->name;
-		devid = simple_strtoull(devstr, &end, 10);
+		ret = kstrtoull(devstr, 10, &devid);
+		if (ret) {
+			pr_err("btrfs: resizer unable to parse device %s\n",
+				devstr);
+			ret = -EINVAL;
+			goto out_free;
+		}
 		printk(KERN_INFO "btrfs: resizing devid %llu\n",
 		       (unsigned long long)devid);
 	}
-- 
1.7.9.5

^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] Btrfs: replace simple_strtoull() with kstrtoull() in btrfs_ioctl_resize()
  2013-01-06  3:53 [PATCH] Btrfs: replace simple_strtoull() with kstrtoull() in btrfs_ioctl_resize() Jeff Liu
@ 2013-01-07 16:03 ` David Sterba
  2013-01-08  7:04   ` Jeff Liu
  0 siblings, 1 reply; 3+ messages in thread
From: David Sterba @ 2013-01-07 16:03 UTC (permalink / raw)
  To: Jeff Liu; +Cc: linux-btrfs

On Sun, Jan 06, 2013 at 11:53:41AM +0800, Jeff Liu wrote:
> -		devid = simple_strtoull(devstr, &end, 10);
> +		ret = kstrtoull(devstr, 10, &devid);
> +		if (ret) {
> +			pr_err("btrfs: resizer unable to parse device %s\n",
> +				devstr);

Code looks ok, I would prefer the message error text to say:

			pr_err("btrfs: resize unable to parse device id %s\n",
				devstr);

but that's maybe just me :)
david

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] Btrfs: replace simple_strtoull() with kstrtoull() in btrfs_ioctl_resize()
  2013-01-07 16:03 ` David Sterba
@ 2013-01-08  7:04   ` Jeff Liu
  0 siblings, 0 replies; 3+ messages in thread
From: Jeff Liu @ 2013-01-08  7:04 UTC (permalink / raw)
  To: dsterba; +Cc: linux-btrfs


On 01/08/2013 12:03 AM, David Sterba wrote:
> On Sun, Jan 06, 2013 at 11:53:41AM +0800, Jeff Liu wrote:
>> -		devid = simple_strtoull(devstr, &end, 10);
>> +		ret = kstrtoull(devstr, 10, &devid);
>> +		if (ret) {
>> +			pr_err("btrfs: resizer unable to parse device %s\n",
>> +				devstr);
> 
> Code looks ok, I would prefer the message error text to say:
> 
> 			pr_err("btrfs: resize unable to parse device id %s\n",
> 				devstr);
> 
> but that's maybe just me :)
Thanks for the review, yours is better :)
The revised patch was shown as following:


simple_strtoull() is obsolete, use kstrtoull() instead.

Signed-off-by: Jie Liu <jeff.liu@oracle.com>
Cc: David Sterba <dsterba@suse.cz>

---
 fs/btrfs/ioctl.c |    9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/fs/btrfs/ioctl.c b/fs/btrfs/ioctl.c
index 8fcf9a5..d9045eb 100644
--- a/fs/btrfs/ioctl.c
+++ b/fs/btrfs/ioctl.c
@@ -1331,11 +1331,16 @@ static noinline int btrfs_ioctl_resize(struct btrfs_root *root,
 	sizestr = vol_args->name;
 	devstr = strchr(sizestr, ':');
 	if (devstr) {
-		char *end;
 		sizestr = devstr + 1;
 		*devstr = '\0';
 		devstr = vol_args->name;
-		devid = simple_strtoull(devstr, &end, 10);
+		ret = kstrtoull(devstr, 10, &devid);
+		if (ret) {
+			pr_err("btrfs: resizer unable to parse device id %s\n",
+				devstr);
+			ret = -EINVAL;
+			goto out_free;
+		}
 		printk(KERN_INFO "btrfs: resizing devid %llu\n",
 		       (unsigned long long)devid);
 	}
-- 
1.7.9.5


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2013-01-08  7:05 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-01-06  3:53 [PATCH] Btrfs: replace simple_strtoull() with kstrtoull() in btrfs_ioctl_resize() Jeff Liu
2013-01-07 16:03 ` David Sterba
2013-01-08  7:04   ` Jeff Liu

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.