Skip to content

Commit

Permalink
daemons: tools: replace 0 exits with BEXIT_SUCCESS
Browse files Browse the repository at this point in the history
  • Loading branch information
alaaeddineelamri committed Sep 20, 2023
1 parent f126bb5 commit 17b1300
Show file tree
Hide file tree
Showing 18 changed files with 81 additions and 62 deletions.
15 changes: 8 additions & 7 deletions core/src/console/console.cc
Expand Up @@ -27,6 +27,7 @@
*/

#include "include/bareos.h"
#include "include/exit_codes.h"
#include "console/console_conf.h"
#include "console/console_globals.h"
#include "console/auth_pam.h"
Expand Down Expand Up @@ -939,16 +940,16 @@ int main(int argc, char* argv[])
my_config = InitConsConfig(configfile, M_CONFIG_ERROR);
PrintConfigSchemaJson(buffer);
printf("%s\n", buffer.c_str());
exit(0);
exit(BEXIT_SUCCESS);
}

my_config = InitConsConfig(configfile, M_CONFIG_ERROR);
my_config->ParseConfigOrExit();

if (export_config) {
my_config->DumpResources(PrintMessage, NULL);
TerminateConsole(0);
exit(0);
TerminateConsole(BEXIT_SUCCESS);
exit(BEXIT_SUCCESS);
}

if (InitCrypto() != 0) {
Expand All @@ -969,8 +970,8 @@ int main(int argc, char* argv[])
}

if (test_config) {
TerminateConsole(0);
exit(0);
TerminateConsole(BEXIT_SUCCESS);
exit(BEXIT_SUCCESS);
}

(void)WSA_Init(); /* Initialize Windows sockets */
Expand Down Expand Up @@ -1097,8 +1098,8 @@ int main(int argc, char* argv[])

if (history_file.size()) { ConsoleUpdateHistory(history_file.c_str()); }

TerminateConsole(0);
return 0;
TerminateConsole(BEXIT_SUCCESS);
return BEXIT_SUCCESS;
}

static void TerminateConsole(int sig)
Expand Down
5 changes: 3 additions & 2 deletions core/src/dird/dbcheck.cc
Expand Up @@ -24,6 +24,7 @@
// Program to check a BAREOS database for consistency and to make repairs

#include "include/bareos.h"
#include "include/exit_codes.h"
#include "cats/cats.h"
#include "lib/runscript.h"
#include "lib/cli.h"
Expand Down Expand Up @@ -906,7 +907,7 @@ int main(int argc, char* argv[])
// Print catalog information and exit (-B)
if (print_catalog) {
PrintCatalogDetails(catalog);
exit(0);
exit(BEXIT_SUCCESS);
}

db_name = catalog->db_name;
Expand Down Expand Up @@ -946,5 +947,5 @@ int main(int argc, char* argv[])
CloseMsg(nullptr);
TermMsg();

return 0;
return BEXIT_SUCCESS;
}
27 changes: 14 additions & 13 deletions core/src/dird/dird.cc
Expand Up @@ -27,6 +27,7 @@
*/

#include "include/bareos.h"
#include "include/exit_codes.h"
#include "cats/sql.h"
#include "cats/sql_pooling.h"
#include "dird.h"
Expand Down Expand Up @@ -258,8 +259,8 @@ int main(int argc, char* argv[])
PrintConfigSchemaJson(buffer);
printf("%s\n", buffer.c_str());

TerminateDird(0);
return 0;
TerminateDird(BEXIT_SUCCESS);
return BEXIT_SUCCESS;
}

my_config->ParseConfigOrExit();
Expand All @@ -272,16 +273,16 @@ int main(int argc, char* argv[])
rc = 1;
}
TerminateDird(rc);
return 0;
return BEXIT_SUCCESS;
}

if (!CheckResources()) {
Jmsg((JobControlRecord*)NULL, M_ERROR_TERM, 0,
_("Please correct the configuration in %s\n"),
my_config->get_base_config_path().c_str());

TerminateDird(0);
return 0;
TerminateDird(BEXIT_SUCCESS);
return BEXIT_SUCCESS;
}

if (my_config->HasWarnings()) {
Expand All @@ -301,8 +302,8 @@ int main(int argc, char* argv[])
Jmsg((JobControlRecord*)nullptr, M_ERROR_TERM, 0,
_("Cryptography library initialization failed.\n"));

TerminateDird(0);
return 0;
TerminateDird(BEXIT_SUCCESS);
return BEXIT_SUCCESS;
}

if (!test_config) {
Expand All @@ -323,8 +324,8 @@ int main(int argc, char* argv[])
_("Please correct the configuration in %s\n"),
my_config->get_base_config_path().c_str());

TerminateDird(0);
return 0;
TerminateDird(BEXIT_SUCCESS);
return BEXIT_SUCCESS;
}

if (test_config) { TerminateDird(0); }
Expand All @@ -334,8 +335,8 @@ int main(int argc, char* argv[])
_("Please correct the configuration in %s\n"),
my_config->get_base_config_path().c_str());

TerminateDird(0);
return 0;
TerminateDird(BEXIT_SUCCESS);
return BEXIT_SUCCESS;
}

MyNameIs(0, nullptr, me->resource_name_); /* set user defined name */
Expand Down Expand Up @@ -370,8 +371,8 @@ int main(int argc, char* argv[])

Scheduler::GetMainScheduler().Run();

TerminateDird(0);
return 0;
TerminateDird(BEXIT_SUCCESS);
return BEXIT_SUCCESS;
}

/**
Expand Down
9 changes: 4 additions & 5 deletions core/src/filed/filed.cc
Expand Up @@ -188,7 +188,7 @@ int main(int argc, char* argv[])
PrintConfigSchemaJson(buffer);
printf("%s\n", buffer.c_str());

exit(0);
exit(BEXIT_SUCCESS);
}

my_config = InitFdConfig(configfile, M_CONFIG_ERROR);
Expand All @@ -197,7 +197,7 @@ int main(int argc, char* argv[])
if (export_config) {
my_config->DumpResources(PrintMessage, nullptr);

exit(0);
exit(BEXIT_SUCCESS);
}

if (!CheckResources()) {
Expand Down Expand Up @@ -248,9 +248,8 @@ int main(int argc, char* argv[])
// start socket server to listen for new connections.
StartSocketServer(me->FDaddrs);

TerminateFiled(0);

exit(0);
TerminateFiled(BEXIT_SUCCESS);
return BEXIT_SUCCESS;
}

namespace filedaemon {
Expand Down
3 changes: 2 additions & 1 deletion core/src/lib/daemon.cc
Expand Up @@ -36,6 +36,7 @@

#include "include/fcntl_def.h"
#include "include/bareos.h"
#include "include/exit_codes.h"
#include "lib/berrno.h"
#include "lib/daemon.h"

Expand Down Expand Up @@ -85,7 +86,7 @@ void daemon_start(const char* progname,
break;
}
default:
exit(0);
exit(BEXIT_SUCCESS);
}

Dmsg0(900, "Exit daemon_start\n");
Expand Down
3 changes: 2 additions & 1 deletion core/src/qt-tray-monitor/tray-monitor.cc
Expand Up @@ -39,6 +39,7 @@
#include "lib/parse_conf.h"
#include "lib/cli.h"
#include "lib/crypto.h"
#include "include/exit_codes.h"

ConfigurationParser* my_config = nullptr;

Expand Down Expand Up @@ -169,7 +170,7 @@ int main(int argc, char* argv[])
PrintConfigSchemaJson(buffer);
printf("%s\n", buffer.c_str());
fflush(stdout);
exit(0);
exit(BEXIT_SUCCESS);
}

// read the config file
Expand Down
3 changes: 2 additions & 1 deletion core/src/stored/bcopy.cc
Expand Up @@ -27,6 +27,7 @@
*/

#include "include/bareos.h"
#include "include/exit_codes.h"
#include "stored/stored.h"
#include "stored/stored_globals.h"
#include "stored/device_control_record.h"
Expand Down Expand Up @@ -266,7 +267,7 @@ int main(int argc, char* argv[])
delete out_dev;


return 0;
return BEXIT_SUCCESS;
}


Expand Down
3 changes: 2 additions & 1 deletion core/src/stored/bextract.cc
Expand Up @@ -28,6 +28,7 @@

#include <unistd.h>
#include "include/bareos.h"
#include "include/exit_codes.h"
#include "include/filetypes.h"
#include "include/streams.h"
#include "stored/stored.h"
Expand Down Expand Up @@ -261,7 +262,7 @@ int main(int argc, char* argv[])
}
TermIncludeExcludeFiles(ff);
TermFindFiles(ff);
return 0;
return BEXIT_SUCCESS;
}

// Cleanup of delayed restore stack with streams for later processing.
Expand Down
3 changes: 2 additions & 1 deletion core/src/stored/bls.cc
Expand Up @@ -28,6 +28,7 @@

#include <unistd.h>
#include "include/bareos.h"
#include "include/exit_codes.h"
#include "include/streams.h"
#include "stored/stored.h"
#include "stored/stored_globals.h"
Expand Down Expand Up @@ -276,7 +277,7 @@ int main(int argc, char* argv[])
if (bsr) { libbareos::FreeBsr(bsr); }
TermIncludeExcludeFiles(ff);
TermFindFiles(ff);
return 0;
return BEXIT_SUCCESS;
}

static void do_close(JobControlRecord* jcr)
Expand Down
3 changes: 2 additions & 1 deletion core/src/stored/bscan.cc
Expand Up @@ -29,6 +29,7 @@
*/

#include "include/bareos.h"
#include "include/exit_codes.h"
#include "include/filetypes.h"
#include "include/streams.h"
#include "stored/stored.h"
Expand Down Expand Up @@ -343,7 +344,7 @@ int main(int argc, char* argv[])
FreeJcr(bjcr);
UnloadSdPlugins();

return 0;
return BEXIT_SUCCESS;
}

/**
Expand Down
9 changes: 5 additions & 4 deletions core/src/stored/stored.cc
Expand Up @@ -32,6 +32,7 @@
*/

#include "include/bareos.h"
#include "include/exit_codes.h"
#include "stored/stored.h"
#include "lib/crypto_cache.h"
#include "stored/acquire.h"
Expand Down Expand Up @@ -220,7 +221,7 @@ int main(int argc, char* argv[])
PrintConfigSchemaJson(buffer);
printf("%s\n", buffer.c_str());

return 0;
return BEXIT_SUCCESS;
}

my_config = InitSdConfig(configfile, M_CONFIG_ERROR);
Expand All @@ -235,7 +236,7 @@ int main(int argc, char* argv[])
if (export_config) {
my_config->DumpResources(PrintMessage, nullptr);

return 0;
return BEXIT_SUCCESS;
}

if (!CheckResources()) {
Expand Down Expand Up @@ -312,9 +313,9 @@ int main(int argc, char* argv[])
StartSocketServer(me->SDaddrs);

/* to keep compiler quiet */
TerminateStored(0);
TerminateStored(BEXIT_SUCCESS);

return 0;
return BEXIT_SUCCESS;
}

/* Check Configuration file for necessary info */
Expand Down
2 changes: 1 addition & 1 deletion core/src/tools/bregex.cc
Expand Up @@ -104,5 +104,5 @@ int main(int argc, char** argv)
fclose(fd);
regfree(&preg);
}
exit(0);
return BEXIT_SUCCESS;
}
3 changes: 2 additions & 1 deletion core/src/tools/bsmtp.cc
Expand Up @@ -61,6 +61,7 @@
#include <pwd.h>
#include <unistd.h>
#include "include/bareos.h"
#include "include/exit_codes.h"
#include "include/jcr.h"
#include "lib/cli.h"
#include "lib/bstringlist.h"
Expand Down Expand Up @@ -619,5 +620,5 @@ int main(int argc, char* argv[])
chat(my_hostname, mailhost, "QUIT\r\n");

// Go away gracefully ...
exit(0);
return BEXIT_SUCCESS;
}
3 changes: 2 additions & 1 deletion core/src/tools/btestls.cc
Expand Up @@ -29,6 +29,7 @@

#include <unistd.h>
#include "include/bareos.h"
#include "include/exit_codes.h"
#include "include/filetypes.h"
#include "include/jcr.h"
#include "findlib/find.h"
Expand Down Expand Up @@ -187,7 +188,7 @@ int main(int argc, char* const* argv)
FreeJcr(jcr);
RecentJobResultsList::Cleanup();
CleanupJcrChain();
exit(0);
exit(BEXIT_SUCCESS);
}

static int CountFiles(JobControlRecord*, FindFilesPacket*, bool)
Expand Down
6 changes: 4 additions & 2 deletions core/src/tools/bwild.cc
Expand Up @@ -26,6 +26,7 @@
*/

#include "include/bareos.h"
#include "include/exit_codes.h"
#include "lib/cli.h"
#include "lib/fnmatch.h"

Expand Down Expand Up @@ -74,7 +75,7 @@ int main(int argc, char** argv)
printf("Enter a wild-card: ");
if (fgets(pat, sizeof(pat) - 1, stdin) == NULL) { break; }
StripTrailingNewline(pat);
if (pat[0] == 0) { exit(0); }
if (pat[0] == 0) { exit(BEXIT_SUCCESS); }
fd = fopen(fname.c_str(), "r");
if (!fd) {
printf(_("Could not open data file: %s\n"), fname.c_str());
Expand All @@ -95,5 +96,6 @@ int main(int argc, char** argv)
}
fclose(fd);
}
exit(0);

return BEXIT_SUCCESS;
}

0 comments on commit 17b1300

Please sign in to comment.