From 2e9603a563521f7c07d4a0879e76e0dd6a6eff3c Mon Sep 17 00:00:00 2001
From: Stephan Bosch <stephan@rename-it.nl>
Date: Thu, 6 Dec 2007 14:10:30 +0100
Subject: [PATCH] Added proper ATTR_FORMAT to all functions that accept a
 string format and fixed one bug in the process.

---
 src/lib-sieve/plugins/vacation/ext-vacation.c |  3 +--
 src/lib-sieve/sieve-code-dumper.h             |  3 ++-
 src/lib-sieve/sieve-error.h                   | 19 ++++++++++++++++---
 src/lib-sieve/sieve-interpreter.h             |  9 ++++++---
 src/lib-sieve/sieve-lexer.c                   | 11 +++++++++--
 src/lib-sieve/sieve-parser.c                  |  9 +++++++--
 src/lib-sieve/sieve-result.h                  | 10 +++++++---
 src/lib-sieve/sieve-validator.h               |  6 ++++--
 8 files changed, 52 insertions(+), 18 deletions(-)

diff --git a/src/lib-sieve/plugins/vacation/ext-vacation.c b/src/lib-sieve/plugins/vacation/ext-vacation.c
index 2c1655ed6..b8b7e9d4f 100644
--- a/src/lib-sieve/plugins/vacation/ext-vacation.c
+++ b/src/lib-sieve/plugins/vacation/ext-vacation.c
@@ -757,8 +757,7 @@ static bool act_vacation_commit
 	if ( *hdsp == NULL ) {
 		/* No, bail out */
 		sieve_result_log(aenv, 
-			"discarding vacation response for implicitly delivered message", 
-			msgdata->return_path);	
+			"discarding vacation response for implicitly delivered message");	
 		return TRUE;				 
 	}	
 		
diff --git a/src/lib-sieve/sieve-code-dumper.h b/src/lib-sieve/sieve-code-dumper.h
index 71e79237b..ae7dee47a 100644
--- a/src/lib-sieve/sieve-code-dumper.h
+++ b/src/lib-sieve/sieve-code-dumper.h
@@ -19,7 +19,8 @@ inline pool_t sieve_code_dumper_pool(struct sieve_code_dumper *dumper);
 /*  */	
 	
 void sieve_code_dumpf
-(const struct sieve_dumptime_env *denv, const char *fmt, ...);
+	(const struct sieve_dumptime_env *denv, const char *fmt, ...)
+		ATTR_FORMAT(2, 3);
 
 inline void sieve_code_mark(const struct sieve_dumptime_env *denv);
 inline void sieve_code_mark_specific
diff --git a/src/lib-sieve/sieve-error.h b/src/lib-sieve/sieve-error.h
index 5085d7f41..dc2c9add3 100644
--- a/src/lib-sieve/sieve-error.h
+++ b/src/lib-sieve/sieve-error.h
@@ -1,6 +1,9 @@
 #ifndef __SIEVE_ERROR_H
 #define __SIEVE_ERROR_H
 
+#include "lib.h"
+#include "compat.h"
+
 #include <stdarg.h>
 
 struct sieve_error_handler;
@@ -17,7 +20,17 @@ void sieve_vinfo
 
 inline static void sieve_error
 (struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, ...) 
+	const char *fmt, ...) ATTR_FORMAT(3, 4);
+inline static void sieve_warning
+(struct sieve_error_handler *ehandler, const char *location, 
+	const char *fmt, ...) ATTR_FORMAT(3, 4);
+inline static void sieve_info
+(struct sieve_error_handler *ehandler, const char *location, 
+	const char *fmt, ...) ATTR_FORMAT(3, 4);
+
+inline static void sieve_error
+(struct sieve_error_handler *ehandler, const char *location, 
+	const char *fmt, ...)
 {
 	va_list args;
 	va_start(args, fmt);
@@ -29,7 +42,7 @@ inline static void sieve_error
 
 inline static void sieve_warning
 (struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, ...) 
+	const char *fmt, ...)
 {
 	va_list args;
 	va_start(args, fmt);
@@ -41,7 +54,7 @@ inline static void sieve_warning
 
 inline static void sieve_info
 (struct sieve_error_handler *ehandler, const char *location, 
-	const char *fmt, ...) 
+	const char *fmt, ...)
 {
 	va_list args;
 	va_start(args, fmt);
diff --git a/src/lib-sieve/sieve-interpreter.h b/src/lib-sieve/sieve-interpreter.h
index 6bbc045d3..5fb77fe38 100644
--- a/src/lib-sieve/sieve-interpreter.h
+++ b/src/lib-sieve/sieve-interpreter.h
@@ -43,11 +43,14 @@ inline bool sieve_interpreter_get_test_result
 /* Error handling */
 
 void sieve_runtime_error
-	(const struct sieve_runtime_env *runenv, const char *fmt, ...);
+	(const struct sieve_runtime_env *runenv, const char *fmt, ...)
+		ATTR_FORMAT(2, 3);
 void sieve_runtime_warning
-	(const struct sieve_runtime_env *runenv, const char *fmt, ...);
+	(const struct sieve_runtime_env *runenv, const char *fmt, ...)
+		ATTR_FORMAT(2, 3);
 void sieve_runtime_log
-	(const struct sieve_runtime_env *runenv, const char *fmt, ...);
+	(const struct sieve_runtime_env *runenv, const char *fmt, ...)
+		ATTR_FORMAT(2, 3);
 
 /* Extension support */
 
diff --git a/src/lib-sieve/sieve-lexer.c b/src/lib-sieve/sieve-lexer.c
index 33db7b996..9f15d64b8 100644
--- a/src/lib-sieve/sieve-lexer.c
+++ b/src/lib-sieve/sieve-lexer.c
@@ -6,6 +6,7 @@
 #include <unistd.h>
 
 #include "lib.h"
+#include "compat.h"
 #include "str.h"
 #include "istream.h"
 
@@ -37,7 +38,13 @@ struct sieve_lexer {
 };
 
 inline static void sieve_lexer_error
-(struct sieve_lexer *lexer, const char *fmt, ...) 
+	(struct sieve_lexer *lexer, const char *fmt, ...) ATTR_FORMAT(2, 3);
+inline static void sieve_lexer_warning
+	(struct sieve_lexer *lexer, const char *fmt, ...) ATTR_FORMAT(2, 3);
+
+
+inline static void sieve_lexer_error
+(struct sieve_lexer *lexer, const char *fmt, ...)
 {
 	va_list args;
 	va_start(args, fmt);
@@ -50,7 +57,7 @@ inline static void sieve_lexer_error
 }
 
 inline static void sieve_lexer_warning
-(struct sieve_lexer *lexer, const char *fmt, ...) 
+(struct sieve_lexer *lexer, const char *fmt, ...)
 {
 	va_list args;
 	va_start(args, fmt);
diff --git a/src/lib-sieve/sieve-parser.c b/src/lib-sieve/sieve-parser.c
index e8dabd029..9eb436731 100644
--- a/src/lib-sieve/sieve-parser.c
+++ b/src/lib-sieve/sieve-parser.c
@@ -28,7 +28,12 @@ struct sieve_parser {
 #define SIEVE_READ_BLOCK_SIZE (1024*8)
 
 inline static void sieve_parser_error
-	(struct sieve_parser *parser, const char *fmt, ...) 
+	(struct sieve_parser *parser, const char *fmt, ...) ATTR_FORMAT(2, 3);
+inline static void sieve_parser_warning
+	(struct sieve_parser *parser, const char *fmt, ...) ATTR_FORMAT(2, 3);
+
+inline static void sieve_parser_error
+	(struct sieve_parser *parser, const char *fmt, ...)
 { 
 	va_list args;
 	va_start(args, fmt);
@@ -46,7 +51,7 @@ inline static void sieve_parser_error
 }
 
 inline static void sieve_parser_warning
-	(struct sieve_parser *parser, const char *fmt, ...) 
+	(struct sieve_parser *parser, const char *fmt, ...)
 {
 	va_list args;
 	va_start(args, fmt);
diff --git a/src/lib-sieve/sieve-result.h b/src/lib-sieve/sieve-result.h
index ab38bb53d..f0889ccbe 100644
--- a/src/lib-sieve/sieve-result.h
+++ b/src/lib-sieve/sieve-result.h
@@ -13,11 +13,15 @@ void sieve_result_ref(struct sieve_result *result);
 void sieve_result_unref(struct sieve_result **result); 
 inline pool_t sieve_result_pool(struct sieve_result *result);
 
+/* Error handling */
+
 void sieve_result_log
-	(const struct sieve_action_exec_env *aenv, const char *fmt, ...);
+	(const struct sieve_action_exec_env *aenv, const char *fmt, ...)
+		ATTR_FORMAT(2, 3);
 void sieve_result_error
-	(const struct sieve_action_exec_env *aenv, const char *fmt, ...);
-	
+	(const struct sieve_action_exec_env *aenv, const char *fmt, ...)
+		ATTR_FORMAT(2, 3);
+
 int sieve_result_add_action
 (const struct sieve_runtime_env *renv,
 	const struct sieve_action *action, struct sieve_side_effects_list *seffects,
diff --git a/src/lib-sieve/sieve-validator.h b/src/lib-sieve/sieve-validator.h
index 3a6e1db12..78f789f55 100644
--- a/src/lib-sieve/sieve-validator.h
+++ b/src/lib-sieve/sieve-validator.h
@@ -16,9 +16,11 @@ inline pool_t sieve_validator_pool(struct sieve_validator *validator);
 bool sieve_validator_run(struct sieve_validator *validator);
 
 void sieve_validator_warning
-	(struct sieve_validator *validator, struct sieve_ast_node *node, const char *fmt, ...);
+	(struct sieve_validator *validator, struct sieve_ast_node *node, 
+		const char *fmt, ...) ATTR_FORMAT(3, 4);
 void sieve_validator_error
-	(struct sieve_validator *validator, struct sieve_ast_node *node, const char *fmt, ...);
+	(struct sieve_validator *validator, struct sieve_ast_node *node, 
+		const char *fmt, ...) ATTR_FORMAT(3, 4);
 
 /* Command Programmers Interface */
 
-- 
GitLab