Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

fix compiler warnings

especially deprecation warnings from glib
  • Loading branch information...
commit dad39f7a8dcf498bb03778dbe80af2447d1526dc 1 parent 4844252
@pjstevns authored
View
2  debian/rules
@@ -30,7 +30,7 @@ ifneq (,$(findstring devel,$(DEB_BUILD_OPTIONS)))
# export REAL_CLEAN=mrproper
export WITH_LDAP=
export WITH_SIEVE=
- CFLAGS = -Wall -g -std=gnu99
+ CFLAGS = -Wall -g
endif
ifneq (,$(findstring ldap,$(DEB_BUILD_OPTIONS)))
export WITH_LDAP=--with-ldap
View
60 src/dbmail-message.c
@@ -299,7 +299,7 @@ static GMimeContentType *find_type(const char *s)
rest = g_strcasestr(s, "\nContent-type: ");
if (! rest) {
- if ((g_strncasecmp(s, "Content-type: ", 14)) == 0)
+ if ((g_ascii_strncasecmp(s, "Content-type: ", 14)) == 0)
rest = (char *)s;
}
if (! rest) return NULL;
@@ -344,7 +344,7 @@ static DbmailMessage * _mime_retrieve(DbmailMessage *self)
char *boundary = NULL;
GMimeContentType *mimetype = NULL;
int maxdepth = 128;
- volatile char **blist = g_new0(char *, maxdepth);
+ volatile char **blist = g_new0(volatile char *, maxdepth);
int prevdepth, depth = 0, order, row = 0, key = 1;
volatile int t = FALSE;
gboolean got_boundary = FALSE, prev_boundary = FALSE, is_header = TRUE, prev_header, finalized=FALSE;
@@ -379,7 +379,7 @@ static DbmailMessage * _mime_retrieve(DbmailMessage *self)
depth = db_result_get_int(r,1);
while (maxdepth < (depth + 1)) {
int newmaxdepth = 2 * depth;
- blist = g_renew(char *, blist, newmaxdepth);
+ blist = g_renew(volatile char *, blist, newmaxdepth);
while (maxdepth < newmaxdepth)
blist[maxdepth++] = NULL;
}
@@ -406,14 +406,14 @@ static DbmailMessage * _mime_retrieve(DbmailMessage *self)
if (is_header && ((boundary = find_boundary(str)) != NULL)) {
got_boundary = TRUE;
dprint("<boundary depth=\"%d\">%s</boundary>\n", depth, boundary);
- if (blist[depth]) g_free(blist[depth]);
+ if (blist[depth]) g_free((void *)blist[depth]);
blist[depth] = boundary;
}
if (prevdepth > depth && blist[depth]) {
dprint("\n--%s at %d--\n", blist[depth], depth);
g_string_append_printf(m, "\n--%s--\n", blist[depth]);
- g_free(blist[depth]);
+ g_free((void *)blist[depth]);
blist[depth] = NULL;
finalized=TRUE;
}
@@ -452,7 +452,7 @@ static DbmailMessage * _mime_retrieve(DbmailMessage *self)
}
if (row > 2 && depth > 0 && boundary && blist[0] && !finalized) {
- if (strcmp(blist[0],boundary)!=0) {
+ if (strcmp((const char *)blist[0],boundary)!=0) {
dprint("\n--%s-- final\n", blist[0]);
g_string_append_printf(m, "\n--%s--\n\n", blist[0]);
} else
@@ -466,7 +466,7 @@ static DbmailMessage * _mime_retrieve(DbmailMessage *self)
g_string_free(n,TRUE);
while (--maxdepth >= 0) {
if (blist[maxdepth])
- g_free(blist[maxdepth]);
+ g_free((void *)blist[maxdepth]);
}
g_free(blist);
return self;
@@ -667,7 +667,7 @@ void dbmail_message_free(DbmailMessage *self)
return;
if (self->headers) {
- g_relation_destroy(self->headers);
+ g_hash_table_destroy(self->headers);
self->headers = NULL;
}
if (self->content) {
@@ -738,7 +738,7 @@ DbmailMessage * dbmail_message_init_with_string(DbmailMessage *self, const GStri
assert(self->content == NULL);
stream = g_mime_stream_mem_new_with_buffer(str->str, str->len);
- g_mime_stream_mem_set_owner(stream, TRUE);
+ g_mime_stream_mem_set_owner(GMIME_STREAM_MEM(stream), TRUE);
parser = g_mime_parser_new_with_stream(stream);
g_object_unref(stream);
@@ -786,12 +786,13 @@ static void _map_headers(DbmailMessage *self)
{
GMimeObject *part;
assert(self->content);
- if (self->headers) g_relation_destroy(self->headers);
+ if (self->headers) g_hash_table_destroy(self->headers);
- self->headers = g_relation_new(2);
-
- g_relation_index(self->headers, 0, (GHashFunc)g_str_hash, (GEqualFunc)g_str_case_equal);
- g_relation_index(self->headers, 1, (GHashFunc)g_str_hash, (GEqualFunc)g_str_case_equal);
+ self->headers = g_hash_table_new_full(
+ (GHashFunc)g_str_hash,
+ (GEqualFunc)g_str_case_equal,
+ (GDestroyNotify)NULL,
+ (GDestroyNotify)NULL);
if (GMIME_IS_MESSAGE(self->content)) {
char *type = NULL;
@@ -825,8 +826,11 @@ static void _register_header(const char *header, const char *value, gpointer use
hvalue = value;
}
- if (m->headers && (! g_relation_exists(m->headers, hname, hvalue)))
- g_relation_insert(m->headers, hname, hvalue);
+ if (m->headers) {
+ GList *values = g_hash_table_lookup(m->headers, hname);
+ values = g_list_append(values, (void *)hvalue);
+ g_hash_table_insert(m->headers, (void *)hname, (void *)values);
+ }
}
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
return g_mime_object_get_header(GMIME_OBJECT(self->content), header);
}
-GTuples * dbmail_message_get_header_repeated(const DbmailMessage *self, const char *header)
+GList * dbmail_message_get_header_repeated(const DbmailMessage *self, const char *header)
{
const char *hname;
if (! (hname = g_tree_lookup(self->header_name,header)))
hname = header;
- return g_relation_select(self->headers, hname, 0);
+ return (GList *)g_hash_table_lookup(self->headers, hname);
}
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
uint64_t headername_id;
uint64_t headervalue_id;
DbmailMessage *self = (DbmailMessage *)user_data;
- GTuples *values;
+ GList *values;
unsigned char *raw;
- unsigned i;
time_t date;
volatile gboolean isaddr = 0, isdate = 0, issubject = 0;
const char *charset = dbmail_message_get_charset(self);
@@ -1663,17 +1666,20 @@ static gboolean _header_cache(const char UNUSED *key, const char *header, gpoint
else if (g_ascii_strcasecmp(header,"Date")==0)
isdate=1;
- values = g_relation_select(self->headers,header,0);
+ values = g_hash_table_lookup(self->headers,header);
- for (i=0; i<values->len;i++) {
+ while (values) {
char *value = NULL;
- raw = (unsigned char *)g_tuples_index(values,i,1);
+ raw = (unsigned char *)values->data;
TRACE(TRACE_DEBUG,"raw header value [%s]", raw);
value = dbmail_iconv_decode_field((const char *)raw, charset, isaddr);
if ((! value) || (strlen(value) == 0)) {
if (value) g_free(value);
+ if (! g_list_next(values))
+ break;
+ values = g_list_next(values);
continue;
}
@@ -1755,9 +1761,13 @@ static gboolean _header_cache(const char UNUSED *key, const char *header, gpoint
g_free(datefield); datefield = NULL;
emaillist=NULL;
date=0;
+
+ if (! g_list_next(values))
+ break;
+
+ values = g_list_next(values);
}
- g_tuples_destroy(values);
return FALSE;
}
@@ -2184,7 +2194,7 @@ dsn_class_t sort_deliver_to_mailbox(DbmailMessage *message,
TRACE(TRACE_NOTICE, "message id=%lu, size=%zd is inserted",
newmsgidnr, msgsize);
if (msgflags || keywords) {
- TRACE(TRACE_NOTICE, "message id=%llu, setting imap flags",
+ TRACE(TRACE_NOTICE, "message id=%lu, setting imap flags",
newmsgidnr);
db_set_msgflag(newmsgidnr, msgflags, keywords, IMAPFA_ADD, NULL);
db_mailbox_seq_update(mboxidnr);
View
2  src/dbmail-message.h
@@ -94,7 +94,7 @@ void dbmail_message_set_header(DbmailMessage *self, const char *header, const ch
const gchar * dbmail_message_get_header(const DbmailMessage *self, const char *header);
/* Get all instances of a header. */
-GTuples * dbmail_message_get_header_repeated(const DbmailMessage *self, const char *header);
+GList * dbmail_message_get_header_repeated(const DbmailMessage *self, const char *header);
void dbmail_message_cache_referencesfield(const DbmailMessage *self);
void dbmail_message_cache_envelope(const DbmailMessage *self);
View
2  src/dbmailtypes.h
@@ -138,7 +138,7 @@ typedef struct {
enum DBMAIL_MESSAGE_CLASS klass;
GMimeObject *content;
gchar *raw_content;
- GRelation *headers;
+ GHashTable *headers;
GHashTable *header_dict;
GTree *header_name;
GTree *header_value;
View
6 src/dm_db.c
@@ -892,7 +892,7 @@ static int user_idnr_is_delivery_user_idnr(uint64_t user_idnr)
{
static int delivery_user_idnr_looked_up = 0;
static uint64_t delivery_user_idnr;
- static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+ G_LOCK_DEFINE_STATIC(mutex);
if (delivery_user_idnr_looked_up == 0) {
uint64_t idnr;
@@ -901,10 +901,10 @@ static int user_idnr_is_delivery_user_idnr(uint64_t user_idnr)
TRACE(TRACE_ERR, "error looking up user_idnr for %s", DBMAIL_DELIVERY_USERNAME);
return DM_EQUERY;
}
- g_static_mutex_lock(&mutex);
+ G_LOCK(mutex);
delivery_user_idnr = idnr;
delivery_user_idnr_looked_up = 1;
- g_static_mutex_unlock(&mutex);
+ G_UNLOCK(mutex);
}
if (delivery_user_idnr == user_idnr)
View
12 src/dm_http.c
@@ -354,12 +354,14 @@ void Http_getMessages(T R)
char *hname = headerlist[i];
hname[0] = g_ascii_toupper(hname[0]);
TRACE(TRACE_DEBUG,"header: [%s]", headerlist[i]);
- unsigned j = 0;
- GTuples * headers = dbmail_message_get_header_repeated(m, headerlist[i]);
- for (j=0; j<headers->len; j++) {
- evbuffer_add_printf(buf, "%s: %s\n", hname, (char *)g_tuples_index(headers,j,1));
+ GList * headers = dbmail_message_get_header_repeated(m, headerlist[i]);
+
+ while(headers) {
+ evbuffer_add_printf(buf, "%s: %s\n", hname, (char *)headers->data);
+ if (! g_list_next(headers))
+ break;
+ headers = g_list_next(headers);
}
- g_tuples_destroy(headers);
i++;
}
} else {
View
22 src/dm_iconv.c
@@ -28,7 +28,7 @@ static GOnce iconv_once = G_ONCE_INIT;
struct DbmailIconv *ic;
-static GStaticRecMutex mutex = G_STATIC_REC_MUTEX_INIT;
+G_LOCK_DEFINE_STATIC(mutex);
static void dbmail_iconv_close(void)
{
@@ -108,9 +108,9 @@ char * dbmail_iconv_str_to_utf8(const char* str_in, const char *charset)
}
if (subj==NULL) {
- LOCK(&mutex);
+ G_LOCK(mutex);
subj=g_mime_iconv_strdup(ic->from_msg,str_in);
- UNLOCK(&mutex);
+ G_UNLOCK(mutex);
}
if (subj==NULL) {
@@ -137,9 +137,9 @@ char * dbmail_iconv_str_to_db(const char* str_in, const char *charset)
if (! g_mime_utils_text_is_8bit((unsigned char *)str_in, strlen(str_in)) )
return g_strdup(str_in);
- LOCK(&mutex);
+ G_LOCK(mutex);
subj = g_mime_iconv_strdup(ic->to_db,str_in);
- UNLOCK(&mutex);
+ G_UNLOCK(mutex);
if (subj != NULL)
return subj;
@@ -155,14 +155,14 @@ char * dbmail_iconv_str_to_db(const char* str_in, const char *charset)
if (subj==NULL) {
char *subj2;
- LOCK(&mutex);
+ G_LOCK(mutex);
subj2 = g_mime_iconv_strdup(ic->from_msg,str_in);
- UNLOCK(&mutex);
+ G_UNLOCK(mutex);
if (subj2 != NULL) {
- LOCK(&mutex);
+ G_LOCK(mutex);
subj = g_mime_iconv_strdup(ic->to_db, subj2);
- UNLOCK(&mutex);
+ G_UNLOCK(mutex);
g_free(subj2);
}
}
@@ -190,9 +190,9 @@ char * dbmail_iconv_db_to_utf7(const char* str_in)
return g_strdup(str_in);
if (! g_utf8_validate((const char *)str_in,-1,NULL)) {
- LOCK(&mutex);
+ G_LOCK(mutex);
subj = g_mime_iconv_strdup(ic->from_db, str_in);
- UNLOCK(&mutex);
+ G_UNLOCK(mutex);
if (subj != NULL){
gchar *subj2;
subj2 = g_mime_utils_header_encode_text((const char *)subj);
View
2  src/dm_misc.c
@@ -1340,7 +1340,7 @@ static GList * imap_append_hash_as_string(GList *list, const GMimeParam *hash)
while (hash) {
size_t len;
char *clean1, *clean2, *clean3;
- gchar *value = g_mime_param_get_value(hash);
+ gchar *value = (char *)g_mime_param_get_value(hash);
l = g_list_append_printf(l, "\"%s\"", g_mime_param_get_name(hash));
clean1 = value;
if (clean1[0] == '"')
View
3  src/dm_sset.c
@@ -24,6 +24,7 @@
#include <glib.h>
#include "dm_sset.h"
+#include "dm_debug.h"
#define THIS_MODULE "SSET"
@@ -88,7 +89,7 @@ struct mapper_data {
void *data;
};
-static int mapper(void *key, void *value, void *data)
+static int mapper(void *key, void UNUSED *value, void *data)
{
struct mapper_data *m = (struct mapper_data *)data;
return m->func(key, m->data)?1:0;
View
16 src/modules/sortsieve.c
@@ -170,7 +170,7 @@ int send_alert(uint64_t user_idnr, char *subject, char *body)
if (sort_deliver_to_mailbox(new_message, user_idnr,
"INBOX", BOX_BRUTEFORCE, msgflags, NULL) != DSN_CLASS_OK) {
- TRACE(TRACE_ERR, "Unable to deliver alert [%s] to user [%llu]", subject, user_idnr);
+ TRACE(TRACE_ERR, "Unable to deliver alert [%s] to user [%lu]", subject, user_idnr);
}
g_free(to);
@@ -522,17 +522,21 @@ int sort_getheader(sieve2_context_t *s, void *my)
struct sort_context *m = (struct sort_context *)my;
char *header;
char **bodylist;
- GTuples *headers;
+ GList *headers;
unsigned i;
header = (char *)sieve2_getvalue_string(s, "header");
headers = dbmail_message_get_header_repeated(m->message, header);
- bodylist = g_new0(char *,headers->len+1);
- for (i=0; i<headers->len; i++)
- bodylist[i] = (char *)g_tuples_index(headers,i,1);
- g_tuples_destroy(headers);
+ bodylist = g_new0(char *,g_list_length(headers)+1);
+ i = 0;
+ while (headers) {
+ bodylist[i++] = (char *)headers->data;
+ if (! g_list_next(headers))
+ break;
+ headers = g_list_next(headers);
+ }
/* We have to free the header array, but not its contents. */
m->freelist = g_list_prepend(m->freelist, bodylist);
View
18 test/check_dbmail_message.c
@@ -425,13 +425,13 @@ END_TEST
START_TEST(test_dbmail_message_init_with_string)
{
DbmailMessage *m;
- GTuples *t;
+ GList *t;
m = message_init(multipart_message);
- t = g_relation_select(m->headers, "Received", 0);
- fail_unless(t->len==2,"Too few or too many headers in tuple [%d]\n", t->len);
- g_tuples_destroy(t);
+ t = g_hash_table_lookup(m->headers, "Received");
+ fail_unless(g_list_length(t)==3,"Too few or too many headers in tuple [%d]\n",
+ g_list_length(t));
dbmail_message_free(m);
// m = message_init(simple_message_part);
@@ -724,7 +724,7 @@ END_TEST
START_TEST(test_dbmail_message_get_header_repeated)
{
- GTuples *headers;
+ GList *headers;
GString *s;
DbmailMessage *m;
@@ -735,17 +735,13 @@ START_TEST(test_dbmail_message_get_header_repeated)
headers = dbmail_message_get_header_repeated(m, "Received");
fail_unless(headers != NULL, "dbmail_message_get_header_repeated failed");
- fail_unless(headers->len==2, "dbmail_message_get_header_repeated failed");
+ fail_unless(g_list_length(headers)==3, "dbmail_message_get_header_repeated failed");
- g_tuples_destroy(headers);
-
headers = dbmail_message_get_header_repeated(m, "received");
fail_unless(headers != NULL, "dbmail_message_get_header_repeated failed");
- fail_unless(headers->len==2, "dbmail_message_get_header_repeated failed");
+ fail_unless(g_list_length(headers)==3, "dbmail_message_get_header_repeated failed");
- g_tuples_destroy(headers);
-
dbmail_message_free(m);
g_string_free(s,TRUE);
}
Please sign in to comment.
Something went wrong with that request. Please try again.