]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
tools/ceph_conf: replace exit(n) with "return n"
authorKefu Chai <kchai@redhat.com>
Tue, 16 Jul 2019 03:49:32 +0000 (11:49 +0800)
committerBrad Hubbard <bhubbard@redhat.com>
Mon, 14 Dec 2020 02:08:05 +0000 (12:08 +1000)
a step to the leak-free `main()`, as we use a smart pointer to manage
the lifecycle of `cct`, it'd be better to let the RAII to do its job.

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

src/tools/ceph_conf.cc

index fb046f8eeb2b8946a5e32de5a88f688f318bdcf8..dd96b525e7146c585fd33219276f1d2571d33358 100644 (file)
@@ -214,7 +214,7 @@ int main(int argc, const char **argv)
       if (pos == string::npos) {
        cerr << "expecting argument like 'key=value' for --filter-key-value (not '" << val << "')" << std::endl;
        usage();
-       exit(1);
+       return EXIT_FAILURE;
       } 
       string key(val, 0, pos);
       string value(val, pos+1);
@@ -235,7 +235,7 @@ int main(int argc, const char **argv)
        }
        cerr << std::endl;
        usage();
-       exit(1);
+       return EXIT_FAILURE;
       }
     }
   }
@@ -243,7 +243,7 @@ int main(int argc, const char **argv)
   cct->_log->flush();
   if (action == "help") {
     usage();
-    exit(0);
+    return EXIT_SUCCESS;
   } else if (action == "list-sections") {
     return list_sections(section_list_prefix, filter_key, filter_key_value);
   } else if (action == "lookup") {
@@ -253,6 +253,6 @@ int main(int argc, const char **argv)
   } else {
     cerr << "You must give an action, such as --lookup or --list-all-sections." << std::endl;
     cerr << "Pass --help for more help." << std::endl;
-    exit(1);
+    return EXIT_FAILURE;
   }
 }