All of lore.kernel.org
 help / color / mirror / Atom feed
From: Zdenek Kabelac <zkabelac@sourceware.org>
To: lvm-devel@redhat.com
Subject: main - cov: use different variable name
Date: Mon, 20 Sep 2021 13:30:05 +0000 (GMT)	[thread overview]
Message-ID: <20210920133005.58F873858C3B@sourceware.org> (raw)

Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=825e49a2447810a806905723bc91072eb7b8b423
Commit:        825e49a2447810a806905723bc91072eb7b8b423
Parent:        376e7072323bc394341c7b9a43a7ca51c2b9e400
Author:        Zdenek Kabelac <zkabelac@redhat.com>
AuthorDate:    Sun Sep 19 20:25:58 2021 +0200
Committer:     Zdenek Kabelac <zkabelac@redhat.com>
CommitterDate: Mon Sep 20 14:26:09 2021 +0200

cov: use different variable name

Better for Coverity to see no change for possibly opened handle.
---
 libdaemon/server/daemon-server.c | 12 ++++++------
 libdm/dm-tools/dmfilemapd.c      |  8 ++++----
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/libdaemon/server/daemon-server.c b/libdaemon/server/daemon-server.c
index 1e900261c..aeb1870a3 100644
--- a/libdaemon/server/daemon-server.c
+++ b/libdaemon/server/daemon-server.c
@@ -326,7 +326,7 @@ static void _remove_lockfile(const char *file)
 static void _daemonise(daemon_state s)
 {
 	int child_status;
-	int fd;
+	int fd, ffd;
 	pid_t pid;
 	struct rlimit rlim;
 	struct timeval tval;
@@ -394,17 +394,17 @@ static void _daemonise(daemon_state s)
 
 	/* Switch to sysconf(_SC_OPEN_MAX) ?? */
 	if (getrlimit(RLIMIT_NOFILE, &rlim) < 0)
-		fd = 256; /* just have to guess */
+		ffd = 256; /* just have to guess */
 	else
-		fd = rlim.rlim_cur;
+		ffd = rlim.rlim_cur;
 
-	for (--fd; fd > STDERR_FILENO; fd--) {
+	for (--ffd; ffd > STDERR_FILENO; ffd--) {
 #ifdef __linux__
 		/* Do not close fds preloaded by systemd! */
-		if (_systemd_activation && fd == SD_FD_SOCKET_SERVER)
+		if (_systemd_activation && ffd == SD_FD_SOCKET_SERVER)
 			continue;
 #endif
-		(void) close(fd);
+		(void) close(ffd);
 	}
 
 	setsid();
diff --git a/libdm/dm-tools/dmfilemapd.c b/libdm/dm-tools/dmfilemapd.c
index 2a86810ed..3799efd83 100644
--- a/libdm/dm-tools/dmfilemapd.c
+++ b/libdm/dm-tools/dmfilemapd.c
@@ -629,7 +629,7 @@ check_unlinked:
 static int _daemonise(struct filemap_monitor *fm)
 {
 	pid_t pid = 0;
-	int fd;
+	int fd, ffd;
 
 	if (!setsid()) {
 		_early_log("setsid failed.");
@@ -670,10 +670,10 @@ static int _daemonise(struct filemap_monitor *fm)
 			(void) close(fd);
 	}
 	/* TODO: Use libdaemon/server/daemon-server.c _daemonise() */
-	for (fd = (int) sysconf(_SC_OPEN_MAX) - 1; fd > STDERR_FILENO; fd--) {
-		if (fd == fm->fd)
+	for (ffd = (int) sysconf(_SC_OPEN_MAX) - 1; ffd > STDERR_FILENO; --ffd) {
+		if (ffd == fm->fd)
 			continue;
-		(void) close(fd);
+		(void) close(ffd);
 	}
 
 	return 1;



                 reply	other threads:[~2021-09-20 13:30 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210920133005.58F873858C3B@sourceware.org \
    --to=zkabelac@sourceware.org \
    --cc=lvm-devel@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.