]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
ceph_argparse: generalize ceph_argparse_with* routines 4208/head
authorDmitry Yatsushkevich <dyatsushkevich@mirantis.com>
Fri, 27 Mar 2015 22:34:24 +0000 (15:34 -0700)
committerDmitry Yatsushkevich <dyatsushkevich@mirantis.com>
Tue, 31 Mar 2015 19:13:55 +0000 (12:13 -0700)
Remove code duplication by generalizing ceph_argparse_with{int,float,longlong}
routines - make one template function for those cases.

Signed-off-by: Dmitry Yatsushkevich <dyatsushkevich@mirantis.com>
src/common/ceph_argparse.cc
src/common/ceph_argparse.h
src/rbd.cc
src/rbd_replay/rbd-replay.cc
src/rgw/rgw_admin.cc
src/test/ceph_argparse.cc
src/test/osdc/object_cacher_stress.cc
src/tools/crushtool.cc
src/tools/osdmaptool.cc

index a76c42422a927b00d5dc0e6b3417048c56c41314..26d1178d34c9bf3b047cdb088baa373e55401ab7 100644 (file)
 #undef generic_dout
 #undef dendl
 
+struct strict_str_convert {
+  const char *str;
+  std::string *err;
+  strict_str_convert(const char *str,  std::string *err)
+    : str(str), err(err) {}
+
+  inline operator float() const
+  {
+    return strict_strtof(str, err);
+  }
+  inline operator int() const
+  {
+    return strict_strtol(str, 10, err);
+  }
+  inline operator long long() const
+  {
+    return  strict_strtoll(str, 10, err);
+  }
+};
+
 void string_to_vec(std::vector<std::string>& args, std::string argstr)
 {
   istringstream iss(argstr);
@@ -314,19 +334,9 @@ static bool va_ceph_argparse_witharg(std::vector<const char*> &args,
   }
 }
 
+template<class T>
 bool ceph_argparse_witharg(std::vector<const char*> &args,
-       std::vector<const char*>::iterator &i, std::string *ret, ...)
-{
-  bool r;
-  va_list ap;
-  va_start(ap, ret);
-  r = va_ceph_argparse_witharg(args, i, ret, ap);
-  va_end(ap);
-  return r;
-}
-
-bool ceph_argparse_withint(std::vector<const char*> &args,
-       std::vector<const char*>::iterator &i, int *ret,
+       std::vector<const char*>::iterator &i, T *ret,
        std::ostream *oss, ...)
 {
   bool r;
@@ -340,7 +350,7 @@ bool ceph_argparse_withint(std::vector<const char*> &args,
   }
 
   std::string err;
-  int myret = strict_strtol(str.c_str(), 10, &err);
+  T myret = strict_str_convert(str.c_str(), &err);
   *ret = myret;
   if (!err.empty()) {
     *oss << err;
@@ -348,50 +358,27 @@ bool ceph_argparse_withint(std::vector<const char*> &args,
   return true;
 }
 
-bool ceph_argparse_withlonglong(std::vector<const char*> &args,
-       std::vector<const char*>::iterator &i, long long *ret,
-       std::ostream *oss, ...)
-{
-  bool r;
-  va_list ap;
-  std::string str;
-  va_start(ap, oss);
-  r = va_ceph_argparse_witharg(args, i, &str, ap);
-  va_end(ap);
-  if (!r) {
-    return false;
-  }
+template bool ceph_argparse_witharg<int>(std::vector<const char*> &args,
+       std::vector<const char*>::iterator &i, int *ret,
+       std::ostream *oss, ...);
 
-  std::string err;
-  long long myret = strict_strtoll(str.c_str(), 10, &err);
-  *ret = myret;
-  if (!err.empty()) {
-    *oss << err;
-  }
-  return true;
-}
+template bool ceph_argparse_witharg<long long>(std::vector<const char*> &args,
+       std::vector<const char*>::iterator &i, long long *ret,
+       std::ostream *oss, ...);
 
-bool ceph_argparse_withfloat(std::vector<const char*> &args,
+template bool ceph_argparse_witharg<float>(std::vector<const char*> &args,
        std::vector<const char*>::iterator &i, float *ret,
-       std::ostream *oss, ...)
+       std::ostream *oss, ...);
+
+bool ceph_argparse_witharg(std::vector<const char*> &args,
+       std::vector<const char*>::iterator &i, std::string *ret, ...)
 {
   bool r;
   va_list ap;
-  std::string str;
-  va_start(ap, oss);
-  r = va_ceph_argparse_witharg(args, i, &str, ap);
+  va_start(ap, ret);
+  r = va_ceph_argparse_witharg(args, i, ret, ap);
   va_end(ap);
-  if (!r) {
-    return false;
-  }
-
-  std::string err;
-  float myret = strict_strtof(str.c_str(), &err);
-  *ret = myret;
-  if (!err.empty()) {
-    *oss << err;
-  }
-  return true;
+  return r;
 }
 
 CephInitParameters ceph_argparse_early_args
index 3ef0251abeb8762bf378c7e0599745384d180e71..41a4cb4609d3366940f61c04bb11ca92c0437b36 100644 (file)
@@ -57,21 +57,16 @@ bool ceph_argparse_flag(std::vector<const char*> &args,
        std::vector<const char*>::iterator &i, ...);
 bool ceph_argparse_witharg(std::vector<const char*> &args,
        std::vector<const char*>::iterator &i, std::string *ret, ...);
+template<class T>
+bool ceph_argparse_witharg(std::vector<const char*> &args,
+       std::vector<const char*>::iterator &i, T *ret,
+       std::ostream *oss, ...);
 bool ceph_argparse_binary_flag(std::vector<const char*> &args,
        std::vector<const char*>::iterator &i, int *ret,
        std::ostream *oss, ...);
 extern CephInitParameters ceph_argparse_early_args
            (std::vector<const char*>& args, uint32_t module_type, int flags,
             std::string *cluster, std::string *conf_file_list);
-extern bool ceph_argparse_withint(std::vector<const char*> &args,
-       std::vector<const char*>::iterator &i, int *ret,
-       std::ostream *oss, ...);
-extern bool ceph_argparse_withfloat(std::vector<const char*> &args,
-       std::vector<const char*>::iterator &i, float *ret,
-       std::ostream *oss, ...);
-extern bool ceph_argparse_withlonglong(std::vector<const char*> &args,
-       std::vector<const char*>::iterator &i, long long *ret,
-       std::ostream *oss, ...);
 extern void generic_server_usage();
 extern void generic_client_usage();
 
index 2469d10846ffeb07e5cfdbd373482c465226a2f9..3d86a92be6a0f427406c79e2d0713c50e9918856 100644 (file)
@@ -2721,7 +2721,7 @@ int main(int argc, const char **argv)
       fromsnapname = strdup(val.c_str());
     } else if (ceph_argparse_witharg(args, i, &val, "-i", "--image", (char*)NULL)) {
       imgname = strdup(val.c_str());
-    } else if (ceph_argparse_withlonglong(args, i, &sizell, &err, "-s", "--size", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &sizell, &err, "-s", "--size", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << "rbd: " << err.str() << std::endl;
        return EXIT_FAILURE;
@@ -2734,14 +2734,14 @@ int main(int argc, const char **argv)
       size_set = true;
     } else if (ceph_argparse_flag(args, i, "-l", "--long", (char*)NULL)) {
       lflag = true;
-    } else if (ceph_argparse_withlonglong(args, i, &stripe_unit, &err, "--stripe-unit", (char*)NULL)) {
-    } else if (ceph_argparse_withlonglong(args, i, &stripe_count, &err, "--stripe-count", (char*)NULL)) {
-    } else if (ceph_argparse_withint(args, i, &order, &err, "--order", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &stripe_unit, &err, "--stripe-unit", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &stripe_count, &err, "--stripe-count", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &order, &err, "--order", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << "rbd: " << err.str() << std::endl;
        return EXIT_FAILURE;
       }
-    } else if (ceph_argparse_withlonglong(args, i, &bench_io_size, &err, "--io-size", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &bench_io_size, &err, "--io-size", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << "rbd: " << err.str() << std::endl;
        return EXIT_FAILURE;
@@ -2750,8 +2750,8 @@ int main(int argc, const char **argv)
        cerr << "rbd: io-size must be > 0" << std::endl;
        return EXIT_FAILURE;
       }
-    } else if (ceph_argparse_withlonglong(args, i, &bench_io_threads, &err, "--io-threads", (char*)NULL)) {
-    } else if (ceph_argparse_withlonglong(args, i, &bench_bytes, &err, "--io-total", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &bench_io_threads, &err, "--io-threads", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &bench_bytes, &err, "--io-total", (char*)NULL)) {
     } else if (ceph_argparse_witharg(args, i, &bench_pattern, "--io-pattern", (char*)NULL)) {
     } else if (ceph_argparse_witharg(args, i, &val, "--path", (char*)NULL)) {
       path = strdup(val.c_str());
index 695053ebacdc9150e8e08a130ed4e9a55a9a4a09..b83e430ee988519eb9a8dac3bc58ab19683e77f7 100644 (file)
@@ -75,7 +75,7 @@ int main(int argc, const char **argv) {
       break;
     } else if (ceph_argparse_witharg(args, i, &val, "-p", "--pool", (char*)NULL)) {
       pool_name = val;
-    } else if (ceph_argparse_withfloat(args, i, &latency_multiplier, &err, "--latency-multiplier",
+    } else if (ceph_argparse_witharg(args, i, &latency_multiplier, &err, "--latency-multiplier",
                                     (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
index e5afb5aba1e9d3639cf57ab0aaad137eabd13005..d7a180e559b61880cda83c989125bcacd169ff68 100644 (file)
@@ -1047,7 +1047,7 @@ int main(int argc, char **argv)
       // do nothing
     } else if (ceph_argparse_binary_flag(args, i, &system, NULL, "--system", (char*)NULL)) {
       system_specified = true;
-    } else if (ceph_argparse_withlonglong(args, i, &tmp, &errs, "-a", "--auth-uid", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &tmp, &errs, "-a", "--auth-uid", (char*)NULL)) {
       if (!errs.str().empty()) {
        cerr << errs.str() << std::endl;
        exit(EXIT_FAILURE);
index d1a790fdf181621df3f49dee93c8f810fed67799..ebd878c5f4e020d857db39144bc1042429077f4d 100644 (file)
@@ -286,9 +286,9 @@ TEST(CephArgParse, WithInt) {
   {
     if (ceph_argparse_double_dash(bazstuff1.arr, i)) {
       break;
-    } else if (ceph_argparse_withint(bazstuff1.arr, i, &foo, &err, "--foo", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(bazstuff1.arr, i, &foo, &err, "--foo", (char*)NULL)) {
       ASSERT_EQ(string(""), err.str());
-    } else if (ceph_argparse_withint(bazstuff1.arr, i, &bar, &err, "--bar", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(bazstuff1.arr, i, &bar, &err, "--bar", (char*)NULL)) {
       ASSERT_EQ(string(""), err.str());
     }
     else {
@@ -306,7 +306,7 @@ TEST(CephArgParse, WithInt) {
   {
     if (ceph_argparse_double_dash(bazstuff2.arr, i)) {
       break;
-    } else if (ceph_argparse_withint(bazstuff2.arr, i, &foo, &err2, "--foo", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(bazstuff2.arr, i, &foo, &err2, "--foo", (char*)NULL)) {
       ASSERT_NE(string(""), err2.str());
     }
     else {
@@ -322,9 +322,9 @@ TEST(CephArgParse, WithInt) {
   {
     if (ceph_argparse_double_dash(bazstuff3.arr, i)) {
       break;
-    } else if (ceph_argparse_withint(bazstuff3.arr, i, &foo, &err, "--foo", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(bazstuff3.arr, i, &foo, &err, "--foo", (char*)NULL)) {
       ASSERT_EQ(string(""), err.str());
-    } else if (ceph_argparse_withint(bazstuff3.arr, i, &bar, &err, "--bar", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(bazstuff3.arr, i, &bar, &err, "--bar", (char*)NULL)) {
       ASSERT_EQ(string(""), err.str());
     }
     else {
index ec5f926082743726c1d65a7b529d264d476404fd..ca663e4d1db2ac1b625cd2528af13d220cea7550 100644 (file)
@@ -187,37 +187,37 @@ int main(int argc, const char **argv)
   std::ostringstream err;
   std::vector<const char*>::iterator i;
   for (i = args.begin(); i != args.end();) {
-    if (ceph_argparse_withlonglong(args, i, &delay_ns, &err, "--delay-ns", (char*)NULL)) {
+    if (ceph_argparse_witharg(args, i, &delay_ns, &err, "--delay-ns", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << argv[0] << ": " << err.str() << std::endl;
        return EXIT_FAILURE;
       }
-    } else if (ceph_argparse_withlonglong(args, i, &num_ops, &err, "--ops", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &num_ops, &err, "--ops", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << argv[0] << ": " << err.str() << std::endl;
        return EXIT_FAILURE;
       }
-    } else if (ceph_argparse_withlonglong(args, i, &num_objs, &err, "--objects", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &num_objs, &err, "--objects", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << argv[0] << ": " << err.str() << std::endl;
        return EXIT_FAILURE;
       }
-    } else if (ceph_argparse_withlonglong(args, i, &obj_bytes, &err, "--obj-size", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &obj_bytes, &err, "--obj-size", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << argv[0] << ": " << err.str() << std::endl;
        return EXIT_FAILURE;
       }
-    } else if (ceph_argparse_withlonglong(args, i, &max_len, &err, "--max-op-size", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &max_len, &err, "--max-op-size", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << argv[0] << ": " << err.str() << std::endl;
        return EXIT_FAILURE;
       }
-    } else if (ceph_argparse_withfloat(args, i, &percent_reads, &err, "--percent-read", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &percent_reads, &err, "--percent-read", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << argv[0] << ": " << err.str() << std::endl;
        return EXIT_FAILURE;
       }
-    } else if (ceph_argparse_withint(args, i, &seed, &err, "--seed", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &seed, &err, "--seed", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << argv[0] << ": " << err.str() << std::endl;
        return EXIT_FAILURE;
index 8448ee60b12707eb5d9dd2eabb382136e9caafa9..f1f490d40e61fc93e44b48832ac02d9eb9ef291b 100644 (file)
@@ -313,35 +313,35 @@ int main(int argc, const char **argv)
       compile = true;
     } else if (ceph_argparse_flag(args, i, "-t", "--test", (char*)NULL)) {
       test = true;
-    } else if (ceph_argparse_withint(args, i, &full_location, &err, "--show-location", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &full_location, &err, "--show-location", (char*)NULL)) {
     } else if (ceph_argparse_flag(args, i, "-s", "--simulate", (char*)NULL)) {
       tester.set_random_placement();
     } else if (ceph_argparse_flag(args, i, "--enable-unsafe-tunables", (char*)NULL)) {
       unsafe_tunables = true;
-    } else if (ceph_argparse_withint(args, i, &choose_local_tries, &err,
+    } else if (ceph_argparse_witharg(args, i, &choose_local_tries, &err,
                                     "--set_choose_local_tries", (char*)NULL)) {
       adjust = true;
-    } else if (ceph_argparse_withint(args, i, &choose_local_fallback_tries, &err,
+    } else if (ceph_argparse_witharg(args, i, &choose_local_fallback_tries, &err,
                                     "--set_choose_local_fallback_tries", (char*)NULL)) {
       adjust = true;
-    } else if (ceph_argparse_withint(args, i, &choose_total_tries, &err,
+    } else if (ceph_argparse_witharg(args, i, &choose_total_tries, &err,
                                     "--set_choose_total_tries", (char*)NULL)) {
       adjust = true;
-    } else if (ceph_argparse_withint(args, i, &chooseleaf_descend_once, &err,
+    } else if (ceph_argparse_witharg(args, i, &chooseleaf_descend_once, &err,
                                     "--set_chooseleaf_descend_once", (char*)NULL)) {
       adjust = true;
-    } else if (ceph_argparse_withint(args, i, &chooseleaf_vary_r, &err,
+    } else if (ceph_argparse_witharg(args, i, &chooseleaf_vary_r, &err,
                                     "--set_chooseleaf_vary_r", (char*)NULL)) {
       adjust = true;
-    } else if (ceph_argparse_withint(args, i, &straw_calc_version, &err,
+    } else if (ceph_argparse_witharg(args, i, &straw_calc_version, &err,
                                     "--set_straw_calc_version", (char*)NULL)) {
       adjust = true;
-    } else if (ceph_argparse_withint(args, i, &allowed_bucket_algs, &err,
+    } else if (ceph_argparse_witharg(args, i, &allowed_bucket_algs, &err,
                                     "--set_allowed_bucket_algs", (char*)NULL)) {
       adjust = true;
     } else if (ceph_argparse_flag(args, i, "--reweight", (char*)NULL)) {
       reweight = true;
-    } else if (ceph_argparse_withint(args, i, &add_item, &err, "--add_item", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &add_item, &err, "--add_item", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
        exit(EXIT_FAILURE);
@@ -358,7 +358,7 @@ int main(int argc, const char **argv)
       }
       add_name.assign(*i);
       i = args.erase(i);
-    } else if (ceph_argparse_withint(args, i, &add_item, &err, "--update_item", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &add_item, &err, "--update_item", (char*)NULL)) {
       update_item = true;
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
@@ -413,72 +413,72 @@ int main(int argc, const char **argv)
       i = args.erase(i);
     } else if (ceph_argparse_flag(args, i, "--build", (char*)NULL)) {
       build = true;
-    } else if (ceph_argparse_withint(args, i, &num_osds, &err, "--num_osds", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &num_osds, &err, "--num_osds", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
        exit(EXIT_FAILURE);
       }
-    } else if (ceph_argparse_withint(args, i, &x, &err, "--num_rep", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &x, &err, "--num_rep", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
        exit(EXIT_FAILURE);
       }
       tester.set_num_rep(x);
-    } else if (ceph_argparse_withint(args, i, &x, &err, "--max_x", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &x, &err, "--max_x", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
        exit(EXIT_FAILURE);
       }
       tester.set_max_x(x);
-    } else if (ceph_argparse_withint(args, i, &x, &err, "--min_x", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &x, &err, "--min_x", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
        exit(EXIT_FAILURE);
       }
       tester.set_min_x(x);
-    } else if (ceph_argparse_withint(args, i, &x, &err, "--x", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &x, &err, "--x", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
        exit(EXIT_FAILURE);
       }
       tester.set_x(x);
-    } else if (ceph_argparse_withint(args, i, &x, &err, "--max_rule", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &x, &err, "--max_rule", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
        exit(EXIT_FAILURE);
       }
       tester.set_max_rule(x);
-    } else if (ceph_argparse_withint(args, i, &x, &err, "--min_rule", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &x, &err, "--min_rule", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
        exit(EXIT_FAILURE);
       }
       tester.set_min_rule(x);
-    } else if (ceph_argparse_withint(args, i, &x, &err, "--rule", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &x, &err, "--rule", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
        exit(EXIT_FAILURE);
       }
       tester.set_rule(x);
-    } else if (ceph_argparse_withint(args, i, &x, &err, "--batches", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &x, &err, "--batches", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
        exit(EXIT_FAILURE);
       }
       tester.set_batches(x);
-    } else if (ceph_argparse_withfloat(args, i, &y, &err, "--mark-down-ratio", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &y, &err, "--mark-down-ratio", (char*)NULL)) {
       if (!err.str().empty()) {
         cerr << err.str() << std::endl;
         exit(EXIT_FAILURE);
       }
       tester.set_device_down_ratio(y);
-    } else if (ceph_argparse_withfloat(args, i, &y, &err, "--mark-down-bucket-ratio", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &y, &err, "--mark-down-bucket-ratio", (char*)NULL)) {
       if (!err.str().empty()) {
         cerr << err.str() << std::endl;
         exit(EXIT_FAILURE);
       }
       tester.set_bucket_down_ratio(y);
-    } else if (ceph_argparse_withint(args, i, &tmp, &err, "--weight", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &tmp, &err, "--weight", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
        exit(EXIT_FAILURE);
index 76c05a0d7ae88181170b0da571c5792c64cc5f6f..993b032f6416ff621ef14af31de5d6bb00c1472a 100644 (file)
@@ -86,7 +86,7 @@ int main(int argc, const char **argv)
       print_json = true;
     } else if (ceph_argparse_flag(args, i, "--tree", (char*)NULL)) {
       tree = true;
-    } else if (ceph_argparse_withint(args, i, &num_osd, &err, "--createsimple", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &num_osd, &err, "--createsimple", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
        exit(EXIT_FAILURE);
@@ -106,12 +106,12 @@ int main(int argc, const char **argv)
       test_random = true;
     } else if (ceph_argparse_flag(args, i, "--clobber", (char*)NULL)) {
       clobber = true;
-    } else if (ceph_argparse_withint(args, i, &pg_bits, &err, "--pg_bits", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &pg_bits, &err, "--pg_bits", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
        exit(EXIT_FAILURE);
       }
-    } else if (ceph_argparse_withint(args, i, &pgp_bits, &err, "--pgp_bits", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &pgp_bits, &err, "--pgp_bits", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
        exit(EXIT_FAILURE);
@@ -126,9 +126,9 @@ int main(int argc, const char **argv)
       test_map_object = val;
     } else if (ceph_argparse_flag(args, i, "--test_crush", (char*)NULL)) {
       test_crush = true;
-    } else if (ceph_argparse_withint(args, i, &range_first, &err, "--range_first", (char*)NULL)) {
-    } else if (ceph_argparse_withint(args, i, &range_last, &err, "--range_last", (char*)NULL)) {
-    } else if (ceph_argparse_withint(args, i, &pool, &err, "--pool", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &range_first, &err, "--range_first", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &range_last, &err, "--range_last", (char*)NULL)) {
+    } else if (ceph_argparse_witharg(args, i, &pool, &err, "--pool", (char*)NULL)) {
       if (!err.str().empty()) {
         cerr << err.str() << std::endl;
         exit(EXIT_FAILURE);