changeset 836:eefa28ef9646 HEAD

Added some missing format attribute declarations. And fixed one more bug found found with them.
author Timo Sirainen <tss@iki.fi>
date Sun, 22 Dec 2002 00:39:15 +0200
parents 91d7ee63a0b5
children ec6dd72cb8e3
files src/lib-index/mail-index-data.h src/lib-index/mail-index-util.h src/lib-index/mail-index.c src/lib-index/mail-tree.h
diffstat 4 files changed, 16 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-index/mail-index-data.h	Sun Dec 22 00:28:07 2002 +0200
+++ b/src/lib-index/mail-index-data.h	Sun Dec 22 00:39:15 2002 +0200
@@ -53,6 +53,7 @@
 
 /* "Error in index data file %s: ...". Also marks the index file as
    corrupted. */
-int index_data_set_corrupted(MailIndexData *data, const char *fmt, ...);
+int index_data_set_corrupted(MailIndexData *data, const char *fmt, ...)
+	__attr_format__(2, 3);
 
 #endif
--- a/src/lib-index/mail-index-util.h	Sun Dec 22 00:28:07 2002 +0200
+++ b/src/lib-index/mail-index-util.h	Sun Dec 22 00:39:15 2002 +0200
@@ -20,7 +20,8 @@
 	__attr_format__(2, 3);
 
 /* "Error in index file %s: ...". Also marks the index file as corrupted. */
-int index_set_corrupted(MailIndex *index, const char *fmt, ...);
+int index_set_corrupted(MailIndex *index, const char *fmt, ...)
+	__attr_format__(2, 3);
 
 /* "%s failed with index file %s: %m" */
 int index_set_syscall_error(MailIndex *index, const char *function);
--- a/src/lib-index/mail-index.c	Sun Dec 22 00:28:07 2002 +0200
+++ b/src/lib-index/mail-index.c	Sun Dec 22 00:39:15 2002 +0200
@@ -499,7 +499,7 @@
 {
 	MailIndexHeader *hdr;
 	MailIndexRecord *rec;
-	const char *format;
+	const char *error;
 	unsigned int idx;
 
 	i_assert(seq > 0);
@@ -517,13 +517,15 @@
 	idx = seq-1;
 	if (hdr->first_hole_records == 0 || hdr->first_hole_index > idx) {
 		/* easy, it's just at the expected index */
-		format = "Invalid first_hole_index in header: %"PRIuUOFF_T;
+		error = t_strdup_printf("Invalid first_hole_index in header: "
+					"%u", idx);
 	} else if (hdr->first_hole_records ==
 		   MAIL_INDEX_RECORD_COUNT(index) - hdr->messages_count) {
 		/* only one hole in file, skip it and we're at
 		   correct position */
 		idx += hdr->first_hole_records;
-		format = "Invalid hole locations in header: %"PRIuUOFF_T;
+		error = t_strdup_printf("Invalid hole locations in header: %u",
+					idx);
 	} else {
 		/* find from binary tree */
 		idx = mail_tree_lookup_sequence(index->tree, seq);
@@ -534,18 +536,20 @@
 				seq, hdr->messages_count);
 			return NULL;
 		}
-		format = "Invalid offset returned by binary tree: %"PRIuUOFF_T;
+
+		error = t_strdup_printf("Invalid offset returned by "
+					"binary tree: %u", idx);
 	}
 
 	if (idx >= MAIL_INDEX_RECORD_COUNT(index)) {
-		index_set_corrupted(index, format, idx);
+		index_set_corrupted(index, "%s", error);
 		return NULL;
 	}
 
 	rec = (MailIndexRecord *) ((char *) index->mmap_base +
 				   sizeof(MailIndexHeader)) + idx;
 	if (rec->uid == 0) {
-		index_set_corrupted(index, format, idx);
+		index_set_corrupted(index, "%s", error);
 		return NULL;
 	}
 
--- a/src/lib-index/mail-tree.h	Sun Dec 22 00:28:07 2002 +0200
+++ b/src/lib-index/mail-tree.h	Sun Dec 22 00:39:15 2002 +0200
@@ -71,7 +71,8 @@
 void mail_tree_delete(MailTree *tree, unsigned int uid);
 
 /* private: */
-int _mail_tree_set_corrupted(MailTree *tree, const char *fmt, ...);
+int _mail_tree_set_corrupted(MailTree *tree, const char *fmt, ...)
+	__attr_format__(2, 3);
 int _mail_tree_mmap_update(MailTree *tree, int forced);
 int _mail_tree_grow(MailTree *tree);
 void _mail_tree_truncate(MailTree *tree);