Re: [PATCH 1/4] Btrfs-progs: new helper to parse string to u64 for btrfs

2014-02-20 Thread David Sterba
On Wed, Feb 19, 2014 at 07:17:51PM +0800, Wang Shilong wrote: +u64 btrfs_strtoull(char *str, int base) +{ + u64 value; + char *ptr_parse_end = NULL; + char *ptr_str_end = str + strlen(str); + + value = strtoull(str, ptr_parse_end, base); + if (ptr_parse_end !=

[PATCH 1/4] Btrfs-progs: new helper to parse string to u64 for btrfs

2014-02-19 Thread Wang Shilong
There are many places that need parse string to u64 for btrfs commands, in fact, we do such things *too casually*, using atoi/atol/atoll..is not right at all, and even we don't check whether it is a valid string. Let's do everything more gracefully, we introduce a new helper btrfs_strtoull()

Re: [PATCH 1/4] Btrfs-progs: new helper to parse string to u64 for btrfs

2014-02-19 Thread Stefan Behrens
On Wed, 19 Feb 2014 19:17:51 +0800, Wang Shilong wrote: There are many places that need parse string to u64 for btrfs commands, in fact, we do such things *too casually*, using atoi/atol/atoll..is not right at all, and even we don't check whether it is a valid string. Let's do everything

Re: [PATCH 1/4] Btrfs-progs: new helper to parse string to u64 for btrfs

2014-02-19 Thread Wang Shilong
Hello Stefan, On Wed, 19 Feb 2014 19:17:51 +0800, Wang Shilong wrote: There are many places that need parse string to u64 for btrfs commands, in fact, we do such things *too casually*, using atoi/atol/atoll..is not right at all, and even we don't check whether it is a valid string. Let's

Re: [PATCH 1/4] Btrfs-progs: new helper to parse string to u64 for btrfs

2014-02-19 Thread Goffredo Baroncelli
Hi Wang, On 02/19/2014 12:17 PM, Wang Shilong wrote: There are many places that need parse string to u64 for btrfs commands, in fact, we do such things *too casually*, using atoi/atol/atoll..is not right at all, and even we don't check whether it is a valid string. Let's do everything more

Re: [PATCH 1/4] Btrfs-progs: new helper to parse string to u64 for btrfs

2014-02-19 Thread Wang Shilong
Hi Goffredo, Hi Wang, On 02/19/2014 12:17 PM, Wang Shilong wrote: There are many places that need parse string to u64 for btrfs commands, in fact, we do such things *too casually*, using atoi/atol/atoll..is not right at all, and even we don't check whether it is a valid string. Let's do

Re: [PATCH 1/4] Btrfs-progs: new helper to parse string to u64 for btrfs

2014-02-19 Thread Goffredo Baroncelli
Hi Wang, On 02/19/2014 05:08 PM, Wang Shilong wrote: Hi Goffredo, Hi Wang, On 02/19/2014 12:17 PM, Wang Shilong wrote: There are many places that need parse string to u64 for btrfs commands, in fact, we do such things *too casually*, using atoi/atol/atoll..is not right at all, and even we

Re: [PATCH 1/4] Btrfs-progs: new helper to parse string to u64 for btrfs

2014-02-19 Thread Wang Shilong
Hi Goffredo, Hi Wang, On 02/19/2014 05:08 PM, Wang Shilong wrote: Hi Goffredo, Hi Wang, On 02/19/2014 12:17 PM, Wang Shilong wrote: There are many places that need parse string to u64 for btrfs commands, in fact, we do such things *too casually*, using atoi/atol/atoll..is not right

Re: [PATCH 1/4] Btrfs-progs: new helper to parse string to u64 for btrfs

2014-02-19 Thread Eric Sandeen
On 2/19/14, 10:31 AM, Goffredo Baroncelli wrote: ... The error message says that the value is out of range. But doesn't tell which is the parameter involved. If you have a command which has several arguments, and the user pass a string instead of a number, the error returned doesn't tell

Re: [PATCH 1/4] Btrfs-progs: new helper to parse string to u64 for btrfs

2014-02-19 Thread Wang Shilong
On 02/20/2014 01:23 AM, Eric Sandeen wrote: On 2/19/14, 10:31 AM, Goffredo Baroncelli wrote: ... The error message says that the value is out of range. But doesn't tell which is the parameter involved. If you have a command which has several arguments, and the user pass a string instead of