Skip to content

Commit

Permalink
filed: replacing NULLs with nullptrs
Browse files Browse the repository at this point in the history
  • Loading branch information
alaaeddineelamri authored and arogge committed Nov 30, 2021
1 parent 9362f48 commit d342f8a
Showing 1 changed file with 21 additions and 20 deletions.
41 changes: 21 additions & 20 deletions core/src/filed/filed.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,8 @@ int main(int argc, char* argv[])
bool export_config = false;
bool export_config_schema = false;
bool keep_readall_caps = false;
char* uid = NULL;
char* gid = NULL;
char* uid = nullptr;
char* gid = nullptr;

setlocale(LC_ALL, "");
tzset();
Expand All @@ -107,8 +107,8 @@ int main(int argc, char* argv[])

InitStackDump();
MyNameIs(argc, argv, "bareos-fd");
InitMsg(NULL, NULL);
daemon_start_time = time(NULL);
InitMsg(nullptr, nullptr);
daemon_start_time = time(nullptr);

while ((ch = getopt(argc, argv, "bc:d:fg:kmrstu:vx:z:?")) != -1) {
switch (ch) {
Expand All @@ -117,7 +117,7 @@ int main(int argc, char* argv[])
break;

case 'c': /* configuration file */
if (configfile != NULL) { free(configfile); }
if (configfile != nullptr) { free(configfile); }
configfile = strdup(optarg);
break;

Expand Down Expand Up @@ -190,7 +190,7 @@ int main(int argc, char* argv[])
argv += optind;

if (argc) {
if (configfile != NULL) free(configfile);
if (configfile != nullptr) free(configfile);
configfile = strdup(*argv);
argc--;
argv++;
Expand Down Expand Up @@ -224,7 +224,7 @@ int main(int argc, char* argv[])
my_config->ParseConfig();

if (export_config) {
my_config->DumpResources(PrintMessage, NULL);
my_config->DumpResources(PrintMessage, nullptr);
goto bail_out;
}

Expand Down Expand Up @@ -317,12 +317,12 @@ void TerminateFiled(int sig)
DeletePidFile(me->pid_directory, "bareos-fd",
GetFirstPortHostOrder(me->FDaddrs));

if (configfile != NULL) { free(configfile); }
if (configfile != nullptr) { free(configfile); }

if (debug_level > 0) { PrintMemoryPoolStats(); }
if (my_config) {
delete my_config;
my_config = NULL;
my_config = nullptr;
}
TermMsg();
CleanupCrypto();
Expand All @@ -343,7 +343,7 @@ static bool CheckResources()

LockRes(my_config);

me = (ClientResource*)my_config->GetNextRes(R_CLIENT, NULL);
me = (ClientResource*)my_config->GetNextRes(R_CLIENT, nullptr);
my_config->own_resource_ = me;
if (!me) {
Emsg1(M_FATAL, 0,
Expand All @@ -357,14 +357,14 @@ static bool CheckResources()
me->MaxConnections = (2 * me->MaxConcurrentJobs) + 2;
}

if (my_config->GetNextRes(R_CLIENT, (BareosResource*)me) != NULL) {
if (my_config->GetNextRes(R_CLIENT, (BareosResource*)me) != nullptr) {
Emsg1(M_FATAL, 0, _("Only one Client resource permitted in %s\n"),
configfile.c_str());
OK = false;
}
MyNameIs(0, NULL, me->resource_name_);
MyNameIs(0, nullptr, me->resource_name_);
if (!me->messages) {
me->messages = (MessagesResource*)my_config->GetNextRes(R_MSGS, NULL);
me->messages = (MessagesResource*)my_config->GetNextRes(R_MSGS, nullptr);
if (!me->messages) {
Emsg1(M_FATAL, 0, _("No Messages resource defined in %s\n"),
configfile.c_str());
Expand All @@ -373,7 +373,7 @@ static bool CheckResources()
}
if (me->pki_encrypt || me->pki_sign) {
#ifndef HAVE_CRYPTO
Jmsg(NULL, M_FATAL, 0,
Jmsg(nullptr, M_FATAL, 0,
_("PKI encryption/signing enabled but not compiled into Bareos.\n"));
OK = false;
#endif
Expand Down Expand Up @@ -408,8 +408,8 @@ static bool CheckResources()
OK = false;
}

if (!CryptoKeypairLoadKey(me->pki_keypair, me->pki_keypair_file, NULL,
NULL)) {
if (!CryptoKeypairLoadKey(me->pki_keypair, me->pki_keypair_file,
nullptr, nullptr)) {
Emsg2(M_FATAL, 0,
_("Failed to load private key for File"
" daemon \"%s\" in %s.\n"),
Expand Down Expand Up @@ -439,7 +439,8 @@ static bool CheckResources()

/* Attempt to load a private key, if available */
if (CryptoKeypairHasKey(filepath)) {
if (!CryptoKeypairLoadKey(keypair, filepath, NULL, NULL)) {
if (!CryptoKeypairLoadKey(keypair, filepath, nullptr,
nullptr)) {
Emsg3(M_FATAL, 0,
_("Failed to load private key from file %s for File"
" daemon \"%s\" in %s.\n"),
Expand Down Expand Up @@ -497,7 +498,7 @@ static bool CheckResources()

/* Verify that a director record exists */
LockRes(my_config);
director = (DirectorResource*)my_config->GetNextRes(R_DIRECTOR, NULL);
director = (DirectorResource*)my_config->GetNextRes(R_DIRECTOR, nullptr);
UnlockRes(my_config);
if (!director) {
Emsg1(M_FATAL, 0, _("No Director resource defined in %s\n"),
Expand All @@ -508,8 +509,8 @@ static bool CheckResources()
UnlockRes(my_config);

if (OK) {
CloseMsg(NULL); /* close temp message handler */
InitMsg(NULL, me->messages); /* open user specified message handler */
CloseMsg(nullptr); /* close temp message handler */
InitMsg(nullptr, me->messages); /* open user specified message handler */
if (me->secure_erase_cmdline) {
SetSecureEraseCmdline(me->secure_erase_cmdline);
}
Expand Down

0 comments on commit d342f8a

Please sign in to comment.