]> 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, 17 Feb 2017 09:32:31 +0000 (11:32 +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 080e244494ed26cd50a6ca19da347a68026f745a..0194f4667861526ae9f24bc3618013d799c5c333 100644 (file)
@@ -1428,6 +1428,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 529870fdf98b999556b269e1fcd5b6a4b0e9a652..47cc7b1f08be1d2d74a0026381b6762ceae00530 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 930ed8c560cc197e2df53ac998a15ca977fc4b0b..ae22cecebc0d24c053d5748c1eaa8198f74654f3 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 cda6aadcbd7f951d95508d94b3fc0a2533d157fa..f8847602047d6ae7cc7c1ecd0315272b380e1786 100644 (file)
@@ -558,6 +558,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 a19126ce2226ff9094ad872f9f76bfd04eba85f8..6bcdf81c4b75c6378b2ff2541a048b8171f89627 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 819d056a77e02997b30d839a674bc12e09f6068b..f76737689416871c5f3fb5d99091ca8bc07af2a5 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 6920c41fae9c83b78c2577f57792f0613229fa03..6f2fa54b08e83e747143fa5f3299c8f2b86cf319 100644 (file)
@@ -151,6 +151,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);
                        }