dovecot-2.2-pigeonhole: Use the new [io]_stream_create_fd_*autoc...

pigeonhole at rename-it.nl pigeonhole at rename-it.nl
Tue Jun 17 20:14:05 UTC 2014


details:   http://hg.rename-it.nl/dovecot-2.2-pigeonhole/rev/f81d25ef0e66
changeset: 1870:f81d25ef0e66
user:      Stephan Bosch <stephan at rename-it.nl>
date:      Tue Jun 17 22:13:52 2014 +0200
description:
Use the new [io]_stream_create_fd_*autoclose() functions wherever possible.
Parallel to identical Dovecot change.

diffstat:

 src/lib-sieve-tool/sieve-tool.c      |  2 +-
 src/lib-sieve/sieve-script-file.c    |  4 ++--
 src/lib-sieve/sieve-script-private.h |  2 --
 src/testsuite/testsuite-smtp.c       |  2 +-
 4 files changed, 4 insertions(+), 6 deletions(-)

diffs (56 lines):

diff -r e547bdec932f -r f81d25ef0e66 src/lib-sieve-tool/sieve-tool.c
--- a/src/lib-sieve-tool/sieve-tool.c	Tue Jun 17 20:58:23 2014 +0200
+++ b/src/lib-sieve-tool/sieve-tool.c	Tue Jun 17 22:13:52 2014 +0200
@@ -515,7 +515,7 @@
 			i_fatal("failed to open file for writing: %m");
 		}
 
-		outstream = o_stream_create_fd(fd, 0, TRUE);
+		outstream = o_stream_create_fd_autoclose(&fd, 0);
 	}
 
 	return outstream;
diff -r e547bdec932f -r f81d25ef0e66 src/lib-sieve/sieve-script-file.c
--- a/src/lib-sieve/sieve-script-file.c	Tue Jun 17 20:58:23 2014 +0200
+++ b/src/lib-sieve/sieve-script-file.c	Tue Jun 17 22:13:52 2014 +0200
@@ -286,14 +286,14 @@
 			*error_r = SIEVE_ERROR_TEMP_FAILURE;
 			result = NULL;
 		} else {
-			result = i_stream_create_fd(fd, SIEVE_FILE_READ_BLOCK_SIZE, TRUE);
+			result = i_stream_create_fd_autoclose(&fd, SIEVE_FILE_READ_BLOCK_SIZE);
 			script->st = script->lnk_st = st;
 		}
 	}
 
 	if ( result == NULL ) {
 		/* Something went wrong, close the fd */
-		if ( close(fd) != 0 ) {
+		if ( fd >= 0 && close(fd) != 0 ) {
 			sieve_sys_error(svinst,
 				"failed to close sieve script: close(fd=%s) failed: %m", script->path);
 		}
diff -r e547bdec932f -r f81d25ef0e66 src/lib-sieve/sieve-script-private.h
--- a/src/lib-sieve/sieve-script-private.h	Tue Jun 17 20:58:23 2014 +0200
+++ b/src/lib-sieve/sieve-script-private.h	Tue Jun 17 22:13:52 2014 +0200
@@ -89,8 +89,6 @@
 	const char *filename;
 	const char *binpath;
 	const char *binprefix;
-
-	int fd;
 };
 
 extern const struct sieve_script sieve_file_script;
diff -r e547bdec932f -r f81d25ef0e66 src/testsuite/testsuite-smtp.c
--- a/src/testsuite/testsuite-smtp.c	Tue Jun 17 20:58:23 2014 +0200
+++ b/src/testsuite/testsuite-smtp.c	Tue Jun 17 22:13:52 2014 +0200
@@ -95,7 +95,7 @@
 			smtp->msg_file);
 	}
 
-	smtp->output = o_stream_create_fd(fd, (size_t)-1, TRUE);
+	smtp->output = o_stream_create_fd_autoclose(&fd, (size_t)-1);
 
 	return (void *) smtp;
 }


More information about the dovecot-cvs mailing list