]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Add asserts to make static analyzer happier.
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 10 Feb 2017 11:17:00 +0000 (13:17 +0200)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Fri, 10 Feb 2017 11:34:54 +0000 (13:34 +0200)
src/auth/db-ldap.c
src/doveadm/doveadm-mail-index.c
src/lib-auth/auth-master.c
src/lib-fs/fs-posix.c
src/lib-storage/index/mbox/mbox-save.c
src/lib-storage/mail-autoexpunge.c
src/lib/file-dotlock.c
src/lib/iostream-temp.c

index c48d63e2e0908506c43b80800ebf169434f252e1..9a247dd1ee48e00a7b646688960b32e51b77d243 100644 (file)
@@ -1446,6 +1446,7 @@ void db_ldap_set_attrs(struct ldap_connection *conn, const char *attrlist,
                        } else if (name[0] == '!' && name == ldap_attr) {
                                /* !ldapAttr */
                                name = "";
+                               i_assert(ldap_attr[0] == '!');
                                ldap_attr++;
                                field->skip = TRUE;
                        }
index 840a52c121181d08d0444d3c55f82be0c4bdfc2c..0e4ebb3375a6e85b10baacb5eb586dd817353415 100644 (file)
@@ -155,6 +155,7 @@ static void cmd_index_queue(struct index_cmd_context *ctx,
 {
        if (ctx->queue_fd == -1)
                index_queue_connect(ctx);
+       i_assert(ctx->queue_fd != -1);
 
        T_BEGIN {
                string_t *str = t_str_new(256);
index cb367bbc2b9a1aac840e44e5b0db70ed0b4db3c7..6f8bde4e18d993c9a71e0ef9a54cd7e834bf30ae 100644 (file)
@@ -399,6 +399,7 @@ static int auth_master_run_cmd_pre(struct auth_master_connection *conn,
        if (conn->fd == -1) {
                if (auth_master_connect(conn) < 0)
                        return -1;
+               i_assert(conn->fd != -1);
        }
        auth_master_set_io(conn);
 
index 119f09b277f8ec561e1d418e8fd47d50a0f96954..8741e22716c33f1ddf5abd006cef4c0a8e38ba56 100644 (file)
@@ -554,6 +554,7 @@ static void fs_posix_write_stream(struct fs_file *_file)
                _file->output = o_stream_create_error_str(errno, "%s",
                        fs_file_last_error(_file));
        } else {
+               i_assert(file->fd != -1);
                _file->output = o_stream_create_fd_file(file->fd,
                                                        (uoff_t)-1, FALSE);
        }
index 29e4cc9a4fa8553dda83a426f23c238e019e2eb4..1db41ecbce3b664982129be3f51df2bab5ba0dc4 100644 (file)
@@ -323,6 +323,7 @@ mbox_save_init_file(struct mbox_save_context *ctx,
                if (mbox_seek_to_end(ctx, &ctx->append_offset) < 0)
                        return -1;
 
+               i_assert(mbox->mbox_fd != -1);
                ctx->output = o_stream_create_fd_file(mbox->mbox_fd,
                                                      ctx->append_offset,
                                                      FALSE);
index b8f5aa8adadb6fe8a14f846b19458fd414d5b9f7..26dc2c3c4d2fb1e8c2d805e958dd67d8883e73c6 100644 (file)
@@ -226,6 +226,8 @@ void mail_user_autoexpunge(struct mail_user *user)
                }
        }
        if (lock.fd != -1) {
+               i_assert(lock.lock != NULL);
+
                i_unlink(lock.path);
                i_close_fd(&lock.fd);
                file_lock_free(&lock.lock);
index 75bb9a09a40853e909eb45abb5caea343e8a6a98..cf159a6c2cad75f5f5c270353428ca9f6f5a110b 100644 (file)
@@ -565,6 +565,7 @@ dotlock_create(struct dotlock *dotlock, enum dotlock_create_flags flags,
        file_lock_wait_end(dotlock->path);
 
        if (ret > 0) {
+               i_assert(lock_info.fd != -1);
                if (fstat(lock_info.fd, &st) < 0) {
                        i_error("fstat(%s) failed: %m", lock_path);
                        ret = -1;
index 3141fb4b58a66b319d3c8b7cb8b3516ac37551ea..274764fb7257dd2e8d73250033ed6a5a88a0c34f 100644 (file)
@@ -160,6 +160,7 @@ o_stream_temp_sendv(struct ostream_private *stream,
        for (i = 0; i < iov_count; i++) {
                if (tstream->buf->used + iov[i].iov_len > tstream->max_mem_size) {
                        if (o_stream_temp_move_to_fd(tstream) == 0) {
+                               i_assert(tstream->fd != -1);
                                return o_stream_temp_fd_sendv(tstream, iov+i,
                                                              iov_count-i);
                        }