From 586d46297ebde6a066a4b7424cc965387575ffba Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan.bosch@dovecot.fi>
Date: Tue, 9 Apr 2019 19:24:02 +0200
Subject: [PATCH] lib-sieve: Replace sieve_storage_sys_warning() with
 e_warning().

---
 src/lib-sieve/sieve-storage-sync.c            | 13 +++----
 .../storage/file/sieve-file-storage-active.c  | 36 +++++++++----------
 .../storage/file/sieve-file-storage-quota.c   |  4 +--
 .../storage/file/sieve-file-storage-save.c    | 13 +++----
 .../storage/file/sieve-file-storage.c         |  8 ++---
 src/lib-sieve/storage/ldap/sieve-ldap-db.c    | 24 ++++++-------
 6 files changed, 50 insertions(+), 48 deletions(-)

diff --git a/src/lib-sieve/sieve-storage-sync.c b/src/lib-sieve/sieve-storage-sync.c
index 8af9aff4d..48ba40bbd 100644
--- a/src/lib-sieve/sieve-storage-sync.c
+++ b/src/lib-sieve/sieve-storage-sync.c
@@ -66,9 +66,9 @@ static int sieve_storage_sync_transaction_begin
 
 	inbox = mailbox_alloc(ns->list, "INBOX", mflags);
 	if (mailbox_open(inbox) < 0) {
-		sieve_storage_sys_warning(storage, "sync: "
-			"Failed to open user INBOX for attribute modifications: %s",
-			mailbox_get_last_error(inbox, &error));
+		e_warning(storage->event, "sync: "
+			  "Failed to open user INBOX for attribute modifications: %s",
+			  mailbox_get_last_error(inbox, &error));
 		mailbox_free(&inbox);
 		return -1;
 	}
@@ -90,9 +90,10 @@ static int sieve_storage_sync_transaction_finish
 	if ((ret=mailbox_transaction_commit(trans)) < 0) {
 		enum mail_error error;
 		
-		sieve_storage_sys_warning(storage, "sync: "
-			"Failed to update INBOX attributes: %s",
-			mail_storage_get_last_error(mailbox_get_storage(inbox), &error));
+		e_warning(storage->event, "sync: "
+			  "Failed to update INBOX attributes: %s",
+			   mail_storage_get_last_error(
+				mailbox_get_storage(inbox), &error));
 	}
 
 	mailbox_free(&inbox);
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 d5b9eef9b..68267bca3 100644
--- a/src/lib-sieve/storage/file/sieve-file-storage-active.c
+++ b/src/lib-sieve/storage/file/sieve-file-storage-active.c
@@ -34,9 +34,9 @@ static int sieve_file_storage_active_read_link
 			 */
 			if ( (storage->flags & SIEVE_STORAGE_FLAG_READWRITE) != 0 &&
 				(storage->flags & SIEVE_STORAGE_FLAG_SYNCHRONIZING) == 0 ) {
-				sieve_storage_sys_warning(storage,
-					"Active sieve script symlink %s is no symlink.",
-				  fstorage->active_path);
+				e_warning(storage->event,
+					  "Active sieve script symlink %s is no symlink.",
+					  fstorage->active_path);
 			}
 			return 0;
 		}
@@ -86,27 +86,27 @@ static const char *sieve_file_storage_active_parse_link
 
 	/* Warn if link is deemed to be invalid */
 	if ( scriptname == NULL ) {
-		sieve_storage_sys_warning(storage,
-			"Active Sieve script symlink %s is broken: "
-			"Invalid scriptname (points to %s).",
-			fstorage->active_path, link);
+		e_warning(storage->event,
+			  "Active Sieve script symlink %s is broken: "
+			  "Invalid scriptname (points to %s).",
+			  fstorage->active_path, link);
 		return NULL;
 	}
 
 	/* Check whether the path is any good */
 	const char *error = NULL;
 	if ( t_normpath_to(scriptpath, link_dir, &scriptpath, &error) < 0 ) {
-		sieve_storage_sys_warning(storage,
-			"Failed to check active Sieve script symlink %s: "
-			"Failed to normalize path (points to %s): %s",
-			fstorage->active_path, scriptpath, error);
+		e_warning(storage->event,
+			  "Failed to check active Sieve script symlink %s: "
+			  "Failed to normalize path (points to %s): %s",
+			  fstorage->active_path, scriptpath, error);
 		return NULL;
 	}
 	if ( strcmp(scriptpath, fstorage->path) != 0 ) {
-		sieve_storage_sys_warning(storage,
-			"Active sieve script symlink %s is broken: "
-			"Invalid/unknown path to storage (points to %s).",
-			fstorage->active_path, scriptpath);
+		e_warning(storage->event,
+			  "Active sieve script symlink %s is broken: "
+			  "Invalid/unknown path to storage (points to %s).",
+			  fstorage->active_path, scriptpath);
 		return NULL;
 	}
 
@@ -287,9 +287,9 @@ struct sieve_script *sieve_file_storage_active_script_open
 		sieve_script_file_get_scriptname(scriptfile),
 		NULL);
 	if ( fscript == NULL && storage->error_code == SIEVE_ERROR_NOT_FOUND ) {
-		sieve_storage_sys_warning(storage,
-			"Active sieve script symlink %s points to non-existent script "
-			"(points to %s).", fstorage->active_path, link);
+		e_warning(storage->event,
+			  "Active sieve script symlink %s points to non-existent script "
+			  "(points to %s).", fstorage->active_path, link);
 	}
 	return (fscript != NULL ? &fscript->script : NULL);
 }
diff --git a/src/lib-sieve/storage/file/sieve-file-storage-quota.c b/src/lib-sieve/storage/file/sieve-file-storage-quota.c
index b44c204b3..65e075dc4 100644
--- a/src/lib-sieve/storage/file/sieve-file-storage-quota.c
+++ b/src/lib-sieve/storage/file/sieve-file-storage-quota.c
@@ -89,8 +89,8 @@ int sieve_file_storage_quota_havespace
 			path = t_strconcat(fstorage->path, "/", dp->d_name, NULL);
 
 			if ( stat(path, &st) < 0 ) {
-				sieve_storage_sys_warning(storage,
-					"quota: stat(%s) failed: %m", path);
+				e_warning(storage->event,
+					  "quota: stat(%s) failed: %m", path);
 				continue;
 			}
 
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 a22333040..68393c46e 100644
--- a/src/lib-sieve/storage/file/sieve-file-storage-save.c
+++ b/src/lib-sieve/storage/file/sieve-file-storage-save.c
@@ -174,8 +174,8 @@ static int sieve_file_storage_script_move
 
 		/* Always destroy temp file */
 		if (unlink(fsctx->tmp_path) < 0 && errno != ENOENT) {
-			sieve_storage_sys_warning(storage, "save: "
-				"unlink(%s) failed: %m", fsctx->tmp_path);
+			e_warning(storage->event, "save: "
+				  "unlink(%s) failed: %m", fsctx->tmp_path);
 		}
 	} T_END;
 
@@ -298,8 +298,9 @@ int sieve_file_storage_save_finish
 		if ( sctx->failed ) {
 			/* delete the tmp file */
 			if (unlink(fsctx->tmp_path) < 0 && errno != ENOENT) {
-				sieve_storage_sys_warning(storage, "save: "
-					"unlink(%s) failed: %m", fsctx->tmp_path);
+				e_warning(storage->event, "save: "
+					  "unlink(%s) failed: %m",
+					  fsctx->tmp_path);
 			}
 
 			fsctx->tmp_path = NULL;
@@ -413,8 +414,8 @@ void sieve_file_storage_save_cancel(struct sieve_storage_save_context *sctx)
 
 	if (fsctx->tmp_path != NULL &&
 		unlink(fsctx->tmp_path) < 0 && errno != ENOENT) {
-		sieve_storage_sys_warning(storage, "save: "
-			"unlink(%s) failed: %m", fsctx->tmp_path);
+		e_warning(storage->event, "save: unlink(%s) failed: %m",
+			  fsctx->tmp_path);
 	}
 
 	i_assert(fsctx->output == NULL);
diff --git a/src/lib-sieve/storage/file/sieve-file-storage.c b/src/lib-sieve/storage/file/sieve-file-storage.c
index d2d969d8a..986756cdb 100644
--- a/src/lib-sieve/storage/file/sieve-file-storage.c
+++ b/src/lib-sieve/storage/file/sieve-file-storage.c
@@ -559,10 +559,10 @@ static int sieve_file_storage_init
 					return -1;
 				}
 				if ( active_path != NULL && *active_path != '\0' ) {
-					sieve_storage_sys_warning(storage,
-						"Explicitly specified active script path `%s' is ignored; "
-						"storage path `%s' is not a directory",
-						active_path, storage_path);
+					e_warning(storage->event,
+						  "Explicitly specified active script path `%s' is ignored; "
+						  "storage path `%s' is not a directory",
+						  active_path, storage_path);
 				}
 				active_path = storage_path;
 				storage_path = NULL;
diff --git a/src/lib-sieve/storage/ldap/sieve-ldap-db.c b/src/lib-sieve/storage/ldap/sieve-ldap-db.c
index a8823864d..86db60504 100644
--- a/src/lib-sieve/storage/ldap/sieve-ldap-db.c
+++ b/src/lib-sieve/storage/ldap/sieve-ldap-db.c
@@ -739,9 +739,9 @@ static int db_ldap_set_tls_options(struct ldap_connection *conn)
 	    set->tls_cert_file != NULL ||
 	    set->tls_key_file != NULL ||
 	    set->tls_cipher_suite != NULL) {
-		sieve_storage_sys_warning(&conn->lstorage->storage, "db: "
-			"tls_* settings ignored, "
-			"your LDAP library doesn't seem to support them");
+		e_warning(&conn->lstorage->storage, "db: "
+			  "tls_* settings ignored, "
+			  "your LDAP library doesn't seem to support them");
 	}
 #endif
 	return 0;
@@ -1108,9 +1108,9 @@ sieve_ldap_db_get_script_modattr(struct ldap_connection *conn,
 				return 0;
 
 			if (vals[1] != NULL) {
-				sieve_storage_sys_warning(storage, "db: "
-					"Search returned more than one Sieve modified attribute `%s'; "
-					"using only the first one.", set->sieve_ldap_mod_attr);
+				e_warning(storage->event, "db: "
+					  "Search returned more than one Sieve modified attribute `%s'; "
+					  "using only the first one.", set->sieve_ldap_mod_attr);
 			} 
 
 			*modattr_r = p_strdup(pool, vals[0]);
@@ -1147,9 +1147,9 @@ sieve_ldap_db_get_script(struct ldap_connection *conn,
 				return 0;
 
 			if (vals[1] != NULL) {
-				sieve_storage_sys_warning(storage, "db: "
-					"Search returned more than one Sieve script attribute `%s'; "
-					"using only the first one.", set->sieve_ldap_script_attr);
+				e_warning(storage->event, "db: "
+					  "Search returned more than one Sieve script attribute `%s'; "
+					  "using only the first one.", set->sieve_ldap_script_attr);
 			} 
 
 			size = vals[0]->bv_len;
@@ -1241,9 +1241,9 @@ sieve_ldap_lookup_script_callback(struct ldap_connection *conn,
 			(void)sieve_ldap_db_get_script_modattr
 				(conn, res, request->pool, &srequest->result_modattr);
 		} else if (srequest->entries++ == 0) {
-			sieve_storage_sys_warning(storage, "db: "
-				"Search returned more than one entry for Sieve script; "
-				"using only the first one.");
+			e_warning(storage->event, "db: "
+				  "Search returned more than one entry for Sieve script; "
+				  "using only the first one.");
 		}
 	} else {
 		io_loop_stop(conn->ioloop);
-- 
GitLab