From: Vincent Bernat Date: Sun, 21 Mar 2021 11:05:16 +0000 (+0100) Subject: daemon: annotate "daemonisation" to help Coverity X-Git-Tag: 1.0.9~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2e304488fac220fa205780a80533a2b955ee6b6d;p=thirdparty%2Flldpd.git daemon: annotate "daemonisation" to help Coverity When daemonizing, we need to use /dev/null for stdin, stdout, and stderr. If one of these file descriptors happen to be already closed, we need to close the new file descriptor only if > 2. This is confusing confusing for Coverity, annotate it correctly. Not all locations are annotated because not all of them are detected, for some reason. --- diff --git a/src/compat/daemon.c b/src/compat/daemon.c index 18f3d8d5..79e0bb6f 100644 --- a/src/compat/daemon.c +++ b/src/compat/daemon.c @@ -62,5 +62,7 @@ daemon(int nochdir, int noclose) if (fd > 2) (void)close (fd); } + /* coverity[resource_leak] + fd may be leaked if < 2, it's expected */ return (0); } diff --git a/src/daemon/lldpd.c b/src/daemon/lldpd.c index 5dd2413a..1fc26db8 100644 --- a/src/daemon/lldpd.c +++ b/src/daemon/lldpd.c @@ -1743,6 +1743,8 @@ lldpd_main(int argc, char *argv[], char *envp[]) dup2(fd, STDERR_FILENO); if (fd > 2) close(fd); } + /* coverity[resource_leak] + fd may be leaked if < 2, it's expected */ } log_debug("main", "lldpd " PACKAGE_VERSION " starting..."); version_check();