Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

fix compiler warnings

especially deprecation warnings from glib
  • Loading branch information...
commit dad39f7a8dcf498bb03778dbe80af2447d1526dc 1 parent 4844252
Paul J Stevens authored August 07, 2012
2  debian/rules
@@ -30,7 +30,7 @@ ifneq (,$(findstring devel,$(DEB_BUILD_OPTIONS)))
30 30
 #	export REAL_CLEAN=mrproper
31 31
 	export WITH_LDAP=
32 32
 	export WITH_SIEVE=
33  
-	CFLAGS = -Wall -g -std=gnu99
  33
+	CFLAGS = -Wall -g
34 34
 endif
35 35
 ifneq (,$(findstring ldap,$(DEB_BUILD_OPTIONS)))
36 36
 	export WITH_LDAP=--with-ldap
60  src/dbmail-message.c
@@ -299,7 +299,7 @@ static GMimeContentType *find_type(const char *s)
299 299
 
300 300
 	rest = g_strcasestr(s, "\nContent-type: ");
301 301
 	if (! rest) {
302  
-		if ((g_strncasecmp(s, "Content-type: ", 14)) == 0)
  302
+		if ((g_ascii_strncasecmp(s, "Content-type: ", 14)) == 0)
303 303
 			rest = (char *)s;
304 304
 	}
305 305
 	if (! rest) return NULL;
@@ -344,7 +344,7 @@ static DbmailMessage * _mime_retrieve(DbmailMessage *self)
344 344
 	char *boundary = NULL;
345 345
 	GMimeContentType *mimetype = NULL;
346 346
 	int maxdepth = 128;
347  
-	volatile char **blist = g_new0(char *, maxdepth);
  347
+	volatile char **blist = g_new0(volatile char *, maxdepth);
348 348
 	int prevdepth, depth = 0, order, row = 0, key = 1;
349 349
 	volatile int t = FALSE;
350 350
 	gboolean got_boundary = FALSE, prev_boundary = FALSE, is_header = TRUE, prev_header, finalized=FALSE;
@@ -379,7 +379,7 @@ static DbmailMessage * _mime_retrieve(DbmailMessage *self)
379 379
 			depth		= db_result_get_int(r,1);
380 380
 			while (maxdepth < (depth + 1)) {
381 381
 				int newmaxdepth = 2 * depth;
382  
-				blist = g_renew(char *, blist, newmaxdepth);
  382
+				blist = g_renew(volatile char *, blist, newmaxdepth);
383 383
 				while (maxdepth < newmaxdepth)
384 384
 					blist[maxdepth++] = NULL;
385 385
 			}
@@ -406,14 +406,14 @@ static DbmailMessage * _mime_retrieve(DbmailMessage *self)
406 406
 			if (is_header && ((boundary = find_boundary(str)) != NULL)) {
407 407
 				got_boundary = TRUE;
408 408
 				dprint("<boundary depth=\"%d\">%s</boundary>\n", depth, boundary);
409  
-				if (blist[depth]) g_free(blist[depth]);
  409
+				if (blist[depth]) g_free((void *)blist[depth]);
410 410
 				blist[depth] = boundary;
411 411
 			}
412 412
 
413 413
 			if (prevdepth > depth && blist[depth]) {
414 414
 				dprint("\n--%s at %d--\n", blist[depth], depth);
415 415
 				g_string_append_printf(m, "\n--%s--\n", blist[depth]);
416  
-				g_free(blist[depth]);
  416
+				g_free((void *)blist[depth]);
417 417
 				blist[depth] = NULL;
418 418
 				finalized=TRUE;
419 419
 			}
@@ -452,7 +452,7 @@ static DbmailMessage * _mime_retrieve(DbmailMessage *self)
452 452
 	}
453 453
 
454 454
 	if (row > 2 && depth > 0 && boundary && blist[0] && !finalized) {
455  
-		if (strcmp(blist[0],boundary)!=0) {
  455
+		if (strcmp((const char *)blist[0],boundary)!=0) {
456 456
 			dprint("\n--%s-- final\n", blist[0]);
457 457
 			g_string_append_printf(m, "\n--%s--\n\n", blist[0]);
458 458
 		} else
@@ -466,7 +466,7 @@ static DbmailMessage * _mime_retrieve(DbmailMessage *self)
466 466
 	g_string_free(n,TRUE);
467 467
 	while (--maxdepth >= 0) {
468 468
 		if (blist[maxdepth])
469  
-			g_free(blist[maxdepth]);
  469
+			g_free((void *)blist[maxdepth]);
470 470
 	}
471 471
 	g_free(blist);
472 472
 	return self;
@@ -667,7 +667,7 @@ void dbmail_message_free(DbmailMessage *self)
667 667
 		return;
668 668
 
669 669
 	if (self->headers) {
670  
-		g_relation_destroy(self->headers);
  670
+		g_hash_table_destroy(self->headers);
671 671
 		self->headers = NULL;
672 672
 	}
673 673
 	if (self->content) {
@@ -738,7 +738,7 @@ DbmailMessage * dbmail_message_init_with_string(DbmailMessage *self, const GStri
738 738
 	assert(self->content == NULL);
739 739
 
740 740
 	stream = g_mime_stream_mem_new_with_buffer(str->str, str->len);
741  
-	g_mime_stream_mem_set_owner(stream, TRUE);
  741
+	g_mime_stream_mem_set_owner(GMIME_STREAM_MEM(stream), TRUE);
742 742
 
743 743
 	parser = g_mime_parser_new_with_stream(stream);
744 744
 	g_object_unref(stream);
@@ -786,12 +786,13 @@ static void _map_headers(DbmailMessage *self)
786 786
 {
787 787
 	GMimeObject *part;
788 788
 	assert(self->content);
789  
-	if (self->headers) g_relation_destroy(self->headers);
  789
+	if (self->headers) g_hash_table_destroy(self->headers);
790 790
 
791  
-	self->headers = g_relation_new(2);
792  
-
793  
-	g_relation_index(self->headers, 0, (GHashFunc)g_str_hash, (GEqualFunc)g_str_case_equal);
794  
-	g_relation_index(self->headers, 1, (GHashFunc)g_str_hash, (GEqualFunc)g_str_case_equal);
  791
+	self->headers = g_hash_table_new_full(
  792
+			(GHashFunc)g_str_hash, 
  793
+			(GEqualFunc)g_str_case_equal,
  794
+			(GDestroyNotify)NULL,
  795
+			(GDestroyNotify)NULL);
795 796
 
796 797
 	if (GMIME_IS_MESSAGE(self->content)) {
797 798
 		char *type = NULL;
@@ -825,8 +826,11 @@ static void _register_header(const char *header, const char *value, gpointer use
825 826
 		hvalue = value;
826 827
 	}
827 828
 	
828  
-	if (m->headers && (! g_relation_exists(m->headers, hname, hvalue)))
829  
-		g_relation_insert(m->headers, hname, hvalue);
  829
+	if (m->headers) {
  830
+		GList *values = g_hash_table_lookup(m->headers, hname);
  831
+		values = g_list_append(values, (void *)hvalue);
  832
+		g_hash_table_insert(m->headers, (void *)hname, (void *)values);
  833
+	}
830 834
 }
831 835
 
832 836
 void dbmail_message_set_physid(DbmailMessage *self, uint64_t physid)
@@ -904,12 +908,12 @@ const gchar * dbmail_message_get_header(const DbmailMessage *self, const char *h
904 908
 	return g_mime_object_get_header(GMIME_OBJECT(self->content), header);
905 909
 }
906 910
 
907  
-GTuples * dbmail_message_get_header_repeated(const DbmailMessage *self, const char *header)
  911
+GList * dbmail_message_get_header_repeated(const DbmailMessage *self, const char *header)
908 912
 {
909 913
 	const char *hname;
910 914
 	if (! (hname = g_tree_lookup(self->header_name,header)))
911 915
 		hname = header;
912  
-	return g_relation_select(self->headers, hname, 0);
  916
+	return (GList *)g_hash_table_lookup(self->headers, hname);
913 917
 }
914 918
 
915 919
 GList * dbmail_message_get_header_addresses(DbmailMessage *message, const char *field_name)
@@ -1627,9 +1631,8 @@ static gboolean _header_cache(const char UNUSED *key, const char *header, gpoint
1627 1631
 	uint64_t headername_id;
1628 1632
 	uint64_t headervalue_id;
1629 1633
 	DbmailMessage *self = (DbmailMessage *)user_data;
1630  
-	GTuples *values;
  1634
+	GList *values;
1631 1635
 	unsigned char *raw;
1632  
-	unsigned i;
1633 1636
 	time_t date;
1634 1637
 	volatile gboolean isaddr = 0, isdate = 0, issubject = 0;
1635 1638
 	const char *charset = dbmail_message_get_charset(self);
@@ -1663,17 +1666,20 @@ static gboolean _header_cache(const char UNUSED *key, const char *header, gpoint
1663 1666
 	else if (g_ascii_strcasecmp(header,"Date")==0)
1664 1667
 		isdate=1;
1665 1668
 
1666  
-	values = g_relation_select(self->headers,header,0);
  1669
+	values = g_hash_table_lookup(self->headers,header);
1667 1670
 
1668  
-	for (i=0; i<values->len;i++) {
  1671
+	while (values) {
1669 1672
 		char *value = NULL;
1670  
-		raw = (unsigned char *)g_tuples_index(values,i,1);
  1673
+		raw = (unsigned char *)values->data;
1671 1674
 		TRACE(TRACE_DEBUG,"raw header value [%s]", raw);
1672 1675
 
1673 1676
 		value = dbmail_iconv_decode_field((const char *)raw, charset, isaddr);
1674 1677
 
1675 1678
 		if ((! value) || (strlen(value) == 0)) {
1676 1679
 			if (value) g_free(value);
  1680
+			if (! g_list_next(values))
  1681
+				break;
  1682
+			values = g_list_next(values);
1677 1683
 			continue;
1678 1684
 		}
1679 1685
 
@@ -1755,9 +1761,13 @@ static gboolean _header_cache(const char UNUSED *key, const char *header, gpoint
1755 1761
 		g_free(datefield); datefield = NULL;
1756 1762
 		emaillist=NULL;
1757 1763
 		date=0;
  1764
+
  1765
+		if (! g_list_next(values))
  1766
+			break;
  1767
+
  1768
+		values = g_list_next(values);
1758 1769
 	}
1759 1770
 	
1760  
-	g_tuples_destroy(values);
1761 1771
 	return FALSE;
1762 1772
 }
1763 1773
 
@@ -2184,7 +2194,7 @@ dsn_class_t sort_deliver_to_mailbox(DbmailMessage *message,
2184 2194
 		TRACE(TRACE_NOTICE, "message id=%lu, size=%zd is inserted", 
2185 2195
 				newmsgidnr, msgsize);
2186 2196
 		if (msgflags || keywords) {
2187  
-			TRACE(TRACE_NOTICE, "message id=%llu, setting imap flags", 
  2197
+			TRACE(TRACE_NOTICE, "message id=%lu, setting imap flags", 
2188 2198
 				newmsgidnr);
2189 2199
 			db_set_msgflag(newmsgidnr, msgflags, keywords, IMAPFA_ADD, NULL);
2190 2200
 			db_mailbox_seq_update(mboxidnr);
2  src/dbmail-message.h
@@ -94,7 +94,7 @@ void dbmail_message_set_header(DbmailMessage *self, const char *header, const ch
94 94
 const gchar * dbmail_message_get_header(const DbmailMessage *self, const char *header);
95 95
 
96 96
 /* Get all instances of a header. */
97  
-GTuples * dbmail_message_get_header_repeated(const DbmailMessage *self, const char *header);
  97
+GList * dbmail_message_get_header_repeated(const DbmailMessage *self, const char *header);
98 98
 
99 99
 void dbmail_message_cache_referencesfield(const DbmailMessage *self);
100 100
 void dbmail_message_cache_envelope(const DbmailMessage *self);
2  src/dbmailtypes.h
@@ -138,7 +138,7 @@ typedef struct {
138 138
 	enum DBMAIL_MESSAGE_CLASS klass;
139 139
 	GMimeObject *content;
140 140
 	gchar *raw_content;
141  
-	GRelation *headers;
  141
+	GHashTable *headers;
142 142
 	GHashTable *header_dict;
143 143
 	GTree *header_name;
144 144
 	GTree *header_value;
6  src/dm_db.c
@@ -892,7 +892,7 @@ static int user_idnr_is_delivery_user_idnr(uint64_t user_idnr)
892 892
 {
893 893
 	static int delivery_user_idnr_looked_up = 0;
894 894
 	static uint64_t delivery_user_idnr;
895  
-	static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
  895
+	G_LOCK_DEFINE_STATIC(mutex);
896 896
 
897 897
 	if (delivery_user_idnr_looked_up == 0) {
898 898
 		uint64_t idnr;
@@ -901,10 +901,10 @@ static int user_idnr_is_delivery_user_idnr(uint64_t user_idnr)
901 901
 			TRACE(TRACE_ERR, "error looking up user_idnr for %s", DBMAIL_DELIVERY_USERNAME);
902 902
 			return DM_EQUERY;
903 903
 		}
904  
-		g_static_mutex_lock(&mutex);
  904
+		G_LOCK(mutex);
905 905
 		delivery_user_idnr = idnr;
906 906
 		delivery_user_idnr_looked_up = 1;
907  
-		g_static_mutex_unlock(&mutex);
  907
+		G_UNLOCK(mutex);
908 908
 	}
909 909
 	
910 910
 	if (delivery_user_idnr == user_idnr)
12  src/dm_http.c
@@ -354,12 +354,14 @@ void Http_getMessages(T R)
354 354
 				char *hname = headerlist[i];
355 355
 				hname[0] = g_ascii_toupper(hname[0]);
356 356
 				TRACE(TRACE_DEBUG,"header: [%s]", headerlist[i]);
357  
-				unsigned j = 0;
358  
-				GTuples * headers = dbmail_message_get_header_repeated(m, headerlist[i]);
359  
-				for (j=0; j<headers->len; j++) {
360  
-					evbuffer_add_printf(buf, "%s: %s\n", hname, (char *)g_tuples_index(headers,j,1));
  357
+				GList * headers = dbmail_message_get_header_repeated(m, headerlist[i]);
  358
+
  359
+				while(headers) {
  360
+					evbuffer_add_printf(buf, "%s: %s\n", hname, (char *)headers->data);
  361
+					if (! g_list_next(headers))
  362
+						break;
  363
+					headers = g_list_next(headers);
361 364
 				}
362  
-				g_tuples_destroy(headers);
363 365
 				i++;
364 366
 			}
365 367
 		} else {
22  src/dm_iconv.c
@@ -28,7 +28,7 @@ static GOnce iconv_once = G_ONCE_INIT;
28 28
 
29 29
 struct DbmailIconv *ic;
30 30
 
31  
-static GStaticRecMutex mutex = G_STATIC_REC_MUTEX_INIT;
  31
+G_LOCK_DEFINE_STATIC(mutex);
32 32
 
33 33
 static void dbmail_iconv_close(void)
34 34
 {
@@ -108,9 +108,9 @@ char * dbmail_iconv_str_to_utf8(const char* str_in, const char *charset)
108 108
 	}
109 109
 
110 110
 	if (subj==NULL) {
111  
-		LOCK(&mutex);
  111
+		G_LOCK(mutex);
112 112
 		subj=g_mime_iconv_strdup(ic->from_msg,str_in);
113  
-		UNLOCK(&mutex);
  113
+		G_UNLOCK(mutex);
114 114
 	}
115 115
 
116 116
 	if (subj==NULL) {
@@ -137,9 +137,9 @@ char * dbmail_iconv_str_to_db(const char* str_in, const char *charset)
137 137
 	if (! g_mime_utils_text_is_8bit((unsigned char *)str_in, strlen(str_in)) )
138 138
 		return g_strdup(str_in);
139 139
 
140  
-	LOCK(&mutex);
  140
+	G_LOCK(mutex);
141 141
 	subj = g_mime_iconv_strdup(ic->to_db,str_in);
142  
-	UNLOCK(&mutex);
  142
+	G_UNLOCK(mutex);
143 143
 
144 144
 	if (subj != NULL)
145 145
 		return subj;
@@ -155,14 +155,14 @@ char * dbmail_iconv_str_to_db(const char* str_in, const char *charset)
155 155
 	if (subj==NULL) {
156 156
 		char *subj2;
157 157
 
158  
-		LOCK(&mutex);
  158
+		G_LOCK(mutex);
159 159
 		subj2 = g_mime_iconv_strdup(ic->from_msg,str_in);
160  
-		UNLOCK(&mutex);
  160
+		G_UNLOCK(mutex);
161 161
 
162 162
 		if (subj2 != NULL) {
163  
-			LOCK(&mutex);
  163
+			G_LOCK(mutex);
164 164
 			subj = g_mime_iconv_strdup(ic->to_db, subj2);
165  
-			UNLOCK(&mutex);
  165
+			G_UNLOCK(mutex);
166 166
 			g_free(subj2);
167 167
 		}
168 168
 	}
@@ -190,9 +190,9 @@ char * dbmail_iconv_db_to_utf7(const char* str_in)
190 190
 		return g_strdup(str_in);
191 191
 
192 192
 	if (! g_utf8_validate((const char *)str_in,-1,NULL)) {
193  
-		LOCK(&mutex);
  193
+		G_LOCK(mutex);
194 194
 		subj = g_mime_iconv_strdup(ic->from_db, str_in);
195  
-		UNLOCK(&mutex);
  195
+		G_UNLOCK(mutex);
196 196
 		if (subj != NULL){
197 197
 			gchar *subj2;
198 198
 			subj2 = g_mime_utils_header_encode_text((const char *)subj);
2  src/dm_misc.c
@@ -1340,7 +1340,7 @@ static GList * imap_append_hash_as_string(GList *list, const GMimeParam *hash)
1340 1340
 	while (hash) {
1341 1341
 		size_t len;
1342 1342
 		char *clean1, *clean2, *clean3;
1343  
-		gchar *value = g_mime_param_get_value(hash);
  1343
+		gchar *value = (char *)g_mime_param_get_value(hash);
1344 1344
 		l = g_list_append_printf(l, "\"%s\"", g_mime_param_get_name(hash));
1345 1345
 		clean1 = value;
1346 1346
 		if (clean1[0] == '"')
3  src/dm_sset.c
@@ -24,6 +24,7 @@
24 24
 #include <glib.h>
25 25
 
26 26
 #include "dm_sset.h"
  27
+#include "dm_debug.h"
27 28
 
28 29
 #define THIS_MODULE "SSET"
29 30
 
@@ -88,7 +89,7 @@ struct mapper_data {
88 89
 	void *data;
89 90
 };
90 91
 
91  
-static int mapper(void *key, void *value, void *data)
  92
+static int mapper(void *key, void UNUSED *value, void *data)
92 93
 {
93 94
 	struct mapper_data *m = (struct mapper_data *)data;
94 95
 	return m->func(key, m->data)?1:0;
16  src/modules/sortsieve.c
@@ -170,7 +170,7 @@ int send_alert(uint64_t user_idnr, char *subject, char *body)
170 170
 
171 171
 	if (sort_deliver_to_mailbox(new_message, user_idnr,
172 172
 			"INBOX", BOX_BRUTEFORCE, msgflags, NULL) != DSN_CLASS_OK) {
173  
-		TRACE(TRACE_ERR, "Unable to deliver alert [%s] to user [%llu]", subject, user_idnr);
  173
+		TRACE(TRACE_ERR, "Unable to deliver alert [%s] to user [%lu]", subject, user_idnr);
174 174
 	}
175 175
 
176 176
 	g_free(to);
@@ -522,17 +522,21 @@ int sort_getheader(sieve2_context_t *s, void *my)
522 522
 	struct sort_context *m = (struct sort_context *)my;
523 523
 	char *header;
524 524
 	char **bodylist;
525  
-	GTuples *headers;
  525
+	GList *headers;
526 526
 	unsigned i;
527 527
 
528 528
 	header = (char *)sieve2_getvalue_string(s, "header");
529 529
 	
530 530
 	headers = dbmail_message_get_header_repeated(m->message, header);
531 531
 	
532  
-	bodylist = g_new0(char *,headers->len+1);
533  
-	for (i=0; i<headers->len; i++)
534  
-		bodylist[i] = (char *)g_tuples_index(headers,i,1);
535  
-	g_tuples_destroy(headers);
  532
+	bodylist = g_new0(char *,g_list_length(headers)+1);
  533
+	i = 0;
  534
+	while (headers) {
  535
+		bodylist[i++] = (char *)headers->data;
  536
+		if (! g_list_next(headers))
  537
+			break;
  538
+		headers = g_list_next(headers);
  539
+	}
536 540
 
537 541
 	/* We have to free the header array, but not its contents. */
538 542
 	m->freelist = g_list_prepend(m->freelist, bodylist);
18  test/check_dbmail_message.c
@@ -425,13 +425,13 @@ END_TEST
425 425
 START_TEST(test_dbmail_message_init_with_string)
426 426
 {
427 427
 	DbmailMessage *m;
428  
-	GTuples *t;
  428
+	GList *t;
429 429
 	
430 430
 	m = message_init(multipart_message);
431 431
 	
432  
-	t = g_relation_select(m->headers, "Received", 0);
433  
-	fail_unless(t->len==2,"Too few or too many headers in tuple [%d]\n", t->len);
434  
-	g_tuples_destroy(t);
  432
+	t = g_hash_table_lookup(m->headers, "Received");
  433
+	fail_unless(g_list_length(t)==3,"Too few or too many headers in tuple [%d]\n", 
  434
+			g_list_length(t));
435 435
 	dbmail_message_free(m);
436 436
 	
437 437
 //	m = message_init(simple_message_part);
@@ -724,7 +724,7 @@ END_TEST
724 724
 
725 725
 START_TEST(test_dbmail_message_get_header_repeated)
726 726
 {
727  
-	GTuples *headers;
  727
+	GList *headers;
728 728
 	GString *s;
729 729
 	DbmailMessage *m;
730 730
 
@@ -735,17 +735,13 @@ START_TEST(test_dbmail_message_get_header_repeated)
735 735
 	headers = dbmail_message_get_header_repeated(m, "Received");
736 736
 
737 737
 	fail_unless(headers != NULL, "dbmail_message_get_header_repeated failed");
738  
-	fail_unless(headers->len==2, "dbmail_message_get_header_repeated failed");
  738
+	fail_unless(g_list_length(headers)==3, "dbmail_message_get_header_repeated failed");
739 739
 	
740  
-	g_tuples_destroy(headers);
741  
-
742 740
 	headers = dbmail_message_get_header_repeated(m, "received");
743 741
 
744 742
 	fail_unless(headers != NULL, "dbmail_message_get_header_repeated failed");
745  
-	fail_unless(headers->len==2, "dbmail_message_get_header_repeated failed");
  743
+	fail_unless(g_list_length(headers)==3, "dbmail_message_get_header_repeated failed");
746 744
 	
747  
-	g_tuples_destroy(headers);
748  
-
749 745
 	dbmail_message_free(m);
750 746
 	g_string_free(s,TRUE);
751 747
 }

0 notes on commit dad39f7

Please sign in to comment.
Something went wrong with that request. Please try again.