From: Mykola Golub Date: Fri, 3 Apr 2015 10:14:31 +0000 (+0300) Subject: common: ceph_argparse_witharg: pass oss by reference X-Git-Tag: v9.0.0~16^2~1 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=c579ebfebb5132e230c661dfb121778a4e0b9e2c;p=ceph.git common: ceph_argparse_witharg: pass oss by reference It is always supposed to be a valid pointer here. Signed-off-by: Mykola Golub --- diff --git a/src/common/ceph_argparse.cc b/src/common/ceph_argparse.cc index 26d1178d34c9..eff6120df201 100644 --- a/src/common/ceph_argparse.cc +++ b/src/common/ceph_argparse.cc @@ -337,7 +337,7 @@ static bool va_ceph_argparse_witharg(std::vector &args, template bool ceph_argparse_witharg(std::vector &args, std::vector::iterator &i, T *ret, - std::ostream *oss, ...) + std::ostream &oss, ...) { bool r; va_list ap; @@ -353,22 +353,22 @@ bool ceph_argparse_witharg(std::vector &args, T myret = strict_str_convert(str.c_str(), &err); *ret = myret; if (!err.empty()) { - *oss << err; + oss << err; } return true; } template bool ceph_argparse_witharg(std::vector &args, std::vector::iterator &i, int *ret, - std::ostream *oss, ...); + std::ostream &oss, ...); template bool ceph_argparse_witharg(std::vector &args, std::vector::iterator &i, long long *ret, - std::ostream *oss, ...); + std::ostream &oss, ...); template bool ceph_argparse_witharg(std::vector &args, std::vector::iterator &i, float *ret, - std::ostream *oss, ...); + std::ostream &oss, ...); bool ceph_argparse_witharg(std::vector &args, std::vector::iterator &i, std::string *ret, ...) diff --git a/src/common/ceph_argparse.h b/src/common/ceph_argparse.h index 41a4cb4609d3..e5845fb32d34 100644 --- a/src/common/ceph_argparse.h +++ b/src/common/ceph_argparse.h @@ -60,7 +60,7 @@ bool ceph_argparse_witharg(std::vector &args, template bool ceph_argparse_witharg(std::vector &args, std::vector::iterator &i, T *ret, - std::ostream *oss, ...); + std::ostream &oss, ...); bool ceph_argparse_binary_flag(std::vector &args, std::vector::iterator &i, int *ret, std::ostream *oss, ...); diff --git a/src/rbd.cc b/src/rbd.cc index 3d86a92be6a0..abe60e597893 100644 --- a/src/rbd.cc +++ b/src/rbd.cc @@ -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_witharg(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_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)) { + } 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_witharg(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_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_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()); diff --git a/src/rbd_replay/rbd-replay.cc b/src/rbd_replay/rbd-replay.cc index b83e430ee988..b00c1310c905 100644 --- a/src/rbd_replay/rbd-replay.cc +++ b/src/rbd_replay/rbd-replay.cc @@ -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_witharg(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; diff --git a/src/rgw/rgw_admin.cc b/src/rgw/rgw_admin.cc index d7a180e559b6..f6cc4b97bc31 100644 --- a/src/rgw/rgw_admin.cc +++ b/src/rgw/rgw_admin.cc @@ -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_witharg(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); diff --git a/src/test/ceph_argparse.cc b/src/test/ceph_argparse.cc index ebd878c5f4e0..49bb962a8870 100644 --- a/src/test/ceph_argparse.cc +++ b/src/test/ceph_argparse.cc @@ -286,9 +286,9 @@ TEST(CephArgParse, WithInt) { { if (ceph_argparse_double_dash(bazstuff1.arr, i)) { break; - } else if (ceph_argparse_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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 { diff --git a/src/test/osdc/object_cacher_stress.cc b/src/test/osdc/object_cacher_stress.cc index ca663e4d1db2..39aabfdeb225 100644 --- a/src/test/osdc/object_cacher_stress.cc +++ b/src/test/osdc/object_cacher_stress.cc @@ -187,37 +187,37 @@ int main(int argc, const char **argv) std::ostringstream err; std::vector::iterator i; for (i = args.begin(); i != args.end();) { - if (ceph_argparse_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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; diff --git a/src/tools/crushtool.cc b/src/tools/crushtool.cc index f1f490d40e61..5e53f0a869fb 100644 --- a/src/tools/crushtool.cc +++ b/src/tools/crushtool.cc @@ -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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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_witharg(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); diff --git a/src/tools/osdmaptool.cc b/src/tools/osdmaptool.cc index 993b032f6416..14331c332005 100644 --- a/src/tools/osdmaptool.cc +++ b/src/tools/osdmaptool.cc @@ -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_witharg(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_witharg(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_witharg(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_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)) { + } 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);