]> git.ipfire.org Git - thirdparty/knot-resolver.git/commitdiff
main() nitpick: deduplicate a bit of code
authorVladimír Čunát <vladimir.cunat@nic.cz>
Mon, 6 May 2019 12:37:12 +0000 (14:37 +0200)
committerVladimír Čunát <vladimir.cunat@nic.cz>
Thu, 13 Jun 2019 13:03:15 +0000 (15:03 +0200)
daemon/main.c

index 764ab4feab3581b1f7f65ab45951ee79b8faf676..83d101bb36a2abd725e92a342846ef8dfaf9a668 100644 (file)
@@ -722,13 +722,10 @@ int main(int argc, char **argv)
        /* Switch to rundir. */
        if (args.rundir != NULL) {
                /* FIXME: access isn't a good way if we start as root and drop privileges later */
-               if (access(args.rundir, W_OK) != 0) {
-                       kr_log_error("[system] rundir '%s': %s\n", args.rundir, strerror(errno));
-                       return EXIT_FAILURE;
-               }
-               ret = chdir(args.rundir);
-               if (ret != 0) {
-                       kr_log_error("[system] rundir '%s': %s\n", args.rundir, strerror(errno));
+               if (access(args.rundir, W_OK) != 0
+                   || chdir(args.rundir) != 0) {
+                       kr_log_error("[system] rundir '%s': %s\n",
+                                       args.rundir, strerror(errno));
                        return EXIT_FAILURE;
                }
        }