dovecot-2.2: Replaced (void)close(fd) and close_keep_errno() wit...

dovecot at dovecot.org dovecot at dovecot.org
Mon Jun 25 02:52:43 EEST 2012


details:   http://hg.dovecot.org/dovecot-2.2/rev/7c058aa05b0a
changeset: 14687:7c058aa05b0a
user:      Timo Sirainen <tss at iki.fi>
date:      Mon Jun 25 02:52:33 2012 +0300
description:
Replaced (void)close(fd) and close_keep_errno() with i_close_fd().
i_close_fd() preserves the errno and logs an error if the close() fails.

diffstat:

 src/auth/db-checkpassword.c                     |  16 ++++++++--------
 src/auth/db-passwd-file.c                       |   2 +-
 src/auth/mech-winbind.c                         |  14 +++++++-------
 src/config/config-parser.c                      |   2 +-
 src/config/sysinfo-get.c                        |   2 +-
 src/director/director-test.c                    |   2 +-
 src/doveadm/doveadm-dump-log.c                  |   2 +-
 src/doveadm/doveadm-dump-mailboxlog.c           |   2 +-
 src/doveadm/doveadm-instance.c                  |   2 +-
 src/doveadm/doveadm-master.c                    |   2 +-
 src/doveadm/doveadm-sis.c                       |   2 +-
 src/doveadm/doveadm-stats.c                     |   2 +-
 src/doveadm/dsync/doveadm-dsync.c               |  20 ++++++++++----------
 src/doveadm/dsync/dsync-slave-io.c              |   3 +--
 src/imap/main.c                                 |   2 +-
 src/lda/main.c                                  |   3 +--
 src/lib-dict/dict-file.c                        |  10 +++++-----
 src/lib-dns/dns-lookup.c                        |   2 +-
 src/lib-imap-client/imapc-client.c              |   2 +-
 src/lib-index/mail-cache-compress.c             |   5 ++---
 src/lib-index/mail-transaction-log.c            |   1 -
 src/lib-lda/smtp-client.c                       |   9 ++++-----
 src/lib-master/master-login.c                   |   2 +-
 src/lib-master/master-service-settings.c        |   6 +++---
 src/lib-master/mountpoint-list.c                |   4 ++--
 src/lib-settings/settings-parser.c              |   8 ++++----
 src/lib-storage/index/index-attachment.c        |   2 +-
 src/lib-storage/index/maildir/maildir-storage.c |   2 +-
 src/lib-storage/index/maildir/maildir-uidlist.c |   5 ++---
 src/lib-storage/index/mbox/mbox-file.c          |   2 +-
 src/lib-storage/index/mbox/mbox-lock.c          |   6 +++---
 src/lib-storage/index/mbox/mbox-storage.c       |   4 ++--
 src/lib-storage/index/pop3c/pop3c-client.c      |   3 +--
 src/lib-storage/list/mailbox-list-maildir.c     |   2 +-
 src/lib-storage/mailbox-uidvalidity.c           |   6 +++---
 src/lib/Makefile.am                             |   2 --
 src/lib/askpass.c                               |   2 +-
 src/lib/close-keep-errno.c                      |  13 -------------
 src/lib/close-keep-errno.h                      |   7 -------
 src/lib/failures.c                              |   6 +++---
 src/lib/fdatasync-path.c                        |   2 +-
 src/lib/file-copy.c                             |   4 ++--
 src/lib/file-dotlock.c                          |   6 +++---
 src/lib/ioloop-notify-dn.c                      |   4 ++--
 src/lib/ioloop-notify-kqueue.c                  |   2 +-
 src/lib/iostream-rawlog.c                       |   2 +-
 src/lib/istream-seekable.c                      |   5 ++---
 src/lib/macros.h                                |   8 ++++++++
 src/lib/network.c                               |  17 ++++++++---------
 src/lib/nfs-workarounds.c                       |   6 +++---
 src/lib/randgen.c                               |   2 +-
 src/lib/safe-mkstemp.c                          |   2 +-
 src/lib/test-ostream-file.c                     |   2 +-
 src/lib/unlink-directory.c                      |  13 ++++++-------
 src/lmtp/commands.c                             |   2 +-
 src/login-common/access-lookup.c                |   2 +-
 src/login-common/ssl-proxy-gnutls.c             |   2 +-
 src/master/main.c                               |   6 +++---
 src/master/service-listen.c                     |   4 ++--
 src/master/service-monitor.c                    |   2 +-
 src/master/service.c                            |   2 +-
 src/plugins/acl/acl-backend-vfile-acllist.c     |   2 +-
 src/plugins/acl/acl-backend-vfile.c             |   6 +++---
 src/plugins/fts-lucene/fts-backend-lucene.c     |   2 +-
 src/plugins/fts-squat/squat-trie.c              |   2 +-
 src/plugins/fts/doveadm-dump-fts-expunge-log.c  |   2 +-
 src/plugins/fts/fts-expunge-log.c               |   2 +-
 src/plugins/fts/fts-indexer.c                   |   2 +-
 src/plugins/fts/fts-parser-script.c             |   4 ++--
 src/plugins/quota/quota-maildir.c               |  10 +++++-----
 src/plugins/trash/trash-plugin.c                |   2 +-
 src/plugins/virtual/virtual-config.c            |   2 +-
 src/plugins/zlib/doveadm-zlib.c                 |   2 +-
 src/plugins/zlib/zlib-plugin.c                  |   2 +-
 src/pop3/main.c                                 |   2 +-
 src/ssl-params/ssl-params.c                     |   6 +++---
 src/util/gdbhelper.c                            |   2 +-
 src/util/rawlog.c                               |  12 ++++++------
 78 files changed, 161 insertions(+), 185 deletions(-)

diffs (truncated from 1576 to 300 lines):

diff -r 9ff19c1d5f69 -r 7c058aa05b0a src/auth/db-checkpassword.c
--- a/src/auth/db-checkpassword.c	Mon Jun 25 02:38:29 2012 +0300
+++ b/src/auth/db-checkpassword.c	Mon Jun 25 02:52:33 2012 +0300
@@ -473,8 +473,8 @@
 		auth_request_log_error(request, "checkpassword",
 				       "pipe() failed: %m");
 		if (fd_in[0] != -1) {
-			(void)close(fd_in[0]);
-			(void)close(fd_in[1]);
+			i_close_fd(fd_in[0]);
+			i_close_fd(fd_in[1]);
 		}
 		callback(request, DB_CHECKPASSWORD_STATUS_INTERNAL_FAILURE,
 			 NULL, request_callback);
@@ -485,10 +485,10 @@
 	if (pid == -1) {
 		auth_request_log_error(request, "checkpassword",
 				       "fork() failed: %m");
-		(void)close(fd_in[0]);
-		(void)close(fd_in[1]);
-		(void)close(fd_out[0]);
-		(void)close(fd_out[1]);
+		i_close_fd(fd_in[0]);
+		i_close_fd(fd_in[1]);
+		i_close_fd(fd_out[0]);
+		i_close_fd(fd_out[1]);
 		callback(request, DB_CHECKPASSWORD_STATUS_INTERNAL_FAILURE,
 			 NULL, request_callback);
 		return;
@@ -496,8 +496,8 @@
 
 	if (pid == 0) {
 		/* child */
-		(void)close(fd_in[0]);
-		(void)close(fd_out[1]);
+		i_close_fd(fd_in[0]);
+		i_close_fd(fd_out[1]);
 		checkpassword_exec(db, request, fd_in[1], fd_out[0],
 				   auth_password != NULL);
 		/* not reached */
diff -r 9ff19c1d5f69 -r 7c058aa05b0a src/auth/db-passwd-file.c
--- a/src/auth/db-passwd-file.c	Mon Jun 25 02:38:29 2012 +0300
+++ b/src/auth/db-passwd-file.c	Mon Jun 25 02:52:33 2012 +0300
@@ -184,7 +184,7 @@
 
 	if (fstat(fd, &st) != 0) {
 		i_error("passwd-file %s: fstat() failed: %m", pw->path);
-		(void)close(fd);
+		i_close_fd(fd);
 		return FALSE;
 	}
 
diff -r 9ff19c1d5f69 -r 7c058aa05b0a src/auth/mech-winbind.c
--- a/src/auth/mech-winbind.c	Mon Jun 25 02:38:29 2012 +0300
+++ b/src/auth/mech-winbind.c	Mon Jun 25 02:52:33 2012 +0300
@@ -111,15 +111,15 @@
 		return;
 	}
 	if (pipe(outfd) < 0) {
-		(void)close(infd[0]); (void)close(infd[1]);
+		i_close_fd(infd[0]); i_close_fd(infd[1]);
 		return;
 	}
 
 	pid = fork();
 	if (pid < 0) {
 		i_error("fork() failed: %m");
-		(void)close(infd[0]); (void)close(infd[1]);
-		(void)close(outfd[0]); (void)close(outfd[1]);
+		i_close_fd(infd[0]); i_close_fd(infd[1]);
+		i_close_fd(outfd[0]); i_close_fd(outfd[1]);
 		return;
 	}
 
@@ -127,8 +127,8 @@
 		/* child */
 		const char *args[3];
 
-		(void)close(infd[0]);
-		(void)close(outfd[1]);
+		i_close_fd(infd[0]);
+		i_close_fd(outfd[1]);
 
 		if (dup2(outfd[0], STDIN_FILENO) < 0 ||
 		    dup2(infd[1], STDOUT_FILENO) < 0)
@@ -141,8 +141,8 @@
 	}
 
 	/* parent */
-	(void)close(infd[1]);
-	(void)close(outfd[0]);
+	i_close_fd(infd[1]);
+	i_close_fd(outfd[0]);
 
 	winbind->pid = pid;
 	winbind->in_pipe =
diff -r 9ff19c1d5f69 -r 7c058aa05b0a src/config/config-parser.c
--- a/src/config/config-parser.c	Mon Jun 25 02:38:29 2012 +0300
+++ b/src/config/config-parser.c	Mon Jun 25 02:52:33 2012 +0300
@@ -439,7 +439,7 @@
 		*error_r = t_strdup_printf("%s: read(%s) failed: %m",
 					   key, path);
 	}
-	(void)close(fd);
+	i_close_fd(fd);
 	return ret < 0 ? -1 : 0;
 }
 
diff -r 9ff19c1d5f69 -r 7c058aa05b0a src/config/sysinfo-get.c
--- a/src/config/sysinfo-get.c	Mon Jun 25 02:38:29 2012 +0300
+++ b/src/config/sysinfo-get.c	Mon Jun 25 02:52:33 2012 +0300
@@ -21,7 +21,7 @@
 	if (fd == -1)
 		return FALSE;
 	ret = read(fd, buf, sizeof(buf));
-	(void)close(fd);
+	i_close_fd(fd);
 	if (ret <= 0)
 		return FALSE;
 
diff -r 9ff19c1d5f69 -r 7c058aa05b0a src/director/director-test.c
--- a/src/director/director-test.c	Mon Jun 25 02:38:29 2012 +0300
+++ b/src/director/director-test.c	Mon Jun 25 02:52:33 2012 +0300
@@ -338,7 +338,7 @@
 
 	out_fd = net_connect_ip(local_ip, DIRECTOR_OUT_PORT, NULL);
 	if (out_fd == -1) {
-		(void)close(in_fd);
+		i_close_fd(in_fd);
 		return;
 	}
 
diff -r 9ff19c1d5f69 -r 7c058aa05b0a src/doveadm/doveadm-dump-log.c
--- a/src/doveadm/doveadm-dump-log.c	Mon Jun 25 02:38:29 2012 +0300
+++ b/src/doveadm/doveadm-dump-log.c	Mon Jun 25 02:52:33 2012 +0300
@@ -509,7 +509,7 @@
 	    hdr.major_version == MAIL_TRANSACTION_LOG_MAJOR_VERSION &&
 	    hdr.hdr_size >= MAIL_TRANSACTION_LOG_HEADER_MIN_SIZE)
 		ret = TRUE;
-	(void)close(fd);
+	i_close_fd(fd);
 	return ret;
 }
 
diff -r 9ff19c1d5f69 -r 7c058aa05b0a src/doveadm/doveadm-dump-mailboxlog.c
--- a/src/doveadm/doveadm-dump-mailboxlog.c	Mon Jun 25 02:38:29 2012 +0300
+++ b/src/doveadm/doveadm-dump-mailboxlog.c	Mon Jun 25 02:52:33 2012 +0300
@@ -100,7 +100,7 @@
 			break;
 		}
 	}
-	(void)close(fd);
+	i_close_fd(fd);
 	return ret;
 }
 
diff -r 9ff19c1d5f69 -r 7c058aa05b0a src/doveadm/doveadm-instance.c
--- a/src/doveadm/doveadm-instance.c	Mon Jun 25 02:38:29 2012 +0300
+++ b/src/doveadm/doveadm-instance.c	Mon Jun 25 02:52:33 2012 +0300
@@ -39,7 +39,7 @@
 				  (kill(pid, 0) < 0 && errno == ESRCH));
 		}
 	}
-	(void)close(fd);
+	i_close_fd(fd);
 	return found;
 }
 
diff -r 9ff19c1d5f69 -r 7c058aa05b0a src/doveadm/doveadm-master.c
--- a/src/doveadm/doveadm-master.c	Mon Jun 25 02:38:29 2012 +0300
+++ b/src/doveadm/doveadm-master.c	Mon Jun 25 02:52:33 2012 +0300
@@ -41,7 +41,7 @@
 				  (kill(*pid_r, 0) < 0 && errno == ESRCH));
 		}
 	}
-	(void)close(fd);
+	i_close_fd(fd);
 	return found;
 }
 
diff -r 9ff19c1d5f69 -r 7c058aa05b0a src/doveadm/doveadm-sis.c
--- a/src/doveadm/doveadm-sis.c	Mon Jun 25 02:38:29 2012 +0300
+++ b/src/doveadm/doveadm-sis.c	Mon Jun 25 02:52:33 2012 +0300
@@ -48,7 +48,7 @@
 	if (fd1 == -1) {
 		if (errno != ENOENT)
 			i_error("open(%s) failed: %m", path2);
-		(void)close(fd1);
+		i_close_fd(fd1);
 		return -1;
 	}
 
diff -r 9ff19c1d5f69 -r 7c058aa05b0a src/doveadm/doveadm-stats.c
--- a/src/doveadm/doveadm-stats.c	Mon Jun 25 02:38:29 2012 +0300
+++ b/src/doveadm/doveadm-stats.c	Mon Jun 25 02:52:33 2012 +0300
@@ -496,7 +496,7 @@
 	array_free(&ctx.lines);
 	pool_unref(&ctx.prev_pool);
 	pool_unref(&ctx.cur_pool);
-	(void)close(ctx.fd);
+	i_close_fd(ctx.fd);
 }
 
 static void cmd_stats_top(int argc, char *argv[])
diff -r 9ff19c1d5f69 -r 7c058aa05b0a src/doveadm/dsync/doveadm-dsync.c
--- a/src/doveadm/dsync/doveadm-dsync.c	Mon Jun 25 02:38:29 2012 +0300
+++ b/src/doveadm/dsync/doveadm-dsync.c	Mon Jun 25 02:52:33 2012 +0300
@@ -79,12 +79,12 @@
 		    dup2(fd_err[1], STDERR_FILENO) < 0)
 			i_fatal("dup2() failed: %m");
 
-		(void)close(fd_in[0]);
-		(void)close(fd_in[1]);
-		(void)close(fd_out[0]);
-		(void)close(fd_out[1]);
-		(void)close(fd_err[0]);
-		(void)close(fd_err[1]);
+		i_close_fd(fd_in[0]);
+		i_close_fd(fd_in[1]);
+		i_close_fd(fd_out[0]);
+		i_close_fd(fd_out[1]);
+		i_close_fd(fd_err[0]);
+		i_close_fd(fd_err[1]);
 
 		execvp_const(args[0], args);
 	default:
@@ -92,9 +92,9 @@
 		break;
 	}
 
-	(void)close(fd_in[0]);
-	(void)close(fd_out[1]);
-	(void)close(fd_err[1]);
+	i_close_fd(fd_in[0]);
+	i_close_fd(fd_out[1]);
+	i_close_fd(fd_err[1]);
 	ctx->fd_in = fd_out[0];
 	ctx->fd_out = fd_in[1];
 	ctx->fd_err = fd_err[0];
@@ -363,7 +363,7 @@
 	if (ctx->io_err != NULL)
 		io_remove(&ctx->io_err);
 	if (ctx->fd_err != -1) {
-		(void)close(ctx->fd_err);
+		i_close_fd(ctx->fd_err);
 		ctx->fd_err = -1;
 	}
 	return ret;
diff -r 9ff19c1d5f69 -r 7c058aa05b0a src/doveadm/dsync/dsync-slave-io.c
--- a/src/doveadm/dsync/dsync-slave-io.c	Mon Jun 25 02:38:29 2012 +0300
+++ b/src/doveadm/dsync/dsync-slave-io.c	Mon Jun 25 02:52:33 2012 +0300
@@ -2,7 +2,6 @@
 
 #include "lib.h"
 #include "array.h"
-#include "close-keep-errno.h"
 #include "fd-set-nonblock.h"
 #include "safe-mkstemp.h"
 #include "ioloop.h"
@@ -1366,7 +1365,7 @@
 	if (unlink(str_c(path)) < 0) {
 		/* shouldn't happen.. */
 		i_error("unlink(%s) failed: %m", str_c(path));
-		close_keep_errno(fd);
+		i_close_fd(fd);
 		return -1;
 	}
 
diff -r 9ff19c1d5f69 -r 7c058aa05b0a src/imap/main.c
--- a/src/imap/main.c	Mon Jun 25 02:38:29 2012 +0300
+++ b/src/imap/main.c	Mon Jun 25 02:52:33 2012 +0300
@@ -277,7 +277,7 @@
 				i_error("write(client) failed: %m");
 		}
 		i_error("%s", error);
-		(void)close(client->fd);
+		i_close_fd(client->fd);
 		master_service_client_connection_destroyed(master_service);
 	}
 }
diff -r 9ff19c1d5f69 -r 7c058aa05b0a src/lda/main.c
--- a/src/lda/main.c	Mon Jun 25 02:38:29 2012 +0300
+++ b/src/lda/main.c	Mon Jun 25 02:52:33 2012 +0300
@@ -4,7 +4,6 @@
 #include "lib-signals.h"
 #include "env-util.h"
 #include "fd-set-nonblock.h"
-#include "close-keep-errno.h"
 #include "istream.h"
 #include "istream-seekable.h"
 #include "abspath.h"
@@ -102,7 +101,7 @@
 	if (unlink(str_c(path)) < 0) {
 		/* shouldn't happen.. */
 		i_error("unlink(%s) failed: %m", str_c(path));
-		close_keep_errno(fd);
+		i_close_fd(fd);
 		return -1;
 	}
 


More information about the dovecot-cvs mailing list