diff options
author | Greg Farnum <gregory.farnum@dreamhost.com> | 2011-08-25 12:22:02 -0700 |
---|---|---|
committer | Greg Farnum <gregory.farnum@dreamhost.com> | 2011-08-25 12:51:06 -0700 |
commit | 4dba8bc25e5aad93769e57389b297a11bfd183e8 (patch) | |
tree | 7eee72669e8fd42b24bee510e029665078e9955d /src/cephfs.cc | |
parent | df8f3cbb987017193e7b2d904b06ac287201769b (diff) | |
download | ceph-4dba8bc25e5aad93769e57389b297a11bfd183e8.tar.gz |
cephfs: use strtol instead of atoi; handle 0 properly
Besides being generally better, this means we can accept pool 0
as the pool to store stuff in.
Signed-off-by: Greg Farnum <gregory.farnum@dreamhost.com>
Diffstat (limited to 'src/cephfs.cc')
-rw-r--r-- | src/cephfs.cc | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/src/cephfs.cc b/src/cephfs.cc index c7b00c915e6..70f433fef36 100644 --- a/src/cephfs.cc +++ b/src/cephfs.cc @@ -188,7 +188,7 @@ int init_options(int argc, char **argv, int *fd, char **path, int *cmd, cerr << "Invalid option for command!" << endl; return 1; } - *stripe_unit = atoi(argv[i+1]); + *stripe_unit = strtol(argv[i+1], NULL, 0); if (!*stripe_unit) { cerr << "invalid value for stripe unit" << endl; return 1; @@ -198,7 +198,7 @@ int init_options(int argc, char **argv, int *fd, char **path, int *cmd, cerr << "Invalid option for command!" << endl; return 1; } - *stripe_count = atoi(argv[i+1]); + *stripe_count = strtol(argv[i+1], NULL, 0); if (!*stripe_count) { cerr << "invalid value for stripe count" << endl; return 1; @@ -208,7 +208,7 @@ int init_options(int argc, char **argv, int *fd, char **path, int *cmd, cerr << "Invalid option for command!" << endl; return 1; } - *object_size = atoi(argv[i+1]); + *object_size = strtol(argv[i+1], NULL, 0); if (!*object_size) { cerr << "invalid value for object size" << endl; return 1; @@ -218,8 +218,9 @@ int init_options(int argc, char **argv, int *fd, char **path, int *cmd, cerr << "Invalid option for command!" << endl; return 1; } - *pool= atoi(argv[i+1]); - if (!*pool) { + errno = 0; + *pool= strtol(argv[i+1], NULL, 0); + if (!*pool && errno) { cerr << "invalid value for pool" << endl; return 1; } @@ -228,8 +229,9 @@ int init_options(int argc, char **argv, int *fd, char **path, int *cmd, cerr << "Invalid option for command!" << endl; return 1; } - *osd = atoi(argv[i+1]); - if (!*osd) { + errno = 0; + *osd = strtol(argv[i+1], NULL, 0); + if (!*osd && errno) { cerr << "invalid value for osd" << endl; return 1; } @@ -238,8 +240,9 @@ int init_options(int argc, char **argv, int *fd, char **path, int *cmd, cerr << "Invalid option for command!" << endl; return 1; } - *file_offset = atoi(argv[i+1]); - if (!*file_offset) { + errno = 0; + *file_offset = strtol(argv[i+1], NULL, 0); + if (!*file_offset && errno) { cerr << "invalid value for offset" << endl; return 1; } |