From c2d0ed0d12cf9756664f68c1ebd4c3f569b6a9d4 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Thu, 9 Jul 2015 01:59:10 +0200 Subject: [PATCH] Fix minor issues in pidfile_read() and pidfile_signal(), caught by Coverity - Simplify pidfile_read(), no need to call access() when fopen() is more than capable of failing on its own if we do not have READ access. - The remove() syscall requires that you check the return value, but we don't care about that when having signalled a TERM signal to a process. Signed-off-by: Joachim Nilsson --- pidfilefn.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/pidfilefn.c b/pidfilefn.c index e8c686f..91adccb 100644 --- a/pidfilefn.c +++ b/pidfilefn.c @@ -19,7 +19,6 @@ #include #include #include -#include extern char *chomp(char *str); @@ -46,9 +45,6 @@ int pidfile_read(const char *pidfile) return -1; } - if (access(pidfile, F_OK) < 0) - return -1; - fp = fopen(pidfile, "r"); if (!fp) return -1; @@ -89,7 +85,7 @@ int pidfile_signal(const char *pidfile, int signal) ret = kill(pid, signal); if ((ret == -1) || (signal == SIGTERM) || (signal == SIGKILL)) - remove(pidfile); + (void)remove(pidfile); return 0; }