Silence clang-tidy warnings about atoi(getenv())
[tinc] / src / tincd.c
index 8a4c1f3..db71983 100644 (file)
@@ -57,6 +57,7 @@
 #include "random.h"
 #include "sandbox.h"
 #include "watchdog.h"
+#include "fs.h"
 
 /* If nonzero, display usage information and exit. */
 static bool show_help = false;
@@ -415,7 +416,9 @@ static bool drop_privs(void) {
                        return false;
                }
 
-#endif
+#endif // HAVE_WINDOWS
+
+       makedirs(DIR_CACHE | DIR_HOSTS | DIR_INVITATIONS);
 
        return sandbox_enter();
 }
@@ -560,7 +563,9 @@ int main(int argc, char **argv) {
 
        g_argv = argv;
 
-       if(getenv("LISTEN_PID") && atoi(getenv("LISTEN_PID")) == getpid()) {
+       const char *listen_pid = getenv("LISTEN_PID");
+
+       if(listen_pid && atoi(listen_pid) == getpid()) {
                do_detach = false;
        }