From 372403760c4adeff5614e795cab879e173c361e8 Mon Sep 17 00:00:00 2001 From: Markus Makela Date: Mon, 24 Aug 2015 16:13:06 +0300 Subject: [PATCH] Cleaned up code. --- server/core/gateway.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/core/gateway.c b/server/core/gateway.c index c5107b3bd..86dc9e051 100644 --- a/server/core/gateway.c +++ b/server/core/gateway.c @@ -2064,7 +2064,7 @@ bool pid_file_exists() print_log_n_stderr(true, true, logbuf, logbuf, errno); return true; } - if(flock(fd,LOCK_EX|LOCK_NB) != 0) + if(flock(fd,LOCK_EX|LOCK_NB)) { close(fd); char* logerr = "Failed to lock PID file '%s'."; @@ -2158,14 +2158,14 @@ static int write_pid_file() { int fd = -1; snprintf(pidfile, PATH_MAX, "%s/maxscale.pid",get_piddir()); fd = open(pidfile, O_WRONLY | O_CREAT | O_TRUNC, 0777); - if (fd == -1 && errno != ENOENT) { + if (fd == -1) { char* logerr = "Failed to open PID file '%s'."; snprintf(logbuf,sizeof(logbuf),logerr,pidfile); print_log_n_stderr(true, true, logbuf, logbuf, errno); return -1; } - if(flock(fd,LOCK_EX|LOCK_NB) != 0) + if(flock(fd,LOCK_EX|LOCK_NB)) { char* logerr = "Failed to lock PID file '%s'."; snprintf(logbuf,sizeof(logbuf),logerr,pidfile); @@ -2177,7 +2177,7 @@ static int write_pid_file() { } /* truncate pidfile content */ - if (ftruncate(pidfd, 0) == -1) { + if (ftruncate(pidfd, 0)) { fprintf(stderr, "MaxScale failed to truncate pidfile %s: error %d, %s\n", pidfile, errno, strerror(errno)); unlock_pidfile(); return -1;