Skip to contentSkip to conversation

main - cov: ignore leak of fd descriptor

PATCH Zdenek Kabelac 1 participant 1 message Sep 21, 2021

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=b0d40109a67a99bf568c168a31f37955a07d7da4
Commit:        b0d40109a67a99bf568c168a31f37955a07d7da4
Parent:        e6d35874827f14d392c4ba4f8608eb0444230c7b
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Tue Sep 21 20:20:53 2021 +0200
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Tue Sep 21 21:03:47 2021 +0200

cov: ignore leak of fd descriptor

There is no 'fd' leak.

---
 libdm/dm-tools/dmfilemapd.c | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)
libdm/dm-tools/dmfilemapd.c +4 -5
index d7ca71d7e..d547e59d5 100644
@@ -671,12 +671,11 @@ static int _daemonise(struct filemap_monitor *fm)
 			(void) close(fd);
 	}
 	/* TODO: Use libdaemon/server/daemon-server.c _daemonise() */
-	for (ffd = (int) sysconf(_SC_OPEN_MAX) - 1; ffd > STDERR_FILENO; --ffd) {
-		if (ffd == fm->fd)
-			continue;
-		(void) close(ffd);
-	}
+	for (ffd = (int) sysconf(_SC_OPEN_MAX) - 1; ffd > STDERR_FILENO; --ffd)
+		if (ffd != fm->fd)
+			(void) close(ffd);
 
+	/* coverity[leaked_handle] no leak */
 	return 1;
 }