From: Vladimír Čunát Date: Mon, 6 May 2019 12:37:12 +0000 (+0200) Subject: main() nitpick: deduplicate a bit of code X-Git-Tag: v4.1.0~21^2~3 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=12c307e4a18866dbb62efdc5cb7cb584e4ee8451;p=thirdparty%2Fknot-resolver.git main() nitpick: deduplicate a bit of code --- diff --git a/daemon/main.c b/daemon/main.c index 764ab4fea..83d101bb3 100644 --- a/daemon/main.c +++ b/daemon/main.c @@ -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; } }