linux-btrfs.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/4] Btrfs-progs: cleanups: new helper for parsing string to u64
@ 2014-02-19 11:17 Wang Shilong
  2014-02-19 11:17 ` [PATCH 1/4] Btrfs-progs: new helper to parse string to u64 for btrfs Wang Shilong
                   ` (3 more replies)
  0 siblings, 4 replies; 14+ messages in thread
From: Wang Shilong @ 2014-02-19 11:17 UTC (permalink / raw)
  To: linux-btrfs

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() which will do all the necessary checks.If we fail to
parse string to u64, we will output message and exit directly, this is
something like what usage() is doing. It is ok to not return erro to
it's caller, because this function should be called when parsing arg
(just like usage!)

I convert most places to btrfs_strtoull, test patches with xfstests.
Feel free to review and comment.

Wang Shilong (4):
  Btrfs-progs: new helper to parse string to u64 for btrfs
  Btrfs-progs: switch to btrfs_strtoull() part1
  Btrfs-progs: switch to btrfs_strtoull() part2
  Btrfs-progs: switch to btrfs_strtoull() part3

 btrfs-corrupt-block.c | 38 +++++++++-----------------------------
 btrfs-debug-tree.c    |  2 +-
 btrfs-find-root.c     | 23 +++--------------------
 btrfs-image.c         |  8 ++++----
 btrfs-list.c          | 14 +++-----------
 btrfs-map-logical.c   | 26 ++++++--------------------
 btrfs-show-super.c    |  7 ++++---
 btrfstune.c           |  4 ++--
 cmds-inspect.c        |  8 ++++----
 cmds-replace.c        |  7 +------
 cmds-restore.c        | 20 ++++----------------
 cmds-subvolume.c      |  8 ++------
 utils.c               | 21 ++++++++++++++++++++-
 utils.h               |  1 +
 14 files changed, 64 insertions(+), 123 deletions(-)

-- 
1.8.3.1


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

end of thread, other threads:[~2014-02-20 16:42 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-02-19 11:17 [PATCH 0/4] Btrfs-progs: cleanups: new helper for parsing string to u64 Wang Shilong
2014-02-19 11:17 ` [PATCH 1/4] Btrfs-progs: new helper to parse string to u64 for btrfs Wang Shilong
2014-02-19 14:46   ` Stefan Behrens
2014-02-19 14:59     ` Wang Shilong
2014-02-19 15:47   ` Goffredo Baroncelli
2014-02-19 16:08     ` Wang Shilong
2014-02-19 16:31       ` Goffredo Baroncelli
2014-02-19 16:43         ` Wang Shilong
2014-02-19 17:23         ` Eric Sandeen
2014-02-20  0:48           ` Wang Shilong
2014-02-20 16:42   ` David Sterba
2014-02-19 11:17 ` [PATCH 2/4] Btrfs-progs: switch to btrfs_strtoull() part1 Wang Shilong
2014-02-19 11:17 ` [PATCH 3/4] Btrfs-progs: switch to btrfs_strtoull() part2 Wang Shilong
2014-02-19 11:17 ` [PATCH 4/4] Btrfs-progs: switch to btrfs_strtoull() part3 Wang Shilong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).