[dovecot-cvs] dovecot/src/lib-storage/index/maildir maildir-storage.h, 1.57, 1.58 maildir-util.c, 1.18, 1.19

tss at dovecot.org tss at dovecot.org
Fri Dec 15 18:11:09 UTC 2006


Update of /var/lib/cvs/dovecot/src/lib-storage/index/maildir
In directory talvi:/tmp/cvs-serv2752/lib-storage/index/maildir

Modified Files:
	maildir-storage.h maildir-util.c 
Log Message:
Type safe callbacks weren't as easy as I thought. Only callback(void
*context) can be handled generically. Others can be handled specially, but
only if all the parameters are pointers, otherwise eg. int parameter can be
replaced with long without compiler giving any warnings.



Index: maildir-storage.h
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-storage.h,v
retrieving revision 1.57
retrieving revision 1.58
diff -u -d -r1.57 -r1.58
--- maildir-storage.h	15 Dec 2006 16:55:45 -0000	1.57
+++ maildir-storage.h	15 Dec 2006 18:11:04 -0000	1.58
@@ -89,10 +89,17 @@
 				 const char *path, void *context);
 
 int maildir_file_do(struct maildir_mailbox *mbox, uint32_t seq,
-		    maildir_file_do_func *func, void *context);
-#define maildir_file_do(mbox, seq, func, context) \
-	CONTEXT_CALLBACK3(maildir_file_do, maildir_file_do_func, \
-			  func, context, mbox, seq)
+		    maildir_file_do_func *callback, void *context);
+#ifdef CONTEXT_TYPE_SAFETY
+#  define maildir_file_do(mbox, seq, callback, context) \
+	({(void)(1 ? 0 : callback((struct maildir_mailbox *)NULL, \
+				  (const char *)NULL, context)); \
+	  maildir_file_do(mbox, seq, \
+		(maildir_file_do_func *)callback, context); })
+#else
+#  define maildir_file_do(mbox, seq, callback, context) \
+	maildir_file_do(mbox, seq, (maildir_file_do_func *)callback, context)
+#endif
 
 const char *maildir_generate_tmp_filename(const struct timeval *tv);
 int maildir_create_tmp(struct maildir_mailbox *mbox, const char *dir,

Index: maildir-util.c
===================================================================
RCS file: /var/lib/cvs/dovecot/src/lib-storage/index/maildir/maildir-util.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- maildir-util.c	15 Dec 2006 16:55:45 -0000	1.18
+++ maildir-util.c	15 Dec 2006 18:11:06 -0000	1.19
@@ -14,7 +14,7 @@
 #include <sys/stat.h>
 
 static int maildir_file_do_try(struct maildir_mailbox *mbox, uint32_t uid,
-			       maildir_file_do_func *func, void *context)
+			       maildir_file_do_func *callback, void *context)
 {
 	const char *fname, *path;
         enum maildir_uidlist_rec_flag flags;
@@ -28,7 +28,7 @@
 	if ((flags & MAILDIR_UIDLIST_REC_FLAG_NEW_DIR) != 0) {
 		/* probably in new/ dir */
 		path = t_strconcat(mbox->path, "/new/", fname, NULL);
-		ret = func(mbox, path, context);
+		ret = callback(mbox, path, context);
 		if (ret != 0) {
 			t_pop();
 			return ret;
@@ -36,18 +36,18 @@
 	}
 
 	path = t_strconcat(mbox->path, "/cur/", fname, NULL);
-	ret = func(mbox, path, context);
+	ret = callback(mbox, path, context);
 	t_pop();
 	return ret;
 }
 
 #undef maildir_file_do
 int maildir_file_do(struct maildir_mailbox *mbox, uint32_t uid,
-		    maildir_file_do_func *func, void *context)
+		    maildir_file_do_func *callback, void *context)
 {
 	int i, ret;
 
-	ret = maildir_file_do_try(mbox, uid, func, context);
+	ret = maildir_file_do_try(mbox, uid, callback, context);
 	for (i = 0; i < 10 && ret == 0; i++) {
 		/* file is either renamed or deleted. sync the maildir and
 		   see which one. if file appears to be renamed constantly,
@@ -55,7 +55,7 @@
 		if (maildir_storage_sync_force(mbox) < 0)
 			return -1;
 
-		ret = maildir_file_do_try(mbox, uid, func, context);
+		ret = maildir_file_do_try(mbox, uid, callback, context);
 	}
 
 	if (i == 10) {



More information about the dovecot-cvs mailing list