changeset 193:c095607a1a28 HEAD

more size_t fixes.
author Timo Sirainen <tss@iki.fi>
date Sun, 08 Sep 2002 18:19:39 +0300
parents fcd6c11710b4
children d82e7d23a28d
files src/lib-imap/imap-bodystructure.c src/lib-index/mail-hash.c src/lib-index/mail-index-update.c src/lib-index/mail-index.c src/lib-index/mail-index.h src/lib-index/mbox/mbox-fsck.c src/lib-index/mbox/mbox-index.c src/lib-storage/index/index-save.c src/lib/macros.h src/login/auth-connection.h
diffstat 10 files changed, 31 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/src/lib-imap/imap-bodystructure.c	Sun Sep 08 18:09:05 2002 +0300
+++ b/src/lib-imap/imap-bodystructure.c	Sun Sep 08 18:19:39 2002 +0300
@@ -105,8 +105,8 @@
 }
 
 static void parse_header(MessagePart *part,
-			 const char *name, unsigned int name_len,
-			 const char *value, unsigned int value_len,
+			 const char *name, size_t name_len,
+			 const char *value, size_t value_len,
 			 void *context)
 {
 	Pool pool = context;
--- a/src/lib-index/mail-hash.c	Sun Sep 08 18:09:05 2002 +0300
+++ b/src/lib-index/mail-hash.c	Sun Sep 08 18:19:39 2002 +0300
@@ -223,7 +223,7 @@
 	size -= pos;
 	memset(block, 0, sizeof(block));
 
-	while (size > sizeof(block)) {
+	while ((uoff_t)size > sizeof(block)) {
 		/* write in 1kb blocks */
 		if (write_full(fd, block, sizeof(block)) < 0)
 			return FALSE;
--- a/src/lib-index/mail-index-update.c	Sun Sep 08 18:09:05 2002 +0300
+++ b/src/lib-index/mail-index-update.c	Sun Sep 08 18:19:39 2002 +0300
@@ -22,8 +22,8 @@
 
 	unsigned int updated_fields;
 	void *fields[FIELD_TYPE_MAX_BITS];
-	unsigned int field_sizes[FIELD_TYPE_MAX_BITS];
-	unsigned int field_extra_sizes[FIELD_TYPE_MAX_BITS];
+	size_t field_sizes[FIELD_TYPE_MAX_BITS];
+	size_t field_extra_sizes[FIELD_TYPE_MAX_BITS];
 };
 
 MailIndexUpdate *mail_index_update_begin(MailIndex *index, MailIndexRecord *rec)
@@ -116,7 +116,7 @@
 	uoff_t fpos;
 	void *mem;
 	const void *src;
-	unsigned int max_size, pos, src_size;
+	size_t max_size, pos, src_size;
 	int i;
 
 	/* allocate the old size + also the new size of all changed or added
@@ -260,8 +260,8 @@
 }
 
 static void update_field_full(MailIndexUpdate *update, MailField field,
-			      const void *value, unsigned int size,
-			      unsigned int extra_space)
+			      const void *value, size_t size,
+			      size_t extra_space)
 {
 	int index;
 
@@ -278,17 +278,11 @@
 void mail_index_update_field(MailIndexUpdate *update, MailField field,
 			     const char *value, unsigned int extra_space)
 {
-	size_t len;
-
-	len = strlen(value);
-	i_assert(len < SSIZE_T_MAX);
-
-	update_field_full(update, field, value,
-			  (unsigned int)len + 1, extra_space);
+	update_field_full(update, field, value, strlen(value) + 1, extra_space);
 }
 
 void mail_index_update_field_raw(MailIndexUpdate *update, MailField field,
-				 const void *value, unsigned int size)
+				 const void *value, size_t size)
 {
 	update_field_full(update, field, value, size, 0);
 }
@@ -309,10 +303,10 @@
 	return 0;
 }
 
-static const char *field_get_value(const char *value, unsigned int len)
+static const char *field_get_value(const char *value, size_t len)
 {
 	char *ret, *p;
-	unsigned int i;
+	size_t i;
 
 	ret = t_malloc(len+1);
 
@@ -398,7 +392,7 @@
 	MessageSize hdr_size;
 	Pool pool;
 	const char *value;
-	unsigned int size;
+	size_t size;
 
 	ctx.update = update;
 	ctx.envelope_pool = NULL;
--- a/src/lib-index/mail-index.c	Sun Sep 08 18:09:05 2002 +0300
+++ b/src/lib-index/mail-index.c	Sun Sep 08 18:19:39 2002 +0300
@@ -1116,7 +1116,7 @@
 }
 
 const void *mail_index_lookup_field_raw(MailIndex *index, MailIndexRecord *rec,
-					MailField field, unsigned int *size)
+					MailField field, size_t *size)
 {
 	MailIndexDataRecord *datarec;
 
--- a/src/lib-index/mail-index.h	Sun Sep 08 18:09:05 2002 +0300
+++ b/src/lib-index/mail-index.h	Sun Sep 08 18:19:39 2002 +0300
@@ -228,7 +228,7 @@
 
 	/* Find field from specified record, or NULL if it's not in index. */
 	const void *(*lookup_field_raw)(MailIndex *index, MailIndexRecord *rec,
-					MailField field, unsigned int *size);
+					MailField field, size_t *size);
 
 	/* Returns sequence for given message, or 0 if failed. */
 	unsigned int (*get_sequence)(MailIndex *index, MailIndexRecord *rec);
@@ -281,9 +281,9 @@
 	int (*update_end)(MailIndexUpdate *update);
 
 	void (*update_field)(MailIndexUpdate *update, MailField field,
-			     const char *value, unsigned int extra_space);
+			     const char *value, size_t extra_space);
 	void (*update_field_raw)(MailIndexUpdate *update, MailField field,
-				 const void *value, unsigned int size);
+				 const void *value, size_t size);
 
 	/* Returns last error message */
 	const char *(*get_last_error)(MailIndex *index);
@@ -359,7 +359,7 @@
 const char *mail_index_lookup_field(MailIndex *index, MailIndexRecord *rec,
 				    MailField field);
 const void *mail_index_lookup_field_raw(MailIndex *index, MailIndexRecord *rec,
-					MailField field, unsigned int *size);
+					MailField field, size_t *size);
 unsigned int mail_index_get_sequence(MailIndex *index, MailIndexRecord *rec);
 int mail_index_expunge(MailIndex *index, MailIndexRecord *rec,
 		       unsigned int seq, int external_change);
@@ -371,9 +371,9 @@
 					 MailIndexRecord *rec);
 int mail_index_update_end(MailIndexUpdate *update);
 void mail_index_update_field(MailIndexUpdate *update, MailField field,
-			     const char *value, unsigned int extra_space);
+			     const char *value, size_t extra_space);
 void mail_index_update_field_raw(MailIndexUpdate *update, MailField field,
-				 const void *value, unsigned int size);
+				 const void *value, size_t size);
 const char *mail_index_get_last_error(MailIndex *index);
 int mail_index_is_inconsistency_error(MailIndex *index);
 
--- a/src/lib-index/mbox/mbox-fsck.c	Sun Sep 08 18:09:05 2002 +0300
+++ b/src/lib-index/mbox/mbox-fsck.c	Sun Sep 08 18:19:39 2002 +0300
@@ -15,7 +15,7 @@
 static void skip_line(IOBuffer *inbuf)
 {
 	unsigned char *msg;
-	unsigned int i, size;
+	size_t i, size;
 
 	while (io_buffer_read_data(inbuf, &msg, &size, 0) >= 0) {
 		for (i = 0; i < size; i++) {
@@ -47,7 +47,7 @@
 static int verify_end_of_body(IOBuffer *inbuf, uoff_t end_offset)
 {
 	unsigned char *data;
-	unsigned int size;
+	size_t size;
 
 	/* don't bother parsing the whole body, just make
 	   sure it ends properly */
@@ -190,7 +190,8 @@
 	MailIndexRecord *rec;
 	uoff_t from_offset;
 	unsigned char *data;
-	unsigned int seq, size;
+	unsigned int seq;
+        size_t size;
 
 	if (!index->set_lock(index, MAIL_LOCK_EXCLUSIVE))
 		return FALSE;
--- a/src/lib-index/mbox/mbox-index.c	Sun Sep 08 18:09:05 2002 +0300
+++ b/src/lib-index/mbox/mbox-index.c	Sun Sep 08 18:19:39 2002 +0300
@@ -256,7 +256,7 @@
 			       uoff_t *offset)
 {
 	const uoff_t *location;
-	size_t size;
+	unsigned int size;
 
 	location = index->lookup_field_raw(index, rec,
 					   FIELD_TYPE_LOCATION, &size);
--- a/src/lib-storage/index/index-save.c	Sun Sep 08 18:09:05 2002 +0300
+++ b/src/lib-storage/index/index-save.c	Sun Sep 08 18:19:39 2002 +0300
@@ -41,8 +41,9 @@
 			       IOBuffer *buf, uoff_t data_size)
 {
 	unsigned char *data;
-	size_t size, last_cr;
+	size_t size;
 	ssize_t ret;
+	int last_cr;
 
 	last_cr = FALSE;
 
--- a/src/lib/macros.h	Sun Sep 08 18:09:05 2002 +0300
+++ b/src/lib/macros.h	Sun Sep 08 18:19:39 2002 +0300
@@ -35,8 +35,8 @@
 #define POINTER_TO_INT(p)	((int) (p))
 #define POINTER_TO_UINT(p)	((unsigned int) ((char *) p - (char *) NULL))
 
-#define INT_TO_POINTER(i)	((void *) (i))
-#define UINT_TO_POINTER(u)	((void *) (u))
+#define INT_TO_POINTER(i)	((void *) (size_t) (i))
+#define UINT_TO_POINTER(u)	((void *) (size_t) (u))
 
 /* Define VA_COPY() to do the right thing for copying va_list variables. */
 #ifndef VA_COPY
--- a/src/login/auth-connection.h	Sun Sep 08 18:09:05 2002 +0300
+++ b/src/login/auth-connection.h	Sun Sep 08 18:19:39 2002 +0300
@@ -7,7 +7,7 @@
    reply_data_size contains the error message. */
 typedef void (*AuthCallback)(AuthRequest *request, int auth_process,
 			     AuthResult result, const unsigned char *reply_data,
-			     unsigned int reply_data_size, void *context);
+			     size_t reply_data_size, void *context);
 
 struct _AuthRequest {
         AuthMethod method;
@@ -28,7 +28,7 @@
 		      void *context, const char **error);
 
 void auth_continue_request(AuthRequest *request, const unsigned char *data,
-			   unsigned int data_size);
+			   size_t data_size);
 
 void auth_connection_init(void);
 void auth_connection_deinit(void);