On 10/25/2014 11:43 AM, Timo Sirainen wrote:
On 25 Oct 2014, at 04:59, Gedalya <geda...@gedalya.net> wrote:

Also I have one minor issue to report.  dovecot broke API from 2.2.13 to 2.2.14 
but it only provides version macros for the first two components of the version 
number.  This has caused a small upgrade problem for the antispam plugin which 
is in a separate package (dovecot-antispam.) Was that addressed in 2.2.15?
I only remember an ABI problem with antispam. Recompiling fixed that AFAIK. 
(And no Dovecot version guarantees ABI compatibility.) Is there some API 
problem also?
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=765943
Oh, it uses the really old way to do things. In v1.1+ T_BEGIN { .. } T_END 
should have been used instead. Patch attached.


OK, it's not working as it is.

This little bit seems like a typo:
-    t_pop();
+    } T_POP;

Gives me:

pipe.c:315:4: error: ‘T_POP’ undeclared (first use in this function)
  } T_POP;


I tried T_END and I still get:

pipe.c: In function ‘backend_handle_mail’:
pipe.c:314:2: error: label at end of compound statement
  out:
  ^

I got it to compile, see the attached. I don't really know C


diff --git a/antispam-plugin.c b/antispam-plugin.c
index 103b5fb..76ced7b 100644
--- a/antispam-plugin.c
+++ b/antispam-plugin.c
@@ -90,7 +90,7 @@ static bool mailbox_patternmatch(struct mailbox *box,
 		return FALSE;
 #endif
 
-	t_push();
+	T_BEGIN {
 
 	boxname = mailbox_get_name(box);
 	if (lowercase) {
@@ -110,7 +110,7 @@ static bool mailbox_patternmatch(struct mailbox *box,
 
 	rc = memcmp(name, boxname, len) == 0;
 
-	t_pop();
+	} T_END;
 
 	return rc;
 }
@@ -257,7 +257,7 @@ static int parse_folder_setting(const struct antispam_config *cfg,
 	int cnt = 0;
 	enum match_type i;
 
-	t_push();
+	T_BEGIN {
 
 	for (i = 0; i < NUM_MT; ++i) {
 		tmp = getenv(t_strconcat(setting, match_info[i].suffix, NULL),
@@ -286,7 +286,7 @@ static int parse_folder_setting(const struct antispam_config *cfg,
 		}
 	}
 
-	t_pop();
+	} T_END;
 
 	if (!cnt)
 		debug(&cfg->dbgcfg, "no %s folders\n", display_name);
diff --git a/antispam-storage-1.1.c b/antispam-storage-1.1.c
index f28a0cf..aab23d9 100644
--- a/antispam-storage-1.1.c
+++ b/antispam-storage-1.1.c
@@ -508,10 +508,10 @@ void antispam_mail_storage_created(struct mail_storage *storage)
 
 static const char *_getenv(const char *env, void *data ATTR_UNUSED)
 {
-	t_push();
+	T_BEGIN {
 	env = t_str_ucase(t_strconcat("antispam_", env, NULL));
 	env = getenv(env);
-	t_pop();
+	} T_END;
 
 	return env;
 }
diff --git a/antispam-storage-1.2.c b/antispam-storage-1.2.c
index 5e0cb97..269a373 100644
--- a/antispam-storage-1.2.c
+++ b/antispam-storage-1.2.c
@@ -498,10 +498,10 @@ void antispam_mail_storage_created(struct mail_storage *storage)
 
 static const char *_getenv(const char *env, void *data ATTR_UNUSED)
 {
-	t_push();
+	T_BEGIN {
 	env = t_str_ucase(t_strconcat("antispam_", env, NULL));
 	env = getenv(env);
-	t_pop();
+	} T_END;
 
 	return env;
 }
diff --git a/antispam-storage-2.0.c b/antispam-storage-2.0.c
index 3e67553..c3d6251 100644
--- a/antispam-storage-2.0.c
+++ b/antispam-storage-2.0.c
@@ -494,11 +494,11 @@ static const char *_getenv(const char *name, void *data)
 	struct mail_user *user = data;
 	const char *env;
 
-	t_push();
+	T_BEGIN {
 	env = t_strconcat("antispam_", t_str_lcase(name), NULL);
 
 	env = mail_user_plugin_getenv(user, env);
-	t_pop();
+	} T_END;
 
 	return env;
 }
diff --git a/crm114-exec.c b/crm114-exec.c
index 5b39ca9..d786e04 100644
--- a/crm114-exec.c
+++ b/crm114-exec.c
@@ -113,7 +113,7 @@ static int call_reaver(const struct antispam_config *cfg,
 
 		debugv(&cfg->dbgcfg, argv);
 
-		t_push();
+		T_BEGIN {
 		for (i = 0; i < cfg->crm.extra_env_num; i++) {
 			char *name, *value;
 			name = t_strdup_noconst(cfg->crm.extra_env[i]);
@@ -124,7 +124,7 @@ static int call_reaver(const struct antispam_config *cfg,
 			}
 			setenv(name, value, 1);
 		}
-		t_pop();
+		} T_END;
 
 		execv(cfg->crm.reaver_binary, argv);
 		/* fall through if reaver can't be found */
diff --git a/debug.c b/debug.c
index d2683fa..7a2353a 100644
--- a/debug.c
+++ b/debug.c
@@ -14,7 +14,7 @@ static void _debug(const struct antispam_debug_config *cfg,
 	if (cfg->target == ADT_NONE)
 		return;
 
-	t_push();
+	T_BEGIN {
 
 	fmt = t_strconcat("antispam: ", format, NULL);
 
@@ -30,7 +30,7 @@ static void _debug(const struct antispam_debug_config *cfg,
 		break;
 	}
 
-	t_pop();
+	} T_END;
 }
 
 void debug(const struct antispam_debug_config *cfg, const char *fmt, ...)
@@ -48,7 +48,7 @@ void debugv(const struct antispam_debug_config *cfg, char **args)
 	char *buf;
 	const char *str;
 
-	t_push();
+	T_BEGIN {
 	buf = t_buffer_get(buflen);
 
 	while (1) {
@@ -72,7 +72,7 @@ void debugv(const struct antispam_debug_config *cfg, char **args)
 	t_buffer_alloc(pos);
 
 	debug(cfg, "%s", buf);
-	t_pop();
+	} T_END;
 }
 
 void debugv_not_stderr(const struct antispam_debug_config *cfg, char **args)
diff --git a/dspam-exec.c b/dspam-exec.c
index 2e353ce..856babb 100644
--- a/dspam-exec.c
+++ b/dspam-exec.c
@@ -141,7 +141,7 @@ static int call_dspam(const struct antispam_config *cfg,
 		 */
 		debugv_not_stderr(&cfg->dbgcfg, argv);
 
-		t_push();
+		T_BEGIN {
 		for (i = 0; i < cfg->dspam.extra_env_num; i++) {
 			char *name, *value;
 			name = t_strdup_noconst(cfg->dspam.extra_env[i]);
@@ -152,7 +152,7 @@ static int call_dspam(const struct antispam_config *cfg,
 			}
 			setenv(name, value, 1);
 		}
-		t_pop();
+		} T_END;
 
 		execv(cfg->dspam.binary, argv);
 		debug(&cfg->dbgcfg, "executing %s failed: %d (uid=%d, gid=%d)",
diff --git a/pipe.c b/pipe.c
index a20b4aa..7c12e43 100644
--- a/pipe.c
+++ b/pipe.c
@@ -136,7 +136,7 @@ static int process_tmpdir(const struct antispam_config *cfg,
 	enum classification wanted;
 	int rc = 0;
 
-	t_push();
+	T_BEGIN {
 
 	buf = t_malloc(20 + ast->tmplen);
 
@@ -159,7 +159,7 @@ static int process_tmpdir(const struct antispam_config *cfg,
 		close(fd);
 	}
 
-	t_pop();
+	} T_END;
 
 	return rc;
 }
@@ -168,7 +168,7 @@ static void clear_tmpdir(struct antispam_transaction_context *ast)
 {
 	char *buf;
 
-	t_push();
+	T_BEGIN {
 
 	buf = t_malloc(20 + ast->tmplen);
 
@@ -180,7 +180,7 @@ static void clear_tmpdir(struct antispam_transaction_context *ast)
 	}
 	rmdir(ast->tmpdir);
 
-	t_pop();
+	} T_END;
 }
 
 static void backend_rollback(const struct antispam_config *cfg ATTR_UNUSED,
@@ -250,7 +250,7 @@ static int backend_handle_mail(const struct antispam_config *cfg,
 		return -1;
 	}
 
-	t_push();
+	T_BEGIN {
 
 	buf = t_malloc(20 + ast->tmplen);
 	i_snprintf(buf, 20 + ast->tmplen - 1, "%s/%d", ast->tmpdir, ast->count);
@@ -312,7 +312,8 @@ static int backend_handle_mail(const struct antispam_config *cfg,
  out_close:
 	close(fd);
  out:
-	t_pop();
+	;
+	} T_END;
 
 	return ret;
 }
diff --git a/spool2dir.c b/spool2dir.c
index cbd1909..cd60e6e 100644
--- a/spool2dir.c
+++ b/spool2dir.c
@@ -165,7 +165,7 @@ static int backend_handle_mail(const struct antispam_config *cfg,
 		return -1;
 	}
 
-	t_push();
+	T_BEGIN {
 
 	/* atomically create a _new_ file */
 	while (ast->count <= 9999) {
@@ -174,9 +174,6 @@ static int backend_handle_mail(const struct antispam_config *cfg,
 		if (fd >= 0 || errno != EEXIST)
 			break;
 		/* current filename in buf already exists, zap it */
-		t_pop();
-		t_push();
-		/* buf is invalid now! */
 	}
 
 	if (fd < 0) {
@@ -226,7 +223,8 @@ static int backend_handle_mail(const struct antispam_config *cfg,
 	if (ret)
 		unlink(buf);
  out:
-	t_pop();
+	;
+	} T_END;
 
 	return ret;
 }

Reply via email to