From d6cacfef0531ff14bf634022c1a845cf8e752a09 Mon Sep 17 00:00:00 2001 From: Timo Sirainen <timo.sirainen@dovecot.fi> Date: Fri, 20 May 2016 15:38:31 +0300 Subject: [PATCH] Use i_unlink() to improve unexpected unlink() error messages. --- src/lib-sieve-tool/mail-raw.c | 3 +-- src/lib-sieve/storage/file/sieve-file-storage-active.c | 2 +- src/lib-sieve/storage/file/sieve-file-storage-save.c | 7 +++---- src/lib-sieve/util/program-client.c | 3 +-- src/sieve-tools/sieve-test.c | 2 +- 5 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/lib-sieve-tool/mail-raw.c b/src/lib-sieve-tool/mail-raw.c index 6f8101cf9..18ab391f4 100644 --- a/src/lib-sieve-tool/mail-raw.c +++ b/src/lib-sieve-tool/mail-raw.c @@ -68,9 +68,8 @@ static int seekable_fd_callback } /* 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 --git a/src/lib-sieve/storage/file/sieve-file-storage-active.c b/src/lib-sieve/storage/file/sieve-file-storage-active.c index f0917a51e..a68c5c23d 100644 --- a/src/lib-sieve/storage/file/sieve-file-storage-active.c +++ b/src/lib-sieve/storage/file/sieve-file-storage-active.c @@ -163,7 +163,7 @@ int sieve_file_storage_active_replace_link if ( ret < 0 ) { /* Failed; created symlink must be deleted */ - (void)unlink(active_path_new); + i_unlink(active_path_new); sieve_storage_set_critical(storage, "Performing rename() %s to %s failed: %m", active_path_new, fstorage->active_path); diff --git a/src/lib-sieve/storage/file/sieve-file-storage-save.c b/src/lib-sieve/storage/file/sieve-file-storage-save.c index 4353fbec7..edb91c3ef 100644 --- a/src/lib-sieve/storage/file/sieve-file-storage-save.c +++ b/src/lib-sieve/storage/file/sieve-file-storage-save.c @@ -443,14 +443,14 @@ sieve_file_storage_save_to(struct sieve_file_storage *fstorage, "read(%s) failed: %s", i_stream_get_name(input), i_stream_get_error(input)); o_stream_destroy(&output); - (void)unlink(str_c(temp_path)); + i_unlink(str_c(temp_path)); return -1; case OSTREAM_SEND_ISTREAM_RESULT_ERROR_OUTPUT: sieve_storage_set_critical(storage, "write(%s) failed: %s", str_c(temp_path), o_stream_get_error(output)); o_stream_destroy(&output); - (void)unlink(str_c(temp_path)); + i_unlink(str_c(temp_path)); return -1; } o_stream_destroy(&output); @@ -468,9 +468,8 @@ sieve_file_storage_save_to(struct sieve_file_storage *fstorage, "rename(%s, %s) failed: %m", str_c(temp_path), target); } + i_unlink(str_c(temp_path)); } - - (void)unlink(str_c(temp_path)); return 0; } diff --git a/src/lib-sieve/util/program-client.c b/src/lib-sieve/util/program-client.c index e7ddd214d..e0f0f9c64 100644 --- a/src/lib-sieve/util/program-client.c +++ b/src/lib-sieve/util/program-client.c @@ -429,9 +429,8 @@ static int program_client_seekable_fd_callback } /* 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 --git a/src/sieve-tools/sieve-test.c b/src/sieve-tools/sieve-test.c index 1b331774a..698ff4d3d 100644 --- a/src/sieve-tools/sieve-test.c +++ b/src/sieve-tools/sieve-test.c @@ -398,7 +398,7 @@ int main(int argc, char **argv) break; case SIEVE_EXEC_BIN_CORRUPT: i_info("corrupt binary deleted."); - (void) unlink(sieve_binary_path(sbin)); + i_unlink_if_exists(sieve_binary_path(sbin)); /* fall through */ case SIEVE_EXEC_FAILURE: i_info("final result: failed; resolved with successful implicit keep"); -- GitLab