]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
Make sure we check all the functions' return values. Minor API changes to simplify...
authorTimo Sirainen <tss@iki.fi>
Sun, 24 Jun 2012 22:14:03 +0000 (01:14 +0300)
committerTimo Sirainen <tss@iki.fi>
Sun, 24 Jun 2012 22:14:03 +0000 (01:14 +0300)
Checked using a patched clang that adds attribute(warn_unused_result) to all
functions. This commit fixes several error handling mistakes.

157 files changed:
src/anvil/main.c
src/auth/auth-request.c
src/auth/mech-digest-md5.c
src/auth/mech-scram-sha1.c
src/auth/passdb-blocking.c
src/auth/password-scheme-otp.c
src/auth/userdb-blocking.c
src/auth/userdb-sql.c
src/config/doveconf.c
src/config/main.c
src/config/old-set-parser.c
src/dict/dict-commands.c
src/dict/main.c
src/director/director-connection.c
src/director/director-host.c
src/director/director.c
src/director/doveadm-connection.c
src/director/mail-host.c
src/director/main.c
src/director/test-user-directory.c
src/doveadm/doveadm-dump-dbox.c
src/doveadm/doveadm-mail-server.c
src/doveadm/doveadm-mailbox-list-iter.c
src/doveadm/doveadm-mount.c
src/doveadm/doveadm-penalty.c
src/doveadm/doveadm-stats.c
src/doveadm/dsync/doveadm-dsync.c
src/doveadm/dsync/dsync-brain-mailbox-tree.c
src/doveadm/dsync/dsync-brain-mailbox.c
src/doveadm/dsync/dsync-brain-mails.c
src/doveadm/dsync/dsync-mailbox-import.c
src/doveadm/dsync/dsync-mailbox-tree.c
src/doveadm/dsync/dsync-slave.c
src/doveadm/dsync/dsync-slave.h
src/doveadm/server-connection.c
src/doveadm/server-connection.h
src/imap-login/client.c
src/imap/cmd-fetch.c
src/imap/cmd-idle.c
src/imap/cmd-list.c
src/imap/imap-client.c
src/imap/imap-client.h
src/imap/imap-fetch-body.c
src/imap/imap-sync.c
src/imap/main.c
src/indexer/master-connection.c
src/lib-auth/auth-client.c
src/lib-imap/imap-parser.c
src/lib-imap/imap-quote.c
src/lib-index/mail-cache-compress.c
src/lib-index/mail-cache-transaction.c
src/lib-index/mail-cache.c
src/lib-index/mail-index-fsck.c
src/lib-index/mail-index-map-hdr.c
src/lib-index/mail-index-modseq.c
src/lib-index/mail-index-private.h
src/lib-index/mail-index-strmap.c
src/lib-index/mail-index-sync-update.c
src/lib-index/mail-index-transaction-private.h
src/lib-index/mail-index-transaction-sort-appends.c
src/lib-index/mail-index-transaction-update.c
src/lib-index/mail-index-view-sync.c
src/lib-index/mail-index-write.c
src/lib-index/mail-index.c
src/lib-index/mail-transaction-log-file.c
src/lib-index/test-mail-index-transaction-update.c
src/lib-index/test-mail-transaction-log-append.c
src/lib-mail/message-header-decode.c
src/lib-mail/message-part-serialize.c
src/lib-mail/rfc822-parser.c
src/lib-mail/test-istream-dot.c
src/lib-ntlm/ntlm-des.c
src/lib-ntlm/ntlm-des.h
src/lib-ntlm/ntlm-encrypt.c
src/lib-ntlm/ntlm-encrypt.h
src/lib-otp/otp-hash.c
src/lib-otp/otp-hash.h
src/lib-storage/index/dbox-common/dbox-file-fix.c
src/lib-storage/index/dbox-common/dbox-file.c
src/lib-storage/index/dbox-common/dbox-sync-rebuild.c
src/lib-storage/index/dbox-multi/mdbox-purge.c
src/lib-storage/index/dbox-single/sdbox-copy.c
src/lib-storage/index/imapc/imapc-mail.c
src/lib-storage/index/imapc/imapc-storage.c
src/lib-storage/index/index-mail.c
src/lib-storage/index/index-search.c
src/lib-storage/index/index-sort-string.c
src/lib-storage/index/index-sort.c
src/lib-storage/index/index-status.c
src/lib-storage/index/index-storage.h
src/lib-storage/index/index-sync-changes.c
src/lib-storage/index/index-sync.c
src/lib-storage/index/index-thread.c
src/lib-storage/index/maildir/maildir-uidlist.c
src/lib-storage/index/mbox/istream-raw-mbox.c
src/lib-storage/index/mbox/mbox-mail.c
src/lib-storage/index/mbox/mbox-save.c
src/lib-storage/index/mbox/mbox-storage.c
src/lib-storage/index/mbox/mbox-storage.h
src/lib-storage/index/mbox/mbox-sync.c
src/lib-storage/index/pop3c/pop3c-client.c
src/lib-storage/index/raw/raw-mail.c
src/lib-storage/mail-search-build.c
src/lib-storage/mail-storage-private.h
src/lib-storage/mail.c
src/lib-storage/mailbox-get.c
src/lib-storage/mailbox-uidvalidity.c
src/lib/data-stack.c
src/lib/hash.c
src/lib/hostpid.c
src/lib/iostream-rawlog.c
src/lib/md4.c
src/lib/md5.c
src/lib/mountpoint.c
src/lib/nfs-workarounds.c
src/lib/nfs-workarounds.h
src/lib/seq-range-array.c
src/lib/seq-range-array.h
src/lib/test-base64.c
src/lib/test-network.c
src/lib/test-ostream-file.c
src/lib/test-seq-range-array.c
src/log/log-connection.c
src/log/log-connection.h
src/login-common/client-common-auth.c
src/login-common/login-proxy-state.c
src/login-common/login-proxy.c
src/login-common/ssl-proxy-openssl.c
src/master/main.c
src/master/service-anvil.c
src/master/service-process.c
src/master/service-process.h
src/plugins/autocreate/autocreate-plugin.c
src/plugins/expire/doveadm-expire.c
src/plugins/expire/expire-plugin.c
src/plugins/fts-lucene/fts-backend-lucene.c
src/plugins/fts-squat/squat-trie.c
src/plugins/fts-squat/squat-uidlist.c
src/plugins/fts/fts-storage.c
src/plugins/imap-acl/imap-acl-plugin.c
src/plugins/imap-quota/imap-quota-plugin.c
src/plugins/imap-zlib/imap-zlib-plugin.c
src/plugins/quota/quota-maildir.c
src/plugins/quota/quota.c
src/plugins/stats/stats-connection.c
src/plugins/virtual/virtual-mail.c
src/plugins/virtual/virtual-sync.c
src/plugins/zlib/doveadm-zlib.c
src/plugins/zlib/ostream-zlib.c
src/pop3/main.c
src/pop3/pop3-client.c
src/pop3/pop3-client.h
src/pop3/pop3-commands.c
src/replication/aggregator/notify-connection.c
src/replication/replicator/notify-connection.c
src/stats/main.c
src/util/rawlog.c

index 39e396bb0bbc8e5c198906479be8b998b8d94e55..79e4df502021d4231dd6a697b5b63be556ddeac2 100644 (file)
@@ -26,7 +26,7 @@ static void client_connected(struct master_service_connection *conn)
        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)
index 6addf0e5f4462523aea62891513cf8913de70bd9..67f21fe98479039031e98bc34a7e70e61965878e 100644 (file)
@@ -237,9 +237,9 @@ bool auth_request_import_info(struct auth_request *request,
        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)
index 343be11ebadcb56c6d81a362096ccfb318e1c7fe..ebabc823716d730bf3a3d3d75a47d830a4303e99 100644 (file)
@@ -283,7 +283,7 @@ static bool auth_handle_response(struct digest_auth_request *request,
 {
        unsigned int i;
 
-       str_lcase(key);
+       (void)str_lcase(key);
 
        if (strcmp(key, "realm") == 0) {
                if (request->auth_request.realm == NULL && *value != '\0')
index ad44605f0c54daece767d4bc4a71db378784f88c..2bef231f7fad848a84545fde59a24df34a77c635 100644 (file)
@@ -328,7 +328,7 @@ static bool parse_scram_client_final(struct scram_auth_request *request,
                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, ","));
 
index 6cb9980b541bbad5076a7df84a8285d970ae8b22..6de2d51a150252c17e1eaeb126c1e325175b1011 100644 (file)
@@ -88,7 +88,8 @@ void passdb_blocking_verify_plain(struct auth_request *request)
        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 @@ void passdb_blocking_lookup_credentials(struct auth_request *request)
        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 @@ void passdb_blocking_set_credentials(struct auth_request *request,
        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);
 }
index a8d9e6a1725bf2ab1722fba891d5e572b85457d8..ad7951b253968c63924fc59e77d35d9c0b9869e8 100644 (file)
@@ -23,10 +23,12 @@ int password_generate_otp(const char *pw, const char *state_data,
        } 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;
index a89a99899a6f09f9d218fbeecfa9bc03a0bd9564..88910d7d1ee90140cabf45da2335f836c847c6a7 100644 (file)
@@ -58,7 +58,7 @@ void userdb_blocking_lookup(struct auth_request *request)
        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)
index 4af44e14932063f422f6e27bbb6dc6ae8d80a17d..6819e15a4ea5525249152874230b386fd423e477 100644 (file)
@@ -136,7 +136,7 @@ static void sql_iter_query_callback(struct sql_result *sql_result,
        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);
 }
index 7195c4a7eadc15c3e9a6c1ef4d3ce39f71a12593..e93f6c1643f4a71679e0caf6dee9cb2b1f6eb5ac 100644 (file)
@@ -478,7 +478,7 @@ config_dump_one(const struct config_filter *filter, bool hide_key,
        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;
 }
 
index 66438b9bbfced2e47882542423264d0be7d28ec9..8f7aed056160c30b578c57d978d09554371bc602 100644 (file)
@@ -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[])
index 674e5f4021cbbac1a00688123ce8ef3ce4080b5e..6795ee5b7e60f061c050b994d096dfae3975064f 100644 (file)
@@ -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;
index b7fdd16637581a17716af2d066f43600331f5620..07369344dc5bd1f9ee804e1158f8721191165ea7 100644 (file)
@@ -101,7 +101,7 @@ static int cmd_iterate(struct dict_connection *conn, const char *line)
        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;
 }
 
index 0608d41064d9683137c7dc41ab4d8ee265bc0e7a..c64aab20ddf1211a824e1a2314122b060a3f5d6d 100644 (file)
@@ -23,7 +23,7 @@ static void dict_die(void)
 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)
index 9be0c3cb5574d578df5cf8feebeb3892753dc701..c56ed92a5e517c193607d3230a31d4e786ccb2f2 100644 (file)
@@ -538,7 +538,8 @@ director_handshake_cmd_user(struct director_connection *conn,
                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 @@ static bool director_connection_sync(struct director_connection *conn,
        }
 
        if (host == NULL || !host->self)
-               director_resend_sync(dir);
+               (void)director_resend_sync(dir);
        return TRUE;
 }
 
index da19795ca0e5a2bb877fd6a1479a5604cd931747..19359061becf35df2a06a6494f35301515a732b2 100644 (file)
@@ -158,7 +158,7 @@ static void director_host_add_string(struct director *dir, const char *host)
                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 @@ void director_host_add_from_string(struct director *dir, const char *hosts)
                /* 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;
        }
index 6dff1d15cbe464c5f52bd4d8adcb06355b8ade7e..331c551685a053a3ef8f4ff01c588b445a9d27b6 100644 (file)
@@ -121,7 +121,7 @@ int director_connect_host(struct director *dir, struct director_host *host)
           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;
 }
 
index 51e485116ac08a22e681a703e169c3918231619f..459e667ed3718303e00f19902f19db478db2742d 100644 (file)
@@ -419,9 +419,9 @@ static void doveadm_connection_input(struct doveadm_connection *conn)
                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)
index 283681643a9dd19cd2a85c588a9d44277d460d8f..2e57bed5fb5ea960199094714de3dcdf2b279106 100644 (file)
@@ -59,7 +59,7 @@ static int mail_host_add(struct mail_host_list *list, const char *host)
        }
 
        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 @@ mail_hosts_add_range(struct mail_host_list *list,
        /* 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;
index c20f0db47595a003d4700641df1f9f3eec67a535..2f78b98eaa773eb1a39d1799860c941c9954ddfc 100644 (file)
@@ -37,7 +37,7 @@ static int director_client_connected(int fd, const struct ip_addr *ip)
                return -1;
        }
 
-       director_connection_init_in(director, fd, ip);
+       (void)director_connection_init_in(director, fd, ip);
        return 0;
 }
 
@@ -90,7 +90,7 @@ static void client_connected(struct master_service_connection *conn)
        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);
        }
index d00f07f6730b191d7a2d97454b781dd141886971..d58eeb7865fcb261f742a38dcc161f66158335c5 100644 (file)
@@ -44,10 +44,10 @@ static void test_user_directory_ascending(void)
 
        test_begin("user directory ascending");
        dir = user_directory_init(USER_DIR_TIMEOUT, "%u");
-       user_directory_add(dir, 1, host, ioloop_time + count+1);
+       (void)user_directory_add(dir, 1, host, ioloop_time + count+1);
 
        for (i = 0; i < count; i++)
-               user_directory_add(dir, i+2, host, ioloop_time + i);
+               (void)user_directory_add(dir, i+2, host, ioloop_time + i);
        verify_user_directory(dir, count+1);
        user_directory_deinit(&dir);
        test_end();
@@ -64,7 +64,7 @@ static void test_user_directory_descending(void)
        dir = user_directory_init(USER_DIR_TIMEOUT, "%u");
 
        for (i = 0; i < count; i++)
-               user_directory_add(dir, i+1, host, ioloop_time - i);
+               (void)user_directory_add(dir, i+1, host, ioloop_time - i);
        verify_user_directory(dir, count);
        user_directory_deinit(&dir);
        test_end();
@@ -84,7 +84,7 @@ static void test_user_directory_random(void)
                        timestamp = ioloop_time;
                else
                        timestamp = ioloop_time-rand()%100;
-               user_directory_add(dir, i+1, host, timestamp);
+               (void)user_directory_add(dir, i+1, host, timestamp);
        }
        verify_user_directory(dir, count);
        user_directory_deinit(&dir);
index e153c41e8b8ffde9b3aaaa2c4132a7d15c27b48e..7bac20f3eb7585dfae083e5a301d94ba7bce2555 100644 (file)
@@ -152,10 +152,10 @@ static void dump_msg_metadata(struct istream *input)
                        dump_timestamp(input, "msg.received", line + 1);
                        break;
                case DBOX_METADATA_PHYSICAL_SIZE:
-                       dump_size(input, "msg.physical-size", line + 1);
+                       (void)dump_size(input, "msg.physical-size", line + 1);
                        break;
                case DBOX_METADATA_VIRTUAL_SIZE:
-                       dump_size(input, "msg.virtual-size", line + 1);
+                       (void)dump_size(input, "msg.virtual-size", line + 1);
                        break;
                case DBOX_METADATA_EXT_REF:
                        printf("msg.ext-ref = %s\n", line + 1);
index 782e7acf6a1f62d0c8b830f15af3dcbac6f5a1f3..74b1ff05760e53ebede4c6fea042811245c53f80 100644 (file)
@@ -241,8 +241,10 @@ int doveadm_mail_server_user(struct doveadm_mail_cmd_context *ctx,
                doveadm_mail_server_handle(conn, input->username);
        else if (array_count(&server->connections) <
                        I_MAX(ctx->set->doveadm_worker_count, 1)) {
-               conn = server_connection_create(server);
-               doveadm_mail_server_handle(conn, input->username);
+               if (server_connection_create(server, &conn) < 0)
+                       internal_failure = TRUE;
+               else
+                       doveadm_mail_server_handle(conn, input->username);
        } else {
                if (array_count(&server->queue) >= DOVEADM_SERVER_QUEUE_MAX)
                        doveadm_server_flush_one(server);
index 9fab65d7e1a0de1e24e68300816002bdff63130d..041f88e4122efcc1387e5443389c5c1f84033929 100644 (file)
@@ -24,7 +24,7 @@ struct doveadm_mailbox_list_iter {
        bool only_selectable;
 };
 
-static int
+static bool
 search_args_get_mailbox_patterns(const struct mail_search_arg *args,
                                 ARRAY_TYPE(const_string) *patterns,
                                 bool *have_guid, bool *have_wildcards)
@@ -43,7 +43,7 @@ search_args_get_mailbox_patterns(const struct mail_search_arg *args,
                                if (!search_args_get_mailbox_patterns(subargs,
                                                        patterns, have_guid,
                                                        have_wildcards))
-                                       return 0;
+                                       return FALSE;
                        }
                        break;
                case SEARCH_MAILBOX_GLOB:
@@ -52,7 +52,7 @@ search_args_get_mailbox_patterns(const struct mail_search_arg *args,
                case SEARCH_MAILBOX:
                        if (args->match_not) {
                                array_clear(patterns);
-                               return 0;
+                               return FALSE;
                        }
                        array_append(patterns, &args->value.str, 1);
                        break;
@@ -63,7 +63,7 @@ search_args_get_mailbox_patterns(const struct mail_search_arg *args,
                        break;
                }
        }
-       return 1;
+       return TRUE;
 }
 
 static struct doveadm_mailbox_list_iter *
@@ -82,8 +82,9 @@ doveadm_mailbox_list_iter_init_nsmask(struct doveadm_mail_cmd_context *ctx,
        iter->search_args = search_args;
        iter->user = user;
        i_array_init(&iter->patterns, 16);
-       search_args_get_mailbox_patterns(search_args->args, &iter->patterns,
-                                        &have_guid, &have_wildcards);
+       (void)search_args_get_mailbox_patterns(search_args->args,
+                                              &iter->patterns,
+                                              &have_guid, &have_wildcards);
 
        if (array_count(&iter->patterns) == 0) {
                iter_flags |= MAILBOX_LIST_ITER_SKIP_ALIASES;
index 38cfe0b81bb4788f76954c005c73ed7a28d30a4c..c4338e4a9ab0406e504a46c49a1af74b9eef7bd5 100644 (file)
@@ -71,13 +71,14 @@ static void cmd_mount_add(int argc, char *argv[])
 {
        struct mountpoint_list *mountpoints;
        struct mountpoint_list_rec rec;
+       int ret = 0;
 
        if (argc > 3)
                mount_cmd_help(cmd_mount_add);
 
        mountpoints = mountpoint_list_get();
        if (argv[1] == NULL) {
-               mountpoint_list_add_missing(mountpoints,
+               ret = mountpoint_list_add_missing(mountpoints,
                        MOUNTPOINT_STATE_DEFAULT,
                        mountpoint_list_default_ignore_prefixes,
                        mountpoint_list_default_ignore_types);
@@ -91,8 +92,11 @@ static void cmd_mount_add(int argc, char *argv[])
                        rec.wildcard = TRUE;
                mountpoint_list_add(mountpoints, &rec);
        }
-       (void)mountpoint_list_save(mountpoints);
+       if (mountpoint_list_save(mountpoints) < 0)
+               ret = -1;
        mountpoint_list_deinit(&mountpoints);
+       if (ret < 0)
+               doveadm_exit_code = EX_TEMPFAIL;
 }
 
 static void cmd_mount_remove(int argc, char *argv[])
index be35174eb645f29ffa009e62044dfa7c0e8c1c0b..4bf67ea16a864c7a8ad05475cde1cbef77277aba 100644 (file)
@@ -35,7 +35,7 @@ static void penalty_parse_line(const char *line, struct penalty_line *line_r)
 
        memset(line_r, 0, sizeof(*line_r));
 
-       net_addr2ip(ident, &line_r->ip);
+       (void)net_addr2ip(ident, &line_r->ip);
        line_r->penalty = strtoul(penalty_str, NULL, 10);
        line_r->last_penalty = strtoul(last_penalty_str, NULL, 10);
        line_r->last_update = strtoul(last_update_str, NULL, 10);
index afa4c58b6fcc3785b643a51b5fd955e8b9f0a6c3..e85ac13642ca7509687657cc90f0a39a27e7efb7 100644 (file)
@@ -388,17 +388,19 @@ stats_top_output_diff(struct top_context *ctx,
 
        if (str_to_uint64(line->prev_values[i], &prev_num) == 0 &&
            str_to_uint64(line->cur_values[i], &cur_num) == 0) {
-               i_snprintf(numstr, sizeof(numstr), "%llu",
-                          (unsigned long long)(cur_num - prev_num));
+               if (i_snprintf(numstr, sizeof(numstr), "%llu",
+                              (unsigned long long)(cur_num - prev_num)) < 0)
+                       i_unreached();
                doveadm_print(numstr);
        } else if (get_double(line->prev_values[i], &prev_double) == 0 &&
                   get_double(line->cur_values[i], &cur_double) == 0 &&
                   get_double(line->prev_values[ctx->last_update_idx], &prev_time) == 0 &&
                   get_double(line->cur_values[ctx->last_update_idx], &cur_time) == 0) {
                /* %CPU */
-               i_snprintf(numstr, sizeof(numstr), "%d",
-                          (int)((cur_double - prev_double) *
-                                (cur_time - prev_time) * 100));
+               if (i_snprintf(numstr, sizeof(numstr), "%d",
+                              (int)((cur_double - prev_double) *
+                                    (cur_time - prev_time) * 100)) < 0)
+                       i_unreached();
                doveadm_print(numstr);
        } else {
                doveadm_print(line->cur_values[i]);
index 9c03dea297a99e6d6dd93309ee3f240b91834854..8e346ef48e6d197a20a81426aef6e40fdf6a6052 100644 (file)
@@ -226,7 +226,7 @@ static bool mirror_get_remote_cmd(struct dsync_cmd_context *ctx,
        return TRUE;
 }
 
-static struct dsync_slave *
+static int
 cmd_dsync_run_local(struct dsync_cmd_context *ctx, struct mail_user *user,
                    struct dsync_brain *brain, struct dsync_slave *slave2)
 {
@@ -281,8 +281,7 @@ cmd_dsync_run_local(struct dsync_cmd_context *ctx, struct mail_user *user,
                brain2_running = dsync_brain_run(brain2, &changed2);
        }
        mail_user_unref(&user2);
-       dsync_brain_deinit(&brain2);
-       return slave2;
+       return dsync_brain_deinit(&brain2);
 }
 
 static void
@@ -349,10 +348,12 @@ cmd_dsync_run(struct doveadm_mail_cmd_context *_ctx, struct mail_user *user)
                                        DSYNC_BRAIN_FLAG_SEND_REQUESTS,
                                        "");
 
-       if (!ctx->remote)
-               cmd_dsync_run_local(ctx, user, brain, slave2);
-       else
+       if (!ctx->remote) {
+               if (cmd_dsync_run_local(ctx, user, brain, slave2) < 0)
+                       _ctx->exit_code = EX_TEMPFAIL;
+       } else {
                cmd_dsync_run_remote(user);
+       }
 
        if (dsync_brain_deinit(&brain) < 0)
                _ctx->exit_code = EX_TEMPFAIL;
index b6422cee2bbf4058336dfb2eab1d9776f824624c..fa664e625fc5bb385023f250fbb66398a12309cb 100644 (file)
@@ -122,8 +122,8 @@ void dsync_brain_send_mailbox_tree_deletes(struct dsync_brain *brain)
 
        deletes = dsync_mailbox_tree_get_deletes(brain->local_mailbox_tree,
                                                 &count);
-       dsync_slave_send_mailbox_deletes(brain->slave, deletes, count,
-                                        brain->hierarchy_sep);
+       (void)dsync_slave_send_mailbox_deletes(brain->slave, deletes, count,
+                                              brain->hierarchy_sep);
 
        brain->state = DSYNC_STATE_RECV_MAILBOX_TREE;
 }
index 7cc1a1c341ff287650dc4fbf26342fafc19994b1..305f3be037ab44ddf5ee1e6bad2f9e2bc3b22fea 100644 (file)
@@ -372,9 +372,9 @@ void dsync_brain_master_send_mailbox(struct dsync_brain *brain)
        }
 
        /* start exporting this mailbox (wait for remote to start importing) */
-       dsync_slave_send_mailbox(brain->slave, &dsync_box);
-       dsync_brain_sync_mailbox_init(brain, box, &dsync_box,
-                                     DSYNC_BOX_STATE_MAILBOX);
+       (void)dsync_slave_send_mailbox(brain->slave, &dsync_box);
+       (void)dsync_brain_sync_mailbox_init(brain, box, &dsync_box,
+                                           DSYNC_BOX_STATE_MAILBOX);
        brain->state = DSYNC_STATE_SYNC_MAILS;
 }
 
@@ -560,13 +560,13 @@ bool dsync_brain_slave_recv_mailbox(struct dsync_brain *brain)
                memcpy(delete_box.mailbox_guid, dsync_box->mailbox_guid,
                       sizeof(delete_box.mailbox_guid));
                delete_box.mailbox_lost = TRUE;
-               dsync_slave_send_mailbox(brain->slave, &delete_box);
+               (void)dsync_slave_send_mailbox(brain->slave, &delete_box);
                return TRUE;
        }
        i_assert(local_dsync_box.uid_validity != 0);
        i_assert(memcmp(dsync_box->mailbox_guid, local_dsync_box.mailbox_guid,
                        sizeof(dsync_box->mailbox_guid)) == 0);
-       dsync_slave_send_mailbox(brain->slave, &local_dsync_box);
+       (void)dsync_slave_send_mailbox(brain->slave, &local_dsync_box);
 
        dsync_brain_mailbox_update_pre(brain, box, &local_dsync_box, dsync_box);
 
index 33f95e53be27057fe67a8200666362cad473c880..e3ca4c975a30f1cb750dd6d8f4969ce72cb5fb57 100644 (file)
@@ -155,7 +155,7 @@ static void dsync_brain_sync_half_finished(struct dsync_brain *brain)
                if (changes_during_sync)
                        brain->changes_during_sync = TRUE;
        }
-       dsync_slave_send_mailbox_state(brain->slave, &state);
+       (void)dsync_slave_send_mailbox_state(brain->slave, &state);
 }
 
 static bool dsync_brain_recv_mail(struct dsync_brain *brain)
index cc6c48e97f1845eb2ffeb8a41726ee8fea8ffeff..9e13175ffbbe12875bc309bd70e8290ff0dca06d 100644 (file)
@@ -170,19 +170,18 @@ dsync_mailbox_import_init(struct mailbox *box,
        return importer;
 }
 
-static int dsync_mail_error(struct dsync_mailbox_importer *importer,
-                           struct mail *mail, const char *field)
+static void dsync_mail_error(struct dsync_mailbox_importer *importer,
+                            struct mail *mail, const char *field)
 {
        const char *errstr;
        enum mail_error error;
 
        errstr = mailbox_get_last_error(importer->box, &error);
        if (error == MAIL_ERROR_EXPUNGED)
-               return 0;
+               return;
 
        i_error("Can't lookup %s for UID=%u: %s", field, mail->uid, errstr);
        importer->failed = TRUE;
-       return -1;
 }
 
 static bool
@@ -768,7 +767,7 @@ dsync_mailbox_rewind_search(struct dsync_mailbox_importer *importer)
        importer->cur_guid = NULL;
        importer->next_local_seq = 0;
 
-       mailbox_search_deinit(&importer->search_ctx);
+       (void)mailbox_search_deinit(&importer->search_ctx);
        dsync_mailbox_import_search_init(importer);
 }
 
@@ -1026,10 +1025,10 @@ void dsync_mailbox_import_changes_finish(struct dsync_mailbox_importer *importer
                dsync_mailbox_common_uid_found(importer);
        }
        /* skip common local mails */
-       importer_next_mail(importer, importer->last_common_uid+1);
+       (void)importer_next_mail(importer, importer->last_common_uid+1);
        /* if there are any local mails left, add them to newmails list */
        while (importer->cur_mail != NULL)
-               dsync_mailbox_try_save(importer, NULL);
+               (void)dsync_mailbox_try_save(importer, NULL);
 
        dsync_mailbox_import_assign_new_uids(importer);
 }
@@ -1431,8 +1430,10 @@ int dsync_mailbox_import_deinit(struct dsync_mailbox_importer **_importer,
                        mailbox_get_vname(importer->box), msgs_left);
        }
 
-       if (importer->search_ctx != NULL)
-               mailbox_search_deinit(&importer->search_ctx);
+       if (importer->search_ctx != NULL) {
+               if (mailbox_search_deinit(&importer->search_ctx) < 0)
+                       importer->failed = TRUE;
+       }
        mail_free(&importer->mail);
        mail_free(&importer->ext_mail);
 
index 1bfe47ed36ba8b831c95c22aee437dc48c82445e..d402bf5e194c3a9f6801100aa579a8dd99873d55 100644 (file)
@@ -300,7 +300,7 @@ int dsync_mailbox_tree_build_guid_hash(struct dsync_mailbox_tree *tree)
                                            guid_128_hash, guid_128_cmp);
        iter = dsync_mailbox_tree_iter_init(tree);
        while (dsync_mailbox_tree_iter_next(iter, &name, &node))
-               dsync_mailbox_tree_guid_hash_add(tree, node);
+               (void)dsync_mailbox_tree_guid_hash_add(tree, node);
        dsync_mailbox_tree_iter_deinit(&iter);
        return ret;
 }
index a63e16338bb436c1a6d89459303d231d00e76df9..30860ffe9609b5bdba95a9cda20bee355a807046 100644 (file)
@@ -40,11 +40,9 @@ dsync_slave_send_ret(struct dsync_slave *slave)
                DSYNC_SLAVE_SEND_RET_OK;
 }
 
-enum dsync_slave_send_ret
-dsync_slave_send_end_of_list(struct dsync_slave *slave)
+void dsync_slave_send_end_of_list(struct dsync_slave *slave)
 {
        slave->v.send_end_of_list(slave);
-       return dsync_slave_send_ret(slave);
 }
 
 enum dsync_slave_send_ret
index 27973689291f06478a3c5150055133c7e9cf56b0..b436450a82a1da72a456f4895c899ac197b88a0d 100644 (file)
@@ -54,8 +54,7 @@ enum dsync_slave_recv_ret
 dsync_slave_recv_handshake(struct dsync_slave *slave,
                           const struct dsync_slave_settings **set_r);
 
-enum dsync_slave_send_ret
-dsync_slave_send_end_of_list(struct dsync_slave *slave);
+void dsync_slave_send_end_of_list(struct dsync_slave *slave);
 
 enum dsync_slave_send_ret
 dsync_slave_send_mailbox_state(struct dsync_slave *slave,
index 50997a56360133039ef11fc1206f2911442ed407..1b31a53b4af9113616b529a3c4b4c4bd4e94fd81 100644 (file)
@@ -303,8 +303,8 @@ static int server_connection_read_settings(struct server_connection *conn)
        return 0;
 }
 
-struct server_connection *
-server_connection_create(struct doveadm_server *server)
+int server_connection_create(struct doveadm_server *server,
+                            struct server_connection **conn_r)
 {
 #define DOVEADM_SERVER_HANDSHAKE "VERSION\tdoveadm-server\t1\t0\n"
        struct server_connection *conn;
@@ -324,8 +324,12 @@ server_connection_create(struct doveadm_server *server)
        o_stream_nsend_str(conn->output, DOVEADM_SERVER_HANDSHAKE);
 
        array_append(&conn->server->connections, &conn, 1);
-       server_connection_read_settings(conn);
-       return conn;
+       if (server_connection_read_settings(conn) < 0) {
+               server_connection_destroy(&conn);
+               return -1;
+       }
+       *conn_r = conn;
+       return 0;
 }
 
 void server_connection_destroy(struct server_connection **_conn)
index 9d36f6ac304a2b8ddcdcb478cb972750603dae86..0d3e4f3f9f01e2c33c8c9f76becec2c411ce7188 100644 (file)
@@ -9,11 +9,12 @@ enum server_cmd_reply {
 };
 
 struct doveadm_server;
+struct server_connection;
 
 typedef void server_cmd_callback_t(enum server_cmd_reply reply, void *context);
 
-struct server_connection *
-server_connection_create(struct doveadm_server *server);
+int server_connection_create(struct doveadm_server *server,
+                            struct server_connection **conn_r);
 void server_connection_destroy(struct server_connection **conn);
 
 /* Return the server given to create() */
index 212bdc0951b5c949decb5d247cafc762ae2566ba..d764cb89af8fd7b81511f361bc1154cbcf6c45e4 100644 (file)
@@ -371,7 +371,7 @@ static void imap_client_input(struct client *client)
                }
        }
        o_stream_uncork(imap_client->common.output);
-       client_unref(&client);
+       (void)client_unref(&client);
 }
 
 static struct client *imap_client_alloc(pool_t pool)
index 6d5a0fb6aa29c430680d93e00d641b54e333dec3..1695d64bbe6edc61a1958b9c2b4e97349dac828c 100644 (file)
@@ -224,7 +224,7 @@ bool cmd_fetch(struct client_command_context *cmd)
        if (!fetch_parse_args(ctx, cmd, &args[1], &next_arg) ||
            (imap_arg_get_list(next_arg, &list_arg) &&
             !fetch_parse_modifiers(ctx, cmd, list_arg))) {
-               imap_fetch_deinit(ctx);
+               (void)imap_fetch_deinit(ctx);
                return TRUE;
        }
 
index ca36ced3777c13209dfdb932aeb483f5f705ed6d..324961a0e5973c99f52086823c7def0ec4a8204a 100644 (file)
@@ -143,7 +143,7 @@ static void idle_sync_now(struct mailbox *box, struct cmd_idle_context *ctx)
 
        ctx->sync_pending = FALSE;
        ctx->sync_ctx = imap_sync_init(ctx->client, box, 0, 0);
-       cmd_idle_continue(ctx->cmd);
+       (void)cmd_idle_continue(ctx->cmd);
 }
 
 static void idle_callback(struct mailbox *box, struct cmd_idle_context *ctx)
index 7606733807ee540e315ffab64d695c182322ba21..8873f991f34e875e33af57dbd019bf5975a070ec 100644 (file)
@@ -479,7 +479,7 @@ list_namespace_mailboxes(struct cmd_list_context *ctx)
                imap_quote_append_string(str, str_c(mutf7_name), FALSE);
                mailbox_childinfo2str(ctx, str, flags);
 
-               ret = client_send_line(ctx->cmd->client, str_c(str));
+               ret = client_send_line_next(ctx->cmd->client, str_c(str));
                if (ctx->used_status) T_BEGIN {
                        list_send_status(ctx, name, flags);
                } T_END;
index 192078ca40fa7b80314d064c93e8f0a542ca0675..147ffb2b82a2a6f18fd7610cd833a417fa998a0c 100644 (file)
@@ -285,7 +285,12 @@ void client_disconnect_with_error(struct client *client, const char *msg)
        client_disconnect(client, msg);
 }
 
-int client_send_line(struct client *client, const char *data)
+void client_send_line(struct client *client, const char *data)
+{
+       (void)client_send_line_next(client, data);
+}
+
+int client_send_line_next(struct client *client, const char *data)
 {
        struct const_iovec iov[2];
 
@@ -807,7 +812,7 @@ bool client_handle_input(struct client *client)
                return FALSE;
 
        if (client->input_lock == NULL)
-               cmd_sync_delayed(client);
+               (void)cmd_sync_delayed(client);
        return TRUE;
 }
 
index 615f0e0dad4399e01adccf5bec03e525843b21bd..989e881001b5bde4408e30a8f422c4df1b6b7cfc 100644 (file)
@@ -176,9 +176,12 @@ void client_destroy(struct client *client, const char *reason) ATTR_NULL(2);
 void client_disconnect(struct client *client, const char *reason);
 void client_disconnect_with_error(struct client *client, const char *msg);
 
+/* Send a line of data to client. */
+void client_send_line(struct client *client, const char *data);
 /* Send a line of data to client. Returns 1 if ok, 0 if buffer is getting full,
-   -1 if error */
-int client_send_line(struct client *client, const char *data);
+   -1 if error. This should be used when you're (potentially) sending a lot of
+   lines to client. */
+int client_send_line_next(struct client *client, const char *data);
 /* Send line of data to client, prefixed with client->tag. You need to prefix
    the data with "OK ", "NO " or "BAD ". */
 void client_send_tagline(struct client_command_context *cmd, const char *data);
index 2bb46e6fbeb65b19d989a42ee69d5011cbd2f9ae..5ad2607e770d858c8c88ead661eb3b81a72d2306 100644 (file)
@@ -333,7 +333,8 @@ fetch_rfc822(struct imap_fetch_context *ctx, struct mail *mail,
        const char *str;
 
        msgpart = imap_msgpart_full();
-       fetch_and_free_msgpart(ctx, mail, &msgpart);
+       if (fetch_and_free_msgpart(ctx, mail, &msgpart) < 0)
+               return -1;
 
        str = t_strdup_printf(" RFC822 {%"PRIuUOFF_T"}\r\n", ctx->cur_size);
        if (ctx->first) {
@@ -353,7 +354,8 @@ fetch_rfc822_header(struct imap_fetch_context *ctx,
        const char *str;
 
        msgpart = imap_msgpart_header();
-       fetch_and_free_msgpart(ctx, mail, &msgpart);
+       if (fetch_and_free_msgpart(ctx, mail, &msgpart) < 0)
+               return -1;
 
        str = t_strdup_printf(" RFC822.HEADER {%"PRIuUOFF_T"}\r\n",
                              ctx->cur_size);
@@ -374,7 +376,8 @@ fetch_rfc822_text(struct imap_fetch_context *ctx, struct mail *mail,
        const char *str;
 
        msgpart = imap_msgpart_body();
-       fetch_and_free_msgpart(ctx, mail, &msgpart);
+       if (fetch_and_free_msgpart(ctx, mail, &msgpart) < 0)
+               return -1;
 
        str = t_strdup_printf(" RFC822.TEXT {%"PRIuUOFF_T"}\r\n",
                              ctx->cur_size);
index 0e787fdbf6093cb46b834d6d3d74d6384674f8c7..150ea372a914cd5b8f6b8f86ebc7492ec0a91559 100644 (file)
@@ -306,7 +306,7 @@ static int imap_sync_send_flags(struct imap_sync_context *ctx, string_t *str)
        str_append(str, "FLAGS (");
        imap_write_flags(str, flags, keywords);
        str_append(str, "))");
-       return client_send_line(ctx->client, str_c(str));
+       return client_send_line_next(ctx->client, str_c(str));
 }
 
 static int imap_sync_send_modseq(struct imap_sync_context *ctx, string_t *str)
@@ -319,7 +319,7 @@ static int imap_sync_send_modseq(struct imap_sync_context *ctx, string_t *str)
                str_printfa(str, "UID %u ", ctx->mail->uid);
        imap_sync_add_modseq(ctx, str);
        str_append_c(str, ')');
-       return client_send_line(ctx->client, str_c(str));
+       return client_send_line_next(ctx->client, str_c(str));
 }
 
 static void imap_sync_vanished(struct imap_sync_context *ctx)
@@ -437,7 +437,7 @@ int imap_sync_more(struct imap_sync_context *ctx)
 
                                str_truncate(str, 0);
                                str_printfa(str, "* %u EXPUNGE", ctx->seq);
-                               ret = client_send_line(ctx->client, str_c(str));
+                               ret = client_send_line_next(ctx->client, str_c(str));
                        }
                        if (ctx->seq < ctx->sync_rec.seq1) {
                                /* update only after we're finished, so that
index 183ea598d68acdb0aeb4eeba0c8a5ee5131b159a..bae2ee6fc71cd257fdef163c73ca72e7906ece85 100644 (file)
@@ -235,9 +235,9 @@ static void main_stdio_run(const char *username)
        if (input.username == NULL)
                i_fatal("USER environment missing");
        if ((value = getenv("IP")) != NULL)
-               net_addr2ip(value, &input.remote_ip);
+               (void)net_addr2ip(value, &input.remote_ip);
        if ((value = getenv("LOCAL_IP")) != NULL)
-               net_addr2ip(value, &input.local_ip);
+               (void)net_addr2ip(value, &input.local_ip);
 
        input_base64 = getenv("CLIENT_INPUT");
        input_buf = input_base64 == NULL ? NULL :
index 3e11205414aefb1f4535d224c2481456b7115798..4658884a6cacc861b2ce4cbfc97304f32bec641e 100644 (file)
@@ -89,9 +89,10 @@ index_mailbox_precache(struct master_connection *conn, struct mailbox *box)
                        percentage = counter*100 / max;
                        if (percentage != percentage_sent && percentage < 100) {
                                percentage_sent = percentage;
-                               i_snprintf(percentage_str,
-                                          sizeof(percentage_str), "%u\n",
-                                          percentage);
+                               if (i_snprintf(percentage_str,
+                                              sizeof(percentage_str), "%u\n",
+                                              percentage) < 0)
+                                       i_unreached();
                                (void)write_full(conn->fd, percentage_str,
                                                 strlen(percentage_str));
                        }
@@ -169,7 +170,8 @@ index_mailbox(struct master_connection *conn, struct mail_user *user,
                }
                ret = -1;
        } else if (strchr(what, 'i') != NULL) {
-               index_mailbox_precache(conn, box);
+               if (index_mailbox_precache(conn, box) < 0)
+                       ret = -1;
        }
        mailbox_free(&box);
        return ret;
index 7e1fd73c2955d63b05d0d59808f25b511f9fbd11..3b13006c1fe7014dabd235433081a32d60782a22 100644 (file)
@@ -34,7 +34,7 @@ void auth_client_deinit(struct auth_client **_client)
 void auth_client_connect(struct auth_client *client)
 {
        if (client->conn->fd == -1)
-               auth_server_connection_connect(client->conn);
+               (void)auth_server_connection_connect(client->conn);
 }
 
 void auth_client_disconnect(struct auth_client *client, const char *reason)
index d45d91d2ed192e56c5ac68647c7b941fa85a3883..4b1bbe4010f5ab71f9f63fb93bb2e20ca73112d5 100644 (file)
@@ -238,7 +238,7 @@ static void imap_parser_save_arg(struct imap_parser *parser,
                if (parser->str_first_escape >= 0 &&
                    (parser->flags & IMAP_PARSE_FLAG_NO_UNESCAPE) == 0) {
                        /* -1 because we skipped the '"' prefix */
-                       str_unescape(str + parser->str_first_escape-1);
+                       (void)str_unescape(str + parser->str_first_escape-1);
                }
                arg->_data.str = str;
                arg->str_len = strlen(str);
index e2720e25d53c1c03f7fd15cf0d827c1bf9b34c8c..d75db909f30e028f29709caec83bad0e6ab19bec 100644 (file)
@@ -95,24 +95,31 @@ void imap_quote_append(string_t *str, const unsigned char *value,
                str_append_c(str, '"');
 }
 
+static const char *
+imap_quote_internal(pool_t pool, const unsigned char *value,
+                   size_t value_len, bool fix_text)
+{
+       string_t *str;
+
+       str = t_str_new(value_len + MAX_INT_STRLEN + 5);
+       imap_quote_append(str, value, value_len, fix_text);
+       return pool->datastack_pool ? str_c(str) :
+               p_strndup(pool, str_data(str), str_len(str));
+}
+
 const char *imap_quote(pool_t pool, const unsigned char *value,
                       size_t value_len, bool fix_text)
 {
-       string_t *str;
-       char *ret;
+       const char *ret;
 
        if (value == NULL)
                return "NIL";
 
        if (!pool->datastack_pool)
-               t_push();
-
-       str = t_str_new(value_len + MAX_INT_STRLEN + 5);
-       imap_quote_append(str, value, value_len, fix_text);
-       ret = p_strndup(pool, str_data(str), str_len(str));
-
-       if (!pool->datastack_pool)
-               t_pop();
+               ret = imap_quote_internal(pool, value, value_len, fix_text);
+       else T_BEGIN {
+               ret = imap_quote_internal(pool, value, value_len, fix_text);
+       } T_END;
        return ret;
 }
 
index bc53c2a31442336af234a1f467ac9de63568c1fc..fce42dd77ca53802c2dec263e1ee3f94bad749e9 100644 (file)
@@ -277,7 +277,7 @@ mail_cache_copy(struct mail_cache *cache, struct mail_index_transaction *trans,
        buffer_free(&ctx.buffer);
        buffer_free(&ctx.field_seen);
 
-       o_stream_seek(output, 0);
+       (void)o_stream_seek(output, 0);
        o_stream_nsend(output, &hdr, sizeof(hdr));
 
        mail_cache_view_close(&cache_view);
index 1eee9d38d344b5df430b539215fc0f9564dbe81d..6184698b8595c1b2a4644c02e78b5c8d210adc40 100644 (file)
@@ -73,7 +73,9 @@ mail_index_transaction_cache_commit(struct mail_index_transaction *t,
        struct mail_cache_transaction_ctx *ctx = CACHE_TRANS_CONTEXT(t);
        struct mail_index_transaction_vfuncs super = ctx->super;
 
-       mail_cache_transaction_commit(&ctx);
+       /* a failed cache commit isn't important enough to fail the entire
+          index transaction, so we'll just ignore it */
+       (void)mail_cache_transaction_commit(&ctx);
        return super.commit(t, result_r);
 }
 
index 08e3a2b444b1eff2d0ac41ce5b5aaf3f4bee68cc..9b337d264f386d9add39f10216d7f0cb0079fc03 100644 (file)
@@ -85,7 +85,7 @@ static void mail_cache_init_file_cache(struct mail_cache *cache)
        file_cache_set_fd(cache->file_cache, cache->fd);
 
        if (fstat(cache->fd, &st) == 0)
-               file_cache_set_size(cache->file_cache, st.st_size);
+               (void)file_cache_set_size(cache->file_cache, st.st_size);
        else if (!ESTALE_FSTAT(errno))
                mail_cache_set_syscall_error(cache, "fstat()");
 
index fd18d6c738925bff3eb4e8a82e92dea343ab9c8c..fc97d29b588c32f67b8d6c8d99d650a0cb882754 100644 (file)
@@ -210,7 +210,7 @@ mail_index_fsck_keywords(struct mail_index *index, struct mail_index_map *map,
        /* add keyword records so we can start appending names directly */
        rec_pos = dest->used;
        memset(&new_kw_rec, 0, sizeof(new_kw_rec));
-       buffer_append_space_unsafe(dest, keywords_count * sizeof(*kw_rec));
+       (void)buffer_append_space_unsafe(dest, keywords_count * sizeof(*kw_rec));
 
        /* write the actual records and names */
        name_base_pos = dest->used;
index 953be63c71a5e84418206ea25e73e88f54a4741c..82898ec3fce732dc6aeb1b7b0a7300024dbda4df 100644 (file)
@@ -52,7 +52,7 @@ int mail_index_map_parse_extensions(struct mail_index_map *map)
                        return -1;
                }
 
-               mail_index_map_register_ext(map, name, ext_offset, ext_hdr);
+               (void)mail_index_map_register_ext(map, name, ext_offset, ext_hdr);
        }
        return 0;
 }
index 8f1860dcb86415d89d4b9a89a1717d4f379c6482..a5fb5318ac838f3e10608569fdd59266cf18b733 100644 (file)
@@ -344,8 +344,7 @@ mail_index_modseq_update_old_rec(struct mail_index_modseq_sync *ctx,
                for (i = 0; i < count; i++) {
                        if (mail_index_lookup_seq(ctx->view,
                                                  appends[i].uid, &seq1)) {
-                               mail_index_modseq_update_to_highest(ctx, seq1,
-                                                                   seq1);
+                               (void)mail_index_modseq_update_to_highest(ctx, seq1, seq1);
                        }
                }
                return;
@@ -385,7 +384,7 @@ mail_index_modseq_update_old_rec(struct mail_index_modseq_sync *ctx,
                rec = array_idx(&uids, i);
                if (mail_index_lookup_seq_range(ctx->view, rec->seq1, rec->seq2,
                                                &seq1, &seq2))
-                       mail_index_modseq_update_to_highest(ctx, seq1, seq2);
+                       (void)mail_index_modseq_update_to_highest(ctx, seq1, seq2);
        }
 }
 
@@ -547,7 +546,7 @@ void mail_index_modseq_hdr_update(struct mail_index_modseq_sync *ctx)
 
 void mail_index_modseq_append(struct mail_index_modseq_sync *ctx, uint32_t seq)
 {
-       mail_index_modseq_update_to_highest(ctx, seq, seq);
+       (void)mail_index_modseq_update_to_highest(ctx, seq, seq);
 }
 
 void mail_index_modseq_expunge(struct mail_index_modseq_sync *ctx,
index 77c56f32231f67e8b8e7e182dc502e6d5cc488f2..56970e0730c4fef60ca9d0cd15ea72ccea5b7b04 100644 (file)
@@ -343,14 +343,14 @@ void mail_index_view_transaction_unref(struct mail_index_view *view);
 
 void mail_index_fsck_locked(struct mail_index *index);
 
-int mail_index_set_error(struct mail_index *index, const char *fmt, ...)
+void mail_index_set_error(struct mail_index *index, const char *fmt, ...)
        ATTR_FORMAT(2, 3);
 /* "%s failed with index file %s: %m" */
-int mail_index_set_syscall_error(struct mail_index *index,
-                                const char *function);
+void mail_index_set_syscall_error(struct mail_index *index,
+                                 const char *function);
 /* "%s failed with file %s: %m" */
-int mail_index_file_set_syscall_error(struct mail_index *index,
-                                     const char *filepath,
-                                     const char *function);
+void mail_index_file_set_syscall_error(struct mail_index *index,
+                                      const char *filepath,
+                                      const char *function);
 
 #endif
index 035de88458ea3f18e8063bbe7506e69e22d161c9..382fd1a730dd3868257c421e97236ab8cb4c4947 100644 (file)
@@ -953,9 +953,9 @@ static void mail_index_strmap_write_block(struct mail_index_strmap_view *view,
        i_assert(block_size != 0);
 
        end_offset = output->offset;
-       o_stream_seek(output, block_offset);
+       (void)o_stream_seek(output, block_offset);
        o_stream_nsend(output, &block_size, sizeof(block_size));
-       o_stream_seek(output, end_offset);
+       (void)o_stream_seek(output, end_offset);
 
        if (output->last_failed_errno != 0)
                return;
@@ -1167,7 +1167,7 @@ mail_index_strmap_write_append(struct mail_index_strmap_view *view)
 
        /* write the new records */
        output = o_stream_create_fd(view->strmap->fd, 0, FALSE);
-       o_stream_seek(output, view->last_read_block_offset);
+       (void)o_stream_seek(output, view->last_read_block_offset);
        o_stream_cork(output);
        mail_index_strmap_write_block(view, output, i,
                                      view->last_read_uid + 1);
index d74e2a6b1495c0ab68d5df1c1b35b8ca06c8e850..da35aa4b080847d85b8cc54f45bb3f453eb03881 100644 (file)
@@ -92,7 +92,7 @@ mail_index_sync_move_to_private_memory(struct mail_index_sync_map_ctx *ctx)
 struct mail_index_map *
 mail_index_sync_get_atomic_map(struct mail_index_sync_map_ctx *ctx)
 {
-       mail_index_sync_move_to_private_memory(ctx);
+       (void)mail_index_sync_move_to_private_memory(ctx);
        mail_index_record_map_move_to_private(ctx->view->map);
        mail_index_modseq_sync_map_replaced(ctx->modseq_ctx);
        return ctx->view->map;
index 2c0e251e627e8a5678154260da5f150aaf2e7094..2a57bec079fa88d87affb13581fa58443e76be86 100644 (file)
@@ -147,7 +147,7 @@ mail_index_transaction_get_flag_update_pos(struct mail_index_transaction *t,
                                           unsigned int right_idx,
                                           uint32_t seq);
 
-bool mail_index_ext_using_reset_id(struct mail_index_transaction *t,
+void mail_index_ext_using_reset_id(struct mail_index_transaction *t,
                                   uint32_t ext_id, uint32_t reset_id);
 
 #endif
index 606850d2a40ae0675006766bf784c10de4a37ee1..47ddbcabed65c4d97fbd2b1a7848192671d5b8a7 100644 (file)
@@ -51,9 +51,9 @@ mail_index_transaction_sort_appends_ext(ARRAY_TYPE(seq_array_array) *updates,
 
                        seq = *ext_rec < first_new_seq ? *ext_rec :
                                old_to_newseq_map[*ext_rec - first_new_seq];
-                       mail_index_seq_array_add(&new_array, seq, ext_rec+1,
-                                                old_array->arr.element_size -
-                                                sizeof(*ext_rec), NULL);
+                       (void)mail_index_seq_array_add(&new_array, seq, ext_rec+1,
+                                                      old_array->arr.element_size -
+                                                      sizeof(*ext_rec), NULL);
                }
                array_free(old_array);
                ext_rec_arrays[j] = new_array;
index 0bd61e9a9c35c604120f7e5511a171f1bc971bc8..697cb2353b6bbca39376310711a7743dec9826f9 100644 (file)
@@ -833,7 +833,7 @@ mail_index_ext_reset_changes(struct mail_index_transaction *t, uint32_t ext_id)
        t->log_ext_updates = mail_index_transaction_has_ext_changes(t);
 }
 
-bool mail_index_ext_using_reset_id(struct mail_index_transaction *t,
+void mail_index_ext_using_reset_id(struct mail_index_transaction *t,
                                   uint32_t ext_id, uint32_t reset_id)
 {
        uint32_t *reset_id_p;
@@ -848,7 +848,6 @@ bool mail_index_ext_using_reset_id(struct mail_index_transaction *t,
                /* reset_id changed, clear existing changes */
                mail_index_ext_reset_changes(t, ext_id);
        }
-       return changed;
 }
 
 void mail_index_ext_set_reset_id(struct mail_index_transaction *t,
@@ -953,8 +952,8 @@ int mail_index_atomic_inc_ext(struct mail_index_transaction *t,
                                     &old_diff32)) {
                /* already incremented this sequence in this transaction */
                diff32 += old_diff32;
-               mail_index_seq_array_add(array, seq, &diff32, sizeof(diff32),
-                                        NULL);
+               (void)mail_index_seq_array_add(array, seq, &diff32,
+                                              sizeof(diff32), NULL);
        }
        return diff32;
 }
index f122150b8ef3d349a07a4da9c03baadbc7e791a4..5c7b8eef7979e093335097a6f954c1085c679ac3 100644 (file)
@@ -370,7 +370,8 @@ static int view_sync_apply_lost_changes(struct mail_index_view_sync_ctx *ctx,
                                           &kw_reset) < 0)
                        return -1;
 
-               view_sync_update_keywords(ctx, new_rec->uid);
+               if (view_sync_update_keywords(ctx, new_rec->uid) < 0)
+                       return -1;
                changed = TRUE;
        }
 
@@ -463,7 +464,8 @@ view_sync_get_log_lost_changes(struct mail_index_view_sync_ctx *ctx,
                        return -1;
                mail_index_map_lookup_keywords(new_map, j + 1,
                                               &ctx->lost_new_kw);
-               view_sync_update_keywords(ctx, new_rec->uid);
+               if (view_sync_update_keywords(ctx, new_rec->uid) < 0)
+                       return -1;
        }
        *expunge_count_r = view_sync_expunges2seqs(ctx);
 
index fb2db373a8ef63eb9b0b0c306ffc59bb4716d0ed..7a7626fd80703ecfcb8f418cd03b5ace77791974 100644 (file)
@@ -102,7 +102,7 @@ static int mail_index_recreate(struct mail_index *index)
        }
 
        if ((index->flags & MAIL_INDEX_OPEN_FLAG_KEEP_BACKUPS) != 0)
-               mail_index_create_backup(index);
+               (void)mail_index_create_backup(index);
 
        if (ret == 0 && rename(path, index->filepath) < 0) {
                mail_index_set_error(index, "rename(%s, %s) failed: %m",
@@ -134,7 +134,7 @@ void mail_index_write(struct mail_index *index, bool want_rotate)
 
        if (!MAIL_INDEX_IS_IN_MEMORY(index)) {
                if (mail_index_recreate(index) < 0) {
-                       mail_index_move_to_memory(index);
+                       (void)mail_index_move_to_memory(index);
                        return;
                }
        }
index b228957acfb3d94f20b13d99bd3bf38c9d15fb4e..2f1b18cebe49d6554627a3f75739627e99d93114 100644 (file)
@@ -403,8 +403,10 @@ int mail_index_try_open_only(struct mail_index *index)
        }
 
        if (index->fd == -1) {
-               if (errno != ENOENT)
-                       return mail_index_set_syscall_error(index, "open()");
+               if (errno != ENOENT) {
+                       mail_index_set_syscall_error(index, "open()");
+                       return -1;
+               }
 
                /* have to create it */
                return 0;
@@ -705,12 +707,15 @@ int mail_index_reopen_if_changed(struct mail_index *index)
        if (nfs_safe_stat(index->filepath, &st2) < 0) {
                if (errno == ENOENT)
                        return 0;
-               return mail_index_set_syscall_error(index, "stat()");
+               mail_index_set_syscall_error(index, "stat()");
+               return -1;
        }
 
        if (fstat(index->fd, &st1) < 0) {
-               if (!ESTALE_FSTAT(errno))
-                       return mail_index_set_syscall_error(index, "fstat()");
+               if (!ESTALE_FSTAT(errno)) {
+                       mail_index_set_syscall_error(index, "fstat()");
+                       return -1;
+               }
                /* deleted/recreated, reopen */
        } else if (st1.st_ino == st2.st_ino &&
                   CMP_DEV_T(st1.st_dev, st2.st_dev)) {
@@ -738,7 +743,7 @@ struct mail_cache *mail_index_get_cache(struct mail_index *index)
        return index->cache;
 }
 
-int mail_index_set_error(struct mail_index *index, const char *fmt, ...)
+void mail_index_set_error(struct mail_index *index, const char *fmt, ...)
 {
        va_list va;
 
@@ -753,8 +758,6 @@ int mail_index_set_error(struct mail_index *index, const char *fmt, ...)
 
                i_error("%s", index->error);
        }
-
-       return -1;
 }
 
 bool mail_index_is_in_memory(struct mail_index *index)
@@ -875,16 +878,15 @@ void mail_index_fchown(struct mail_index *index, int fd, const char *path)
                mail_index_file_set_syscall_error(index, path, "fchmod()");
 }
 
-int mail_index_set_syscall_error(struct mail_index *index,
-                                const char *function)
+void mail_index_set_syscall_error(struct mail_index *index,
+                                 const char *function)
 {
-       return mail_index_file_set_syscall_error(index, index->filepath,
-                                                function);
+       mail_index_file_set_syscall_error(index, index->filepath, function);
 }
 
-int mail_index_file_set_syscall_error(struct mail_index *index,
-                                     const char *filepath,
-                                     const char *function)
+void mail_index_file_set_syscall_error(struct mail_index *index,
+                                      const char *filepath,
+                                      const char *function)
 {
        const char *errstr;
 
@@ -894,7 +896,7 @@ int mail_index_file_set_syscall_error(struct mail_index *index,
        if (ENOSPACE(errno)) {
                index->nodiskspace = TRUE;
                if ((index->flags & MAIL_INDEX_OPEN_FLAG_NEVER_IN_MEMORY) == 0)
-                       return -1;
+                       return;
        }
 
        if (errno == EACCES) {
@@ -904,12 +906,12 @@ int mail_index_file_set_syscall_error(struct mail_index *index,
                        errstr = eacces_error_get_creating(function, filepath);
                else
                        errstr = eacces_error_get(function, filepath);
-               return mail_index_set_error(index, "%s", errstr);
+               mail_index_set_error(index, "%s", errstr);
        } else {
                const char *suffix = errno != EFBIG ? "" :
                        " (process was started with ulimit -f limit)";
-               return mail_index_set_error(index, "%s failed with file %s: "
-                                           "%m%s", function, filepath, suffix);
+               mail_index_set_error(index, "%s failed with file %s: "
+                                    "%m%s", function, filepath, suffix);
        }
 }
 
index 27ee42a3e2a83cd93c2da65fb8bbd00cabebc276..f189182fc14dab2abb9dd38fdfaf6d45d3127272 100644 (file)
 static int
 mail_transaction_log_file_sync(struct mail_transaction_log_file *file);
 
-static int
+static void
 log_file_set_syscall_error(struct mail_transaction_log_file *file,
                           const char *function)
 {
-       return mail_index_file_set_syscall_error(file->log->index,
-                                                file->filepath, function);
+       mail_index_file_set_syscall_error(file->log->index,
+                                         file->filepath, function);
 }
 
 static void
@@ -392,7 +392,7 @@ void mail_transaction_log_file_unlock(struct mail_transaction_log_file *file)
        }
 
        if (file->log->index->lock_method == FILE_LOCK_METHOD_DOTLOCK) {
-               mail_transaction_log_file_undotlock(file);
+               (void)mail_transaction_log_file_undotlock(file);
                return;
        }
 
@@ -654,8 +654,10 @@ mail_transaction_log_file_create2(struct mail_transaction_log_file *file,
        if (reset)
                rename_existing = FALSE;
        else if (nfs_safe_stat(file->filepath, &st) < 0) {
-               if (errno != ENOENT)
-                       return log_file_set_syscall_error(file, "stat()");
+               if (errno != ENOENT) {
+                       log_file_set_syscall_error(file, "stat()");
+                       return -1;
+               }
                rename_existing = FALSE;
        } else if (st.st_ino == file->st_ino &&
                   CMP_DEV_T(st.st_dev, file->st_dev) &&
@@ -712,14 +714,18 @@ mail_transaction_log_file_create2(struct mail_transaction_log_file *file,
 
        if (index->ext_hdr_init_data != NULL && reset)
                log_write_ext_hdr_init_data(index, writebuf);
-       if (write_full(new_fd, writebuf->data, writebuf->used) < 0)
-               return log_file_set_syscall_error(file, "write_full()");
+       if (write_full(new_fd, writebuf->data, writebuf->used) < 0) {
+               log_file_set_syscall_error(file, "write_full()");
+               return -1;
+       }
 
        if (file->log->index->fsync_mode == FSYNC_MODE_ALWAYS) {
                /* the header isn't important, so don't bother calling
                   fdatasync() unless it's required */
-               if (fdatasync(new_fd) < 0)
-                       return log_file_set_syscall_error(file, "fdatasync()");
+               if (fdatasync(new_fd) < 0) {
+                       log_file_set_syscall_error(file, "fdatasync()");
+                       return -1;
+               }
        }
 
        file->fd = new_fd;
@@ -795,8 +801,10 @@ int mail_transaction_log_file_create(struct mail_transaction_log_file *file,
        fd = file_dotlock_open(&new_dotlock_set, file->filepath, 0, &dotlock);
        umask(old_mask);
 
-       if (fd == -1)
-               return log_file_set_syscall_error(file, "file_dotlock_open()");
+       if (fd == -1) {
+               log_file_set_syscall_error(file, "file_dotlock_open()");
+               return -1;
+       }
        mail_index_fchown(index, fd, file_dotlock_get_lock_path(dotlock));
 
         /* either fd gets used or the dotlock gets deleted and returned fd
@@ -828,7 +836,8 @@ int mail_transaction_log_file_open(struct mail_transaction_log_file *file,
                        if (errno == ENOENT)
                                return 0;
 
-                       return log_file_set_syscall_error(file, "open()");
+                       log_file_set_syscall_error(file, "open()");
+                       return -1;
                 }
 
                ignore_estale = i < MAIL_INDEX_ESTALE_RETRY_COUNT;
@@ -1326,8 +1335,10 @@ mail_transaction_log_file_sync(struct mail_transaction_log_file *file)
                   Without this check we might see partial transactions,
                   sometimes causing "Extension record updated without intro
                   prefix" errors. */
-               if (fstat(file->fd, &st) < 0)
-                       return log_file_set_syscall_error(file, "fstat()");
+               if (fstat(file->fd, &st) < 0) {
+                       log_file_set_syscall_error(file, "fstat()");
+                       return -1;
+               }
                if ((uoff_t)st.st_size != file->last_size) {
                        file->last_size = st.st_size;
                        return 0;
@@ -1399,7 +1410,8 @@ mail_transaction_log_file_insert_read(struct mail_transaction_log_file *file,
                /* log file was deleted in NFS server, fail silently */
                return 0;
        } else {
-               return log_file_set_syscall_error(file, "pread()");
+               log_file_set_syscall_error(file, "pread()");
+               return -1;
        }
 }
 
@@ -1430,7 +1442,8 @@ mail_transaction_log_file_read_more(struct mail_transaction_log_file *file)
                        /* log file was deleted in NFS server, fail silently */
                        return 0;
                }
-               return log_file_set_syscall_error(file, "pread()");
+               log_file_set_syscall_error(file, "pread()");
+               return -1;
        }
        return 1;
 }
@@ -1472,10 +1485,8 @@ mail_transaction_log_file_read(struct mail_transaction_log_file *file,
        if (file->log->nfs_flush && nfs_flush) {
                if (!file->locked)
                        nfs_flush_attr_cache_unlocked(file->filepath);
-               else {
-                       nfs_flush_attr_cache_fd_locked(file->filepath,
-                                                      file->fd);
-               }
+               else
+                       nfs_flush_attr_cache_fd_locked(file->filepath, file->fd);
        }
 
        if (file->buffer != NULL && file->buffer_offset > start_offset) {
@@ -1543,7 +1554,8 @@ mail_transaction_log_file_mmap(struct mail_transaction_log_file *file)
        if (file->mmap_base == MAP_FAILED) {
                file->mmap_base = NULL;
                file->mmap_size = 0;
-               return log_file_set_syscall_error(file, "mmap()");
+               log_file_set_syscall_error(file, "mmap()");
+               return -1;
        }
 
        if (file->mmap_size > mmap_get_page_size()) {
@@ -1584,8 +1596,10 @@ mail_transaction_log_file_map_mmap(struct mail_transaction_log_file *file,
        i_assert(file->buffer_offset == 0 || file->mmap_base == NULL);
        i_assert(file->mmap_size == 0 || file->mmap_base != NULL);
 
-       if (fstat(file->fd, &st) < 0)
-               return log_file_set_syscall_error(file, "fstat()");
+       if (fstat(file->fd, &st) < 0) {
+               log_file_set_syscall_error(file, "fstat()");
+               return -1;
+       }
        file->last_size = st.st_size;
 
        if ((uoff_t)st.st_size < file->sync_offset) {
index 74ac40ec5677b146a947db4294469ebe2c898d1a..a464de20297a4433bb5e48c46e3ff50f727d1361 100644 (file)
@@ -277,7 +277,7 @@ static void test_mail_index_flag_update_complex_merges(void)
        test_end();
 }
 
-static bool
+static void
 flags_array_check(struct mail_index_transaction *t,
                  const enum mail_flags *flags, unsigned int msg_count)
 {
@@ -304,7 +304,6 @@ flags_array_check(struct mail_index_transaction *t,
        }
        for (; seq <= msg_count; seq++)
                test_assert(flags[seq] == 0);
-       return TRUE;
 }
 
 static void test_mail_index_flag_update_random(void)
@@ -367,15 +366,15 @@ static void test_mail_index_cancel_flag_updates(void)
        updates = array_get(&t->updates, &count);
        test_assert(count == 1);
        test_assert(updates[0].uid1 == 5 && updates[0].uid2 == 7);
-       mail_index_cancel_flag_updates(t, 5);
+       test_assert(mail_index_cancel_flag_updates(t, 5));
        test_assert(updates[0].uid1 == 6 && updates[0].uid2 == 7);
-       mail_index_cancel_flag_updates(t, 7);
+       test_assert(mail_index_cancel_flag_updates(t, 7));
        test_assert(updates[0].uid1 == 6 && updates[0].uid2 == 6);
-       mail_index_cancel_flag_updates(t, 6);
+       test_assert(mail_index_cancel_flag_updates(t, 6));
        test_assert(!array_is_created(&t->updates));
 
        mail_index_update_flags_range(t, 5, 7, MODIFY_REPLACE, 0);
-       mail_index_cancel_flag_updates(t, 6);
+       test_assert(mail_index_cancel_flag_updates(t, 6));
        updates = array_get(&t->updates, &count);
        test_assert(count == 2);
        test_assert(updates[0].uid1 == 5 && updates[0].uid2 == 5);
index dcbdd1ee169638db7717e58c4ba647022ddf2f77..50d6cda7bf82b6106d1d1cf01014a4239fb79ea1 100644 (file)
 
 static bool log_lock_failure = FALSE;
 
-int mail_index_file_set_syscall_error(struct mail_index *index ATTR_UNUSED,
-                                     const char *filepath ATTR_UNUSED,
-                                     const char *function ATTR_UNUSED)
+void mail_index_file_set_syscall_error(struct mail_index *index ATTR_UNUSED,
+                                      const char *filepath ATTR_UNUSED,
+                                      const char *function ATTR_UNUSED)
 {
-       return -1;
 }
 
 int mail_transaction_log_lock_head(struct mail_transaction_log *log ATTR_UNUSED)
index e750e9d7078fe41f3421569e22d0b8a7cf3deeb1..cb4b014894a3790ccf1cdb513ae3baeef8d20a03 100644 (file)
@@ -178,7 +178,6 @@ void message_header_decode_utf8(const unsigned char *data, size_t size,
                                buffer_t *dest, bool dtcase)
 {
        struct decode_utf8_context ctx;
-       size_t used = dest->used;
 
        memset(&ctx, 0, sizeof(ctx));
        ctx.dest = dest;
index f7b3345d265f9d7b2945ef6ce21bc25a820be556..3f0fd2bbc34a743e3b384674e50161d2d00b7301 100644 (file)
@@ -39,8 +39,8 @@ struct deserialize_context {
        const char *error;
 };
 
-static unsigned int
-part_serialize(struct message_part *part, buffer_t *dest)
+static void part_serialize(struct message_part *part, buffer_t *dest,
+                          unsigned int *children_count_r)
 {
        unsigned int count, children_count;
        size_t children_offset;
@@ -79,8 +79,8 @@ part_serialize(struct message_part *part, buffer_t *dest)
                                      sizeof(children_count));
 
                        if (part->children != NULL) {
-                               children_count =
-                                       part_serialize(part->children, dest);
+                               part_serialize(part->children, dest,
+                                              &children_count);
 
                                buffer_write(dest, children_offset,
                                             &children_count,
@@ -94,12 +94,14 @@ part_serialize(struct message_part *part, buffer_t *dest)
                part = part->next;
        }
 
-       return count;
+       *children_count_r = count;
 }
 
 void message_part_serialize(struct message_part *part, buffer_t *dest)
 {
-       part_serialize(part, dest);
+       unsigned int children_count;
+
+       part_serialize(part, dest, &children_count);
 }
 
 static bool read_next(struct deserialize_context *ctx,
index ae874e64abc741a940ef739e5a5045176048f941..80f1292c0049a1af6ed7e90aa7b418c31b0ec383 100644 (file)
@@ -407,7 +407,7 @@ int rfc822_parse_content_param(struct rfc822_parser_context *ctx,
                /* broken / no value */
        } else if (*ctx->data == '"') {
                ret = rfc822_parse_quoted_string(ctx, tmp);
-               str_unescape(str_c_modifiable(tmp) + value_pos);
+               (void)str_unescape(str_c_modifiable(tmp) + value_pos);
        } else if (ctx->data != ctx->end && *ctx->data == '=') {
                /* workaround for broken input:
                   name==?utf-8?b?...?= */
index 27709773b9f15d448234d8d64a603dbfafea99dc..49c52a5adc568371809008c106da7a968e854341 100644 (file)
@@ -71,7 +71,7 @@ static void test_istream_dot_one(const struct dot_test *test,
                        }
                }
                test_istream_set_size(test_input, input_len);
-               i_stream_read(test_input);
+               (void)i_stream_read(test_input);
        } else {
                test_istream_set_size(test_input, input_len);
                size = 0;
index 3d4157ba419d9c49b9b418fccaf6e7209f96d0b4..0c84802338495fc42bea89f929b05f76523acba6 100644 (file)
@@ -589,9 +589,8 @@ des_cbc_encrypt(unsigned char *dest, const unsigned char *src,
        PUT_32BIT_MSB_FIRST(dest + 4, out[1]);
 }
 
-unsigned char *
-deshash(unsigned char *dst, const unsigned char *key,
-       const unsigned char *src)
+void deshash(unsigned char *dst, const unsigned char *key,
+            const unsigned char *src)
 {
        struct des_context ctx;
 
@@ -599,6 +598,4 @@ deshash(unsigned char *dst, const unsigned char *key,
                      GET_32BIT_MSB_FIRST(key + 3), &ctx);
 
        des_cbc_encrypt(dst, src, &ctx);
-
-       return dst;
 }
index 8930986bf9cdbbd164228c8d22535057f84ed764..6a84c9a966d57a410b1a6e72785307bebb78dbb6 100644 (file)
@@ -1,7 +1,7 @@
 #ifndef NTLM_DES_H
 #define NTLM_DES_H
 
-unsigned char * deshash(unsigned char *dst, const unsigned char *key,
-                       const unsigned char *src);
+void deshash(unsigned char *dst, const unsigned char *key,
+            const unsigned char *src);
 
 #endif
index 787a20d2f4b18f3fdc180b08f9b9f2d80beafefd..3aff708cd927811aa8f23df26d19fdc85a8d83ee 100644 (file)
@@ -32,8 +32,7 @@ t_unicode_str(const char *src, bool ucase, size_t *size)
        return buffer_free_without_data(&wstr);
 }
 
-const unsigned char *
-lm_hash(const char *passwd, unsigned char hash[LM_HASH_SIZE])
+void lm_hash(const char *passwd, unsigned char hash[LM_HASH_SIZE])
 {
        static const unsigned char lm_magic[8] = "KGS!@#$%";
        unsigned char buffer[14];
@@ -48,12 +47,9 @@ lm_hash(const char *passwd, unsigned char hash[LM_HASH_SIZE])
        deshash(hash + 8, buffer + 7, lm_magic);
 
        safe_memset(buffer, 0, sizeof(buffer));
-
-       return hash;
 }
 
-const unsigned char *
-ntlm_v1_hash(const char *passwd, unsigned char hash[NTLMSSP_HASH_SIZE])
+void ntlm_v1_hash(const char *passwd, unsigned char hash[NTLMSSP_HASH_SIZE])
 {
        size_t len;
        void *wpwd = t_unicode_str(passwd, 0, &len);
@@ -61,8 +57,6 @@ ntlm_v1_hash(const char *passwd, unsigned char hash[NTLMSSP_HASH_SIZE])
        md4_get_digest(wpwd, len, hash);
 
        safe_memset(wpwd, 0, len);
-
-       return hash;
 }
 
 static void
index b17767538ca2294fd2bdf9354c4bf44f44052d46..fe3b1b93e31c520a444fcbe053cf62890ad8ff0c 100644 (file)
@@ -1,11 +1,8 @@
 #ifndef NTLM_ENCRYPT_H
 #define NTLM_ENCRYPT_H
 
-const unsigned char *
-lm_hash(const char *passwd, unsigned char hash[LM_HASH_SIZE]);
-
-const unsigned char *
-ntlm_v1_hash(const char *passwd, unsigned char hash[NTLMSSP_HASH_SIZE]);
+void lm_hash(const char *passwd, unsigned char hash[LM_HASH_SIZE]);
+void ntlm_v1_hash(const char *passwd, unsigned char hash[NTLMSSP_HASH_SIZE]);
 
 void ntlmssp_v1_response(const unsigned char *hash,
                         const unsigned char *challenge,
index 100eb71f13c8d542c8cc8b4f51c19e295e844209..bf364f4271d47985711c3c0d050146884eb6215f 100644 (file)
@@ -107,14 +107,12 @@ int digest_find(const char *name)
        return -1;
 }
 
-int digest_init(struct digest_context *ctx, const unsigned int algo)
+void digest_init(struct digest_context *ctx, const unsigned int algo)
 {
        i_assert(algo < N_ELEMENTS(digests));
 
        ctx->digest = digests + algo;
        ctx->digest->init(&ctx->ctx);
-
-       return 0;
 }
 
 void digest_update(struct digest_context *ctx, const void *data,
index 84fb23f128f653a3bdc29c632e898f877ab47feb..152f28e728e0dea86fa6086dac11c1e5d032e07d 100644 (file)
@@ -10,7 +10,7 @@ enum {
 };
 
 int digest_find(const char *name);
-int digest_init(struct digest_context *ctx, const unsigned int algo);
+void digest_init(struct digest_context *ctx, const unsigned int algo);
 void digest_update(struct digest_context *ctx, const void *data,
                   const size_t size);
 void digest_final(struct digest_context *ctx, unsigned char *result);
index 8901f1b4f952bde85dcc7927f676f3af8178489d..5104c946145f84155aaf71dcb7d10dedfbd1d429 100644 (file)
@@ -30,7 +30,7 @@ dbox_file_find_next_magic(struct dbox_file *file, uoff_t *offset_r, bool *pre_r)
        /* \n isn't part of the DBOX_MAGIC_PRE, but it always preceds it.
           assume that at this point we've already just read the \n. when
           scanning for it later we'll need to find the \n though. */
-       str_find_more(pre_ctx, (const unsigned char *)"\n", 1);
+       (void)str_find_more(pre_ctx, (const unsigned char *)"\n", 1);
 
        orig_offset = input->v_offset;
        while ((ret = i_stream_read_data(input, &data, &size, 0)) > 0) {
index 35893adbb0ed6402b7f9118b49b296dcf74d25dc..e0357ad001a95b7215fdf01bd158b34b2ca42a38 100644 (file)
@@ -601,7 +601,10 @@ int dbox_file_get_append_stream(struct dbox_file_append_context *ctx,
                                "dbox file size too small");
                        return 0;
                }
-               o_stream_seek(ctx->output, st.st_size);
+               if (o_stream_seek(ctx->output, st.st_size) < 0) {
+                       dbox_file_set_syscall_error(file, "lseek()");
+                       return -1;
+               }
        }
        *output_r = ctx->output;
        return 1;
index 8601d551f00ee924fc5617973369cc378cb67854..24dd8407176e0bafd44064fd7a16a5b9e075bc63 100644 (file)
@@ -158,7 +158,7 @@ dbox_sync_index_rebuild_init(struct mailbox *box,
        ctx->trans = trans;
        mail_index_reset(ctx->trans);
        index_mailbox_reset_uidvalidity(box);
-       mail_index_ext_lookup(box->index, "cache", &ctx->cache_ext_id);
+       (void)mail_index_ext_lookup(box->index, "cache", &ctx->cache_ext_id);
 
        /* open cache and read the caching decisions. we'll reset the cache in
           case it contains any invalid data, but we want to preserve the
index fb8ae298c621248b4a174ec72ad6336b7acfb676..b94674ea29b2d116ecafd3e16566730ae54c6618 100644 (file)
@@ -423,7 +423,8 @@ mdbox_file_purge(struct mdbox_purge_context *ctx, struct dbox_file *file,
           temporarily vanished */
        if (ret > 0) {
                (void)dbox_file_unlink(file);
-               mdbox_map_remove_file_id(ctx->storage->map, file_id);
+               if (mdbox_map_remove_file_id(ctx->storage->map, file_id) < 0)
+                       ret = -1;
        } else {
                dbox_file_unlock(file);
        }
@@ -670,7 +671,8 @@ int mdbox_purge(struct mail_storage *_storage)
                        if (mdbox_file_purge(ctx, file, file_id) < 0)
                                ret = -1;
                } else {
-                       mdbox_map_remove_file_id(storage->map, file_id);
+                       if (mdbox_map_remove_file_id(storage->map, file_id) < 0)
+                               ret = -1;
                }
                dbox_file_unref(&file);
        } T_END;
index 09bd4b1cc75b4ffd26e482553ec85cf38bdbcb5d..f84ad90e4b9294bec599303086d7886922563b15 100644 (file)
@@ -123,7 +123,7 @@ sdbox_copy_hardlink(struct mail_save_context *_ctx, struct mail *mail)
        ret = sdbox_file_copy_attachments((struct sdbox_file *)src_file,
                                          (struct sdbox_file *)dest_file);
        if (ret <= 0) {
-               sdbox_file_unlink_aborted_save((struct sdbox_file *)dest_file);
+               (void)sdbox_file_unlink_aborted_save((struct sdbox_file *)dest_file);
                dbox_file_unref(&src_file);
                dbox_file_unref(&dest_file);
                return ret;
index 6ff16e33954a62abb38be375ccc5ff1b2a7972ad..68a694c21ba6f537a39d648b8d90c4523445192d 100644 (file)
@@ -176,7 +176,8 @@ imapc_mail_get_stream(struct mail *_mail, bool get_body,
        if (data->stream == NULL) {
                if (!data->initialized) {
                        /* coming here from mail_set_seq() */
-                       return mail_set_aborted(_mail);
+                       mail_set_aborted(_mail);
+                       return -1;
                }
                fetch_field = get_body ||
                        (data->access_part & READ_BODY) != 0 ?
index c364c701ea44b31b63c1c579b4617f20cb03541f..78183a810bdb50d60f66dea5f5f45fb467171504 100644 (file)
@@ -603,7 +603,7 @@ static void imapc_mailbox_get_selected_status(struct imapc_mailbox *mbox,
                                              enum mailbox_status_items items,
                                              struct mailbox_status *status_r)
 {
-       index_storage_get_status(&mbox->box, items, status_r);
+       index_storage_get_open_status(&mbox->box, items, status_r);
        if ((items & STATUS_PERMANENT_FLAGS) != 0)
                status_r->permanent_flags = mbox->permanent_flags;
 }
index c4874e62a8dd2c8b601af82be47daedbf000071c..35e996c378037d7828db320b645a09b528e8c2f7 100644 (file)
@@ -353,7 +353,7 @@ static bool get_cached_msgpart_sizes(struct index_mail *mail)
        struct index_mail_data *data = &mail->data;
 
        if (data->parts == NULL)
-               get_cached_parts(mail);
+               (void)get_cached_parts(mail);
 
        if (data->parts != NULL) {
                data->hdr_size_set = TRUE;
@@ -903,9 +903,14 @@ int index_mail_init_stream(struct index_mail *mail,
                                if (index_mail_parse_headers(mail, NULL) < 0)
                                        return -1;
                        } else {
-                               message_get_header_size(data->stream,
-                                                       &data->hdr_size,
-                                                       &has_nuls);
+                               if (message_get_header_size(data->stream,
+                                                           &data->hdr_size,
+                                                           &has_nuls) < 0) {
+                                       mail_storage_set_critical(_mail->box->storage,
+                                               "read(%s) failed: %m",
+                                               i_stream_get_name(data->stream));
+                                       return -1;
+                               }
                                data->hdr_size_set = TRUE;
                        }
                }
@@ -924,9 +929,14 @@ int index_mail_init_stream(struct index_mail *mail,
                                if (index_mail_parse_body(mail, 0) < 0)
                                        return -1;
                        } else {
-                               message_get_body_size(data->stream,
-                                                     &data->body_size,
-                                                     &has_nuls);
+                               if (message_get_body_size(data->stream,
+                                                         &data->body_size,
+                                                         &has_nuls) < 0) {
+                                       mail_storage_set_critical(_mail->box->storage,
+                                               "read(%s) failed: %m",
+                                               i_stream_get_name(data->stream));
+                                       return -1;
+                               }
                                data->body_size_set = TRUE;
                        }
                }
index 3d1fb0b014ee45c286e1fdb558978476ffc1f8b5..63793b51e5550feac8ede9cf2cfb0638e2487257 100644 (file)
@@ -548,7 +548,8 @@ static void search_header(struct message_header_line *hdr,
 {
        if (hdr == NULL) {
                /* end of headers, mark all unknown SEARCH_HEADERs unmatched */
-               mail_search_args_foreach(ctx->args, search_header_unmatch, ctx);
+               (void)mail_search_args_foreach(ctx->args, search_header_unmatch,
+                                              ctx);
                return;
        }
 
@@ -562,7 +563,7 @@ static void search_header(struct message_header_line *hdr,
                ctx->hdr = hdr;
 
                ctx->custom_header = FALSE;
-               mail_search_args_foreach(ctx->args, search_header_arg, ctx);
+               (void)mail_search_args_foreach(ctx->args, search_header_arg, ctx);
        }
 }
 
@@ -859,8 +860,8 @@ static void search_limit_lowwater(struct index_search_context *ctx,
        if (uid_lowwater == 0)
                return;
 
-       mail_index_lookup_seq_range(ctx->view, uid_lowwater, (uint32_t)-1,
-                                   &seq1, &seq2);
+       (void)mail_index_lookup_seq_range(ctx->view, uid_lowwater, (uint32_t)-1,
+                                         &seq1, &seq2);
        if (*first_seq < seq1)
                *first_seq = seq1;
 }
index 6f1777d00803797722282cc7a0effa2678b1c056..cc81893c3925d98ecd61aa1113efe95189abdd97 100644 (file)
@@ -275,8 +275,8 @@ static void index_sort_zeroes(struct sort_string_context *ctx)
                i_assert(nodes[i].seq <= ctx->last_seq);
 
                T_BEGIN {
-                       index_sort_header_get(mail, nodes[i].seq,
-                                             sort_type, str);
+                       (void)index_sort_header_get(mail, nodes[i].seq,
+                                                   sort_type, str);
                        ctx->sort_strings[nodes[i].seq] =
                                str_len(str) == 0 ? "" :
                                p_strdup(pool, str_c(str));
index 4c76cd728fcb5c6e86a3c7e98533e7fa885578c0..60e6e1e5231e8e58ac2e1b0c5a552297123a7df4 100644 (file)
@@ -470,8 +470,8 @@ int index_sort_node_cmp_type(struct mail *mail,
 
                        str1 = t_str_new(256);
                        str2 = t_str_new(256);
-                       index_sort_header_get(mail, seq1, sort_type, str1);
-                       index_sort_header_get(mail, seq2, sort_type, str2);
+                       (void)index_sort_header_get(mail, seq1, sort_type, str1);
+                       (void)index_sort_header_get(mail, seq2, sort_type, str2);
 
                        ret = strcmp(str_c(str1), str_c(str2));
                } T_END;
index 524b0fc68ea5b197253ab9f2672f9085d5b9f4cc..f975d50432f8ccca25749910492d6a84e9e3faf9 100644 (file)
@@ -33,16 +33,23 @@ int index_storage_get_status(struct mailbox *box,
                             enum mailbox_status_items items,
                             struct mailbox_status *status_r)
 {
-       const struct mail_index_header *hdr, *hdr_pvt;
-
-       memset(status_r, 0, sizeof(struct mailbox_status));
-
        if (!box->opened) {
                if (mailbox_open(box) < 0)
                        return -1;
                if (mailbox_sync(box, 0) < 0)
                        return -1;
        }
+       index_storage_get_open_status(box, items, status_r);
+       return 0;
+}
+
+void index_storage_get_open_status(struct mailbox *box,
+                                  enum mailbox_status_items items,
+                                  struct mailbox_status *status_r)
+{
+       const struct mail_index_header *hdr, *hdr_pvt;
+
+       memset(status_r, 0, sizeof(struct mailbox_status));
 
        /* we can get most of the status items without any trouble */
        hdr = mail_index_get_header(box->view);
@@ -96,7 +103,6 @@ int index_storage_get_status(struct mailbox *box,
                                !box->disallow_new_keywords;
                }
        }
-       return 0;
 }
 
 static void
index b407e32197726c1512803eb8c96c37cf3b1c2867..aacbccbc09626c2782052322fd881a29c4d4861a 100644 (file)
@@ -109,6 +109,9 @@ void index_sync_update_recent_count(struct mailbox *box);
 int index_storage_get_status(struct mailbox *box,
                             enum mailbox_status_items items,
                             struct mailbox_status *status_r);
+void index_storage_get_open_status(struct mailbox *box,
+                                  enum mailbox_status_items items,
+                                  struct mailbox_status *status_r);
 int index_mailbox_get_metadata(struct mailbox *box,
                               enum mailbox_metadata_items items,
                               struct mailbox_metadata *metadata_r);
index 31fb6ba086aa1557b845f3aa834062f1f5355174..c882381ca5ce31cf80bea94c7c6a3a9a0621bb7d 100644 (file)
@@ -131,10 +131,10 @@ void index_sync_changes_read(struct index_sync_changes_context *ctx,
                                break;
 
                        /* mark the changes as dirty */
-                       mail_index_lookup_seq_range(ctx->sync_view,
-                                                   sync_rec->uid1,
-                                                   sync_rec->uid2,
-                                                   &seq1, &seq2);
+                       (void)mail_index_lookup_seq_range(ctx->sync_view,
+                                                         sync_rec->uid1,
+                                                         sync_rec->uid2,
+                                                         &seq1, &seq2);
                        memset(sync_rec, 0, sizeof(*sync_rec));
 
                        if (seq1 == 0)
index 9e4644e4c5f93ebd4dfc2ad9fd4a084a53bf2b11..e82805dd46590c44d13691c0a0fba1181989cc74 100644 (file)
@@ -305,15 +305,15 @@ index_mailbox_expunge_unseen_recent(struct index_mailbox_sync_context *ctx)
                        continue;
 
                ibox->recent_flags_count -=
-                       seq_range_array_remove_range(&ibox->recent_flags,
-                                                    start_uid + 1, uid - 1);
+                       seq_range_array_remove_range_count(&ibox->recent_flags,
+                                                          start_uid + 1, uid - 1);
        }
 
        if (uid + 1 < hdr->next_uid) {
                ibox->recent_flags_count -=
-                       seq_range_array_remove_range(&ibox->recent_flags,
-                                                    uid + 1,
-                                                    hdr->next_uid - 1);
+                       seq_range_array_remove_range_count(&ibox->recent_flags,
+                                                          uid + 1,
+                                                          hdr->next_uid - 1);
        }
 #ifdef DEBUG
        if (!mail_index_view_is_inconsistent(view)) {
@@ -325,7 +325,7 @@ index_mailbox_expunge_unseen_recent(struct index_mailbox_sync_context *ctx)
                        for (uid = range[i].seq1; uid <= range[i].seq2; uid++) {
                                if (uid >= hdr->next_uid)
                                        break;
-                               mail_index_lookup_seq(view, uid, &seq);
+                               (void)mail_index_lookup_seq(view, uid, &seq);
                                i_assert(seq != 0);
                        }
                }
@@ -341,11 +341,10 @@ void index_sync_update_recent_count(struct mailbox *box)
 
        hdr = mail_index_get_header(box->view);
        if (hdr->first_recent_uid > ibox->recent_flags_prev_uid) {
-               mail_index_lookup_seq_range(box->view,
-                                           hdr->first_recent_uid,
-                                           hdr->next_uid,
-                                           &seq1, &seq2);
-               if (seq1 != 0) {
+               if (mail_index_lookup_seq_range(box->view,
+                                               hdr->first_recent_uid,
+                                               hdr->next_uid,
+                                               &seq1, &seq2)) {
                        index_mailbox_set_recent_seq(box, box->view,
                                                     seq1, seq2);
                }
index fe399971a6e549a6f47052086bb4664bc55a43cd..205769dd4e54a2b6a2c637aef1026a5aea0f8a12 100644 (file)
@@ -387,8 +387,9 @@ static bool mail_thread_cache_update_removes(struct mail_thread_mailbox *tbox,
        uids = array_get(&removed_uids, &uid_count);
        for (i = j = 0; i < uid_count; i++) {
                /* find and remove from the map */
-               bsearch_insert_pos(&uids[i].seq1, &msgid_map[j], map_count - j,
-                                  sizeof(*msgid_map), msgid_map_cmp, &idx);
+               (void)bsearch_insert_pos(&uids[i].seq1, &msgid_map[j],
+                                        map_count - j, sizeof(*msgid_map),
+                                        msgid_map_cmp, &idx);
                j += idx;
                if (j == map_count) {
                        /* all removals after this are about messages we never
index 623aa76e4549bbd5c35b82b76e2eb0f2696059c9..21a3c827f03babc4a570699430ee239d670f049d 100644 (file)
@@ -328,7 +328,7 @@ void maildir_uidlist_deinit(struct maildir_uidlist **_uidlist)
        i_assert(!UIDLIST_IS_LOCKED(uidlist));
 
        *_uidlist = NULL;
-       maildir_uidlist_update(uidlist);
+       (void)maildir_uidlist_update(uidlist);
        maildir_uidlist_close(uidlist);
 
        hash_table_destroy(&uidlist->files);
@@ -553,7 +553,7 @@ static bool maildir_uidlist_next(struct maildir_uidlist *uidlist,
                if (uidlist->retry_rewind)
                        return FALSE;
                /* Delete the old UID */
-               maildir_uidlist_records_array_delete(uidlist, old_rec);
+               (void)maildir_uidlist_records_array_delete(uidlist, old_rec);
                /* Replace the old record with this new one */
                *old_rec = *rec;
                rec = old_rec;
@@ -1336,7 +1336,7 @@ maildir_uidlist_records_drop_expunges(struct maildir_uidlist *uidlist)
        if (!uidlist->box->opened)
                return;
 
-       mail_index_refresh(uidlist->box->index);
+       (void)mail_index_refresh(uidlist->box->index);
        view = mail_index_view_open(uidlist->box->index);
        count = array_count(&uidlist->records);
        hdr = mail_index_get_header(view);
index 0c5e77810056d6591ff60e5db73e0db20cf63e02..0bbff803ca686d656eaf4fcdc4981d0a736297a9 100644 (file)
@@ -537,7 +537,7 @@ uoff_t istream_raw_mbox_get_body_offset(struct istream *stream)
        offset = stream->v_offset;
        i_stream_seek(stream, rstream->hdr_offset);
        while (rstream->body_offset == (uoff_t)-1) {
-               i_stream_get_data(stream, &pos);
+               (void)i_stream_get_data(stream, &pos);
                i_stream_skip(stream, pos);
 
                if (i_stream_raw_mbox_read(&rstream->istream) < 0) {
index e6c5611b1072e3e32891e73b257f6863970478be..89b1f5d6aac4637e32525bade424bcaa9eed240a 100644 (file)
@@ -43,8 +43,10 @@ static int mbox_mail_seek(struct index_mail *mail)
        if (_mail->expunged || mbox->syncing)
                return -1;
 
-       if (_mail->lookup_abort != MAIL_LOOKUP_ABORT_NEVER)
-               return mail_set_aborted(_mail);
+       if (_mail->lookup_abort != MAIL_LOOKUP_ABORT_NEVER) {
+               mail_set_aborted(_mail);
+               return -1;
+       }
 
        if (mbox->mbox_stream != NULL &&
            istream_raw_mbox_is_corrupted(mbox->mbox_stream)) {
index 4fa4ae6ad57a274f6b58ae883bb43d990d485b4e..85539dd20cf1c9cdd509120532e323065d88f16e 100644 (file)
@@ -58,11 +58,10 @@ struct mbox_save_context {
        unsigned int finished:1;
 };
 
-static int write_error(struct mbox_save_context *ctx)
+static void write_error(struct mbox_save_context *ctx)
 {
        mbox_set_syscall_error(ctx->mbox, "write()");
        ctx->failed = TRUE;
-       return -1;
 }
 
 static int mbox_seek_to_end(struct mbox_save_context *ctx, uoff_t *offset)
@@ -77,8 +76,10 @@ static int mbox_seek_to_end(struct mbox_save_context *ctx, uoff_t *offset)
        }
 
        fd = ctx->mbox->mbox_fd;
-       if (fstat(fd, &st) < 0)
-                return mbox_set_syscall_error(ctx->mbox, "fstat()");
+       if (fstat(fd, &st) < 0) {
+               mbox_set_syscall_error(ctx->mbox, "fstat()");
+               return -1;
+       }
 
        ctx->orig_atime = st.st_atime;
 
@@ -86,15 +87,21 @@ static int mbox_seek_to_end(struct mbox_save_context *ctx, uoff_t *offset)
        if (st.st_size == 0)
                return 0;
 
-       if (lseek(fd, st.st_size-1, SEEK_SET) < 0)
-                return mbox_set_syscall_error(ctx->mbox, "lseek()");
+       if (lseek(fd, st.st_size-1, SEEK_SET) < 0) {
+                mbox_set_syscall_error(ctx->mbox, "lseek()");
+               return -1;
+       }
 
-       if (read(fd, &ch, 1) != 1)
-               return mbox_set_syscall_error(ctx->mbox, "read()");
+       if (read(fd, &ch, 1) != 1) {
+               mbox_set_syscall_error(ctx->mbox, "read()");
+               return -1;
+       }
 
        if (ch != '\n') {
-               if (write_full(fd, "\n", 1) < 0)
-                       return write_error(ctx);
+               if (write_full(fd, "\n", 1) < 0) {
+                       write_error(ctx);
+                       return -1;
+               }
                *offset += 1;
        }
 
@@ -103,8 +110,10 @@ static int mbox_seek_to_end(struct mbox_save_context *ctx, uoff_t *offset)
 
 static int mbox_append_lf(struct mbox_save_context *ctx)
 {
-       if (o_stream_send(ctx->output, "\n", 1) < 0)
-               return write_error(ctx);
+       if (o_stream_send(ctx->output, "\n", 1) < 0) {
+               write_error(ctx);
+               return -1;
+       }
 
        return 0;
 }
@@ -162,18 +171,26 @@ static int mbox_write_content_length(struct mbox_save_context *ctx)
 
        /* flush manually here so that we don't confuse seek() errors with
           buffer flushing errors */
-       if (o_stream_flush(ctx->output) < 0)
-               return write_error(ctx);
+       if (o_stream_flush(ctx->output) < 0) {
+               write_error(ctx);
+               return -1;
+       }
        if (o_stream_seek(ctx->output, ctx->extra_hdr_offset +
-                         ctx->space_end_idx - len) < 0)
-               return mbox_set_syscall_error(ctx->mbox, "o_stream_seek()");
+                         ctx->space_end_idx - len) < 0) {
+               mbox_set_syscall_error(ctx->mbox, "lseek()");
+               return -1;
+       }
 
        if (o_stream_send(ctx->output, str, len) < 0 ||
-           o_stream_flush(ctx->output) < 0)
-               return write_error(ctx);
+           o_stream_flush(ctx->output) < 0) {
+               write_error(ctx);
+               return -1;
+       }
 
-       if (o_stream_seek(ctx->output, end_offset) < 0)
-               return mbox_set_syscall_error(ctx->mbox, "o_stream_seek()");
+       if (o_stream_seek(ctx->output, end_offset) < 0) {
+               mbox_set_syscall_error(ctx->mbox, "lseek()");
+               return -1;
+       }
        return 0;
 }
 
@@ -528,8 +545,10 @@ static int mbox_save_body_input(struct mbox_save_context *ctx)
 
        data = i_stream_get_data(ctx->input, &size);
        if (size > 0) {
-               if (o_stream_send(ctx->output, data, size) < 0)
-                       return write_error(ctx);
+               if (o_stream_send(ctx->output, data, size) < 0) {
+                       write_error(ctx);
+                       return -1;
+               }
                ctx->last_char = data[size-1];
                i_stream_skip(ctx->input, size);
        }
@@ -564,8 +583,10 @@ static int mbox_save_finish_headers(struct mbox_save_context *ctx)
        /* append our own headers and ending empty line */
        ctx->extra_hdr_offset = ctx->output->offset;
        if (o_stream_send(ctx->output, str_data(ctx->headers),
-                         str_len(ctx->headers)) < 0)
-               return write_error(ctx);
+                         str_len(ctx->headers)) < 0) {
+               write_error(ctx);
+               return -1;
+       }
        ctx->eoh_offset = ctx->output->offset;
        return 0;
 }
@@ -602,15 +623,19 @@ int mbox_save_continue(struct mail_save_context *_ctx)
                if (i != size) {
                        /* found end of headers. write the rest of them
                           (not including the finishing empty line) */
-                       if (o_stream_send(ctx->output, data, i) < 0)
-                               return write_error(ctx);
+                       if (o_stream_send(ctx->output, data, i) < 0) {
+                               write_error(ctx);
+                               return -1;
+                       }
                        ctx->last_char = '\n';
                        i_stream_skip(ctx->input, i + 1);
                        break;
                }
 
-               if (o_stream_send(ctx->output, data, size) < 0)
-                       return write_error(ctx);
+               if (o_stream_send(ctx->output, data, size) < 0) {
+                       write_error(ctx);
+                       return -1;
+               }
                ctx->last_char = data[size-1];
                i_stream_skip(ctx->input, size);
        }
@@ -687,7 +712,7 @@ int mbox_save_finish(struct mail_save_context *_ctx)
                (void)o_stream_nfinish(ctx->output);
                if (ftruncate(ctx->mbox->mbox_fd, (off_t)ctx->mail_offset) < 0)
                        mbox_set_syscall_error(ctx->mbox, "ftruncate()");
-               o_stream_seek(ctx->output, ctx->mail_offset);
+               (void)o_stream_seek(ctx->output, ctx->mail_offset);
                ctx->mail_offset = (uoff_t)-1;
        }
 
index fea35f7d52956d52fc0408bc92f4d15ee8632745..eb4b43f8d84ba340bce73957f72731abab6e902f 100644 (file)
@@ -68,7 +68,7 @@ extern struct mailbox mbox_mailbox;
 static MODULE_CONTEXT_DEFINE_INIT(mbox_mailbox_list_module,
                                  &mailbox_list_module_register);
 
-int mbox_set_syscall_error(struct mbox_mailbox *mbox, const char *function)
+void mbox_set_syscall_error(struct mbox_mailbox *mbox, const char *function)
 {
        i_assert(function != NULL);
 
@@ -82,7 +82,6 @@ int mbox_set_syscall_error(struct mbox_mailbox *mbox, const char *function)
                        "%s failed with mbox file %s: %m%s", function,
                        mailbox_get_path(&mbox->box), toobig_error);
        }
-       return -1;
 }
 
 static const char *
index 8515cf95aab9ef3da4f773685142131808a763c9..e1f3ea54de6f90adfd587e93c384f63a27f7bb20 100644 (file)
@@ -76,7 +76,7 @@ extern struct mail_vfuncs mbox_mail_vfuncs;
 extern const char *mbox_hide_headers[], *mbox_save_drop_headers[];
 extern unsigned int mbox_hide_headers_count, mbox_save_drop_headers_count;
 
-int mbox_set_syscall_error(struct mbox_mailbox *mbox, const char *function);
+void mbox_set_syscall_error(struct mbox_mailbox *mbox, const char *function);
 
 struct mailbox_sync_context *
 mbox_storage_sync_init(struct mailbox *box, enum mailbox_sync_flags flags);
index f380255eb19bcac4db555ff336177f18807e3091..89b39b189f72a775244897af5b586c92cb022328 100644 (file)
@@ -1687,9 +1687,8 @@ int mbox_sync_get_guid(struct mbox_mailbox *mbox)
                mbox_sync_index_update_ext_header(mbox, trans);
                ret = mail_index_transaction_commit(&trans);
        }
-       mbox_unlock(mbox, lock_id);
+       (void)mbox_unlock(mbox, lock_id);
        return ret;
-
 }
 
 int mbox_sync_has_changed(struct mbox_mailbox *mbox, bool leave_dirty)
index 90567b6560a37b5329e4a528293f2fc2f1fe4799..c4482372705a062aeb17d4d4f0916a3692c6b2f6 100644 (file)
@@ -170,7 +170,7 @@ void pop3c_client_deinit(struct pop3c_client **_client)
 static void pop3c_client_ioloop_changed(struct pop3c_client *client)
 {
        if (client->to != NULL)
-               io_loop_move_timeout(&client->to);
+               client->to = io_loop_move_timeout(&client->to);
        if (client->io != NULL)
                client->io = io_loop_move_io(&client->io);
        if (client->output != NULL)
index 3ad6f0c98c89756132712ef3fc21c695fda82ce6..b12a0230b654e550b7d4bff6e384619f5f1dec83 100644 (file)
@@ -14,8 +14,10 @@ static int raw_mail_stat(struct mail *mail)
        struct raw_mailbox *mbox = (struct raw_mailbox *)mail->box;
        const struct stat *st;
 
-       if (mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE)
-               return mail_set_aborted(mail);
+       if (mail->lookup_abort == MAIL_LOOKUP_ABORT_NOT_IN_CACHE) {
+               mail_set_aborted(mail);
+               return -1;
+       }
 
        mail->transaction->stats.fstat_lookup_count++;
        st = i_stream_stat(mail->box->input, TRUE);
index 3c6fcc38d6f5110c24fd6c536dd0c2de5bc9abc4..b6c50500c09780a20d66fd4196d9c98cb0fc3e69 100644 (file)
@@ -207,7 +207,7 @@ mail_search_build_add(struct mail_search_args *args,
 
 void mail_search_build_add_all(struct mail_search_args *args)
 {
-       mail_search_build_add(args, SEARCH_ALL);
+       (void)mail_search_build_add(args, SEARCH_ALL);
 }
 
 void mail_search_build_add_seqset(struct mail_search_args *args,
index 0f779320a7a97ffcdfec18404417a8a53e98264b..35db087eac62c34825634f1818f6e22ee8d6e0e2 100644 (file)
@@ -526,7 +526,7 @@ void mail_storage_copy_list_error(struct mail_storage *storage,
 
 /* Returns TRUE if everything should already be in memory after this call. */
 bool mail_prefetch(struct mail *mail);
-int mail_set_aborted(struct mail *mail);
+void mail_set_aborted(struct mail *mail);
 void mail_set_expunged(struct mail *mail);
 void mail_set_seq_saving(struct mail *mail, uint32_t seq);
 void mailbox_set_deleted(struct mailbox *box);
index 7079b7d32423cba322ee9c81114da777b44bd929..739aa053d7cc8ea200a4a6552fe0da263c1b1da0 100644 (file)
@@ -183,11 +183,10 @@ int mail_get_header_stream(struct mail *mail,
        return p->v.get_header_stream(mail, headers, stream_r);
 }
 
-int mail_set_aborted(struct mail *mail)
+void mail_set_aborted(struct mail *mail)
 {
        mail_storage_set_error(mail->box->storage, MAIL_ERROR_NOTPOSSIBLE,
                               "Mail field not cached");
-       return -1;
 }
 
 int mail_get_stream(struct mail *mail, struct message_size *hdr_size,
@@ -195,8 +194,10 @@ int mail_get_stream(struct mail *mail, struct message_size *hdr_size,
 {
        struct mail_private *p = (struct mail_private *)mail;
 
-       if (mail->lookup_abort != MAIL_LOOKUP_ABORT_NEVER)
-               return mail_set_aborted(mail);
+       if (mail->lookup_abort != MAIL_LOOKUP_ABORT_NEVER) {
+               mail_set_aborted(mail);
+               return -1;
+       }
        return p->v.get_stream(mail, TRUE, hdr_size, body_size, stream_r);
 }
 
@@ -205,8 +206,10 @@ int mail_get_hdr_stream(struct mail *mail, struct message_size *hdr_size,
 {
        struct mail_private *p = (struct mail_private *)mail;
 
-       if (mail->lookup_abort != MAIL_LOOKUP_ABORT_NEVER)
-               return mail_set_aborted(mail);
+       if (mail->lookup_abort != MAIL_LOOKUP_ABORT_NEVER) {
+               mail_set_aborted(mail);
+               return -1;
+       }
        return p->v.get_stream(mail, FALSE, hdr_size, NULL, stream_r);
 }
 
index 27cce0ad8e066352286ea9ea4f0459476c9514be..553f397920b4a3fd4bb317e98d4706370e155c76 100644 (file)
@@ -8,7 +8,7 @@
 void mailbox_get_seq_range(struct mailbox *box, uint32_t uid1, uint32_t uid2,
                           uint32_t *seq1_r, uint32_t *seq2_r)
 {
-       mail_index_lookup_seq_range(box->view, uid1, uid2, seq1_r, seq2_r);
+       (void)mail_index_lookup_seq_range(box->view, uid1, uid2, seq1_r, seq2_r);
 }
 
 void mailbox_get_uid_range(struct mailbox *box,
index a4b3c1a74472040b615e5288c688c15fefbd57ef..f0784d713ff13294a93b8a06e0195957caf290a9 100644 (file)
@@ -61,7 +61,8 @@ static void mailbox_uidvalidity_write(struct mailbox_list *list,
                }
        }
 
-       i_snprintf(buf, sizeof(buf), "%08x", uid_validity);
+       if (i_snprintf(buf, sizeof(buf), "%08x", uid_validity) < 0)
+               i_unreached();
        if (pwrite_full(fd, buf, strlen(buf), 0) < 0)
                i_error("write(%s) failed: %m", path);
        if (close(fd) < 0)
@@ -217,7 +218,8 @@ uint32_t mailbox_uidvalidity_next(struct mailbox_list *list, const char *path)
 
        /* fast path succeeded. write the current value to the main
           uidvalidity file. */
-       i_snprintf(buf, sizeof(buf), "%08x", cur_value);
+       if (i_snprintf(buf, sizeof(buf), "%08x", cur_value) < 0)
+               i_unreached();
        if (pwrite_full(fd, buf, strlen(buf), 0) < 0)
                i_error("write(%s) failed: %m", path);
        if (close(fd) < 0)
index e70a0fce19cdba7c150951ab16f13ad03514d90a..30baf6a237b2f4ed35dd3ec1f945d3208918cf0d 100644 (file)
@@ -476,13 +476,13 @@ void t_buffer_alloc(size_t size)
        i_assert(current_block->left >= size);
 
        /* we've already reserved the space, now we just mark it used */
-       t_malloc_real(size, TRUE);
+       (void)t_malloc_real(size, TRUE);
 }
 
 void t_buffer_alloc_last_full(void)
 {
        if (last_buffer_block != NULL)
-               t_malloc_real(last_buffer_size, TRUE);
+               (void)t_malloc_real(last_buffer_size, TRUE);
 }
 
 void data_stack_set_clean_after_pop(bool enable ATTR_UNUSED)
@@ -515,12 +515,12 @@ void data_stack_init(void)
        last_buffer_block = NULL;
        last_buffer_size = 0;
 
-       t_push();
+       (void)t_push();
 }
 
 void data_stack_deinit(void)
 {
-       t_pop();
+       (void)t_pop();
 
        if (frame_pos != BLOCK_FRAME_COUNT-1)
                i_panic("Missing t_pop() call");
index 17b77e21c02db94d027b56c09193af4f6f9bd9ac..b790093e61d2433dec2b1afd15098727d40872d4 100644 (file)
@@ -438,16 +438,16 @@ static bool hash_table_resize(struct hash_table *table, bool grow)
        for (i = 0; i < old_size; i++) {
                node = &old_nodes[i];
                if (node->key != NULL) {
-                       hash_table_insert_node(table, node->key,
-                                              node->value, FALSE);
+                       (void)hash_table_insert_node(table, node->key,
+                                                    node->value, FALSE);
                }
 
                for (node = node->next; node != NULL; node = next) {
                        next = node->next;
 
                        if (node->key != NULL) {
-                               hash_table_insert_node(table, node->key,
-                                                      node->value, FALSE);
+                               (void)hash_table_insert_node(table, node->key,
+                                                            node->value, FALSE);
                        }
                        free_node(table, node);
                }
index 82e50dba91bb74c9ca42aedfc0e126232bcc8e5a..16266a63c29d3a39d8f08111bdf0bfba0911aebc 100644 (file)
@@ -15,8 +15,10 @@ void hostpid_init(void)
 {
        static char hostname[256], pid[MAX_INT_STRLEN];
 
-       if (gethostname(hostname, sizeof(hostname)-1) == -1)
-               i_strocpy(hostname, "unknown", sizeof(hostname));
+       if (gethostname(hostname, sizeof(hostname)-1) == -1) {
+               if (i_strocpy(hostname, "unknown", sizeof(hostname)) < 0)
+                       i_unreached();
+       }
        hostname[sizeof(hostname)-1] = '\0';
        my_hostname = hostname;
 
@@ -26,7 +28,8 @@ void hostpid_init(void)
        /* allow calling hostpid_init() multiple times to reset hostname */
        i_free_and_null(my_domain);
 
-       i_strocpy(pid, dec2str(getpid()), sizeof(pid));
+       if (i_strocpy(pid, dec2str(getpid()), sizeof(pid)) < 0)
+               i_unreached();
        my_pid = pid;
 }
 
index 29b61448d6cf5dbdb3b30e3b85be0413fb3fc1e9..53f43f582f5b3da345e7a7a8ae31e3e1bceaec82 100644 (file)
@@ -33,9 +33,10 @@ static void rawlog_write_timestamp(struct rawlog_iostream *rstream)
 {
        char buf[MAX_INT_STRLEN + 6 + 2];
 
-       i_snprintf(buf, sizeof(buf), "%lu.%06u ",
-                  (unsigned long)ioloop_timeval.tv_sec,
-                  (unsigned int)ioloop_timeval.tv_usec);
+       if (i_snprintf(buf, sizeof(buf), "%lu.%06u ",
+                      (unsigned long)ioloop_timeval.tv_sec,
+                      (unsigned int)ioloop_timeval.tv_usec) < 0)
+               i_unreached();
        rawlog_write(rstream, buf, strlen(buf));
 }
 
index 114d8f7c618f16710aa85451a966d5e564e8c928..2a5a294ffdaf157aac9c034d922e40d9b73703dc 100644 (file)
@@ -193,7 +193,7 @@ void md4_update(struct md4_context *ctx, const void *data, size_t size)
                memcpy(&ctx->buffer[used], data, free);
                data = (const unsigned char *) data + free;
                size -= free;
-               body(ctx, ctx->buffer, 64);
+               (void)body(ctx, ctx->buffer, 64);
        }
 
        if (size >= 64) {
@@ -217,7 +217,7 @@ void md4_final(struct md4_context *ctx, unsigned char result[MD4_RESULTLEN])
 
        if (free < 8) {
                memset(&ctx->buffer[used], 0, free);
-               body(ctx, ctx->buffer, 64);
+               (void)body(ctx, ctx->buffer, 64);
                used = 0;
                free = 64;
        }
@@ -234,7 +234,7 @@ void md4_final(struct md4_context *ctx, unsigned char result[MD4_RESULTLEN])
        ctx->buffer[62] = ctx->hi >> 16;
        ctx->buffer[63] = ctx->hi >> 24;
 
-       body(ctx, ctx->buffer, 64);
+       (void)body(ctx, ctx->buffer, 64);
 
        result[0] = ctx->a;
        result[1] = ctx->a >> 8;
index 9f1dfea7fcfdd04ab4ab9c98c89e104def332160..3bd394c71ad9cdc286e424acd6b29b778181f765 100644 (file)
@@ -208,7 +208,7 @@ void md5_update(struct md5_context *ctx, const void *data, size_t size)
                memcpy(&ctx->buffer[used], data, free);
                data = (const unsigned char *) data + free;
                size -= free;
-               body(ctx, ctx->buffer, 64);
+               (void)body(ctx, ctx->buffer, 64);
        }
 
        if (size >= 64) {
@@ -232,7 +232,7 @@ void md5_final(struct md5_context *ctx, unsigned char result[MD5_RESULTLEN])
 
        if (free < 8) {
                memset(&ctx->buffer[used], 0, free);
-               body(ctx, ctx->buffer, 64);
+               (void)body(ctx, ctx->buffer, 64);
                used = 0;
                free = 64;
        }
@@ -249,7 +249,7 @@ void md5_final(struct md5_context *ctx, unsigned char result[MD5_RESULTLEN])
        ctx->buffer[62] = ctx->hi >> 16;
        ctx->buffer[63] = ctx->hi >> 24;
 
-       body(ctx, ctx->buffer, 64);
+       (void)body(ctx, ctx->buffer, 64);
 
        result[0] = ctx->a;
        result[1] = ctx->a >> 8;
index c107156d719fa5fd6d011a8cd89c804638929ebc..09b42fba0f77f4e227b3a8e5b6166c04a26d9bb4 100644 (file)
@@ -123,7 +123,8 @@ int mountpoint_get(const char *path, pool_t pool, struct mountpoint *point_r)
                 point_r->dev = mnt->dev;
                 point_r->block_size = st.st_blksize;
         }
-       mountpoint_iter_deinit(&iter);
+       if (mountpoint_iter_deinit(&iter) < 0 && mnt == NULL)
+               return -1;
         return mnt != NULL ? 1 : 0;
 #endif
 }
index d197fa6b1b4ee95a1f9b6a908cb8f9aba5afe485..92f20765a32357b4b7195ac4f64f6d3f8e3024a1 100644 (file)
@@ -274,16 +274,15 @@ void nfs_flush_attr_cache_maybe_locked(const char *path)
        nfs_flush_chown_uid(path);
 }
 
-bool nfs_flush_attr_cache_fd_locked(const char *path ATTR_UNUSED,
+void nfs_flush_attr_cache_fd_locked(const char *path ATTR_UNUSED,
                                    int fd ATTR_UNUSED)
 {
 #ifdef __FreeBSD__
        /* FreeBSD doesn't flush attribute cache with fcntl(), so we have
           to do it ourself. */
-       return nfs_flush_fchown_uid(path, fd);
+       (void)nfs_flush_fchown_uid(path, fd);
 #else
        /* Linux and Solaris are fine. */
-       return TRUE;
 #endif
 }
 
@@ -359,10 +358,10 @@ static void nfs_flush_file_handle_cache_parent_dir(const char *path)
        p = strrchr(path, '/');
        T_BEGIN {
                if (p == NULL)
-                       nfs_flush_file_handle_cache_dir(".", TRUE);
+                       (void)nfs_flush_file_handle_cache_dir(".", TRUE);
                else
-                       nfs_flush_file_handle_cache_dir(t_strdup_until(path, p),
-                                                       TRUE);
+                       (void)nfs_flush_file_handle_cache_dir(t_strdup_until(path, p),
+                                                             TRUE);
        } T_END;
 }
 
index 7c9733bb2e46520290aa89272797d78aeffa9885..261f523512a649e559e8dbf272c73371ce9e8706 100644 (file)
@@ -27,7 +27,7 @@ void nfs_flush_attr_cache_maybe_locked(const char *path);
 /* Flush attribute cache for a fcntl locked file descriptor. If locking flushes
    the attribute cache with the running OS, this function does nothing.
    The given path is used only for logging. */
-bool nfs_flush_attr_cache_fd_locked(const char *path, int fd);
+void nfs_flush_attr_cache_fd_locked(const char *path, int fd);
 /* Flush file handle cache for given file. */
 void nfs_flush_file_handle_cache(const char *path);
 
index 5151448fcfd9764e535238594c3c20d5aa89a268..1f4c955b7956b62fa53a7df28c43711298b6454f 100644 (file)
@@ -243,8 +243,20 @@ bool seq_range_array_try_remove(ARRAY_TYPE(seq_range) *array, uint32_t seq)
        return FALSE;
 }
 
-unsigned int seq_range_array_remove_range(ARRAY_TYPE(seq_range) *array,
-                                         uint32_t seq1, uint32_t seq2)
+void seq_range_array_remove_range(ARRAY_TYPE(seq_range) *array,
+                                 uint32_t seq1, uint32_t seq2)
+{
+       (void)seq_range_array_remove_range_count(array, seq1, seq2);
+}
+
+void seq_range_array_remove_seq_range(ARRAY_TYPE(seq_range) *dest,
+                                     const ARRAY_TYPE(seq_range) *src)
+{
+       (void)seq_range_array_remove_seq_range_count(dest, src);
+}
+
+unsigned int seq_range_array_remove_range_count(ARRAY_TYPE(seq_range) *array,
+                                               uint32_t seq1, uint32_t seq2)
 {
        const struct seq_range *data;
        unsigned int idx, idx2, count, remove_count = 0;
@@ -282,22 +294,22 @@ unsigned int seq_range_array_remove_range(ARRAY_TYPE(seq_range) *array,
        return remove_count;
 }
 
-unsigned int seq_range_array_remove_seq_range(ARRAY_TYPE(seq_range) *dest,
-                                             const ARRAY_TYPE(seq_range) *src)
+unsigned int
+seq_range_array_remove_seq_range_count(ARRAY_TYPE(seq_range) *dest,
+                                      const ARRAY_TYPE(seq_range) *src)
 {
        unsigned int ret = 0;
        const struct seq_range *src_range;
 
        array_foreach(src, src_range) {
-               ret += seq_range_array_remove_range(dest, src_range->seq1,
-                                                   src_range->seq2);
+               ret += seq_range_array_remove_range_count(dest, src_range->seq1,
+                                                         src_range->seq2);
        }
        return ret;
 }
 
-unsigned int
-seq_range_array_intersect(ARRAY_TYPE(seq_range) *dest,
-                         const ARRAY_TYPE(seq_range) *src)
+void seq_range_array_intersect(ARRAY_TYPE(seq_range) *dest,
+                              const ARRAY_TYPE(seq_range) *src)
 {
        const struct seq_range *src_range;
        unsigned int i, count, ret = 0;
@@ -306,16 +318,15 @@ seq_range_array_intersect(ARRAY_TYPE(seq_range) *dest,
        src_range = array_get(src, &count);
        for (i = 0; i < count; i++) {
                if (last_seq + 1 < src_range[i].seq1) {
-                       ret += seq_range_array_remove_range(dest, last_seq + 1,
-                                                       src_range[i].seq1 - 1);
+                       ret += seq_range_array_remove_range_count(dest,
+                                       last_seq + 1, src_range[i].seq1 - 1);
                }
                last_seq = src_range[i].seq2;
        }
        if (last_seq != (uint32_t)-1) {
-               ret += seq_range_array_remove_range(dest, last_seq + 1,
-                                                   (uint32_t)-1);
+               ret += seq_range_array_remove_range_count(dest, last_seq + 1,
+                                                         (uint32_t)-1);
        }
-       return ret;
 }
 
 bool seq_range_exists(const ARRAY_TYPE(seq_range) *array, uint32_t seq)
index 793ae0c39fde7d65773ee89ff8201ef69f77609e..234e595816e270675699fd331f21d29284c8166c 100644 (file)
@@ -29,16 +29,20 @@ void seq_range_array_merge(ARRAY_TYPE(seq_range) *dest,
 void seq_range_array_remove(ARRAY_TYPE(seq_range) *array, uint32_t seq);
 /* Remove the given sequrence from range. Returns TRUE if it was found. */
 bool seq_range_array_try_remove(ARRAY_TYPE(seq_range) *array, uint32_t seq);
+/* Remove a sequence range. */
+void seq_range_array_remove_range(ARRAY_TYPE(seq_range) *array,
+                                 uint32_t seq1, uint32_t seq2);
+void seq_range_array_remove_seq_range(ARRAY_TYPE(seq_range) *dest,
+                                     const ARRAY_TYPE(seq_range) *src);
 /* Remove a sequence range. Returns number of sequences actually removed. */
-unsigned int seq_range_array_remove_range(ARRAY_TYPE(seq_range) *array,
-                                         uint32_t seq1, uint32_t seq2);
-unsigned int seq_range_array_remove_seq_range(ARRAY_TYPE(seq_range) *dest,
-                                             const ARRAY_TYPE(seq_range) *src);
-/* Remove sequences from dest that don't exist in src.
-   Returns the number of sequences actually removed. */
+unsigned int seq_range_array_remove_range_count(ARRAY_TYPE(seq_range) *array,
+                                               uint32_t seq1, uint32_t seq2);
 unsigned int
-seq_range_array_intersect(ARRAY_TYPE(seq_range) *dest,
-                         const ARRAY_TYPE(seq_range) *src);
+seq_range_array_remove_seq_range_count(ARRAY_TYPE(seq_range) *dest,
+                                      const ARRAY_TYPE(seq_range) *src);
+/* Remove sequences from dest that don't exist in src. */
+void seq_range_array_intersect(ARRAY_TYPE(seq_range) *dest,
+                              const ARRAY_TYPE(seq_range) *src);
 /* Returns TRUE if sequence exists in the range. */
 bool seq_range_exists(const ARRAY_TYPE(seq_range) *array,
                      uint32_t seq) ATTR_PURE;
index 496a5dcc7ca268f0aaf83b3db592fd808e432f09..456c1c0553c9c20cb9863dc63d85dad9a420630f 100644 (file)
@@ -95,7 +95,7 @@ static void test_base64_random(void)
                str_truncate(str, 0);
                str_truncate(dest, 0);
                base64_encode(buf, max, str);
-               base64_decode(str_data(str), str_len(str), NULL, dest);
+               test_assert(base64_decode(str_data(str), str_len(str), NULL, dest) >= 0);
                test_assert(str_len(dest) == max &&
                            memcmp(buf, str_data(dest), max) == 0);
        }
index bffc3816e4f2746972e95e6c6606c4f6347e5ce4..51d299608dd0d9c230802ddc7ae2cd84d80a75f6 100644 (file)
@@ -39,8 +39,8 @@ static void test_net_is_in_network(void)
        bool success;
 
        for (i = 0; i < N_ELEMENTS(input); i++) {
-               net_addr2ip(input[i].ip, &ip);
-               net_addr2ip(input[i].net, &net_ip);
+               test_assert(net_addr2ip(input[i].ip, &ip) == 0);
+               test_assert(net_addr2ip(input[i].net, &net_ip) == 0);
                success = net_is_in_network(&ip, &net_ip, input[i].bits) ==
                        input[i].ret;
                test_out(t_strdup_printf("net_is_in_network(%u)", i), success);
index 6737bb404bc7efb5d6f8417150abeeb994cf731a..7e84f985f7c6494a320b5684d12e43b48bdf95b6 100644 (file)
@@ -32,19 +32,19 @@ static void test_ostream_file_random(void)
        size = (rand() % MAX_BUFSIZE) + 1;
        random_fill_weak(randbuf, size);
        memcpy(buf, randbuf, size);
-       (void)o_stream_send(output, buf, size);
+       test_assert(o_stream_send(output, buf, size) > 0);
 
        for (i = 0; i < 10; i++) {
                offset = rand() % (MAX_BUFSIZE*3);
                size = (rand() % MAX_BUFSIZE) + 1;
                random_fill_weak(randbuf, size);
                memcpy(buf + offset, randbuf, size);
-               o_stream_pwrite(output, randbuf, size, offset);
+               test_assert(o_stream_pwrite(output, randbuf, size, offset) == 0);
                if (rand() % 10 == 0)
-                       (void)o_stream_flush(output);
+                       test_assert(o_stream_flush(output) > 0);
        }
 
-       (void)o_stream_flush(output);
+       test_assert(o_stream_flush(output) > 0);
        o_stream_uncork(output);
        ret = pread(fd, buf2, sizeof(buf2), 0);
        if (ret < 0)
index 786d5a3968beaf29bb7b9d8a4965283ae0de8768..1e4465bc735653fe2592dd4a00408928269ffaf9 100644 (file)
@@ -52,7 +52,7 @@ static void test_seq_range_array_random(void)
                        shadowbuf[seq1] = 0;
                        break;
                case 3:
-                       ret = seq_range_array_remove_range(&range, seq1, seq2);
+                       ret = seq_range_array_remove_range_count(&range, seq1, seq2);
                        for (ret2 = 0; seq1 <= seq2; seq1++) {
                                if (shadowbuf[seq1] != 0) {
                                        ret2++;
index 356b85bc21ea6b1de134bc80bddd1e517b43d33a..5711788b327e33f1cda90b0090c090d037751d2b 100644 (file)
@@ -43,6 +43,8 @@ struct log_connection {
 static struct log_connection *log_connections = NULL;
 static ARRAY_DEFINE(logs_by_fd, struct log_connection *);
 
+static void log_connection_destroy(struct log_connection *log);
+
 static struct log_client *log_client_get(struct log_connection *log, pid_t pid)
 {
        struct log_client *client;
@@ -304,8 +306,8 @@ static void log_connection_input(struct log_connection *log)
        }
 }
 
-struct log_connection *
-log_connection_create(struct log_error_buffer *errorbuf, int fd, int listen_fd)
+void log_connection_create(struct log_error_buffer *errorbuf,
+                          int fd, int listen_fd)
 {
        struct log_connection *log;
 
@@ -321,10 +323,9 @@ log_connection_create(struct log_error_buffer *errorbuf, int fd, int listen_fd)
 
        DLLIST_PREPEND(&log_connections, log);
        log_connection_input(log);
-       return log;
 }
 
-void log_connection_destroy(struct log_connection *log)
+static void log_connection_destroy(struct log_connection *log)
 {
        struct hash_iterate_context *iter;
        void *key, *value;
index 6a491bbcc384415e23e8cf2b0784e4f11dcd3cd3..cfec98bb007a050a81f969ca9adae487e0a29e05 100644 (file)
@@ -1,9 +1,10 @@
 #ifndef LOG_CONNECTION_H
 #define LOG_CONNECTION_H
 
-struct log_connection *
-log_connection_create(struct log_error_buffer *errorbuf, int fd, int listen_fd);
-void log_connection_destroy(struct log_connection *log);
+struct log_connection;
+
+void log_connection_create(struct log_error_buffer *errorbuf,
+                          int fd, int listen_fd);
 
 void log_connections_init(void);
 void log_connections_deinit(void);
index ed0a1f9021880c1cd3c06e3c00408debb0c04460..b4e43a73ba42574b3f66d4a8ff91e494939e039e 100644 (file)
@@ -574,7 +574,7 @@ sasl_callback(struct client *client, enum sasl_server_reply sasl_reply,
                return;
        }
 
-       client_unref(&client);
+       (void)client_unref(&client);
 }
 
 int client_auth_begin(struct client *client, const char *mech_name,
index 358ca0390f633d67d4b810dab328a0226c73a030..d42068b9b7c1a04b266dbc82576a0fb737ff6ea3 100644 (file)
@@ -160,5 +160,5 @@ void login_proxy_state_notify(struct login_proxy_state *state,
                              const char *user)
 {
        if (!login_proxy_state_try_notify(state, user))
-               login_proxy_state_try_notify(state, user);
+               (void)login_proxy_state_try_notify(state, user);
 }
index 8f3a78aacf76291b608766f4da05145ca3fbaa9c..d6503dc901404a48ffcc5d95c6bb8f65984427ee 100644 (file)
@@ -383,7 +383,7 @@ login_proxy_free_reason(struct login_proxy **_proxy, const char *reason)
        i_free(proxy);
 
        client->login_proxy = NULL;
-       client_unref(&client);
+       (void)client_unref(&client);
 }
 
 void login_proxy_free(struct login_proxy **_proxy)
index 945da456d29c07a93b09a73084560a44c8610657..a25acf1d9f5ebbb92819b1478d61fcaa7d637084 100644 (file)
@@ -311,15 +311,15 @@ static void plain_read(struct ssl_proxy *proxy)
                } else {
                        proxy->sslout_size += ret;
                        if (!corked) {
-                               net_set_cork(proxy->fd_ssl, TRUE);
-                               corked = TRUE;
+                               if (net_set_cork(proxy->fd_ssl, TRUE) == 0)
+                                       corked = TRUE;
                        }
                        ssl_write(proxy);
                }
        }
 
        if (corked)
-               net_set_cork(proxy->fd_ssl, FALSE);
+               (void)net_set_cork(proxy->fd_ssl, FALSE);
 
        ssl_proxy_unref(proxy);
 }
@@ -536,9 +536,9 @@ static void ssl_step(struct ssl_proxy *proxy)
                if (proxy->sslout_size == 0)
                        ssl_set_io(proxy, SSL_REMOVE_OUTPUT);
                else {
-                       net_set_cork(proxy->fd_ssl, TRUE);
+                       (void)net_set_cork(proxy->fd_ssl, TRUE);
                        ssl_write(proxy);
-                       net_set_cork(proxy->fd_ssl, FALSE);
+                       (void)net_set_cork(proxy->fd_ssl, FALSE);
                }
        }
 
@@ -806,7 +806,7 @@ static void ssl_proxy_destroy(struct ssl_proxy *proxy)
        (void)net_disconnect(proxy->fd_plain);
 
        if (proxy->client != NULL)
-               client_unref(&proxy->client);
+               (void)client_unref(&proxy->client);
        ssl_proxy_unref(proxy);
 }
 
index 8bdc851cf6c07e15b24d0ffc9e16e23677664e68..48c28303c9dcf7dc4290d908794e2f9ac1bac44c 100644 (file)
@@ -155,7 +155,7 @@ master_fatal_callback(const struct failure_context *ctx,
                if (fd != -1) {
                        VA_COPY(args2, args);
                        str = t_strdup_vprintf(format, args2);
-                       write_full(fd, str, strlen(str));
+                       (void)write_full(fd, str, strlen(str));
                        (void)close(fd);
                }
        }
@@ -332,7 +332,7 @@ static void instance_update_now(struct master_instance_list *list)
                                            services->set->instance_name);
        if (ret == 0) {
                /* duplicate instance names. allow without warning.. */
-               master_instance_list_update(list, services->set->base_dir);
+               (void)master_instance_list_update(list, services->set->base_dir);
        }
        
        if (to_instance != NULL)
index 871fc8edc76f2bcd2eda4e8542bd9d8a3080224d..6ba2f6e9e5e279139b9346eeced741ca6c84c272 100644 (file)
@@ -98,7 +98,7 @@ void service_anvil_monitor_start(struct service_list *service_list)
                service_list_anvil_discard_input(service_anvil_global);
        else {
                service = service_lookup_type(service_list, SERVICE_TYPE_ANVIL);
-               service_process_create(service);
+               (void)service_process_create(service);
        }
 }
 
index e055f3a8ff3f989097629d75d544d0b03d635a06..e1d317bd98ca2f599de0201d14afbd8cb7e59c22 100644 (file)
@@ -365,17 +365,15 @@ void service_process_ref(struct service_process *process)
        process->refcount++;
 }
 
-int service_process_unref(struct service_process *process)
+void service_process_unref(struct service_process *process)
 {
        i_assert(process->refcount > 0);
 
        if (--process->refcount > 0)
-               return TRUE;
+               return;
 
        i_assert(process->destroyed);
-
        i_free(process);
-       return FALSE;
 }
 
 static const char *
index 04c3a6f33d7e1e87ac0b237fd8d476dd19bf5e2b..6cd381bb4b133dd3af1230ebad198def38941d88 100644 (file)
@@ -38,7 +38,7 @@ struct service_process *service_process_create(struct service *service);
 void service_process_destroy(struct service_process *process);
 
 void service_process_ref(struct service_process *process);
-int service_process_unref(struct service_process *process);
+void service_process_unref(struct service_process *process);
 
 void service_process_log_status_error(struct service_process *process,
                                      int status);
index 0218a44115b0b8ef3a8b4624a52cd4ceb5c7e92a..b5060d5c55b4c0d0079258f63f101ea48208978f 100644 (file)
@@ -66,15 +66,16 @@ read_autobox_settings(struct mail_user *user, const char *env_name_base,
                      bool subscriptions)
 {
        const char *value;
-       char env_name[20];
+       char env_name[13+MAX_INT_STRLEN+1];
        unsigned int i = 1;
 
        value = mail_user_plugin_getenv(user, env_name_base);
        while (value != NULL) {
                add_autobox(user, value, subscriptions);
 
-               i_snprintf(env_name, sizeof(env_name), "%s%d",
-                          env_name_base, ++i);
+               if (i_snprintf(env_name, sizeof(env_name), "%s%u",
+                              env_name_base, ++i) < 0)
+                       i_unreached();
                value = mail_user_plugin_getenv(user, env_name);
        }
 }
index 8a5fed168031170453cba98aa3bf74a7dc97f686..726b6178cb9f44bc54a5cfc32d645cfe02f79cf6 100644 (file)
@@ -166,7 +166,7 @@ static const char *const *doveadm_expire_get_patterns(void)
 {
        ARRAY_TYPE(const_string) patterns;
        const char *str;
-       char set_name[20];
+       char set_name[6+MAX_INT_STRLEN+1];
        unsigned int i;
 
        t_array_init(&patterns, 16);
@@ -174,7 +174,8 @@ static const char *const *doveadm_expire_get_patterns(void)
        for (i = 2; str != NULL; i++) {
                array_append(&patterns, &str, 1);
 
-               i_snprintf(set_name, sizeof(set_name), "expire%u", i);
+               if (i_snprintf(set_name, sizeof(set_name), "expire%u", i) < 0)
+                       i_unreached();
                str = doveadm_plugin_getenv(set_name);
        }
        (void)array_append_space(&patterns);
@@ -350,9 +351,10 @@ static void doveadm_expire_mail_cmd_deinit(struct doveadm_mail_cmd_context *ctx)
 
        if (ectx->iter != NULL) {
                if (dict_iterate_deinit(&ectx->iter) < 0)
-                       i_error("Dictionary iteration failed");
+                       i_error("expire: Dictionary iteration failed");
        }
-       dict_transaction_commit(&ectx->trans);
+       if (dict_transaction_commit(&ectx->trans) < 0)
+               i_error("expire: Dictionary commit failed");
        dict_deinit(&ectx->dict);
        hash_table_destroy(&ectx->users);
 
index 1cece2c7107aeb4ec8393dff06dc442b5511c658..38f922419367938583f8709eb78c3c7c64fab4ce 100644 (file)
@@ -306,7 +306,7 @@ static const char *const *expire_get_patterns(struct mail_user *user)
 {
        ARRAY_TYPE(const_string) patterns;
        const char *str;
-       char set_name[20];
+       char set_name[6+MAX_INT_STRLEN+1];
        unsigned int i;
 
        t_array_init(&patterns, 16);
@@ -314,7 +314,8 @@ static const char *const *expire_get_patterns(struct mail_user *user)
        for (i = 2; str != NULL; i++) {
                array_append(&patterns, &str, 1);
 
-               i_snprintf(set_name, sizeof(set_name), "expire%u", i);
+               if (i_snprintf(set_name, sizeof(set_name), "expire%u", i) < 0)
+                       i_unreached();
                str = mail_user_set_plugin_getenv(user->set, set_name);
        }
        (void)array_append_space(&patterns);
index 6ee5d173b807f1adcfedd41d25682da89dc48e06..3a11a3732ab968bebc470d954c008e3c43381d95 100644 (file)
@@ -248,8 +248,10 @@ fts_backend_lucene_update_deinit(struct fts_backend_update_context *_ctx)
        i_assert(backend->updating);
 
        backend->updating = FALSE;
-       if (ctx->lucene_opened)
-               lucene_index_build_deinit(backend->index);
+       if (ctx->lucene_opened) {
+               if (lucene_index_build_deinit(backend->index) < 0)
+                       ret = -1;
+       }
 
        if (ctx->expunge_ctx != NULL) {
                if (fts_expunge_log_append_commit(&ctx->expunge_ctx) < 0)
@@ -547,7 +549,7 @@ static void fts_backend_lucene_lookup_done(struct fts_backend *_backend)
 {
        /* the next refresh is going to close the index anyway, so we might as
           well do it now */
-       fts_backend_lucene_refresh(_backend);
+       (void)fts_backend_lucene_refresh(_backend);
 }
 
 struct fts_backend fts_backend_lucene = {
index c64eebec33e6879bdae20e420800fc9bf2c42c00..4998f34b0f98f1b172b3fff302a23b425a58c8c6 100644 (file)
@@ -1658,7 +1658,7 @@ static int squat_trie_write(struct squat_trie_build_context *ctx)
                o_stream_cork(output);
 
                if (trie->hdr.used_file_size != 0)
-                       o_stream_seek(output, trie->hdr.used_file_size);
+                       (void)o_stream_seek(output, trie->hdr.used_file_size);
                else
                        o_stream_nsend(output, &trie->hdr, sizeof(trie->hdr));
        }
@@ -1677,7 +1677,7 @@ static int squat_trie_write(struct squat_trie_build_context *ctx)
                ret = squat_trie_write_lock(ctx);
        if (ret == 0) {
                trie->hdr.used_file_size = output->offset;
-               o_stream_seek(output, 0);
+               (void)o_stream_seek(output, 0);
                o_stream_nsend(output, &trie->hdr, sizeof(trie->hdr));
        }
        if (o_stream_nfinish(output) < 0) {
index 1a63ae84e75dd7503e457093232618773e12b75c..105df9315c63d0f9cc5bc27ddfd5b3ee315b498e 100644 (file)
@@ -372,7 +372,7 @@ static int squat_uidlist_map_header(struct squat_uidlist *uidlist)
        }
        if (uidlist->hdr.indexid != uidlist->trie->hdr.indexid) {
                /* see if trie was recreated */
-               squat_trie_refresh(uidlist->trie);
+               (void)squat_trie_refresh(uidlist->trie);
        }
        if (uidlist->hdr.indexid != uidlist->trie->hdr.indexid) {
                squat_uidlist_set_corrupted(uidlist, "wrong indexid");
@@ -855,10 +855,10 @@ int squat_uidlist_build_finish(struct squat_uidlist_build_context *ctx)
                return -1;
 
        if (!ctx->output->closed) {
-               o_stream_seek(ctx->output, 0);
+               (void)o_stream_seek(ctx->output, 0);
                o_stream_nsend(ctx->output,
                               &ctx->build_hdr, sizeof(ctx->build_hdr));
-               o_stream_seek(ctx->output, ctx->build_hdr.used_file_size);
+               (void)o_stream_seek(ctx->output, ctx->build_hdr.used_file_size);
        }
 
        if (o_stream_nfinish(ctx->output) < 0) {
@@ -1056,11 +1056,11 @@ int squat_uidlist_rebuild_finish(struct squat_uidlist_rebuild_context *ctx,
                                                    &ctx->new_block_offsets,
                                                    &ctx->new_block_end_indexes,
                                                    FALSE);
-               o_stream_seek(ctx->output, 0);
+               (void)o_stream_seek(ctx->output, 0);
                o_stream_nsend(ctx->output, &ctx->build_ctx->build_hdr,
                               sizeof(ctx->build_ctx->build_hdr));
-               o_stream_seek(ctx->output,
-                             ctx->build_ctx->build_hdr.used_file_size);
+               (void)o_stream_seek(ctx->output,
+                                   ctx->build_ctx->build_hdr.used_file_size);
 
                if (ctx->uidlist->corrupted)
                        ret = -1;
@@ -1176,8 +1176,8 @@ uint32_t squat_uidlist_build_add_uid(struct squat_uidlist_build_context *ctx,
                }
                for (; mask <= 128; mask <<= 1, idx++) {
                        if ((old_list_idx & mask) != 0) {
-                               squat_uidlist_build_add_uid(ctx,
-                                                           uid_list_idx, idx);
+                               (void)squat_uidlist_build_add_uid(ctx,
+                                                       uid_list_idx, idx);
                        }
                }
        }
@@ -1548,7 +1548,8 @@ int squat_uidlist_filter(struct squat_uidlist *uidlist, uint32_t uid_list_idx,
 
        i_array_init(&relative_uids, 128);
        i_array_init(&dest_uids, 128);
-       squat_uidlist_get(uidlist, uid_list_idx, &relative_uids);
+       if (squat_uidlist_get(uidlist, uid_list_idx, &relative_uids) < 0)
+               ret = -1;
 
        parent_idx = 0;
        rel_range = array_get(&relative_uids, &rel_count);
index 2a3e2b92e6c72fd3024d11bd8f66cd0d727293ad..2b390e0c3a5b4255ebdcf57ec6cc5f6a5ea92c46 100644 (file)
@@ -356,8 +356,9 @@ static int fts_mail_get_special(struct mail *_mail, enum mail_fetch_field field,
        }
        if (scores != NULL) {
                i_assert(scores->uid == _mail->uid);
-               i_snprintf(fmail->score, sizeof(fmail->score),
-                          "%f", scores->score);
+               (void)i_snprintf(fmail->score, sizeof(fmail->score),
+                                "%f", scores->score);
+                       
                *value_r = fmail->score;
                return 0;
        }
index 2060545c77e51c9984a61e942d8e513e46da259f..ed16b519c7423413cdf8b14010d58c0c1ca7e67c 100644 (file)
@@ -687,7 +687,7 @@ void imap_acl_plugin_deinit(void)
        command_unregister("DELETEACL");
        command_unregister("LISTRIGHTS");
 
-       imap_client_created_hook_set(next_hook_client_created);
+       (void)imap_client_created_hook_set(next_hook_client_created);
 }
 
 const char *imap_acl_plugin_dependencies[] = { "acl", NULL };
index a3e4f672e39354861b429225d45f472c32070ac3..e3b9e79670972fa533055dd53eb5d5fb2fbfe5d2 100644 (file)
@@ -230,7 +230,7 @@ void imap_quota_plugin_deinit(void)
        command_unregister("GETQUOTA");
        command_unregister("SETQUOTA");
 
-       imap_client_created_hook_set(next_hook_client_created);
+       (void)imap_client_created_hook_set(next_hook_client_created);
 }
 
 const char *imap_quota_plugin_dependencies[] = { "quota", NULL };
index dfa1f9c53f5e67617d31b82a470b390c515022e7..c28821bbc8d6f88cf91f455a19307caa8abb999f 100644 (file)
@@ -153,7 +153,7 @@ void imap_zlib_plugin_deinit(void)
 {
        command_unregister("COMPRESS");
 
-       imap_client_created_hook_set(next_hook_client_created);
+       (void)imap_client_created_hook_set(next_hook_client_created);
 }
 
 const char *imap_zlib_plugin_dependencies[] = { "zlib", NULL };
index df7d7fe9d3f483df482a5ba397375b705a32371c..a421394ee6827b900d73963f23f520359f68b4b9 100644 (file)
@@ -696,7 +696,7 @@ maildirquota_refresh(struct maildir_quota_root *root, bool *recalculated_r)
 static int maildirsize_update(struct maildir_quota_root *root,
                              int count_diff, int64_t bytes_diff)
 {
-       char str[MAX_INT_STRLEN*2 + 2];
+       char str[MAX_INT_STRLEN*2 + 2 + 1];
        int ret = 0;
 
        if (count_diff == 0 && bytes_diff == 0)
@@ -707,8 +707,9 @@ static int maildirsize_update(struct maildir_quota_root *root,
           a while, and sooner if corruption causes calculations to go
           over quota. This is also how Maildir++ spec specifies it should be
           done.. */
-       i_snprintf(str, sizeof(str), "%lld %d\n",
-                  (long long)bytes_diff, count_diff);
+       if (i_snprintf(str, sizeof(str), "%lld %d\n",
+                      (long long)bytes_diff, count_diff) < 0)
+               i_unreached();
        if (write_full(root->fd, str, strlen(str)) < 0) {
                ret = -1;
                if (errno == ESTALE) {
index 221e606f49a3f623fd2aaceaf465f1574a0e5891..4ca942ade11047ea60cd5ff041d46c5383e75857 100644 (file)
@@ -183,7 +183,7 @@ int quota_user_read_settings(struct mail_user *user,
                             const char **error_r)
 {
        struct quota_settings *quota_set;
-       char root_name[6 + MAX_INT_STRLEN];
+       char root_name[5 + MAX_INT_STRLEN + 1];
        const char *env, *error;
        unsigned int i;
        pool_t pool;
@@ -199,7 +199,8 @@ int quota_user_read_settings(struct mail_user *user,
                quota_set->quota_exceeded_msg = DEFAULT_QUOTA_EXCEEDED_MSG;
 
        p_array_init(&quota_set->root_sets, pool, 4);
-       i_strocpy(root_name, "quota", sizeof(root_name));
+       if (i_strocpy(root_name, "quota", sizeof(root_name)) < 0)
+               i_unreached();
        for (i = 2;; i++) {
                env = mail_user_plugin_getenv(user, root_name);
                if (env == NULL || *env == '\0')
@@ -212,7 +213,8 @@ int quota_user_read_settings(struct mail_user *user,
                        pool_unref(&pool);
                        return -1;
                }
-               i_snprintf(root_name, sizeof(root_name), "quota%d", i);
+               if (i_snprintf(root_name, sizeof(root_name), "quota%d", i) < 0)
+                       i_unreached();
        }
        if (array_count(&quota_set->root_sets) == 0) {
                pool_unref(&pool);
index 38f2ec88513b2c9490328643bb6f6b5956881a53..5de81a1fdaf8518c7f9642df7fd7673055e0005c 100644 (file)
@@ -40,7 +40,7 @@ stats_connection_create(const char *path)
        conn = i_new(struct stats_connection, 1);
        conn->refcount = 1;
        conn->path = i_strdup(path);
-       stats_connection_open(conn);
+       (void)stats_connection_open(conn);
        return conn;
 }
 
index 1b1dbc4261efa98106ba151530bfa025fbf899e1..06d92316376dccc043924389a603a821ee3a64fb 100644 (file)
@@ -124,7 +124,7 @@ static void virtual_mail_set_seq(struct mail *mail, uint32_t seq, bool saving)
        bbox = virtual_backend_box_lookup(mbox, vrec->mailbox_id);
        vmail->backend_mail = backend_mail_find(vmail, bbox->box);
        if (vmail->backend_mail == NULL)
-               virtual_mail_set_backend_mail(mail, bbox);
+               (void)virtual_mail_set_backend_mail(mail, bbox);
        vmail->lost = !mail_set_uid(vmail->backend_mail, vrec->real_uid);
        memset(&vmail->imail.data, 0, sizeof(vmail->imail.data));
        p_clear(vmail->imail.data_pool);
index 894a7018bbc8e40f4267055dcc06d91f4bb66772..40c401fa371be8089784b26472d49d3879cd09a6 100644 (file)
@@ -835,7 +835,7 @@ static void virtual_sync_mailbox_box_update(struct virtual_sync_context *ctx,
        if (count1 > 0 && count2 > 0) {
                t_array_init(&temp_uids, count1);
                array_append_array(&temp_uids, &bbox->sync_pending_removes);
-               if (seq_range_array_remove_seq_range(
+               if (seq_range_array_remove_seq_range_count(
                                &bbox->sync_pending_removes, &added_uids) > 0) {
                        seq_range_array_remove_seq_range(&added_uids,
                                                         &temp_uids);
index 6743b1853f9fdfe3923e2a7f97162a4aae01738c..851a2f6319347a34fb6a10ecd92202d188b5d935 100644 (file)
@@ -75,7 +75,7 @@ static bool test_dump_imapzlib(const char *path)
        ret = read(fd, buf, sizeof(buf)-1);
        if (ret > 0) {
                buf[ret] = '\0';
-               str_lcase(buf);
+               (void)str_lcase(buf);
                match = strstr(buf, " ok begin compression.") != NULL ||
                        strstr(buf, " compress deflate") != NULL;
        }
index 15d1356b70b0d1bd834f0f4b93054b407c73fe99..a014a1e89f2bf4e69c0aff16357e29954404514d 100644 (file)
@@ -115,8 +115,10 @@ o_stream_zlib_send_chunk(struct zlib_ostream *zstream,
        flush = zstream->ostream.corked || zstream->gz ?
                Z_NO_FLUSH : Z_SYNC_FLUSH;
 
-       if (!zstream->header_sent)
-               o_stream_zlib_send_gz_header(zstream);
+       if (!zstream->header_sent) {
+               if (o_stream_zlib_send_gz_header(zstream) < 0)
+                       return -1;
+       }
 
        zs->next_in = (void *)data;
        zs->avail_in = size;
@@ -169,8 +171,10 @@ static int o_stream_zlib_send_flush(struct zlib_ostream *zstream)
 
        if (zstream->flushed)
                return 0;
-       if (!zstream->header_sent)
-               o_stream_zlib_send_gz_header(zstream);
+       if (!zstream->header_sent) {
+               if (o_stream_zlib_send_gz_header(zstream) < 0)
+                       return -1;
+       }
 
        if ((ret = o_stream_zlib_send_outbuf(zstream)) <= 0)
                return ret;
index 714d78cca7f78e298e4eb2d89d57cb53f6b18b5f..85cff1024afed2cf17123654984aa0bf429bf791 100644 (file)
@@ -138,9 +138,9 @@ static void main_stdio_run(const char *username)
        if (input.username == NULL)
                i_fatal("USER environment missing");
        if ((value = getenv("IP")) != NULL)
-               net_addr2ip(value, &input.remote_ip);
+               (void)net_addr2ip(value, &input.remote_ip);
        if ((value = getenv("LOCAL_IP")) != NULL)
-               net_addr2ip(value, &input.local_ip);
+               (void)net_addr2ip(value, &input.local_ip);
 
        input_base64 = getenv("CLIENT_INPUT");
        input_buf = input_base64 == NULL ? NULL :
index 90c6827554a593df733e377486bd79ef31c85fdb..b41407743330981e5beea06bb783ba34605a0ebe 100644 (file)
@@ -485,7 +485,7 @@ void client_destroy(struct client *client, const char *reason)
 static void client_default_destroy(struct client *client, const char *reason)
 {
        if (client->seen_change_count > 0)
-               client_update_mails(client);
+               (void)client_update_mails(client);
 
        if (!client->disconnected) {
                if (reason == NULL)
@@ -568,13 +568,13 @@ void client_disconnect(struct client *client, const char *reason)
        client->to_idle = timeout_add(0, client_destroy_timeout, client);
 }
 
-int client_send_line(struct client *client, const char *fmt, ...)
+void client_send_line(struct client *client, const char *fmt, ...)
 {
        va_list va;
        ssize_t ret;
 
        if (client->output->closed)
-               return -1;
+               return;
 
        va_start(va, fmt);
 
@@ -592,10 +592,8 @@ int client_send_line(struct client *client, const char *fmt, ...)
        if (ret >= 0) {
                if (o_stream_get_buffer_used_size(client->output) <
                    OUTBUF_THROTTLE_SIZE) {
-                       ret = 1;
                        client->last_output = ioloop_time;
                } else {
-                       ret = 0;
                        if (client->io != NULL) {
                                /* no more input until client has read
                                   our output */
@@ -609,9 +607,7 @@ int client_send_line(struct client *client, const char *fmt, ...)
                        }
                }
        }
-
        va_end(va);
-       return (int)ret;
 }
 
 void client_send_storage_error(struct client *client)
index 77d7200f55f9dbdee2414631df32d80ee86747ea..890a9e0743ed1c0da08fd7564788fb2e4daf3bc5 100644 (file)
@@ -9,6 +9,9 @@ typedef void command_func_t(struct client *client);
 #define MSGS_BITMASK_SIZE(client) \
        (((client)->messages_count + (CHAR_BIT-1)) / CHAR_BIT)
 
+#define POP3_CLIENT_OUTPUT_FULL(client) \
+       ((client)->io == NULL)
+
 struct pop3_client_vfuncs {
        void (*destroy)(struct client *client, const char *reason);
 
@@ -110,7 +113,7 @@ void client_destroy(struct client *client, const char *reason) ATTR_NULL(2);
 void client_disconnect(struct client *client, const char *reason);
 
 /* Send a line of data to client */
-int client_send_line(struct client *client, const char *fmt, ...)
+void client_send_line(struct client *client, const char *fmt, ...)
        ATTR_FORMAT(2, 3);
 void client_send_storage_error(struct client *client);
 
index a87b728a145c685adf997d62c6f6a9f21822ad21..319e2be7585667ab4eb0f991d0cb86a46e9a7624 100644 (file)
@@ -130,10 +130,9 @@ struct cmd_list_context {
 static void cmd_list_callback(struct client *client)
 {
        struct cmd_list_context *ctx = client->cmd_context;
-       int ret = 1;
 
        for (; ctx->msgnum != client->messages_count; ctx->msgnum++) {
-               if (ret == 0) {
+               if (POP3_CLIENT_OUTPUT_FULL(client)) {
                        /* buffer full */
                        return;
                }
@@ -144,9 +143,9 @@ static void cmd_list_callback(struct client *client)
                                continue;
                }
 
-               ret = client_send_line(client, "%u %"PRIuUOFF_T, ctx->msgnum+1,
-                                      client->message_sizes[ctx->msgnum]);
-               if (ret < 0)
+               client_send_line(client, "%u %"PRIuUOFF_T, ctx->msgnum+1,
+                                client->message_sizes[ctx->msgnum]);
+               if (client->output->closed)
                        break;
        }
 
@@ -512,7 +511,7 @@ static int cmd_rset(struct client *client, const char *args ATTR_UNUSED)
                        mail_update_flags(mail, MODIFY_REMOVE, MAIL_SEEN);
                (void)mailbox_search_deinit(&search_ctx);
 
-               mailbox_transaction_commit(&client->trans);
+               (void)mailbox_transaction_commit(&client->trans);
                client->trans = mailbox_transaction_begin(client->mailbox, 0);
        }
 
@@ -587,8 +586,9 @@ pop3_get_uid(struct client *client, struct mail *mail, string_t *str,
        tab[0].value = t_strdup_printf("%u", client->uid_validity);
 
        if ((client->uidl_keymask & UIDL_UID) != 0) {
-               i_snprintf(uid_str, sizeof(uid_str), "%u",
-                          mail->uid);
+               if (i_snprintf(uid_str, sizeof(uid_str), "%u",
+                              mail->uid) < 0)
+                       i_unreached();
                tab[1].value = uid_str;
        }
        if ((client->uidl_keymask & UIDL_MD5) != 0) {
@@ -625,7 +625,6 @@ static bool
 list_uidls_saved_iter(struct client *client, struct cmd_uidl_context *ctx)
 {
        bool found = FALSE;
-       int ret;
 
        while (ctx->msgnum < client->messages_count) {
                uint32_t msgnum = ctx->msgnum++;
@@ -637,12 +636,12 @@ list_uidls_saved_iter(struct client *client, struct cmd_uidl_context *ctx)
                }
                found = TRUE;
 
-               ret = client_send_line(client,
-                                      ctx->list_all ? "%u %s" : "+OK %u %s",
-                                      msgnum+1, client->message_uidls[msgnum]);
-               if (ret < 0 || !ctx->list_all)
+               client_send_line(client,
+                                ctx->list_all ? "%u %s" : "+OK %u %s",
+                                msgnum+1, client->message_uidls[msgnum]);
+               if (client->output->closed || !ctx->list_all)
                        break;
-               if (ret == 0) {
+               if (POP3_CLIENT_OUTPUT_FULL(client)) {
                        /* output is being buffered, continue when there's
                           more space */
                        return FALSE;
@@ -660,7 +659,6 @@ list_uidls_saved_iter(struct client *client, struct cmd_uidl_context *ctx)
 static bool list_uids_iter(struct client *client, struct cmd_uidl_context *ctx)
 {
        string_t *str;
-       int ret;
        bool permanent_uidl, found = FALSE;
 
        if (client->message_uidls != NULL)
@@ -684,12 +682,11 @@ static bool list_uids_iter(struct client *client, struct cmd_uidl_context *ctx)
                if (client->set->pop3_save_uidl && !permanent_uidl)
                        mail_update_pop3_uidl(ctx->mail, str_c(str));
 
-               ret = client_send_line(client,
-                                      ctx->list_all ? "%u %s" : "+OK %u %s",
-                                      msgnum+1, str_c(str));
-               if (ret < 0)
+               client_send_line(client, ctx->list_all ? "%u %s" : "+OK %u %s",
+                                msgnum+1, str_c(str));
+               if (client->output->closed)
                        break;
-               if (ret == 0 && ctx->list_all) {
+               if (POP3_CLIENT_OUTPUT_FULL(client) && ctx->list_all) {
                        /* output is being buffered, continue when there's
                           more space */
                        return FALSE;
index a26a231a4236508b3e3864cadced71cb5f809701..6fdf7311af7a266b8868773cbcca2f858fd4f849 100644 (file)
@@ -82,7 +82,7 @@ static void notify_input(struct notify_connection *conn)
        case -2:
                /* buffer full */
                i_error("Client sent too long line");
-               notify_input_error(conn);
+               (void)notify_input_error(conn);
                return;
        case -1:
                /* disconnected */
index e6af9a7686eaa414aaaab556cdb88a675b90d6ae..88a4abcab534a628733349aec78b5a73a43a25c6 100644 (file)
@@ -73,7 +73,7 @@ notify_connection_input_line(struct notify_connection *conn, const char *line)
                return -1;
        }
        if (priority != REPLICATION_PRIORITY_SYNC)
-               replicator_queue_add(conn->queue, args[1], priority);
+               (void)replicator_queue_add(conn->queue, args[1], priority);
        else if (args[3] == NULL || str_to_uint(args[3], &id) < 0) {
                i_error("notify client sent invalid sync id: %s", line);
                return -1;
index 02d555ad7ee4c8fd0a71582680e608963cb59f5b..adfc01051ad665e60db9c943d61b992b38caaa0d 100644 (file)
@@ -26,7 +26,7 @@ static void client_connected(struct master_service_connection *conn)
                }
                mail_server_conn = mail_server_connection_create(conn->fd);
        } else {
-               client_create(conn->fd);
+               (void)client_create(conn->fd);
        }
        master_service_client_connection_accept(conn);
 }
index 732fa8c68ea48986aeda9a2cc95760884b294f85..69e9a28e8f738b02fc056ee8478fc2546bd78588 100644 (file)
@@ -348,7 +348,7 @@ static void rawlog_open(enum rawlog_flags flags)
                                          dec2str(getppid())));
 
        ioloop = io_loop_create();
-       rawlog_proxy_create(0, 1, sfd[0], path, flags);
+       (void)rawlog_proxy_create(0, 1, sfd[0], path, flags);
        io_loop_run(ioloop);
        io_loop_destroy(&ioloop);