]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
crushtool: s/exit(EXIT_FAILURE)/return EXIT_FAILURE/
authorKefu Chai <kchai@redhat.com>
Wed, 16 Nov 2016 03:56:09 +0000 (11:56 +0800)
committerNathan Cutler <ncutler@suse.com>
Tue, 25 Apr 2017 07:02:21 +0000 (09:02 +0200)
so the destructor(s) can be called.

Signed-off-by: Kefu Chai <kchai@redhat.com>
(cherry picked from commit e01b89ed6be6b99fec5c725f4bc5769b42468cac)

Conflicts:
src/tools/crushtool.cc - jewel does not have 17feefbcb3105553b763cb7ce123b20b77b95857

src/tools/crushtool.cc

index 03ff4dacd37fe1775fff6f3c425b253b92a2a0ee..e723fb00cce1970a6a25a3d0528d3e93544cc27b 100644 (file)
@@ -285,7 +285,7 @@ int main(int argc, const char **argv)
       break;
     } else if (ceph_argparse_flag(args, i, "-h", "--help", (char*)NULL)) {
       usage();
-      exit(0);
+      return EXIT_SUCCESS;
     } else if (ceph_argparse_witharg(args, i, &val, "-d", "--decompile", (char*)NULL)) {
       infn = val;
       decompile = true;
@@ -356,17 +356,17 @@ int main(int argc, const char **argv)
     } 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);
+       return EXIT_FAILURE;
       }
       if (i == args.end()) {
        cerr << "expecting additional argument to --add-item" << std::endl;
-       exit(EXIT_FAILURE);
+       return EXIT_FAILURE;
       }
       add_weight = atof(*i);
       i = args.erase(i);
       if (i == args.end()) {
        cerr << "expecting additional argument to --add-item" << std::endl;
-       exit(EXIT_FAILURE);
+       return EXIT_FAILURE;
       }
       add_name.assign(*i);
       i = args.erase(i);
@@ -374,17 +374,17 @@ int main(int argc, const char **argv)
       update_item = true;
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
-       exit(EXIT_FAILURE);
+       return EXIT_FAILURE;
       }
       if (i == args.end()) {
        cerr << "expecting additional argument to --update-item" << std::endl;
-       exit(EXIT_FAILURE);
+       return EXIT_FAILURE;
       }
       add_weight = atof(*i);
       i = args.erase(i);
       if (i == args.end()) {
        cerr << "expecting additional argument to --update-item" << std::endl;
-       exit(EXIT_FAILURE);
+       return EXIT_FAILURE;
       }
       add_name.assign(*i);
       i = args.erase(i);
@@ -392,7 +392,7 @@ int main(int argc, const char **argv)
       std::string type(val);
       if (i == args.end()) {
        cerr << "expecting additional argument to --loc" << std::endl;
-       exit(EXIT_FAILURE);
+       return EXIT_FAILURE;
       }
       std::string name(*i);
       i = args.erase(i);
@@ -403,12 +403,12 @@ int main(int argc, const char **argv)
       tester.set_output_csv(true);
     } else if (ceph_argparse_flag(args, i, "--help-output", (char*)NULL)) {
       data_analysis_usage();
-      exit(0);
+      return EXIT_SUCCESS;
     } else if (ceph_argparse_witharg(args, i, &val, "--output-name", (char*)NULL)) {
       std::string name(val);
       if (i == args.end()) {
        cerr << "expecting additional argument to --output-name" << std::endl;
-       exit(EXIT_FAILURE);
+       return EXIT_FAILURE;
       }
       else {
         tester.set_output_data_file_name(name + "-");
@@ -419,7 +419,7 @@ int main(int argc, const char **argv)
       reweight_name = val;
       if (i == args.end()) {
        cerr << "expecting additional argument to --reweight-item" << std::endl;
-       exit(EXIT_FAILURE);
+       return EXIT_FAILURE;
       }
       reweight_weight = atof(*i);
       i = args.erase(i);
@@ -428,83 +428,83 @@ int main(int argc, const char **argv)
     } 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);
+       return EXIT_FAILURE;
       }
     } 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);
+       return EXIT_FAILURE;
       }
       tester.set_num_rep(x);
     } 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);
+       return EXIT_FAILURE;
       }
       tester.set_max_x(x);
     } 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);
+       return EXIT_FAILURE;
       }
       tester.set_min_x(x);
     } else if (ceph_argparse_witharg(args, i, &x, err, "--x", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
-       exit(EXIT_FAILURE);
+       return EXIT_FAILURE;
       }
       tester.set_x(x);
     } 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);
+       return EXIT_FAILURE;
       }
       tester.set_max_rule(x);
     } 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);
+       return EXIT_FAILURE;
       }
       tester.set_min_rule(x);
     } else if (ceph_argparse_witharg(args, i, &x, err, "--rule", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
-       exit(EXIT_FAILURE);
+       return EXIT_FAILURE;
       }
       tester.set_rule(x);
     } else if (ceph_argparse_witharg(args, i, &x, err, "--ruleset", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
-       exit(EXIT_FAILURE);
+       return EXIT_FAILURE;
       }
       tester.set_ruleset(x);
     } else if (ceph_argparse_witharg(args, i, &x, err, "--batches", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
-       exit(EXIT_FAILURE);
+       return EXIT_FAILURE;
       }
       tester.set_batches(x);
     } 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);
+        return EXIT_FAILURE;
       }
       tester.set_device_down_ratio(y);
     } 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);
+        return EXIT_FAILURE;
       }
       tester.set_bucket_down_ratio(y);
     } else if (ceph_argparse_witharg(args, i, &tmp, err, "--weight", (char*)NULL)) {
       if (!err.str().empty()) {
        cerr << err.str() << std::endl;
-       exit(EXIT_FAILURE);
+       return EXIT_FAILURE;
       }
       int dev = tmp;
       if (i == args.end()) {
        cerr << "expecting additional argument to --weight" << std::endl;
-       exit(EXIT_FAILURE);
+       return EXIT_FAILURE;
       }
       float f = atof(*i);
       i = args.erase(i);
@@ -521,24 +521,24 @@ int main(int argc, const char **argv)
 
   if (decompile + compile + build > 1) {
     cerr << "cannot specify more than one of compile, decompile, and build" << std::endl;
-    exit(EXIT_FAILURE);
+    return EXIT_FAILURE;
   }
   if (!check && !compile && !decompile && !build && !test && !reweight && !adjust && !tree &&
       add_item < 0 && full_location < 0 &&
       remove_name.empty() && reweight_name.empty()) {
     cerr << "no action specified; -h for help" << std::endl;
-    exit(EXIT_FAILURE);
+    return EXIT_FAILURE;
   }
   if ((!build) && (!args.empty())) {
     cerr << "unrecognized arguments: " << args << std::endl;
-    exit(EXIT_FAILURE);
+    return EXIT_FAILURE;
   }
   else {
     if ((args.size() % 3) != 0U) {
       cerr << "remaining args: " << args << std::endl;
       cerr << "layers must be specified with 3-tuples of (name, buckettype, size)"
           << std::endl;
-      exit(EXIT_FAILURE);
+      return EXIT_FAILURE;
     }
     for (size_t j = 0; j < args.size(); j += 3) {
       layer_t l;
@@ -567,19 +567,19 @@ int main(int argc, const char **argv)
     if (infn == "-") {
       if (isatty(STDIN_FILENO)) {
         cerr << "stdin must not be from a tty" << std::endl;
-        exit(EXIT_FAILURE);
+        return EXIT_FAILURE;
       }
       r = get_fd_data(STDIN_FILENO, bl);
       if (r < 0) {
         cerr << "error reading data from STDIN" << std::endl;
-        exit(EXIT_FAILURE);
+        return EXIT_FAILURE;
       }
     } else {
       r = bl.read_file(infn.c_str(), &error);
       if (r < 0) {
         cerr << me << ": error reading '" << infn << "': " 
              << error << std::endl;
-        exit(1);
+        return EXIT_FAILURE;
       }
     }
     bufferlist::iterator p = bl.begin();
@@ -587,7 +587,7 @@ int main(int argc, const char **argv)
       crush.decode(p);
     } catch(...) {
       cerr << me << ": unable to decode " << infn << std::endl;
-      exit(EXIT_FAILURE);
+      return EXIT_FAILURE;
     }
   }
 
@@ -606,7 +606,7 @@ int main(int argc, const char **argv)
       cc.enable_unsafe_tunables();
     int r = cc.compile(in, srcfn.c_str());
     if (r < 0) 
-      exit(1);
+      return EXIT_FAILURE;
 
     modified = true;
   }
@@ -614,7 +614,7 @@ int main(int argc, const char **argv)
   if (build) {
     if (layers.empty()) {
       cerr << me << ": must specify at least one layer" << std::endl;
-      exit(1);
+      return EXIT_FAILURE;
     }
 
     crush.create();
@@ -650,7 +650,7 @@ int main(int argc, const char **argv)
        }
       if (buckettype < 0) {
        cerr << "unknown bucket type '" << l.buckettype << "'" << std::endl;
-       exit(EXIT_FAILURE);
+       return EXIT_FAILURE;
       }
 
       // build items
@@ -725,7 +725,7 @@ int main(int argc, const char **argv)
     }
     
     if (OSDMap::build_simple_crush_rulesets(g_ceph_context, crush, root, &cerr))
-      exit(EXIT_FAILURE);
+      return EXIT_FAILURE;
 
     modified = true;
   }
@@ -843,7 +843,7 @@ int main(int argc, const char **argv)
       o.open(outfn.c_str(), ios::out | ios::binary | ios::trunc);
       if (!o.is_open()) {
        cerr << me << ": error writing '" << outfn << "'" << std::endl;
-       exit(1);
+       return EXIT_FAILURE;
       }
       cc.decompile(o);
       o.close();
@@ -856,7 +856,7 @@ int main(int argc, const char **argv)
     tester.check_overlapped_rules();
     if (max_id >= 0) {
       if (!tester.check_name_maps(max_id)) {
-       exit(1);
+       return EXIT_FAILURE;
       }
     }
   }
@@ -868,7 +868,7 @@ int main(int argc, const char **argv)
 
     int r = tester.test();
     if (r < 0)
-      exit(1);
+      return EXIT_FAILURE;
   }
 
   // output ---
@@ -883,7 +883,7 @@ int main(int argc, const char **argv)
       int r = bl.write_file(outfn.c_str());
       if (r < 0) {
        cerr << me << ": error writing '" << outfn << "': " << cpp_strerror(r) << std::endl;
-       exit(1);
+       return EXIT_FAILURE;
       }
       if (verbose)
        cout << "wrote crush map to " << outfn << std::endl;