dovecot-2.2: Replaced unlink() calls with i_unlink*() wherever p...
dovecot at dovecot.org
dovecot at dovecot.org
Tue Sep 8 16:08:34 UTC 2015
details: http://hg.dovecot.org/dovecot-2.2/rev/fefaa6d09a81
changeset: 19136:fefaa6d09a81
user: Timo Sirainen <tss at iki.fi>
date: Tue Sep 08 19:07:02 2015 +0300
description:
Replaced unlink() calls with i_unlink*() wherever possible.
diffstat:
src/auth/auth-token.c | 12 ++----
src/doveadm/doveadm-sis.c | 12 ++----
src/doveadm/dsync/dsync-brain.c | 3 +-
src/doveadm/dsync/dsync-ibc-stream.c | 3 +-
src/lda/main.c | 3 +-
src/lib-compression/test-compression.c | 3 +-
src/lib-fs/fs-posix.c | 3 +-
src/lib-imap-client/imapc-client.c | 3 +-
src/lib-imap-urlauth/imap-urlauth-connection.c | 3 +-
src/lib-index/mail-cache-compress.c | 3 +-
src/lib-index/mail-cache.c | 2 +-
src/lib-index/mail-index-strmap.c | 6 +-
src/lib-index/mail-index-transaction.c | 3 +-
src/lib-index/mail-index.c | 4 +-
src/lib-index/mailbox-log.c | 3 +-
src/lib-index/test-mail-transaction-log-append.c | 2 +-
src/lib-lda/duplicate.c | 6 +--
src/lib-lda/smtp-client.c | 3 +-
src/lib-mail/test-istream-attachment.c | 2 +-
src/lib-master/mountpoint-list.c | 2 +-
src/lib-storage/index/dbox-common/dbox-file-fix.c | 6 +--
src/lib-storage/index/dbox-common/dbox-storage.c | 3 +-
src/lib-storage/index/dbox-multi/mdbox-storage-rebuild.c | 3 +-
src/lib-storage/index/dbox-single/sdbox-file.c | 8 ++--
src/lib-storage/index/index-mail-binary.c | 3 +-
src/lib-storage/index/maildir/maildir-keywords.c | 2 +-
src/lib-storage/index/maildir/maildir-save.c | 2 +-
src/lib-storage/index/maildir/maildir-uidlist.c | 2 +-
src/lib-storage/index/pop3c/pop3c-client.c | 3 +-
src/lib-storage/mailbox-uidvalidity.c | 3 +-
src/lib/file-copy.c | 6 +--
src/lib/file-create-locked.c | 6 +--
src/lib/file-dotlock.c | 31 ++++-----------
src/lib/iostream-rawlog.c | 2 +-
src/lib/iostream-temp.c | 3 +-
src/lib/istream-seekable.c | 3 +-
src/lib/net.c | 3 +-
src/lib/safe-mkstemp.c | 2 +-
src/lib/test-istream-seekable.c | 2 +-
src/lib/test-ostream-file.c | 3 +-
src/lib/unlink-old-files.c | 3 +-
src/lmtp/commands.c | 3 +-
src/login-common/ssl-proxy-gnutls.c | 8 ++--
src/master/main.c | 9 +---
src/master/master-settings.c | 3 +-
src/master/service-listen.c | 5 +--
src/plugins/acl/acl-backend-vfile-acllist.c | 9 +---
src/plugins/fts-squat/squat-test.c | 4 +-
src/plugins/fts-squat/squat-trie.c | 6 +--
src/plugins/fts-squat/squat-uidlist.c | 9 +---
src/plugins/fts/fts-expunge-log.c | 10 ++---
src/plugins/mail-filter/mail-filter-plugin.c | 3 +-
src/plugins/quota/quota-maildir.c | 6 +--
src/ssl-params/ssl-params.c | 2 +-
54 files changed, 91 insertions(+), 166 deletions(-)
diffs (truncated from 989 to 300 lines):
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/auth/auth-token.c
--- a/src/auth/auth-token.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/auth/auth-token.c Tue Sep 08 19:07:02 2015 +0300
@@ -57,8 +57,7 @@
if (st.st_size != AUTH_TOKEN_SECRET_LEN || !S_ISREG(st.st_mode)) {
i_error("Corrupted token secret file: %s", path);
i_close_fd(&fd);
- if (unlink(path) < 0)
- i_error("unlink(%s) failed: %m", path);
+ i_unlink(path);
return -1;
}
@@ -76,8 +75,7 @@
!CMP_DEV_T(st.st_dev, lst.st_dev)) {
i_error("Compromised token secret file: %s", path);
i_close_fd(&fd);
- if (unlink(path) < 0)
- i_error("unlink(%s) failed: %m", path);
+ i_unlink(path);
return -1;
}
@@ -126,15 +124,13 @@
}
if (ret < 0) {
- if (unlink(temp_path) < 0)
- i_error("unlink(%s) failed: %m", temp_path);
+ i_unlink(temp_path);
return -1;
}
if (rename(temp_path, path) < 0) {
i_error("rename(%s, %s) failed: %m", temp_path, path);
- if (unlink(temp_path) < 0)
- i_error("unlink(%s) failed: %m", temp_path);
+ i_unlink(temp_path);
return -1;
}
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/doveadm/doveadm-sis.c
--- a/src/doveadm/doveadm-sis.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/doveadm/doveadm-sis.c Tue Sep 08 19:07:02 2015 +0300
@@ -118,14 +118,12 @@
return -1;
}
if (st.st_ino != src_inode) {
- if (unlink(tmppath) < 0)
- i_error("unlink(%s) failed: %m", tmppath);
+ i_unlink(tmppath);
return 0;
}
if (rename(tmppath, dest) < 0) {
i_error("rename(%s, %s) failed: %m", src, tmppath);
- if (unlink(tmppath) < 0)
- i_error("unlink(%s) failed: %m", tmppath);
+ i_unlink(tmppath);
return -1;
}
return 1;
@@ -258,10 +256,8 @@
T_BEGIN {
ret = sis_try_deduplicate(rootdir, d->d_name);
} T_END;
- if (ret == 0) {
- if (unlink(str_c(path)) < 0)
- i_error("unlink(%s) failed: %m", str_c(path));
- }
+ if (ret == 0)
+ i_unlink(str_c(path));
}
if (closedir(dir) < 0)
i_error("closedir(%s) failed: %m", queuedir);
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/doveadm/dsync/dsync-brain.c
--- a/src/doveadm/dsync/dsync-brain.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/doveadm/dsync/dsync-brain.c Tue Sep 08 19:07:02 2015 +0300
@@ -332,8 +332,7 @@
if (brain->lock_fd != -1) {
/* unlink the lock file before it gets unlocked */
- if (unlink(brain->lock_path) < 0)
- i_error("unlink(%s) failed: %m", brain->lock_path);
+ i_unlink(brain->lock_path);
file_lock_free(&brain->lock);
i_close_fd(&brain->lock_fd);
}
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/doveadm/dsync/dsync-ibc-stream.c
--- a/src/doveadm/dsync/dsync-ibc-stream.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/doveadm/dsync/dsync-ibc-stream.c Tue Sep 08 19:07:02 2015 +0300
@@ -467,9 +467,8 @@
}
/* we just want the fd, unlink it */
- if (unlink(str_c(path)) < 0) {
+ if (i_unlink(str_c(path)) < 0) {
/* shouldn't happen.. */
- i_error("unlink(%s) failed: %m", str_c(path));
i_close_fd(&fd);
return -1;
}
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/lda/main.c
--- a/src/lda/main.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/lda/main.c Tue Sep 08 19:07:02 2015 +0300
@@ -98,9 +98,8 @@
}
/* we just want the fd, unlink it */
- if (unlink(str_c(path)) < 0) {
+ if (i_unlink(str_c(path)) < 0) {
/* shouldn't happen.. */
- i_error("unlink(%s) failed: %m", str_c(path));
i_close_fd(&fd);
return -1;
}
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/lib-compression/test-compression.c
--- a/src/lib-compression/test-compression.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/lib-compression/test-compression.c Tue Sep 08 19:07:02 2015 +0300
@@ -80,8 +80,7 @@
sha1_result(&sha1, input_sha1);
test_assert(memcmp(input_sha1, output_sha1, sizeof(input_sha1)) == 0);
- if (unlink(path) < 0)
- i_error("unlink(%s) failed: %m", path);
+ i_unlink(path);
test_end();
}
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/lib-fs/fs-posix.c
--- a/src/lib-fs/fs-posix.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/lib-fs/fs-posix.c Tue Sep 08 19:07:02 2015 +0300
@@ -630,8 +630,7 @@
ret = link(src->full_path, dest->full_path);
if (errno == EEXIST && dest->open_mode == FS_OPEN_MODE_REPLACE) {
/* destination file already exists - replace it */
- if (unlink(dest->full_path) < 0 && errno != ENOENT)
- i_error("unlink(%s) failed: %m", dest->full_path);
+ i_unlink_if_exists(dest->full_path);
ret = link(src->full_path, dest->full_path);
}
while (ret < 0 && errno == ENOENT &&
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/lib-imap-client/imapc-client.c
--- a/src/lib-imap-client/imapc-client.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/lib-imap-client/imapc-client.c Tue Sep 08 19:07:02 2015 +0300
@@ -460,9 +460,8 @@
}
/* we just want the fd, unlink it */
- if (unlink(str_c(path)) < 0) {
+ if (i_unlink(str_c(path)) < 0) {
/* shouldn't happen.. */
- i_error("unlink(%s) failed: %m", str_c(path));
i_close_fd(&fd);
return -1;
}
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/lib-imap-urlauth/imap-urlauth-connection.c
--- a/src/lib-imap-urlauth/imap-urlauth-connection.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/lib-imap-urlauth/imap-urlauth-connection.c Tue Sep 08 19:07:02 2015 +0300
@@ -493,9 +493,8 @@
}
/* we just want the fd, unlink it */
- if (unlink(str_c(path)) < 0) {
+ if (i_unlink(str_c(path)) < 0) {
/* shouldn't happen.. */
- i_error("unlink(%s) failed: %m", str_c(path));
i_close_fd(&fd);
return -1;
}
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/lib-index/mail-cache-compress.c
--- a/src/lib-index/mail-cache-compress.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/lib-index/mail-cache-compress.c Tue Sep 08 19:07:02 2015 +0300
@@ -458,8 +458,7 @@
return -1;
if (mail_cache_compress_write(cache, trans, fd, temp_path, unlock) < 0) {
i_close_fd(&fd);
- if (unlink(temp_path) < 0)
- i_error("unlink(%s) failed: %m", temp_path);
+ i_unlink(temp_path);
return -1;
}
if (cache->file_cache != NULL)
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/lib-index/mail-cache.c
--- a/src/lib-index/mail-cache.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/lib-index/mail-cache.c Tue Sep 08 19:07:02 2015 +0300
@@ -25,7 +25,7 @@
static void mail_cache_unlink(struct mail_cache *cache)
{
if (!cache->index->readonly)
- (void)unlink(cache->filepath);
+ i_unlink(cache->filepath);
}
void mail_cache_reset(struct mail_cache *cache)
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/lib-index/mail-index-strmap.c
--- a/src/lib-index/mail-index-strmap.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/lib-index/mail-index-strmap.c Tue Sep 08 19:07:02 2015 +0300
@@ -243,7 +243,7 @@
mail_index_set_error(view->strmap->index,
"Corrupted strmap index file: %s",
view->strmap->path);
- (void)unlink(view->strmap->path);
+ i_unlink(view->strmap->path);
mail_index_strmap_close(view->strmap);
mail_index_strmap_view_reset(view);
}
@@ -285,7 +285,7 @@
hdr.uid_validity != idx_hdr->uid_validity) {
/* need to rebuild. if we already had something in the strmap,
we can keep it. */
- (void)unlink(strmap->path);
+ i_unlink(strmap->path);
mail_index_strmap_close(strmap);
return 0;
}
@@ -1034,7 +1034,7 @@
ret = -1;
}
if (ret < 0)
- (void)unlink(temp_path);
+ i_unlink(temp_path);
return ret;
}
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/lib-index/mail-index-transaction.c
--- a/src/lib-index/mail-index-transaction.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/lib-index/mail-index-transaction.c Tue Sep 08 19:07:02 2015 +0300
@@ -176,8 +176,7 @@
if (t->reset) {
/* get rid of the old index. it might just confuse readers,
especially if it's broken. */
- if (unlink(log->index->filepath) < 0 && errno != ENOENT)
- i_error("unlink(%s) failed: %m", log->index->filepath);
+ i_unlink_if_exists(log->index->filepath);
}
*commit_size_r = log_offset2 - log_offset1;
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/lib-index/mail-index.c
--- a/src/lib-index/mail-index.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/lib-index/mail-index.c Tue Sep 08 19:07:02 2015 +0300
@@ -468,10 +468,8 @@
if (fd == -1 && errno == EEXIST) {
/* stale temp file. unlink and recreate rather than overwriting,
just to make sure locking problems won't cause corruption */
- if (unlink(path) < 0) {
- i_error("unlink(%s) failed: %m", path);
+ if (i_unlink(path) < 0)
return -1;
- }
old_mask = umask(0);
fd = open(path, O_RDWR|O_CREAT|O_EXCL, index->mode);
umask(old_mask);
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/lib-index/mailbox-log.c
--- a/src/lib-index/mailbox-log.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/lib-index/mailbox-log.c Tue Sep 08 19:07:02 2015 +0300
@@ -276,8 +276,7 @@
(iter->count - iter->idx) * sizeof(iter->buf[0]);
i_error("Corrupted mailbox log %s at offset %"PRIuUOFF_T": "
"type=%d", iter->filepath, offset, rec->type);
- if (unlink(iter->filepath) < 0)
- i_error("unlink(%s) failed: %m", iter->filepath);
+ i_unlink(iter->filepath);
return NULL;
}
return rec;
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/lib-index/test-mail-transaction-log-append.c
--- a/src/lib-index/test-mail-transaction-log-append.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/lib-index/test-mail-transaction-log-append.c Tue Sep 08 19:07:02 2015 +0300
@@ -162,7 +162,7 @@
i_free(log->head);
i_free(log->index);
i_free(log);
- unlink(tmp_path);
+ i_unlink(tmp_path);
}
int main(void)
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/lib-lda/duplicate.c
--- a/src/lib-lda/duplicate.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/lib-lda/duplicate.c Tue Sep 08 19:07:02 2015 +0300
@@ -184,10 +184,8 @@
}
if (record_size == 0 ||
- duplicate_read_records(file, input, record_size) < 0) {
- if (unlink(file->path) < 0 && errno != ENOENT)
- i_error("unlink(%s) failed: %m", file->path);
- }
+ duplicate_read_records(file, input, record_size) < 0)
+ i_unlink_if_exists(file->path);
i_stream_unref(&input);
if (close(fd) < 0)
diff -r 2ec2b0a51fec -r fefaa6d09a81 src/lib-lda/smtp-client.c
--- a/src/lib-lda/smtp-client.c Tue Sep 08 18:49:00 2015 +0300
+++ b/src/lib-lda/smtp-client.c Tue Sep 08 19:07:02 2015 +0300
@@ -87,9 +87,8 @@
}
/* we just want the fd, unlink it */
More information about the dovecot-cvs
mailing list