dovecot-2.2: Make sure we check all the functions' return values...
dovecot at dovecot.org
dovecot at dovecot.org
Mon Jun 25 01:14:28 EEST 2012
details: http://hg.dovecot.org/dovecot-2.2/rev/d0d7b810646b
changeset: 14682:d0d7b810646b
user: Timo Sirainen <tss at iki.fi>
date: Mon Jun 25 01:14:03 2012 +0300
description:
Make sure we check all the functions' return values. Minor API changes to simplify this.
Checked using a patched clang that adds attribute(warn_unused_result) to all
functions. This commit fixes several error handling mistakes.
diffstat:
src/anvil/main.c | 2 +-
src/auth/auth-request.c | 4 +-
src/auth/mech-digest-md5.c | 2 +-
src/auth/mech-scram-sha1.c | 2 +-
src/auth/passdb-blocking.c | 11 +-
src/auth/password-scheme-otp.c | 6 +-
src/auth/userdb-blocking.c | 2 +-
src/auth/userdb-sql.c | 2 +-
src/config/doveconf.c | 2 +-
src/config/main.c | 2 +-
src/config/old-set-parser.c | 2 +
src/dict/dict-commands.c | 2 +-
src/dict/main.c | 2 +-
src/director/director-connection.c | 5 +-
src/director/director-host.c | 5 +-
src/director/director.c | 2 +-
src/director/doveadm-connection.c | 4 +-
src/director/mail-host.c | 4 +-
src/director/main.c | 4 +-
src/director/test-user-directory.c | 8 +-
src/doveadm/doveadm-dump-dbox.c | 4 +-
src/doveadm/doveadm-mail-server.c | 6 +-
src/doveadm/doveadm-mailbox-list-iter.c | 13 +-
src/doveadm/doveadm-mount.c | 8 +-
src/doveadm/doveadm-penalty.c | 2 +-
src/doveadm/doveadm-stats.c | 12 +-
src/doveadm/dsync/doveadm-dsync.c | 13 +-
src/doveadm/dsync/dsync-brain-mailbox-tree.c | 4 +-
src/doveadm/dsync/dsync-brain-mailbox.c | 10 +-
src/doveadm/dsync/dsync-brain-mails.c | 2 +-
src/doveadm/dsync/dsync-mailbox-import.c | 19 ++--
src/doveadm/dsync/dsync-mailbox-tree.c | 2 +-
src/doveadm/dsync/dsync-slave.c | 4 +-
src/doveadm/dsync/dsync-slave.h | 3 +-
src/doveadm/server-connection.c | 12 +-
src/doveadm/server-connection.h | 5 +-
src/imap-login/client.c | 2 +-
src/imap/cmd-fetch.c | 2 +-
src/imap/cmd-idle.c | 2 +-
src/imap/cmd-list.c | 2 +-
src/imap/imap-client.c | 9 +-
src/imap/imap-client.h | 7 +-
src/imap/imap-fetch-body.c | 9 +-
src/imap/imap-sync.c | 6 +-
src/imap/main.c | 4 +-
src/indexer/master-connection.c | 10 +-
src/lib-auth/auth-client.c | 2 +-
src/lib-imap/imap-parser.c | 2 +-
src/lib-imap/imap-quote.c | 27 +++--
src/lib-index/mail-cache-compress.c | 2 +-
src/lib-index/mail-cache-transaction.c | 4 +-
src/lib-index/mail-cache.c | 2 +-
src/lib-index/mail-index-fsck.c | 2 +-
src/lib-index/mail-index-map-hdr.c | 2 +-
src/lib-index/mail-index-modseq.c | 7 +-
src/lib-index/mail-index-private.h | 12 +-
src/lib-index/mail-index-strmap.c | 6 +-
src/lib-index/mail-index-sync-update.c | 2 +-
src/lib-index/mail-index-transaction-private.h | 2 +-
src/lib-index/mail-index-transaction-sort-appends.c | 6 +-
src/lib-index/mail-index-transaction-update.c | 7 +-
src/lib-index/mail-index-view-sync.c | 6 +-
src/lib-index/mail-index-write.c | 4 +-
src/lib-index/mail-index.c | 40 ++++----
src/lib-index/mail-transaction-log-file.c | 62 ++++++++-----
src/lib-index/test-mail-index-transaction-update.c | 11 +-
src/lib-index/test-mail-transaction-log-append.c | 7 +-
src/lib-mail/message-header-decode.c | 1 -
src/lib-mail/message-part-serialize.c | 14 +-
src/lib-mail/rfc822-parser.c | 2 +-
src/lib-mail/test-istream-dot.c | 2 +-
src/lib-ntlm/ntlm-des.c | 7 +-
src/lib-ntlm/ntlm-des.h | 4 +-
src/lib-ntlm/ntlm-encrypt.c | 10 +-
src/lib-ntlm/ntlm-encrypt.h | 7 +-
src/lib-otp/otp-hash.c | 4 +-
src/lib-otp/otp-hash.h | 2 +-
src/lib-storage/index/dbox-common/dbox-file-fix.c | 2 +-
src/lib-storage/index/dbox-common/dbox-file.c | 5 +-
src/lib-storage/index/dbox-common/dbox-sync-rebuild.c | 2 +-
src/lib-storage/index/dbox-multi/mdbox-purge.c | 6 +-
src/lib-storage/index/dbox-single/sdbox-copy.c | 2 +-
src/lib-storage/index/imapc/imapc-mail.c | 3 +-
src/lib-storage/index/imapc/imapc-storage.c | 2 +-
src/lib-storage/index/index-mail.c | 24 +++-
src/lib-storage/index/index-search.c | 9 +-
src/lib-storage/index/index-sort-string.c | 4 +-
src/lib-storage/index/index-sort.c | 4 +-
src/lib-storage/index/index-status.c | 16 ++-
src/lib-storage/index/index-storage.h | 3 +
src/lib-storage/index/index-sync-changes.c | 8 +-
src/lib-storage/index/index-sync.c | 21 ++--
src/lib-storage/index/index-thread.c | 5 +-
src/lib-storage/index/maildir/maildir-uidlist.c | 6 +-
src/lib-storage/index/mbox/istream-raw-mbox.c | 2 +-
src/lib-storage/index/mbox/mbox-mail.c | 6 +-
src/lib-storage/index/mbox/mbox-save.c | 83 ++++++++++++------
src/lib-storage/index/mbox/mbox-storage.c | 3 +-
src/lib-storage/index/mbox/mbox-storage.h | 2 +-
src/lib-storage/index/mbox/mbox-sync.c | 3 +-
src/lib-storage/index/pop3c/pop3c-client.c | 2 +-
src/lib-storage/index/raw/raw-mail.c | 6 +-
src/lib-storage/mail-search-build.c | 2 +-
src/lib-storage/mail-storage-private.h | 2 +-
src/lib-storage/mail.c | 15 ++-
src/lib-storage/mailbox-get.c | 2 +-
src/lib-storage/mailbox-uidvalidity.c | 6 +-
src/lib/data-stack.c | 8 +-
src/lib/hash.c | 8 +-
src/lib/hostpid.c | 9 +-
src/lib/iostream-rawlog.c | 7 +-
src/lib/md4.c | 6 +-
src/lib/md5.c | 6 +-
src/lib/mountpoint.c | 3 +-
src/lib/nfs-workarounds.c | 11 +-
src/lib/nfs-workarounds.h | 2 +-
src/lib/seq-range-array.c | 39 +++++---
src/lib/seq-range-array.h | 20 ++-
src/lib/test-base64.c | 2 +-
src/lib/test-network.c | 4 +-
src/lib/test-ostream-file.c | 8 +-
src/lib/test-seq-range-array.c | 2 +-
src/log/log-connection.c | 9 +-
src/log/log-connection.h | 7 +-
src/login-common/client-common-auth.c | 2 +-
src/login-common/login-proxy-state.c | 2 +-
src/login-common/login-proxy.c | 2 +-
src/login-common/ssl-proxy-openssl.c | 12 +-
src/master/main.c | 4 +-
src/master/service-anvil.c | 2 +-
src/master/service-process.c | 6 +-
src/master/service-process.h | 2 +-
src/plugins/autocreate/autocreate-plugin.c | 7 +-
src/plugins/expire/doveadm-expire.c | 10 +-
src/plugins/expire/expire-plugin.c | 5 +-
src/plugins/fts-lucene/fts-backend-lucene.c | 8 +-
src/plugins/fts-squat/squat-trie.c | 4 +-
src/plugins/fts-squat/squat-uidlist.c | 19 ++--
src/plugins/fts/fts-storage.c | 5 +-
src/plugins/imap-acl/imap-acl-plugin.c | 2 +-
src/plugins/imap-quota/imap-quota-plugin.c | 2 +-
src/plugins/imap-zlib/imap-zlib-plugin.c | 2 +-
src/plugins/quota/quota-maildir.c | 7 +-
src/plugins/quota/quota.c | 8 +-
src/plugins/stats/stats-connection.c | 2 +-
src/plugins/virtual/virtual-mail.c | 2 +-
src/plugins/virtual/virtual-sync.c | 2 +-
src/plugins/zlib/doveadm-zlib.c | 2 +-
src/plugins/zlib/ostream-zlib.c | 12 +-
src/pop3/main.c | 4 +-
src/pop3/pop3-client.c | 10 +-
src/pop3/pop3-client.h | 5 +-
src/pop3/pop3-commands.c | 37 +++----
src/replication/aggregator/notify-connection.c | 2 +-
src/replication/replicator/notify-connection.c | 2 +-
src/stats/main.c | 2 +-
src/util/rawlog.c | 2 +-
157 files changed, 623 insertions(+), 492 deletions(-)
diffs (truncated from 3703 to 300 lines):
diff -r ca37d1577291 -r d0d7b810646b src/anvil/main.c
--- a/src/anvil/main.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/anvil/main.c Mon Jun 25 01:14:03 2012 +0300
@@ -26,7 +26,7 @@
bool master = conn->listen_fd == MASTER_LISTEN_FD_FIRST;
master_service_client_connection_accept(conn);
- anvil_connection_create(conn->fd, master, conn->fifo);
+ (void)anvil_connection_create(conn->fd, master, conn->fifo);
}
static void ATTR_NULL(1)
diff -r ca37d1577291 -r d0d7b810646b src/auth/auth-request.c
--- a/src/auth/auth-request.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/auth/auth-request.c Mon Jun 25 01:14:03 2012 +0300
@@ -237,9 +237,9 @@
if (strcmp(key, "service") == 0)
request->service = p_strdup(request->pool, value);
else if (strcmp(key, "lip") == 0)
- net_addr2ip(value, &request->local_ip);
+ (void)net_addr2ip(value, &request->local_ip);
else if (strcmp(key, "rip") == 0)
- net_addr2ip(value, &request->remote_ip);
+ (void)net_addr2ip(value, &request->remote_ip);
else if (strcmp(key, "lport") == 0)
request->local_port = atoi(value);
else if (strcmp(key, "rport") == 0)
diff -r ca37d1577291 -r d0d7b810646b src/auth/mech-digest-md5.c
--- a/src/auth/mech-digest-md5.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/auth/mech-digest-md5.c Mon Jun 25 01:14:03 2012 +0300
@@ -283,7 +283,7 @@
{
unsigned int i;
- str_lcase(key);
+ (void)str_lcase(key);
if (strcmp(key, "realm") == 0) {
if (request->auth_request.realm == NULL && *value != '\0')
diff -r ca37d1577291 -r d0d7b810646b src/auth/mech-scram-sha1.c
--- a/src/auth/mech-scram-sha1.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/auth/mech-scram-sha1.c Mon Jun 25 01:14:03 2012 +0300
@@ -328,7 +328,7 @@
return FALSE;
}
- str_array_remove(fields, fields[field_count-1]);
+ (void)str_array_remove(fields, fields[field_count-1]);
request->client_final_message_without_proof =
p_strdup(request->pool, t_strarray_join(fields, ","));
diff -r ca37d1577291 -r d0d7b810646b src/auth/passdb-blocking.c
--- a/src/auth/passdb-blocking.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/auth/passdb-blocking.c Mon Jun 25 01:14:03 2012 +0300
@@ -88,7 +88,8 @@
auth_request_export(request, reply);
auth_request_ref(request);
- auth_worker_call(request->pool, reply, verify_plain_callback, request);
+ (void)auth_worker_call(request->pool, reply,
+ verify_plain_callback, request);
}
static bool lookup_credentials_callback(const char *reply, void *context)
@@ -130,8 +131,8 @@
auth_request_export(request, reply);
auth_request_ref(request);
- auth_worker_call(request->pool, reply,
- lookup_credentials_callback, request);
+ (void)auth_worker_call(request->pool, reply,
+ lookup_credentials_callback, request);
}
static bool
@@ -158,6 +159,6 @@
auth_request_export(request, reply);
auth_request_ref(request);
- auth_worker_call(request->pool, reply,
- set_credentials_callback, request);
+ (void)auth_worker_call(request->pool, reply,
+ set_credentials_callback, request);
}
diff -r ca37d1577291 -r d0d7b810646b src/auth/password-scheme-otp.c
--- a/src/auth/password-scheme-otp.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/auth/password-scheme-otp.c Mon Jun 25 01:14:03 2012 +0300
@@ -23,10 +23,12 @@
} else {
/* Generate new OTP credentials from plaintext */
unsigned char random_data[OTP_MAX_SEED_LEN / 2];
+ const char *random_hex;
random_fill(random_data, sizeof(random_data));
- i_strocpy(state.seed, binary_to_hex(random_data,
- OTP_MAX_SEED_LEN / 2), sizeof(state.seed));
+ random_hex = binary_to_hex(random_data, sizeof(random_data));
+ if (i_strocpy(state.seed, random_hex, sizeof(state.seed)) < 0)
+ i_unreached();
state.seq = 1024;
state.algo = algo;
diff -r ca37d1577291 -r d0d7b810646b src/auth/userdb-blocking.c
--- a/src/auth/userdb-blocking.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/auth/userdb-blocking.c Mon Jun 25 01:14:03 2012 +0300
@@ -58,7 +58,7 @@
auth_request_export(request, reply);
auth_request_ref(request);
- auth_worker_call(request->pool, reply, user_callback, request);
+ (void)auth_worker_call(request->pool, reply, user_callback, request);
}
static bool iter_callback(const char *reply, void *context)
diff -r ca37d1577291 -r d0d7b810646b src/auth/userdb-sql.c
--- a/src/auth/userdb-sql.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/auth/userdb-sql.c Mon Jun 25 01:14:03 2012 +0300
@@ -136,7 +136,7 @@
sql_result_ref(sql_result);
if (ctx->freed)
- userdb_sql_iterate_deinit(&ctx->ctx);
+ (void)userdb_sql_iterate_deinit(&ctx->ctx);
else if (ctx->call_iter)
userdb_sql_iterate_next(&ctx->ctx);
}
diff -r ca37d1577291 -r d0d7b810646b src/config/doveconf.c
--- a/src/config/doveconf.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/config/doveconf.c Mon Jun 25 01:14:03 2012 +0300
@@ -478,7 +478,7 @@
config_dump_human_deinit(ctx);
if (dump_section)
- config_dump_human(filter, "", scope, setting_name_filter);
+ (void)config_dump_human(filter, "", scope, setting_name_filter);
return 0;
}
diff -r ca37d1577291 -r d0d7b810646b src/config/main.c
--- a/src/config/main.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/config/main.c Mon Jun 25 01:14:03 2012 +0300
@@ -11,7 +11,7 @@
static void client_connected(struct master_service_connection *conn)
{
master_service_client_connection_accept(conn);
- config_connection_create(conn->fd);
+ (void)config_connection_create(conn->fd);
}
int main(int argc, char *argv[])
diff -r ca37d1577291 -r d0d7b810646b src/config/old-set-parser.c
--- a/src/config/old-set-parser.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/config/old-set-parser.c Mon Jun 25 01:14:03 2012 +0300
@@ -6,6 +6,8 @@
#include "config-parser-private.h"
#include "old-set-parser.h"
+#define config_apply_line (void)config_apply_line
+
struct socket_set {
const char *path, *mode, *user, *group;
bool master;
diff -r ca37d1577291 -r d0d7b810646b src/dict/dict-commands.c
--- a/src/dict/dict-commands.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/dict/dict-commands.c Mon Jun 25 01:14:03 2012 +0300
@@ -101,7 +101,7 @@
conn->iter_ctx = dict_iterate_init_multiple(conn->dict, args+1, flags);
o_stream_set_flush_callback(conn->output, cmd_iterate_flush, conn);
- cmd_iterate_flush(conn);
+ (void)cmd_iterate_flush(conn);
return 0;
}
diff -r ca37d1577291 -r d0d7b810646b src/dict/main.c
--- a/src/dict/main.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/dict/main.c Mon Jun 25 01:14:03 2012 +0300
@@ -23,7 +23,7 @@
static void client_connected(struct master_service_connection *conn)
{
master_service_client_connection_accept(conn);
- dict_connection_create(conn->fd);
+ (void)dict_connection_create(conn->fd);
}
static void main_preinit(void)
diff -r ca37d1577291 -r d0d7b810646b src/director/director-connection.c
--- a/src/director/director-connection.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/director/director-connection.c Mon Jun 25 01:14:03 2012 +0300
@@ -538,7 +538,8 @@
return FALSE;
}
- director_user_refresh(conn, username_hash, host, timestamp, weak, &user);
+ (void)director_user_refresh(conn, username_hash, host,
+ timestamp, weak, &user);
return TRUE;
}
@@ -1081,7 +1082,7 @@
}
if (host == NULL || !host->self)
- director_resend_sync(dir);
+ (void)director_resend_sync(dir);
return TRUE;
}
diff -r ca37d1577291 -r d0d7b810646b src/director/director-host.c
--- a/src/director/director-host.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/director/director-host.c Mon Jun 25 01:14:03 2012 +0300
@@ -158,7 +158,7 @@
i_fatal("Unknown director host: %s", host);
for (i = 0; i < ips_count; i++)
- director_host_add(dir, &ips[i], port);
+ (void)director_host_add(dir, &ips[i], port);
}
void director_host_add_from_string(struct director *dir, const char *hosts)
@@ -175,7 +175,8 @@
/* standalone director */
struct ip_addr ip;
- net_addr2ip("127.0.0.1", &ip);
+ if (net_addr2ip("127.0.0.1", &ip) < 0)
+ i_unreached();
dir->self_host = director_host_add(dir, &ip, 0);
dir->self_host->self = TRUE;
}
diff -r ca37d1577291 -r d0d7b810646b src/director/director.c
--- a/src/director/director.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/director/director.c Mon Jun 25 01:14:03 2012 +0300
@@ -121,7 +121,7 @@
while we're still trying to connect to it */
host->last_network_failure = 0;
- director_connection_init_out(dir, fd, host);
+ (void)director_connection_init_out(dir, fd, host);
return 0;
}
diff -r ca37d1577291 -r d0d7b810646b src/director/doveadm-connection.c
--- a/src/director/doveadm-connection.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/director/doveadm-connection.c Mon Jun 25 01:14:03 2012 +0300
@@ -419,9 +419,9 @@
else if (strcmp(cmd, "DIRECTOR-LIST") == 0)
doveadm_cmd_director_list(conn);
else if (strcmp(cmd, "DIRECTOR-ADD") == 0)
- doveadm_cmd_director_add(conn, args);
+ ret = doveadm_cmd_director_add(conn, args);
else if (strcmp(cmd, "DIRECTOR-REMOVE") == 0)
- doveadm_cmd_director_remove(conn, args);
+ ret = doveadm_cmd_director_remove(conn, args);
else if (strcmp(cmd, "HOST-SET") == 0)
ret = doveadm_cmd_host_set(conn, args);
else if (strcmp(cmd, "HOST-REMOVE") == 0)
diff -r ca37d1577291 -r d0d7b810646b src/director/mail-host.c
--- a/src/director/mail-host.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/director/mail-host.c Mon Jun 25 01:14:03 2012 +0300
@@ -59,7 +59,7 @@
}
for (i = 0; i < ips_count; i++)
- mail_host_add_ip(list, &ips[i]);
+ (void)mail_host_add_ip(list, &ips[i]);
return 0;
}
@@ -120,7 +120,7 @@
/* create hosts from the final bits */
do {
ip1_arr[i] = ntohl(i1);
- mail_host_add_ip(list, &ip1);
+ (void)mail_host_add_ip(list, &ip1);
i1++;
} while (ip1_arr[i] != ip2_arr[i]);
return 0;
diff -r ca37d1577291 -r d0d7b810646b src/director/main.c
--- a/src/director/main.c Mon Jun 25 00:01:59 2012 +0300
+++ b/src/director/main.c Mon Jun 25 01:14:03 2012 +0300
@@ -37,7 +37,7 @@
return -1;
}
- director_connection_init_in(director, fd, ip);
+ (void)director_connection_init_in(director, fd, ip);
return 0;
}
@@ -90,7 +90,7 @@
auth = auth_connection_init(socket_path);
if (auth_connection_connect(auth) == 0) {
master_service_client_connection_accept(conn);
- login_connection_init(director, conn->fd, auth, userdb);
+ (void)login_connection_init(director, conn->fd, auth, userdb);
} else {
auth_connection_deinit(&auth);
}
diff -r ca37d1577291 -r d0d7b810646b src/director/test-user-directory.c
More information about the dovecot-cvs
mailing list