summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSadie Powell <sadie@witchery.services>2024-11-07 19:34:46 +0000
committerSadie Powell <sadie@witchery.services>2024-11-07 19:34:46 +0000
commit1393518555769efebf39ffaa56508ac767dff703 (patch)
treef59f76ae6cbe3616e726374df22346f9e745bb80 /src
parent51827b94ad11e6fd21b661127e4036e4a211aabe (diff)
Fix some compiler warnings from not checking chdir.
Diffstat (limited to 'src')
-rw-r--r--src/init.cpp2
-rw-r--r--src/main.cpp12
2 files changed, 8 insertions, 6 deletions
diff --git a/src/init.cpp b/src/init.cpp
index 309bb3117..8e79bd5bb 100644
--- a/src/init.cpp
+++ b/src/init.cpp
@@ -427,7 +427,7 @@ bool Anope::Init(int ac, char **av)
/* Chdir to Anope data directory. */
Log() << "Moving to " << Anope::ServicesDir;
- if (chdir(Anope::ServicesDir.c_str()) < 0)
+ if (chdir(Anope::ServicesDir.c_str()) != 0)
{
throw CoreException("Unable to chdir to " + Anope::ServicesDir + ": " + Anope::LastError());
}
diff --git a/src/main.cpp b/src/main.cpp
index 7a18a26d1..ddd8a3a6e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -217,11 +217,13 @@ int main(int ac, char **av, char **envp)
if (Anope::Restarting)
{
- chdir(BinaryDir.c_str());
- Anope::string sbin = "./" + Anope::ServicesBin;
- av[0] = const_cast<char *>(sbin.c_str());
- execve(Anope::ServicesBin.c_str(), av, envp);
- Log() << "Restart failed";
+ if (chdir(BinaryDir.c_str()) != 0)
+ {
+ Anope::string sbin = "./" + Anope::ServicesBin;
+ av[0] = const_cast<char *>(sbin.c_str());
+ execve(Anope::ServicesBin.c_str(), av, envp);
+ }
+ Log() << "Restart failed: " << strerror(errno);
Anope::ReturnValue = -1;
}