]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Require comparisons to be strict boolean expressions
authorTimo Sirainen <timo.sirainen@dovecot.fi>
Sun, 5 Jun 2016 02:06:27 +0000 (05:06 +0300)
committerTimo Sirainen <timo.sirainen@dovecot.fi>
Mon, 6 Jun 2016 12:37:05 +0000 (15:37 +0300)
 * No implicit integer -> boolean or pointer -> boolean conversions
 * !expr can be used only if expr is boolean type

These were checked with a patched clang. It found various actual bugs,
which were fixed by the previous commits.

77 files changed:
src/auth/db-ldap.c
src/auth/mech-digest-md5.c
src/auth/mech-ntlm.c
src/auth/mech-scram-sha1.c
src/auth/password-scheme-md5crypt.c
src/auth/password-scheme-rpa.c
src/director/director-connection.c
src/doveadm/doveadm-auth.c
src/doveadm/doveadm-director.c
src/doveadm/doveadm-util.c
src/doveadm/dsync/dsync-mailbox-export.c
src/imap/imap-sync.c
src/lib-dcrypt/dcrypt-openssl.c
src/lib-dict-extra/dict-ldap-settings.c
src/lib-http/http-server-request.c
src/lib-http/test-http-client-errors.c
src/lib-http/test-http-payload.c
src/lib-imap/imap-bodystructure.c
src/lib-index/mail-index-sync-ext.c
src/lib-index/mail-index-sync.c
src/lib-index/mail-index-transaction-export.c
src/lib-lda/duplicate.c
src/lib-ldap/ldap-connection.c
src/lib-mail/message-header-parser.c
src/lib-mail/message-parser.c
src/lib-mail/message-part-serialize.c
src/lib-mail/test-message-header-encode.c
src/lib-mail/test-message-parser.c
src/lib-master/test-master-service-settings-cache.c
src/lib-ntlm/ntlm-des.c
src/lib-ntlm/ntlm-encrypt.c
src/lib-ntlm/ntlm-message.c
src/lib-otp/otp-parse.c
src/lib-settings/settings-parser.c
src/lib-settings/settings.c
src/lib-sql/driver-cassandra.c
src/lib-sql/driver-pgsql.c
src/lib-ssl-iostream/iostream-openssl-context.c
src/lib-ssl-iostream/iostream-openssl.c
src/lib-storage/index/maildir/maildir-filename-flags.c
src/lib-storage/index/maildir/maildir-filename.c
src/lib-storage/index/mbox/mbox-file.c
src/lib-storage/index/mbox/mbox-lock.c
src/lib-storage/index/mbox/mbox-save.c
src/lib-storage/index/mbox/mbox-sync.c
src/lib-storage/mail-search.c
src/lib-storage/mail-search.h
src/lib/askpass.c
src/lib/buffer.h
src/lib/compat.h
src/lib/file-cache.c
src/lib/file-lock.c
src/lib/hash.c
src/lib/ioloop-select.c
src/lib/macros.h
src/lib/md4.c
src/lib/md5.c
src/lib/net.c
src/lib/test-timing.c
src/lib/test-unichar.c
src/lib/var-expand.c
src/lib/wildcard-match.c
src/login-common/sasl-server.c
src/login-common/ssl-proxy-openssl.c
src/master/service-process.c
src/plugins/fts-lucene/fts-backend-lucene.c
src/plugins/fts-solr/solr-connection.c
src/plugins/push-notification/push-notification-event-flagsclear.c
src/plugins/push-notification/push-notification-event-flagsset.c
src/plugins/push-notification/push-notification-event-messageappend.c
src/plugins/push-notification/push-notification-event-messagenew.c
src/plugins/push-notification/push-notification-event-messageread.c
src/plugins/push-notification/push-notification-event-messagetrash.c
src/plugins/push-notification/push-notification-plugin.c
src/plugins/quota/Makefile.am
src/pop3/pop3-client.c
src/pop3/pop3-commands.c

index f5f974d9c94d253b2cf05ba63baada67442612cc..be61e049c247eaeb075c68237b4c344528ac14ec 100644 (file)
@@ -1600,7 +1600,7 @@ static const char *db_ldap_field_expand(const char *data, void *context)
        ldap_value = hash_table_lookup(ctx->ldap_attrs, field_name);
        if (ldap_value == NULL) {
                /* requested ldap attribute wasn't returned at all */
-               if (ctx->debug)
+               if (ctx->debug != NULL)
                        str_printfa(ctx->debug, "; %s missing", field_name);
                return db_ldap_field_get_default(data);
        }
@@ -1702,7 +1702,7 @@ bool db_ldap_result_iterate_next(struct db_ldap_result_iterate_context *ctx,
                hash_table_lookup(ctx->ldap_attrs, field->ldap_attr_name);
        if (ldap_value != NULL)
                ldap_value->used = TRUE;
-       else if (ctx->debug && *field->ldap_attr_name != '\0')
+       else if (ctx->debug != NULL && *field->ldap_attr_name != '\0')
                str_printfa(ctx->debug, "; %s missing", field->ldap_attr_name);
 
        str_truncate(ctx->var, 0);
index cedd06273f7f477771ef63675534a01a6a58c540..87c04b0d337c0156d954a048f9c09b3668faf970 100644 (file)
@@ -96,7 +96,7 @@ static string_t *get_digest_challenge(struct digest_auth_request *request)
 
        str_append(str, "qop=\""); first_qop = TRUE;
        for (i = 0; i < QOP_COUNT; i++) {
-               if (request->qop & (1 << i)) {
+               if ((request->qop & (1 << i)) != 0) {
                        if (first_qop)
                                first_qop = FALSE;
                        else
index 721f968bc70c31dfb9448ab68ea6e4aa0481a728..d190436745f0f34637a82d1ea90aa87a03503903 100644 (file)
@@ -180,7 +180,7 @@ mech_ntlm_auth_continue(struct auth_request *auth_request,
                (struct ntlm_auth_request *)auth_request;
        const char *error;
 
-       if (!request->challenge) {
+       if (request->challenge == NULL) {
                const struct ntlmssp_request *ntlm_request =
                        (const struct ntlmssp_request *)data;
                const struct ntlmssp_challenge *message;
@@ -197,8 +197,8 @@ mech_ntlm_auth_continue(struct auth_request *auth_request,
                message = ntlmssp_create_challenge(request->pool, ntlm_request,
                                                   &message_size);
                flags = read_le32(&message->flags);
-               request->ntlm2_negotiated = flags & NTLMSSP_NEGOTIATE_NTLM2;
-               request->unicode_negotiated = flags & NTLMSSP_NEGOTIATE_UNICODE;
+               request->ntlm2_negotiated = (flags & NTLMSSP_NEGOTIATE_NTLM2) != 0;
+               request->unicode_negotiated = (flags & NTLMSSP_NEGOTIATE_UNICODE) != 0;
                request->challenge = message->challenge;
 
                auth_request_handler_reply_continue(auth_request, message,
index 2b7018d59afb9549a166ee6d1d625f5fe3b40af1..99e11ef1a2296cb8800f695c93f68c4d10afc207 100644 (file)
@@ -352,7 +352,7 @@ static void mech_scram_sha1_auth_continue(struct auth_request *auth_request,
        const char *server_final_message;
        int len;
 
-       if (!request->client_first_message_bare) {
+       if (request->client_first_message_bare == NULL) {
                /* Received client-first-message */
                if (parse_scram_client_first(request, data,
                                             data_size, &error)) {
index d1c7994d4a8d73f5656b9816af1c392f508deff0..065286acf19321d0f9618a38e3347aede00b67c4 100644 (file)
@@ -64,7 +64,7 @@ const char *password_generate_md5_crypt(const char *pw, const char *salt)
                sp += sizeof(magic)-1;
 
        /* It stops at the first '$', max 8 chars */
-       for(ep=sp;*ep && *ep != '$' && ep < (sp+8);ep++)
+       for(ep=sp;*ep != '\0' && *ep != '$' && ep < (sp+8);ep++)
                continue;
 
        /* get the length of the true salt */
@@ -94,8 +94,8 @@ const char *password_generate_md5_crypt(const char *pw, const char *salt)
        safe_memset(final, 0, sizeof(final));
 
        /* Then something really weird... */
-       for (j=0,i = pw_len; i ; i >>= 1)
-               if(i&1)
+       for (j=0,i = pw_len; i != 0; i >>= 1)
+               if ((i&1) != 0)
                    md5_update(&ctx, final+j, 1);
                else
                    md5_update(&ctx, pw+j, 1);
@@ -115,18 +115,18 @@ const char *password_generate_md5_crypt(const char *pw, const char *salt)
         */
        for(i=0;i<1000;i++) {
                md5_init(&ctx1);
-               if(i & 1)
+               if((i & 1) != 0)
                        md5_update(&ctx1,pw,pw_len);
                else
                        md5_update(&ctx1,final,MD5_RESULTLEN);
 
-               if(i % 3)
+               if((i % 3) != 0)
                        md5_update(&ctx1,sp,sl);
 
-               if(i % 7)
+               if((i % 7) != 0)
                        md5_update(&ctx1,pw,pw_len);
 
-               if(i & 1)
+               if((i & 1) != 0)
                        md5_update(&ctx1,final,MD5_RESULTLEN);
                else
                        md5_update(&ctx1,pw,pw_len);
index d75f8d4c6b6b94b4f223fe834405e4f19a26dcf8..8ab0ba9c988b52976f2eed6a33581ee356cf456b 100644 (file)
@@ -15,7 +15,7 @@ void *ucs2be_str(pool_t pool, const char *str, size_t *size)
 {
        buffer_t *buf = buffer_create_dynamic(pool, 32);
 
-       while (*str) {
+       while (*str != '\0') {
                buffer_append_c(buf, '\0');
                buffer_append_c(buf, *str++);
        }
index 84d711573ca29c0bab98fb7f5961d53708b4a08b..8f0db20adbaa08379130107fb0db7eea16f890e3 100644 (file)
@@ -741,14 +741,14 @@ director_cmd_host_hand_start(struct director_connection *conn,
                return FALSE;
        }
 
-       if (remote_ring_completed && !conn->dir->ring_handshaked) {
+       if (remote_ring_completed != 0 && !conn->dir->ring_handshaked) {
                /* clear everything we have and use only what remote sends us */
                hosts = mail_hosts_get(conn->dir->mail_hosts);
                while (array_count(hosts) > 0) {
                        hostp = array_idx(hosts, 0);
                        director_remove_host(conn->dir, NULL, NULL, *hostp);
                }
-       } else if (!remote_ring_completed && conn->dir->ring_handshaked) {
+       } else if (remote_ring_completed == 0 && conn->dir->ring_handshaked) {
                /* ignore whatever remote sends */
                conn->ignore_host_events = TRUE;
        }
index 338deb6d289c2d4cff1cdc9c158f983dfab6ca38..d61b7fcfd79e76b19f16a851607c986b8b54a927 100644 (file)
@@ -88,7 +88,7 @@ cmd_user_input(struct auth_master_connection *conn,
        } else if (show_field != NULL) {
                unsigned int show_field_len = strlen(show_field);
 
-               for (; *fields; fields++) {
+               for (; *fields != NULL; fields++) {
                        if (strncmp(*fields, show_field, show_field_len) == 0 &&
                            (*fields)[show_field_len] == '=')
                                printf("%s\n", *fields + show_field_len + 1);
@@ -98,7 +98,7 @@ cmd_user_input(struct auth_master_connection *conn,
 
                if (updated_username != NULL)
                        printf("  %-10s: %s\n", "user", updated_username);
-               for (; *fields; fields++) {
+               for (; *fields != NULL; fields++) {
                        p = strchr(*fields, '=');
                        if (p == NULL)
                                printf("  %-10s\n", *fields);
index eab67cc3c43c70a1a2a7bb6b8fa224aa6a2a76dc..9e66d7efd06d3bd19824bdb481231e744aa5f1f1 100644 (file)
@@ -752,7 +752,7 @@ static void cmd_director_ring_add(struct doveadm_cmd_context *cctx)
        ctx = cmd_director_init(cctx);
        if (ctx->ip == NULL ||
            net_addr2ip(ctx->ip, &ip) < 0 ||
-           (ctx->port && net_str2port(ctx->port, &port) < 0)) {
+           (ctx->port != 0 && net_str2port(ctx->port, &port) < 0)) {
                director_cmd_help(cctx->cmd);
                return;
        }
index ef44dfbc0a42ed8619e47b517275d3a31dc04cf9..bef804a472e37d96dfed56988710d1c90ddc4a39 100644 (file)
@@ -153,7 +153,7 @@ int doveadm_connect(const char *path)
 
 int i_strccdascmp(const char *a, const char *b)
 {
-       while(*a && *b) {
+       while(*a != '\0' && *b != '\0') {
                if ((*a == ' ' || *a == '-') && *a != *b && *b != ' ' && *b != '-') {
                        if (i_toupper(*(a+1)) == *(b)) a++;
                        else break;
index 32f89d360ea47d4d6bf3f122fdf5f176bcb46047..2f0fe2a667ab944fd639b8960f0e9bc0e4c39d8b 100644 (file)
@@ -509,7 +509,7 @@ dsync_mailbox_export_init(struct mailbox *box,
        exporter->export_received_timestamps =
                (flags & DSYNC_MAILBOX_EXPORTER_FLAG_TIMESTAMPS) != 0;
        exporter->hdr_hash_version =
-               (flags & DSYNC_MAILBOX_EXPORTER_FLAG_HDR_HASH_V2) ? 2 : 1;
+               (flags & DSYNC_MAILBOX_EXPORTER_FLAG_HDR_HASH_V2) != 0 ? 2 : 1;
        exporter->no_hdr_hashes =
                (flags & DSYNC_MAILBOX_EXPORTER_FLAG_NO_HDR_HASHES) != 0;
        p_array_init(&exporter->requested_uids, pool, 16);
index 05d58f1f774806c8ff77253f8e66f5ad15c3872e..a8dd7b1526578d7d466985a764722cd385bf73bc 100644 (file)
@@ -412,7 +412,7 @@ static int imap_sync_send_flags(struct imap_sync_context *ctx, string_t *str)
 
        str_truncate(str, 0);
        str_printfa(str, "* %u FETCH (", ctx->seq);
-       if (ctx->imap_flags & IMAP_SYNC_FLAG_SEND_UID)
+       if ((ctx->imap_flags & IMAP_SYNC_FLAG_SEND_UID) != 0)
                str_printfa(str, "UID %u ", ctx->mail->uid);
        if ((ctx->client->enabled_features & MAILBOX_FEATURE_CONDSTORE) != 0 &&
            !ctx->client->nonpermanent_modseqs) {
@@ -431,7 +431,7 @@ static int imap_sync_send_modseq(struct imap_sync_context *ctx, string_t *str)
 
        str_truncate(str, 0);
        str_printfa(str, "* %u FETCH (", ctx->seq);
-       if (ctx->imap_flags & IMAP_SYNC_FLAG_SEND_UID)
+       if ((ctx->imap_flags & IMAP_SYNC_FLAG_SEND_UID) != 0)
                str_printfa(str, "UID %u ", ctx->mail->uid);
        imap_sync_add_modseq(ctx, str);
        str_append_c(str, ')');
@@ -697,7 +697,7 @@ static void get_common_sync_flags(struct client *client,
                    cmd->sync->counter == client->sync_counter) {
                        if ((cmd->sync->flags & MAILBOX_SYNC_FLAG_FAST) != 0)
                                fast_count++;
-                       if (cmd->sync->flags & MAILBOX_SYNC_FLAG_NO_EXPUNGES)
+                       if ((cmd->sync->flags & MAILBOX_SYNC_FLAG_NO_EXPUNGES) != 0)
                                noexpunges_count++;
                        *flags_r |= cmd->sync->flags;
                        *imap_flags_r |= cmd->sync->imap_flags;
@@ -830,7 +830,7 @@ static bool cmd_sync_delayed_real(struct client *client)
        for (cmd = client->command_queue; cmd != NULL; cmd = cmd->next) {
                if (cmd->sync != NULL &&
                    cmd->sync->counter == client->sync_counter) {
-                       if (cmd->sync->flags & MAILBOX_SYNC_FLAG_NO_EXPUNGES) {
+                       if ((cmd->sync->flags & MAILBOX_SYNC_FLAG_NO_EXPUNGES) != 0) {
                                if (first_nonexpunge == NULL)
                                        first_nonexpunge = cmd;
                        } else {
index 8bec673dceca7c8b81ad9f37c5d83098e97e30c3..2d6482952f2725303698ebe078f1be55c6729313 100644 (file)
@@ -170,7 +170,7 @@ static
 void dcrypt_openssl_ctx_sym_destroy(struct dcrypt_context_symmetric **ctx)
 {
        pool_t pool = (*ctx)->pool;
-       if ((*ctx)->ctx) EVP_CIPHER_CTX_free((*ctx)->ctx);
+       if ((*ctx)->ctx != NULL) EVP_CIPHER_CTX_free((*ctx)->ctx);
        pool_unref(&pool);
        *ctx = NULL;
 }
index 200ca8c3e660acef2e1c697d0ac53d8a04d37761..39b66ecc65401f7275edd432d89c50d9f6e13e5f 100644 (file)
@@ -155,9 +155,9 @@ static const char *dict_ldap_map_finish(struct setting_parser_ctx *ctx)
        if (ctx->cur_map.scope == NULL) {
                ctx->cur_map.scope_val = 2; /* subtree */
        } else {
-               if (!strcasecmp(ctx->cur_map.scope, "one")) ctx->cur_map.scope_val = 1;
-               else if (!strcasecmp(ctx->cur_map.scope, "base")) ctx->cur_map.scope_val = 0;
-               else if (!strcasecmp(ctx->cur_map.scope, "subtree")) ctx->cur_map.scope_val = 2;
+               if (strcasecmp(ctx->cur_map.scope, "one") == 0) ctx->cur_map.scope_val = 1;
+               else if (strcasecmp(ctx->cur_map.scope, "base") == 0) ctx->cur_map.scope_val = 0;
+               else if (strcasecmp(ctx->cur_map.scope, "subtree") == 0) ctx->cur_map.scope_val = 2;
                else return "Scope must be one, base or subtree";
        }
        if (!array_is_created(&ctx->cur_map.ldap_attributes)) {
index d263669840cf610a147b94a879814c449c82319c..3395eef709da6dd7366e1293dc4ac95ae506dd2d 100644 (file)
@@ -100,7 +100,7 @@ void http_server_request_destroy(struct http_server_request **_req)
        if (req->state < HTTP_SERVER_REQUEST_STATE_FINISHED)
                req->state = HTTP_SERVER_REQUEST_STATE_ABORTED;
 
-       if (server->ioloop)
+       if (server->ioloop != NULL)
                io_loop_stop(server->ioloop);
 
        if (req->delay_destroy) {
index 36f88891c421909ed234798a1996df3213f6ebed..df30bd583485173de9ad584d6c21c9193011576e 100644 (file)
@@ -1750,7 +1750,7 @@ volatile sig_atomic_t terminating = 0;
 static void
 test_signal_handler(int signo)
 {
-       if (terminating)
+       if (terminating != 0)
                raise(signo);
        terminating = 1;
 
index d8270d468826d11dd9c22e66a03e2c35ebe7fd7a..c50713ff33568393a1f378ee25cc07576ca7efbe 100644 (file)
@@ -1503,7 +1503,7 @@ volatile sig_atomic_t terminating = 0;
 static void
 test_signal_handler(int signo)
 {
-       if (terminating)
+       if (terminating != 0)
                raise(signo);
        terminating = 1;
 
index 58ff92cb1698bcd322ab2452795b78f5d3b64afa..d00514d5d148d887fc80144a139a29c255b6ca9c 100644 (file)
@@ -363,7 +363,7 @@ static void part_write_body(const struct message_part *part,
        struct message_part_body_data *data = part->context;
        bool text;
 
-       if (part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) {
+       if ((part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) != 0) {
                str_append(str, "\"message\" \"rfc822\"");
                text = FALSE;
        } else {
@@ -406,7 +406,7 @@ static void part_write_body(const struct message_part *part,
        if (text) {
                /* text/.. contains line count */
                str_printfa(str, " %u", part->body_size.lines);
-       } else if (part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) {
+       } else if ((part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) != 0) {
                /* message/rfc822 contains envelope + body + line count */
                struct message_part_body_data *child_data;
 
@@ -482,7 +482,7 @@ bool imap_bodystructure_is_plain_7bit(const struct message_part *part)
 void imap_bodystructure_write(const struct message_part *part,
                              string_t *dest, bool extended)
 {
-       if (part->flags & MESSAGE_PART_FLAG_MULTIPART)
+       if ((part->flags & MESSAGE_PART_FLAG_MULTIPART) != 0)
                part_write_body_multipart(part, dest, extended);
        else
                part_write_body(part, dest, extended);
index e758e53df3081cd0a0d85311546c93f39e8aa4a7..c8dae4631c60a47aa00b9b7b6548e4a66374adbe 100644 (file)
@@ -606,7 +606,7 @@ int mail_index_sync_ext_reset(struct mail_index_sync_map_ctx *ctx,
        ext = array_idx_modifiable(&map->extensions, ctx->cur_ext_map_idx);
        ext->reset_id = u->new_reset_id;
 
-       if (!u->preserve_data)
+       if (u->preserve_data == 0)
                mail_index_sync_ext_clear(ctx->view, map, ext);
 
        ext_hdr = get_ext_header(map, ext);
index a7a2662610c1d1c08cbc24447a384c95302e2326..13e5aa6647dcfc027a83975c6cb665217f5bbc06 100644 (file)
@@ -173,7 +173,7 @@ mail_index_sync_read_and_sort(struct mail_index_sync_ctx *ctx)
        unsigned int i, keyword_count;
        int ret;
 
-       if ((ctx->view->map->hdr.flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) &&
+       if ((ctx->view->map->hdr.flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) != 0 &&
            (ctx->flags & MAIL_INDEX_SYNC_FLAG_FLUSH_DIRTY) != 0) {
                /* show dirty flags as flag updates */
                mail_index_sync_add_dirty_updates(ctx);
@@ -251,7 +251,7 @@ mail_index_need_sync(struct mail_index *index, enum mail_index_sync_flags flags,
            (flags & MAIL_INDEX_SYNC_FLAG_DROP_RECENT) != 0)
                return TRUE;
 
-       if ((hdr->flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) &&
+       if ((hdr->flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) != 0 &&
            (flags & MAIL_INDEX_SYNC_FLAG_FLUSH_DIRTY) != 0)
                return TRUE;
 
@@ -531,7 +531,7 @@ static bool mail_index_sync_view_have_any(struct mail_index_view *view,
            (flags & MAIL_INDEX_SYNC_FLAG_DROP_RECENT) != 0)
                return TRUE;
 
-       if ((view->map->hdr.flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) &&
+       if ((view->map->hdr.flags & MAIL_INDEX_HDR_FLAG_HAVE_DIRTY) != 0 &&
            (flags & MAIL_INDEX_SYNC_FLAG_FLUSH_DIRTY) != 0)
                return TRUE;
 
index 1996c80c900fc73b110f92d4a3a790809786a4e6..28b8b60fdcdb0ecfc52a08a03365eaeff168fb9d 100644 (file)
@@ -64,7 +64,7 @@ log_get_hdr_update_buffer(struct mail_index_transaction *t, bool prepend)
 
        buf = buffer_create_dynamic(pool_datastack_create(), 256);
        for (offset = 0; offset <= sizeof(t->pre_hdr_change); offset++) {
-               if (offset < sizeof(t->pre_hdr_change) && mask[offset]) {
+               if (offset < sizeof(t->pre_hdr_change) && mask[offset] != 0) {
                        if (state == 0) {
                                u.offset = offset;
                                state++;
@@ -294,7 +294,7 @@ mail_transaction_log_append_ext_intros(struct mail_index_export_context *ctx)
                        ext_reset = reset[ext_id];
                else
                        ext_reset.new_reset_id = 0;
-               if ((ext_id < resize_count && resize[ext_id].name_size) ||
+               if ((ext_id < resize_count && resize[ext_id].name_size > 0) ||
                    ext_reset.new_reset_id != 0 ||
                    (ext_id < hdrs_count && hdrs[ext_id].alloc_size > 0)) {
                        if (ext_reset.new_reset_id != 0) {
index bc806ba668245aaf6b972a8fea16651c53e390df..6af2e676e4e272d94bfbc0776e1c1b040c1f7a53 100644 (file)
@@ -73,7 +73,7 @@ static unsigned int duplicate_hash(const struct duplicate *d)
 
        while (s != end) {
                h = (h << 4) + *s;
-               if ((g = h & 0xf0000000UL)) {
+               if ((g = h & 0xf0000000UL) != 0) {
                        h = h ^ (g >> 24);
                        h = h ^ g;
                }
index 31a27cf5139d108bc863cf50e6ece27bb37d71a0..f857eab8c6b9944d1bb12b58b44773675a8716a6 100644 (file)
@@ -559,7 +559,7 @@ void ldap_connection_kill(struct ldap_connection *conn)
                timeout_remove(&(conn->to_disconnect));
        if (conn->to_reconnect != NULL)
                timeout_remove(&(conn->to_reconnect));
-       if (conn->request_queue) {
+       if (conn->request_queue != NULL) {
                unsigned int n = aqueue_count(conn->request_queue);
 
                for (unsigned int i = 0; i < n; i++) {
index ecaa43b4bded787d12382aa13d6d534e6ecb8901..6f327044e61d3f382480ded3a917686d91640f01 100644 (file)
@@ -275,7 +275,7 @@ int message_parse_header_next(struct message_header_parser_ctx *ctx,
 
                line->value = msg + colon_pos+1;
                line->value_len = size - colon_pos - 1;
-               if (ctx->flags & MESSAGE_HEADER_PARSER_FLAG_SKIP_INITIAL_LWSP) {
+               if ((ctx->flags & MESSAGE_HEADER_PARSER_FLAG_SKIP_INITIAL_LWSP) != 0) {
                        /* get value. skip all LWSP after ':'. Note that
                           RFC2822 doesn't say we should, but history behind
                           it..
@@ -340,7 +340,7 @@ int message_parse_header_next(struct message_header_parser_ctx *ctx,
                                buffer_append_c(ctx->value_buf, '\r');
                        buffer_append_c(ctx->value_buf, '\n');
                }
-               if ((ctx->flags & MESSAGE_HEADER_PARSER_FLAG_CLEAN_ONELINE) &&
+               if ((ctx->flags & MESSAGE_HEADER_PARSER_FLAG_CLEAN_ONELINE) != 0 &&
                    line->value_len > 0 && line->value[0] != ' ' &&
                    IS_LWSP(line->value[0])) {
                        buffer_append_c(ctx->value_buf, ' ');
index 3ce3af2be48882a13be354c39cbd05b558d47c26..b426b079b253fd6f9a38e2be2dd9304fb3dc72aa 100644 (file)
@@ -658,7 +658,7 @@ static int parse_next_header(struct message_parser_ctx *ctx,
                i_assert(ctx->last_boundary == NULL);
                ctx->multipart = FALSE;
                ctx->parse_next_block = parse_next_body_to_boundary;
-       } else if (part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822)
+       } else if ((part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) != 0)
                ctx->parse_next_block = parse_next_body_message_rfc822_init;
        else if (ctx->boundaries != NULL)
                ctx->parse_next_block = parse_next_body_to_boundary;
index a5e74438ecb7ed50f1001e24a3d7bbd82109b041..93bb55bfa8fdc6de6a5375b3cbf59ed3723e36c0 100644 (file)
@@ -198,7 +198,7 @@ message_part_deserialize_part(struct deserialize_context *ctx,
                         children_count = 0;
                }
 
-               if (part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) {
+               if ((part->flags & MESSAGE_PART_FLAG_MESSAGE_RFC822) != 0) {
                        /* Only one child is possible */
                        if (children_count == 0) {
                                ctx->error =
index e7ea96b7711bca0541a26c89c2c5c0234fe4374c..7cd5817c62d4ad387a2d2930045bd79b56762ea3 100644 (file)
@@ -69,7 +69,7 @@ static void test_message_header_encode_q(void)
                        message_header_encode_q(str_data(input) + skip,
                                                str_len(input) - skip, str,
                                                i == 0 ? 0 : i+1);
-                       test_assert(verify_q(str_c(str), i, !skip));
+                       test_assert(verify_q(str_c(str), i, skip == 0));
                }
        }
        test_end();
@@ -156,7 +156,7 @@ static void test_message_header_encode_b(void)
                        message_header_encode_b(str_data(input) + skip,
                                                str_len(input) - skip, str,
                                                i == 0 ? 0 : i+1);
-                       test_assert(verify_b(str_c(str), i, !skip));
+                       test_assert(verify_b(str_c(str), i, skip == 0));
                }
        }
        test_end();
index 3ea3907fd1a0345edbd6c3804deb7ce4d8661d97..d8c48ade4b265b18319da7525f425f58172d1d06 100644 (file)
@@ -47,7 +47,7 @@ static bool msg_parts_cmp(struct message_part *p1, struct message_part *p2)
                if ((p1->children != NULL) != (p2->children != NULL))
                        return FALSE;
 
-               if (p1->children) {
+               if (p1->children != NULL) {
                        if (!msg_parts_cmp(p1->children, p2->children))
                                return FALSE;
                }
index 8d9a4d2a3df5e9502704daaf182c58729493918c..88647104ac43949d08d101e498b1f94bd9f4a625 100644 (file)
@@ -64,12 +64,12 @@ static void test_master_service_settings_cache_once(void)
        const struct setting_parser_context *parser;
        const char *error;
 
-       output.used_local = output.service_uses_local && rand() % 2;
+       output.used_local = output.service_uses_local && (rand() % 2) != 0;
        if (output.used_local) {
                input.local_ip.family = AF_INET;
                input.local_ip.u.ip4.s_addr = 100 + rand() % 100;
        }
-       output.used_remote = output.service_uses_remote && rand() % 2;
+       output.used_remote = output.service_uses_remote && (rand() % 2) != 0;
        if (output.used_remote) {
                input.remote_ip.family = AF_INET;
                input.remote_ip.u.ip4.s_addr = 100 + rand() % 100;
index 0c84802338495fc42bea89f929b05f76523acba6..a2e5a4bb5f6e76715547d7bb72290bbb6f1694b6 100644 (file)
@@ -290,7 +290,7 @@ struct des_context {
 static uint32_t bitsel(uint32_t * input, const int *bitnums, int size)
 {
        uint32_t ret = 0;
-       while (size--) {
+       while (size-- > 0) {
                int bitpos = *bitnums++;
                ret <<= 1;
                if (bitpos >= 0)
index 48cb367eba4116d8b0dc9bc16d397dd2423ddf23..dcc6a8f74223b08a3d5646e10f687dc052d9807b 100644 (file)
@@ -24,7 +24,7 @@ t_unicode_str(const char *src, bool ucase, size_t *size)
        buffer_t *wstr;
 
        wstr = buffer_create_dynamic(unsafe_data_stack_pool, 32);
-       for ( ; *src; src++) {
+       for ( ; *src != '\0'; src++) {
                buffer_append_c(wstr, ucase ? i_toupper(*src) : *src);
                buffer_append_c(wstr, '\0');
        }
index 53cfb45a26cf4d05e0cbcda104b08e66e52f1b66..bc62651449a98453885669d3fd11a6a097fc87a8 100644 (file)
@@ -43,7 +43,7 @@ static unsigned int append_string(buffer_t *buf, const char *str,
 {
        unsigned int length = 0;
 
-       for ( ; *str; str++) {
+       for ( ; *str != '\0'; str++) {
                buffer_append_c(buf, ucase ? i_toupper(*str) : *str);
                if (unicode) {
                        buffer_append_c(buf, 0);
@@ -126,15 +126,15 @@ static inline uint32_t ntlmssp_flags(uint32_t client_flags)
        uint32_t flags = NTLMSSP_NEGOTIATE_NTLM |
                         NTLMSSP_NEGOTIATE_TARGET_INFO;
 
-       if (client_flags & NTLMSSP_NEGOTIATE_UNICODE)
+       if ((client_flags & NTLMSSP_NEGOTIATE_UNICODE) != 0)
                flags |= NTLMSSP_NEGOTIATE_UNICODE;
        else
                flags |= NTLMSSP_NEGOTIATE_OEM;
 
-       if (client_flags & NTLMSSP_NEGOTIATE_NTLM2)
+       if ((client_flags & NTLMSSP_NEGOTIATE_NTLM2) != 0)
                flags |= NTLMSSP_NEGOTIATE_NTLM2;
 
-       if (client_flags & NTLMSSP_REQUEST_TARGET)
+       if ((client_flags & NTLMSSP_REQUEST_TARGET) != 0)
                flags |= NTLMSSP_REQUEST_TARGET | NTLMSSP_TARGET_TYPE_SERVER;
 
        return flags;
@@ -159,7 +159,7 @@ ntlmssp_create_challenge(pool_t pool, const struct ntlmssp_request *request,
 
        buffer_write(buf, 0, &c, sizeof(c));
 
-       if (flags & NTLMSSP_TARGET_TYPE_SERVER)
+       if ((flags & NTLMSSP_TARGET_TYPE_SERVER) != 0)
                ntlmssp_append_string(buf,
                        offsetof(struct ntlmssp_challenge, target_name),
                        my_hostname, unicode);
@@ -173,8 +173,8 @@ ntlmssp_create_challenge(pool_t pool, const struct ntlmssp_request *request,
        return buffer_free_without_data(&buf);
 }
 
-static int ntlmssp_check_buffer(const struct ntlmssp_buffer *buffer,
-                               size_t data_size, const char **error)
+static bool ntlmssp_check_buffer(const struct ntlmssp_buffer *buffer,
+                                size_t data_size, const char **error)
 {
        uint32_t offset = read_le32(&buffer->offset);
        uint16_t length = read_le16(&buffer->length);
@@ -182,19 +182,19 @@ static int ntlmssp_check_buffer(const struct ntlmssp_buffer *buffer,
 
        /* Empty buffer is ok */
        if (length == 0 && space == 0)
-               return 1;
+               return TRUE;
 
        if (offset >= data_size) {
                *error = "buffer offset out of bounds";
-               return 0;
+               return FALSE;
        }
 
        if (offset + space > data_size) {
                *error = "buffer end out of bounds";
-               return 0;
+               return FALSE;
        }
 
-       return 1;
+       return TRUE;
 }
 
 bool ntlmssp_check_request(const struct ntlmssp_request *request,
index 2c1da0b465ac7ac5b3c053fbdf48e0fa3d536af0..15a325e2cedd147c5d2c0415badcded53dfed2f8 100644 (file)
 
 static inline const char *otp_skip_lws(const char *data)
 {
-       while (*data && IS_LWS(*data))
+       while (*data != '\0' && IS_LWS(*data))
                data++;
        return data;
 }
 
-static inline int otp_check_tail(const char *data)
+static inline bool otp_check_tail(const char *data)
 {
        data = otp_skip_lws(data);
 
@@ -44,7 +44,7 @@ int otp_read_hex(const char *data, const char **endptr, unsigned char *hash)
        str = t_str_new(18);
        buffer_create_from_data(&buf, hash, OTP_HASH_SIZE);
 
-       while (*data) {
+       while (*data != '\0') {
                char c = *data;
 
                if (i_isxdigit(c)) {
@@ -91,7 +91,7 @@ int otp_read_words(const char *data, const char **endptr, unsigned char *hash)
 
        buffer_create_from_data(&buf, bits, sizeof(bits));
 
-       for (; *data && (count < OTP_WORDS_NUMBER); data++) {
+       for (; *data != '\0' && (count < OTP_WORDS_NUMBER); data++) {
                char c = *data;
 
                if (space) {
@@ -124,7 +124,7 @@ int otp_read_words(const char *data, const char **endptr, unsigned char *hash)
        if ((str_len(word) > 0) && (count == OTP_WORDS_NUMBER - 1))
                add_word();
 
-       if (endptr)
+       if (endptr != NULL)
                *endptr = data;
 
        if (count < OTP_WORDS_NUMBER)
@@ -221,7 +221,7 @@ int otp_parse_init_response(const char *data, struct otp_state *new_state,
                return -1;
        }
 
-       if (otp_check_tail(end) != 0) {
+       if (otp_check_tail(end)) {
                *error = "trailing garbage found";
                return -1;
        }
index 6023ee181874073802d2d6fbd2283a5578afca93..058d9eb87f5652984048295d2b55cd59deda3c94 100644 (file)
@@ -919,7 +919,7 @@ bool settings_parse_is_changed(struct setting_parser_context *ctx,
                return FALSE;
 
        p = STRUCT_MEMBER_P(link->change_struct, def->offset);
-       return *p;
+       return *p != 0;
 }
 
 int settings_parse_line(struct setting_parser_context *ctx, const char *line)
index d0f96d1ab4142e8cdedb1a4fcf46c229d9184d8a..6ddd7aaf72eba97406052d0c72e6ea3be80b54c7 100644 (file)
@@ -290,7 +290,7 @@ prevfile:
                                line = str_unescape(line+1);
                        }
 
-                       errormsg = skip ? NULL :
+                       errormsg = skip > 0 ? NULL :
                                callback(key, line, context);
                } else if (strcmp(key, "}") != 0 || *line != '\0') {
                        /* b) + errors */
index ad44d766bbc4cf047ba5561fe0bda470500f1309..ca81b11d8a0b4139ca4f8035e78836f76d598231 100644 (file)
@@ -944,7 +944,7 @@ driver_cassandra_get_value(struct cassandra_result *result,
        CassError rc;
        const char *type;
 
-       if (cass_value_is_null(value)) {
+       if (cass_value_is_null(value) != 0) {
                *str_r = NULL;
                return 0;
        }
@@ -993,7 +993,7 @@ static int driver_cassandra_result_next_row(struct sql_result *_result)
        if (result->iterator == NULL)
                return -1;
 
-       if (!cass_iterator_next(result->iterator))
+       if (cass_iterator_next(result->iterator) == 0)
                return 0;
        result->row_count++;
 
index abf62f0a4060c6acf9cb15970f4ef4bc42eda730..608a7862d8923b297cf3c5515eb36fd6b21b9066 100644 (file)
@@ -321,8 +321,8 @@ static void consume_results(struct pgsql_db *db)
 
        driver_pgsql_stop_io(db);
 
-       while (PQconsumeInput(db->pg)) {
-               if (PQisBusy(db->pg)) {
+       while (PQconsumeInput(db->pg) != 0) {
+               if (PQisBusy(db->pg) != 0) {
                        db->io = io_add(PQsocket(db->pg), IO_READ,
                                        consume_results, db);
                        db->io_dir = IO_READ;
@@ -423,12 +423,12 @@ static void get_result(struct pgsql_result *result)
 
        driver_pgsql_stop_io(db);
 
-       if (!PQconsumeInput(db->pg)) {
+       if (PQconsumeInput(db->pg) == 0) {
                result_finish(result);
                return;
        }
 
-       if (PQisBusy(db->pg)) {
+       if (PQisBusy(db->pg) != 0) {
                db->io = io_add(PQsocket(db->pg), IO_READ,
                                get_result, result);
                db->io_dir = IO_READ;
@@ -487,7 +487,7 @@ static void do_query(struct pgsql_result *result, const char *query)
        result->to = timeout_add(SQL_QUERY_TIMEOUT_SECS * 1000,
                                 query_timeout, result);
 
-       if (!PQsendQuery(db->pg, query) ||
+       if (PQsendQuery(db->pg, query) == 0 ||
            (ret = PQflush(db->pg)) < 0) {
                /* failed to send query */
                result_finish(result);
@@ -755,7 +755,7 @@ driver_pgsql_result_get_field_value(struct sql_result *_result,
 {
        struct pgsql_result *result = (struct pgsql_result *)_result;
 
-       if (PQgetisnull(result->pgres, result->rownum, idx))
+       if (PQgetisnull(result->pgres, result->rownum, idx) != 0)
                return NULL;
 
        return PQgetvalue(result->pgres, result->rownum, idx);
@@ -769,7 +769,7 @@ driver_pgsql_result_get_field_value_binary(struct sql_result *_result,
        const char *value;
        struct pgsql_binary_value *binary_value;
 
-       if (PQgetisnull(result->pgres, result->rownum, idx)) {
+       if (PQgetisnull(result->pgres, result->rownum, idx) != 0) {
                *size_r = 0;
                return NULL;
        }
index f0ea1e403c2a9345a713da94e7c7c559425b0cb0..c32ae2c3ceea0e43ba82aede5dabb18184682c8d 100644 (file)
@@ -42,7 +42,7 @@ static DH *ssl_tmp_dh_callback(SSL *ssl ATTR_UNUSED,
        ssl_io = SSL_get_ex_data(ssl, dovecot_ssl_extdata_index);
        /* Well, I'm not exactly sure why the logic in here is this.
           It's the same as in Postfix, so it can't be too wrong. */
-       if (is_export && keylength == 512 && ssl_io->ctx->dh_512 != NULL)
+       if (is_export != 0 && keylength == 512 && ssl_io->ctx->dh_512 != NULL)
                return ssl_io->ctx->dh_512;
        else
                return ssl_io->ctx->dh_default;
@@ -110,7 +110,7 @@ ssl_iostream_ctx_use_key(struct ssl_iostream_context *ctx,
 
        if (openssl_iostream_load_key(set, &pkey, error_r) < 0)
                return -1;
-       if (!SSL_CTX_use_PrivateKey(ctx->ssl_ctx, pkey)) {
+       if (SSL_CTX_use_PrivateKey(ctx->ssl_ctx, pkey) == 0) {
                *error_r = t_strdup_printf(
                        "Can't load SSL private key: %s",
                        openssl_iostream_key_load_error());
@@ -149,7 +149,7 @@ static int ssl_ctx_use_certificate_chain(SSL_CTX *ctx, const char *cert)
                
                while ((ca = PEM_read_bio_X509(in,NULL,NULL,NULL)) != NULL) {
                        r = SSL_CTX_add_extra_chain_cert(ctx, ca);
-                       if (!r) {
+                       if (r == 0) {
                                X509_free(ca);
                                ret = 0;
                                goto end;
@@ -194,7 +194,7 @@ static int load_ca(X509_STORE *store, const char *ca,
                i_fatal("sk_X509_NAME_new_null() failed");
        for(i = 0; i < sk_X509_INFO_num(inf); i++) {
                itmp = sk_X509_INFO_value(inf, i);
-               if(itmp->x509) {
+               if(itmp->x509 != NULL) {
                        X509_STORE_add_cert(store, itmp->x509);
                        xname = X509_get_subject_name(itmp->x509);
                        if (xname != NULL)
@@ -202,7 +202,7 @@ static int load_ca(X509_STORE *store, const char *ca,
                        if (xname != NULL)
                                sk_X509_NAME_push(xnames, xname);
                }
-               if(itmp->crl)
+               if(itmp->crl != NULL)
                        X509_STORE_add_crl(store, itmp->crl);
        }
        sk_X509_INFO_pop_free(inf, X509_INFO_free);
@@ -269,7 +269,7 @@ ssl_iostream_context_load_ca(struct ssl_iostream_context *ctx,
        ca_dir = set->ca_dir == NULL || *set->ca_dir == '\0' ?
                NULL : set->ca_dir;
        if (ca_file != NULL || ca_dir != NULL) {
-               if (!SSL_CTX_load_verify_locations(ctx->ssl_ctx, ca_file, ca_dir)) {
+               if (SSL_CTX_load_verify_locations(ctx->ssl_ctx, ca_file, ca_dir) == 0) {
                        *error_r = t_strdup_printf(
                                "Can't load CA certs from directory %s: %s",
                                set->ca_dir, openssl_iostream_error());
@@ -294,7 +294,7 @@ ssl_iostream_context_set(struct ssl_iostream_context *ctx,
 {
        ctx->set = ssl_iostream_settings_dup(ctx->pool, set);
        if (set->cipher_list != NULL &&
-           !SSL_CTX_set_cipher_list(ctx->ssl_ctx, set->cipher_list)) {
+           SSL_CTX_set_cipher_list(ctx->ssl_ctx, set->cipher_list) == 0) {
                *error_r = t_strdup_printf("Can't set cipher list to '%s': %s",
                        set->cipher_list, openssl_iostream_error());
                return -1;
@@ -385,7 +385,7 @@ ssl_proxy_ctx_set_crypto_params(SSL_CTX *ssl_ctx,
        int nid;
        const char *curve_name;
 #endif
-       if (SSL_CTX_need_tmp_RSA(ssl_ctx))
+       if (SSL_CTX_need_tmp_RSA(ssl_ctx) != 0)
                SSL_CTX_set_tmp_rsa_callback(ssl_ctx, ssl_gen_rsa_key);
        SSL_CTX_set_tmp_dh_callback(ssl_ctx, ssl_tmp_dh_callback);
 #ifdef HAVE_ECDH
@@ -396,7 +396,7 @@ ssl_proxy_ctx_set_crypto_params(SSL_CTX *ssl_ctx,
 #ifdef SSL_CTRL_SET_ECDH_AUTO
        /* OpenSSL >= 1.0.2 automatically handles ECDH temporary key parameter
           selection. */
-       if (!SSL_CTX_set_ecdh_auto(ssl_ctx, 1)) {
+       if (SSL_CTX_set_ecdh_auto(ssl_ctx, 1) == 0) {
                /* shouldn't happen */
                *error_r = t_strdup_printf("SSL_CTX_set_ecdh_auto() failed: %s",
                                           openssl_iostream_error());
index 18b2e43bc06efbbdbbc81ecc233bc367d6707262..db5c1216fcd344c71de245c0b44c35f35fc0a971 100644 (file)
@@ -121,7 +121,7 @@ openssl_iostream_verify_client_cert(int preverify_ok, X509_STORE_CTX *ctx)
                certname[0] = '\0';
        else
                certname[sizeof(certname)-1] = '\0'; /* just in case.. */
-       if (!preverify_ok) {
+       if (preverify_ok == 0) {
                openssl_iostream_set_error(ssl_io, t_strdup_printf(
                        "Received invalid SSL certificate: %s: %s",
                        X509_verify_cert_error_string(ctx->error), certname));
@@ -130,7 +130,7 @@ openssl_iostream_verify_client_cert(int preverify_ok, X509_STORE_CTX *ctx)
        } else if (ssl_io->verbose) {
                i_info("Received valid SSL certificate: %s", certname);
        }
-       if (!preverify_ok) {
+       if (preverify_ok == 0) {
                ssl_io->cert_broken = TRUE;
                if (ssl_io->require_valid_cert) {
                        ssl_io->handshake_failed = TRUE;
@@ -153,7 +153,7 @@ openssl_iostream_set(struct ssl_iostream *ssl_io,
 
        if (set->cipher_list != NULL &&
            strcmp(ctx_set->cipher_list, set->cipher_list) != 0) {
-               if (!SSL_set_cipher_list(ssl_io->ssl, set->cipher_list)) {
+               if (SSL_set_cipher_list(ssl_io->ssl, set->cipher_list) == 0) {
                        *error_r = t_strdup_printf(
                                "Can't set cipher list to '%s': %s",
                                set->cipher_list, openssl_iostream_error());
index 522284a0d4f88d69dadf722eaf4b5bbda815d2b6..d7b39099834eed316667a9950241a5d744405261 100644 (file)
@@ -127,23 +127,23 @@ maildir_filename_flags_full_set(struct maildir_keywords_sync_ctx *ctx,
                nextflag = *oldflags == '\0' || *oldflags == MAILDIR_FLAGS_SEP ?
                        256 : (unsigned char) *oldflags;
 
-               if ((flags_left & MAIL_DRAFT) && nextflag > 'D') {
+               if ((flags_left & MAIL_DRAFT) != 0 && nextflag > 'D') {
                        str_append_c(flags_str, 'D');
                        flags_left &= ~MAIL_DRAFT;
                }
-               if ((flags_left & MAIL_FLAGGED) && nextflag > 'F') {
+               if ((flags_left & MAIL_FLAGGED) != 0 && nextflag > 'F') {
                        str_append_c(flags_str, 'F');
                        flags_left &= ~MAIL_FLAGGED;
                }
-               if ((flags_left & MAIL_ANSWERED) && nextflag > 'R') {
+               if ((flags_left & MAIL_ANSWERED) != 0 && nextflag > 'R') {
                        str_append_c(flags_str, 'R');
                        flags_left &= ~MAIL_ANSWERED;
                }
-               if ((flags_left & MAIL_SEEN) && nextflag > 'S') {
+               if ((flags_left & MAIL_SEEN) != 0 && nextflag > 'S') {
                        str_append_c(flags_str, 'S');
                        flags_left &= ~MAIL_SEEN;
                }
-               if ((flags_left & MAIL_DELETED) && nextflag > 'T') {
+               if ((flags_left & MAIL_DELETED) != 0 && nextflag > 'T') {
                        str_append_c(flags_str, 'T');
                        flags_left &= ~MAIL_DELETED;
                }
index 2f76cf1715a6bd9f99d822533d3c7f600f80cc54..95c28891a214cd7026e62179fb5df4638ee9f882 100644 (file)
@@ -66,7 +66,7 @@ unsigned int maildir_filename_base_hash(const char *s)
        while (*s != MAILDIR_INFO_SEP && *s != '\0') {
                i_assert(*s != '/');
                h = (h << 4) + *s;
-               if ((g = h & 0xf0000000UL)) {
+               if ((g = h & 0xf0000000UL) != 0) {
                        h = h ^ (g >> 24);
                        h = h ^ g;
                }
index e2f80df698ee29d72486e9f32b4501687e0546a5..7c23b29165bd921095d1fd8d4f613f837918da76 100644 (file)
@@ -185,7 +185,7 @@ int mbox_file_seek(struct mbox_mailbox *mbox, struct mail_index_view *view,
                        return -1;
                }
 
-               if (mbox->mbox_hdr.dirty_flag)
+               if (mbox->mbox_hdr.dirty_flag != 0)
                        return 0;
 
                mail_storage_set_critical(&mbox->storage->storage,
@@ -196,7 +196,7 @@ int mbox_file_seek(struct mbox_mailbox *mbox, struct mail_index_view *view,
                return 0;
        }
 
-       if (mbox->mbox_hdr.dirty_flag) {
+       if (mbox->mbox_hdr.dirty_flag != 0) {
                /* we're dirty - make sure this is the correct mail */
                if (!mbox_sync_parse_match_mail(mbox, view, seq))
                        return 0;
index 9b6ff4ffc45a083750a90e1a28bef3a82150255e..99cf5b1780901d3c4c41bc2e3a53571a0ae121cb 100644 (file)
@@ -848,7 +848,7 @@ int mbox_unlock(struct mbox_mailbox *mbox, unsigned int lock_id)
 
        i_assert(mbox->mbox_lock_id == (lock_id & ~1));
 
-       if (lock_id & 1) {
+       if ((lock_id & 1) != 0) {
                /* dropping exclusive lock */
                i_assert(mbox->mbox_excl_locks > 0);
                if (--mbox->mbox_excl_locks > 0)
index 47bde17c32c012b561aebb625ec88c08ff61240e..d19612773faecdf2fbbba6c5e620fc683e1b2a03 100644 (file)
@@ -642,7 +642,7 @@ int mbox_save_continue(struct mail_save_context *_ctx)
 
        i_assert(ctx->last_char == '\n');
 
-       if (ctx->mbox_md5_ctx) {
+       if (ctx->mbox_md5_ctx != NULL) {
                unsigned char hdr_md5_sum[16];
 
                if (ctx->x_delivery_id_header != NULL) {
index ce09d7d602fb02aaffbd14e0da5381599e00baee..9b9fc5df9277d1e808946a117ddc7bcf24f71ef4 100644 (file)
@@ -965,7 +965,7 @@ static int mbox_sync_partial_seek_next(struct mbox_sync_context *sync_ctx,
        } else {
                /* if there's no sync records left, we can stop. except if
                   this is a dirty sync, check if there are new messages. */
-               if (!sync_ctx->mbox->mbox_hdr.dirty_flag)
+               if (sync_ctx->mbox->mbox_hdr.dirty_flag == 0)
                        return 0;
 
                messages_count =
@@ -1067,7 +1067,7 @@ static int mbox_sync_loop(struct mbox_sync_context *sync_ctx,
                if (mail_ctx->mail.uid_broken && partial) {
                        /* UID ordering problems, resync everything to make
                           sure we get everything right */
-                       if (sync_ctx->mbox->mbox_hdr.dirty_flag)
+                       if (sync_ctx->mbox->mbox_hdr.dirty_flag != 0)
                                return 0;
 
                        mbox_sync_set_critical(sync_ctx,
@@ -1618,7 +1618,7 @@ static int mbox_sync_do(struct mbox_sync_context *sync_ctx,
        } else if ((uint32_t)st->st_mtime == mbox_hdr->sync_mtime &&
                   (uint64_t)st->st_size == mbox_hdr->sync_size) {
                /* file is fully synced */
-               if (mbox_hdr->dirty_flag && (flags & MBOX_SYNC_UNDIRTY) != 0)
+               if (mbox_hdr->dirty_flag != 0 && (flags & MBOX_SYNC_UNDIRTY) != 0)
                        partial = FALSE;
                else
                        partial = TRUE;
@@ -1777,7 +1777,7 @@ int mbox_sync_has_changed_full(struct mbox_mailbox *mbox, bool leave_dirty,
        if ((uint32_t)st->st_mtime == mbox->mbox_hdr.sync_mtime &&
            (uint64_t)st->st_size == mbox->mbox_hdr.sync_size) {
                /* fully synced */
-               if (!mbox->mbox_hdr.dirty_flag || leave_dirty)
+               if (mbox->mbox_hdr.dirty_flag != 0 || leave_dirty)
                        return 0;
                /* flushing dirtyness */
        }
index 5c805b2119074ea5a28cad9e3c3b9ee6335fcd22..9d1a40a81358c90b47c4c4aea4c63c9ba4c0f7f8 100644 (file)
@@ -399,7 +399,7 @@ static void search_arg_foreach(struct mail_search_arg *arg,
                        subarg = subarg->next;
                }
                if (arg->match_not && arg->result != -1)
-                       arg->result = !arg->result;
+                       arg->result = arg->result > 0 ? 0 : 1;
        } else if (arg->type == SEARCH_OR) {
                /* OR-list of conditions */
                i_assert(arg->value.subargs != NULL);
@@ -421,7 +421,7 @@ static void search_arg_foreach(struct mail_search_arg *arg,
                        subarg = subarg->next;
                }
                if (arg->match_not && arg->result != -1)
-                       arg->result = !arg->result;
+                       arg->result = arg->result > 0 ? 0 : 1;
        } else {
                /* just a single condition */
                callback(arg, context);
index 2e17891364d000c945b98060d0288efa621367c9..ed35b89ac47d63bf74b24f1fb1bffd3d4574ab36 100644 (file)
@@ -126,7 +126,7 @@ struct mail_search_args {
 #define ARG_SET_RESULT(arg, res) \
        STMT_START { \
                (arg)->result = !(arg)->match_not ? (res) : \
-                       (res) == -1 ? -1 : !(res); \
+                       ((res) == -1 ? -1 : ((res) == 0 ? 1 : 0)); \
        } STMT_END
 
 typedef void mail_search_foreach_callback_t(struct mail_search_arg *arg,
index ea5ad5ad65e1496a36fc03f21e85c678a35c7172..23875ba59f0adff9b5442ec63c6dde343bd60dcf 100644 (file)
@@ -17,7 +17,7 @@ static void askpass_str(const char *prompt, buffer_t *pass)
        char ch;
        int fd;
 
-       tty = isatty(STDIN_FILENO);
+       tty = isatty(STDIN_FILENO) != 0;
        if (tty) {
                fputs(prompt, stderr);
                fflush(stderr);
index dfe9e954c405813b39651646cc2dcd8295f14db7..723c79a4a0acf8c0a2f4541a8b97c58b7cc9fb8c 100644 (file)
@@ -19,11 +19,11 @@ void buffer_create_from_data(buffer_t *buffer, void *data, size_t size);
 void buffer_create_from_const_data(buffer_t *buffer,
                                   const void *data, size_t size);
 #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) > 401
-#define buffer_create_from_data(b,d,s) ({                                      \
-       (void)COMPILE_ERROR_IF_TRUE(__builtin_object_size((d),1) < ((s)?(s):1)); \
+#define buffer_create_from_data(b,d,s) ({                                         \
+       (void)COMPILE_ERROR_IF_TRUE(__builtin_object_size((d),1) < ((s)>0?(s):1)); \
        buffer_create_from_data((b), (d), (s)); })
-#define buffer_create_from_const_data(b,d,s) ({                                        \
-       (void)COMPILE_ERROR_IF_TRUE(__builtin_object_size((d),1) < ((s)?(s):1)); \
+#define buffer_create_from_const_data(b,d,s) ({                                           \
+       (void)COMPILE_ERROR_IF_TRUE(__builtin_object_size((d),1) < ((s)>0?(s):1)); \
        buffer_create_from_const_data((b), (d), (s)); })
 #endif
 /* Creates a dynamically growing buffer. Whenever write would exceed the
index f6bb6e3526031035d29dcadc10b087cce91f8f37..8f8b27a112ef5ff797becf6f344f61b40c66f633 100644 (file)
@@ -202,19 +202,19 @@ int i_my_clock_gettime(int clk_id, struct timespec *tp);
    use our own instead if really needed */
 #define i_toupper(x) ((char) toupper((int) (unsigned char) (x)))
 #define i_tolower(x) ((char) tolower((int) (unsigned char) (x)))
-#define i_isalnum(x) isalnum((int) (unsigned char) (x))
-#define i_isalpha(x) isalpha((int) (unsigned char) (x))
-#define i_isascii(x) isascii((int) (unsigned char) (x))
-#define i_isblank(x) isblank((int) (unsigned char) (x))
-#define i_iscntrl(x) iscntrl((int) (unsigned char) (x))
-#define i_isdigit(x) isdigit((int) (unsigned char) (x))
-#define i_isgraph(x) isgraph((int) (unsigned char) (x))
-#define i_islower(x) islower((int) (unsigned char) (x))
-#define i_isprint(x) isprint((int) (unsigned char) (x))
-#define i_ispunct(x) ispunct((int) (unsigned char) (x))
-#define i_isspace(x) isspace((int) (unsigned char) (x))
-#define i_isupper(x) isupper((int) (unsigned char) (x))
-#define i_isxdigit(x) isxdigit((int) (unsigned char) (x))
+#define i_isalnum(x) (isalnum((int) (unsigned char) (x)) != 0)
+#define i_isalpha(x) (isalpha((int) (unsigned char) (x)) != 0)
+#define i_isascii(x) (isascii((int) (unsigned char) (x)) != 0)
+#define i_isblank(x) (isblank((int) (unsigned char) (x)) != 0)
+#define i_iscntrl(x) (iscntrl((int) (unsigned char) (x)) != 0)
+#define i_isdigit(x) (isdigit((int) (unsigned char) (x)) != 0)
+#define i_isgraph(x) (isgraph((int) (unsigned char) (x)) != 0)
+#define i_islower(x) (islower((int) (unsigned char) (x)) != 0)
+#define i_isprint(x) (isprint((int) (unsigned char) (x)) != 0)
+#define i_ispunct(x) (ispunct((int) (unsigned char) (x)) != 0)
+#define i_isspace(x) (isspace((int) (unsigned char) (x)) != 0)
+#define i_isupper(x) (isupper((int) (unsigned char) (x)) != 0)
+#define i_isxdigit(x) (isxdigit((int) (unsigned char) (x)) != 0)
 
 #ifndef EOVERFLOW
 #  define EOVERFLOW ERANGE
index 1f592d233dc1aeb015b97aa5d87bb5ef39097c50..e7d66d2bde45ff3c9c64a24875b088f2517ee44c 100644 (file)
@@ -145,7 +145,7 @@ ssize_t file_cache_read(struct file_cache *cache, uoff_t offset, size_t size)
        dest_size = page_size;
 
        while (psize > 0) {
-               if (bits[poffset / CHAR_BIT] & (1 << (poffset % CHAR_BIT))) {
+               if ((bits[poffset / CHAR_BIT] & (1 << (poffset % CHAR_BIT))) != 0) {
                        /* page is already in cache */
                        dest_offset += page_size;
                        if (dest_offset <= cache->read_highwater) {
index dab0d898a699a31f5dd5a36ec619288ff26fef27..92b66ae729fc58a626316f52b5b8f30b67888f13 100644 (file)
@@ -185,7 +185,7 @@ static int file_lock_do(int fd, const char *path, int lock_type,
                fl.l_start = 0;
                fl.l_len = 0;
 
-               ret = fcntl(fd, timeout_secs ? F_SETLKW : F_SETLK, &fl);
+               ret = fcntl(fd, timeout_secs != 0 ? F_SETLKW : F_SETLK, &fl);
                if (timeout_secs != 0) alarm(0);
 
                if (ret == 0)
index c1f5917c598be4b6f634c3d9e452314ec9a4b9f0..a544e01c98dc2fca336c1091e8f24f9d2d9a1a07 100644 (file)
@@ -513,7 +513,7 @@ unsigned int str_hash(const char *p)
 
        while (*s != '\0') {
                h = (h << 4) + *s;
-               if ((g = h & 0xf0000000UL)) {
+               if ((g = h & 0xf0000000UL) != 0) {
                        h = h ^ (g >> 24);
                        h = h ^ g;
                }
@@ -531,7 +531,7 @@ unsigned int strcase_hash(const char *p)
 
        while (*s != '\0') {
                h = (h << 4) + i_toupper(*s);
-               if ((g = h & 0xf0000000UL)) {
+               if ((g = h & 0xf0000000UL) != 0) {
                        h = h ^ (g >> 24);
                        h = h ^ g;
                }
@@ -548,7 +548,7 @@ unsigned int mem_hash(const void *p, unsigned int size)
 
        for (i = 0; i < size; i++) {
                h = (h << 4) + *s;
-               if ((g = h & 0xf0000000UL)) {
+               if ((g = h & 0xf0000000UL) != 0) {
                        h = h ^ (g >> 24);
                        h = h ^ g;
                }
index e2f05105bfbd84a7206b09931bdd1851c24c423e..05fc1edf7e4870211eed52258898e3a26cfea560 100644 (file)
@@ -99,8 +99,8 @@ void io_loop_handle_remove(struct io_file *io, bool closed ATTR_UNUSED)
 }
 
 #define io_check_condition(ctx, fd, cond) \
-       ((FD_ISSET((fd), &(ctx)->tmp_read_fds) && ((cond) & (IO_READ|IO_ERROR))) || \
-        (FD_ISSET((fd), &(ctx)->tmp_write_fds) && ((cond) & IO_WRITE)) || \
+       ((FD_ISSET((fd), &(ctx)->tmp_read_fds) && ((cond) & (IO_READ|IO_ERROR)) != 0) || \
+        (FD_ISSET((fd), &(ctx)->tmp_write_fds) && ((cond) & IO_WRITE) != 0) || \
         (FD_ISSET((fd), &(ctx)->tmp_except_fds)))
 
 void io_loop_handler_run_internal(struct ioloop *ioloop)
index 2faf0c8cf17808aa4f59c3d2ac30dcfdc2ee6796..247f4baf83a8ae6236dad763773fe1d333b03456 100644 (file)
 #endif
 
 #if __GNUC__ > 2
-#  define unlikely(expr) __builtin_expect(!!(expr), 0)
-#  define likely(expr) __builtin_expect(!!(expr), 1)
+#  define unlikely(expr) (__builtin_expect((expr) ? 1 : 0, 0) != 0)
+#  define likely(expr) (__builtin_expect((expr) ? 1 : 0, 1) != 0)
 #else
 #  define unlikely(expr) expr
 #  define likely(expr) expr
index de59b38c81fd7df5bafb093181fb0708b0ddfa1e..49fc0b3c71bf8f9a01814f8501c15a3b6336492e 100644 (file)
@@ -152,7 +152,7 @@ body(struct md4_context *ctx, const void *data, size_t size)
                d += saved_d;
 
                ptr += 64;
-       } while (size -= 64);
+       } while ((size -= 64) != 0);
 
        ctx->a = a;
        ctx->b = b;
@@ -186,7 +186,7 @@ void md4_update(struct md4_context *ctx, const void *data, size_t size)
 
        used = saved_lo & 0x3f;
 
-       if (used) {
+       if (used != 0) {
                free = 64 - used;
 
                if (size < free) {
index 16264290c557727bd9e3e26d799e1bcde80464c3..00eeaa81cf677a35734f4637b46aa0a4b0696594 100644 (file)
@@ -164,7 +164,7 @@ body(struct md5_context *ctx, const void *data, size_t size)
                d += saved_d;
 
                ptr += 64;
-       } while (size -= 64);
+       } while ((size -= 64) != 0);
 
        ctx->a = a;
        ctx->b = b;
@@ -198,7 +198,7 @@ void md5_update(struct md5_context *ctx, const void *data, size_t size)
 
        used = saved_lo & 0x3f;
 
-       if (used) {
+       if (used != 0) {
                free = 64 - used;
 
                if (size < free) {
index 06034eb4c4989ee681d62ded642e4752c3321f46..3e6b5accf528dc6d6b46d4193a5aaa97e2540049 100644 (file)
@@ -66,7 +66,7 @@ unsigned int net_ip_hash(const struct ip_addr *ip)
 
        for (; len > 0; len--, p++) {
                h = (h << 4) + *p;
-               if ((g = h & 0xf0000000UL)) {
+               if ((g = h & 0xf0000000UL) != 0) {
                        h = h ^ (g >> 24);
                        h = h ^ g;
                }
index c79d144dc39bcb919d1c589de1a10d6f3e8dc5ce..e79dbef532414217dd26a5b30b784e2ee5c42c9b 100644 (file)
@@ -38,7 +38,7 @@ test_timing_verify(const struct timing *t, const int64_t *input,
                        timing_get_median(t) <= copy[input_size/2],
                        input_size);
        /* when we have 20 elements, [19] is the max, not the 95th %ile, so subtract 1 */
-       test_assert_idx(timing_get_95th(t) == copy[input_size*95/100 - !(input_size%20)],
+       test_assert_idx(timing_get_95th(t) == copy[input_size*95/100 - ((input_size%20) == 0 ? 1 : 0)],
                        input_size);
 
        i_free(copy);
index e83aa2365645328ba3120c1d7ddfabd2b807dfed..c86b1ef544c4b4670ee187c0b23557021875241c 100644 (file)
@@ -83,7 +83,7 @@ void test_unichar(void)
        collate_out = buffer_create_dynamic(default_pool, 32);
        uni_utf8_to_decomposed_titlecase(collate_in, sizeof(collate_in),
                                         collate_out);
-       test_assert(!strcmp(collate_out->data, collate_exp));
+       test_assert(strcmp(collate_out->data, collate_exp) == 0);
        buffer_free(&collate_out);
 
        test_assert(!uni_utf8_str_is_valid(overlong_utf8));
index d334c8ed57779b484f69c4ad74a5dc411f3d9aab..fdc872348cfff0966e3dd71c29623630c8355789 100644 (file)
@@ -129,7 +129,7 @@ m_str_ldap_dn(const char *str, struct var_expand_context *ctx ATTR_UNUSED)
 {
        string_t *ret = t_str_new(256);
 
-       while (*str) {
+       while (*str != '\0') {
                if (*str == '.')
                        str_append(ret, ",dc=");
                else
index 925052b7be648c9cdc98d8ed3f3293ceae309a22..c33ef5bbc229ea89a6fe11955056905bb74bf7de 100644 (file)
@@ -35,16 +35,16 @@ static int wildcard_match_int(const char *data, const char *mask, bool icase)
          return ma[0] == '\0' ? MATCH : NOMATCH;
   }
   /* find the end of each string */
-  while (*(mask++));
+  while (*(mask++) != '\0');
   mask-=2;
-  while (*(data++));
+  while (*(data++) != '\0');
   data-=2;
 
   while (data >= na) {
     /* If the mask runs out of chars before the string, fall back on
      * a wildcard or fail. */
     if (mask < ma) {
-      if (lsm) {
+      if (lsm != NULL) {
         data = --lsn;
         mask = lsm;
         if (data < na)
@@ -79,7 +79,7 @@ static int wildcard_match_int(const char *data, const char *mask, bool icase)
       sofar++;                  /* Tally the match */
       continue;                 /* Next char, please */
     }
-    if (lsm) {                  /* To to fallback on '*' */
+    if (lsm != NULL) {          /* To to fallback on '*' */
       data = --lsn;
       mask = lsm;
       if (data < na)
index 49a3c59aed415d0594451881d639b575e07e5c30..8323b02dae3fb43a5dd8bf417d94f6a85d356b64 100644 (file)
@@ -135,7 +135,7 @@ static void master_send_request(struct anvil_request *anvil_request)
        req.remote_ip = client->ip;
        req.client_pid = getpid();
        if (client->ssl_proxy != NULL &&
-           ssl_proxy_get_compression(client->ssl_proxy))
+           ssl_proxy_get_compression(client->ssl_proxy) != NULL)
                req.flags |= MAIL_AUTH_REQUEST_FLAG_TLS_COMPRESSION;
        memcpy(req.cookie, anvil_request->cookie, sizeof(req.cookie));
 
index b1c6498af16e39630e40558c0895eac112374fbf..fc9ef65ae28c3f4ed01e3ea703c9a94273c41d7b 100644 (file)
@@ -147,7 +147,7 @@ static unsigned int ssl_server_context_hash(const struct ssl_server_context *ctx
           and it should be enough to check only the first few bytes. */
        for (i = 0; i < 16 && ctx->cert[i] != '\0'; i++) {
                h = (h << 4) + ctx->cert[i];
-               if ((g = h & 0xf0000000UL)) {
+               if ((g = h & 0xf0000000UL) != 0) {
                        h = h ^ (g >> 24);
                        h = h ^ g;
                }
@@ -832,7 +832,7 @@ static RSA *ssl_gen_rsa_key(SSL *ssl ATTR_UNUSED,
 static DH *ssl_tmp_dh_callback(SSL *ssl ATTR_UNUSED,
                               int is_export, int keylength)
 {
-       if (is_export && keylength == 512 && ssl_params.dh_512 != NULL)
+       if (is_export != 0 && keylength == 512 && ssl_params.dh_512 != NULL)
                return ssl_params.dh_512;
 
        return ssl_params.dh_default;
@@ -890,7 +890,7 @@ static int ssl_verify_client_cert(int preverify_ok, X509_STORE_CTX *ctx)
                /* no CRL given with the CA list. don't worry about it. */
                preverify_ok = 1;
        }
-       if (!preverify_ok)
+       if (preverify_ok == 0)
                proxy->cert_broken = TRUE;
 
        subject = X509_get_subject_name(ctx->current_cert);
@@ -903,8 +903,8 @@ static int ssl_verify_client_cert(int preverify_ok, X509_STORE_CTX *ctx)
        }
 
        if (proxy->ssl_set->verbose_ssl ||
-           (proxy->login_set->auth_verbose && !preverify_ok)) {
-               if (preverify_ok) {
+           (proxy->login_set->auth_verbose && preverify_ok == 0)) {
+               if (preverify_ok != 0) {
                        client_log(proxy->client, t_strdup_printf(
                                "Valid certificate: %s", buf));
                } else {
@@ -964,7 +964,7 @@ static void load_ca(X509_STORE *store, const char *ca,
        }
        for(i = 0; i < sk_X509_INFO_num(inf); i++) {
                itmp = sk_X509_INFO_value(inf, i);
-               if(itmp->x509) {
+               if(itmp->x509 != NULL) {
                        X509_STORE_add_cert(store, itmp->x509);
                        xname = X509_get_subject_name(itmp->x509);
                        if (xname != NULL && xnames_r != NULL) {
@@ -974,7 +974,7 @@ static void load_ca(X509_STORE *store, const char *ca,
                                sk_X509_NAME_push(*xnames_r, xname);
                        }
                }
-               if(itmp->crl)
+               if(itmp->crl != NULL)
                        X509_STORE_add_crl(store, itmp->crl);
        }
        sk_X509_INFO_pop_free(inf, X509_INFO_free);
@@ -1023,7 +1023,7 @@ ssl_proxy_ctx_set_crypto_params(SSL_CTX *ssl_ctx,
        int nid;
        const char *curve_name;
 #endif
-       if (SSL_CTX_need_tmp_RSA(ssl_ctx))
+       if (SSL_CTX_need_tmp_RSA(ssl_ctx) != 0)
                SSL_CTX_set_tmp_rsa_callback(ssl_ctx, ssl_gen_rsa_key);
        SSL_CTX_set_tmp_dh_callback(ssl_ctx, ssl_tmp_dh_callback);
 #ifdef HAVE_ECDH
@@ -1175,7 +1175,7 @@ ssl_proxy_ctx_use_certificate_chain(SSL_CTX *ctx, const char *cert)
                
                while ((ca = PEM_read_bio_X509(in,NULL,NULL,NULL)) != NULL) {
                        r = SSL_CTX_add_extra_chain_cert(ctx, ca);
-                       if (!r) {
+                       if (r == 0) {
                                X509_free(ca);
                                ret = 0;
                                goto end;
index d0f1df69a122402654fc0a74d40f3f8e3985198b..6883cc707281da13ca406bc31d532991d903bfc9 100644 (file)
@@ -439,7 +439,7 @@ log_coredump(struct service *service, string_t *str, int status)
 #ifdef WCOREDUMP
        int signum = WTERMSIG(status);
 
-       if (WCOREDUMP(status)) {
+       if (WCOREDUMP(status) != 0) {
                str_append(str, " (core dumped)");
                return;
        }
index 8fe13c8e8c324af5964f6ac06cdd84d120936f98..da1c3c1299079dedebb395919706cd6da8ab0517 100644 (file)
@@ -499,7 +499,7 @@ static unsigned int wstr_hash(const wchar_t *s)
 
        while (*s != '\0') {
                h = (h << 4) + *s;
-               if ((g = h & 0xf0000000UL)) {
+               if ((g = h & 0xf0000000UL) != 0) {
                        h = h ^ (g >> 24);
                        h = h ^ g;
                }
index 08edcd8d96fbaa417052eb9e1e7212677acda36a..4be3a4c172bb3510aba957d46fe1638324f4293f 100644 (file)
@@ -83,7 +83,7 @@ static int solr_xml_parse(struct solr_connection *conn,
        if (conn->xml_failed)
                return -1;
 
-       if (XML_Parse(conn->xml_parser, data, size, done))
+       if (XML_Parse(conn->xml_parser, data, size, done) != 0)
                return 0;
 
        err = XML_GetErrorCode(conn->xml_parser);
index c2371b23cb7e5a969af62b77fd86d47a1cd4a8f2..fbe6542c094cac7a683c14c61d5c2e6b990598c5 100644 (file)
@@ -29,19 +29,19 @@ static void push_notification_event_flagsclear_debug_msg
     struct push_notification_event_flagsclear_data *data = event->data;
     const char *const *keyword;
 
-    if (data->flags_clear & MAIL_ANSWERED) {
+    if ((data->flags_clear & MAIL_ANSWERED) != 0) {
         i_debug("%s: Answered flag cleared", EVENT_NAME);
     }
-    if (data->flags_clear & MAIL_FLAGGED) {
+    if ((data->flags_clear & MAIL_FLAGGED) != 0) {
         i_debug("%s: Flagged flag cleared", EVENT_NAME);
     }
-    if (data->flags_clear & MAIL_DELETED) {
+    if ((data->flags_clear & MAIL_DELETED) != 0) {
         i_debug("%s: Deleted flag cleared", EVENT_NAME);
     }
-    if (data->flags_clear & MAIL_SEEN) {
+    if ((data->flags_clear & MAIL_SEEN) != 0) {
         i_debug("%s: Seen flag cleared", EVENT_NAME);
     }
-    if (data->flags_clear & MAIL_DRAFT) {
+    if ((data->flags_clear & MAIL_DRAFT) != 0) {
         i_debug("%s: Draft flag cleared", EVENT_NAME);
     }
 
@@ -100,8 +100,8 @@ static void push_notification_event_flagsclear_flags_event(
     flags = mail_get_flags(mail);
 
     for (i = 0; i < N_ELEMENTS(flag_check_always); i++) {
-        if (!(flags & flag_check_always[i]) &&
-            (old_flags & flag_check_always[i])) {
+        if ((flags & flag_check_always[i]) == 0 &&
+            (old_flags & flag_check_always[i]) != 0) {
             data->flags_clear |= flag_check_always[i];
         }
     }
index fd4b16202d0c65993dc60ac3b72fc9b122bffd0f..fbcb5011f7e7031bc243e6621cc6cedbbe0da87f 100644 (file)
@@ -29,19 +29,19 @@ static void push_notification_event_flagsset_debug_msg
     struct push_notification_event_flagsset_data *data = event->data;
     const char *const *keyword;
 
-    if (data->flags_set & MAIL_ANSWERED) {
+    if ((data->flags_set & MAIL_ANSWERED) != 0) {
         i_debug("%s: Answered flag set", EVENT_NAME);
     }
-    if (data->flags_set & MAIL_FLAGGED) {
+    if ((data->flags_set & MAIL_FLAGGED) != 0) {
         i_debug("%s: Flagged flag set", EVENT_NAME);
     }
-    if (data->flags_set & MAIL_DELETED) {
+    if ((data->flags_set & MAIL_DELETED) != 0) {
         i_debug("%s: Deleted flag set", EVENT_NAME);
     }
-    if (data->flags_set & MAIL_SEEN) {
+    if ((data->flags_set & MAIL_SEEN) != 0) {
         i_debug("%s: Seen flag set", EVENT_NAME);
     }
-    if (data->flags_set & MAIL_DRAFT) {
+    if ((data->flags_set & MAIL_DRAFT) != 0) {
         i_debug("%s: Draft flag set", EVENT_NAME);
     }
 
@@ -91,26 +91,26 @@ static void push_notification_event_flagsset_flags_event(
     flags = mail_get_flags(mail);
 
     for (i = 0; i < N_ELEMENTS(flag_check_always); i++) {
-        if ((flags & flag_check_always[i]) &&
-            !(old_flags & flag_check_always[i])) {
+        if ((flags & flag_check_always[i]) != 0 &&
+            (old_flags & flag_check_always[i]) == 0) {
             flags_set |= flag_check_always[i];
         }
     }
 
     if (!config->hide_deleted &&
-        (flags & MAIL_DELETED) &&
-        !(old_flags & MAIL_DELETED)) {
+        (flags & MAIL_DELETED) != 0 &&
+        (old_flags & MAIL_DELETED) == 0) {
         flags_set |= MAIL_DELETED;
     }
 
     if (!config->hide_seen &&
-        (flags & MAIL_SEEN) &&
-        !(old_flags & MAIL_SEEN)) {
+        (flags & MAIL_SEEN) != 0 &&
+        (old_flags & MAIL_SEEN) == 0) {
         flags_set |= MAIL_SEEN;
     }
 
     /* Only create data element if at least one flag was set. */
-    if (flags_set) {
+    if (flags_set != 0) {
         data = push_notification_event_flagsset_get_data(ptxn, msg, ec);
         data->flags_set |= flags_set;
     }
index 5f9ce2f8978d6817b7916ad59aae2dca4756c412..88afc14dbeb0bb41fcc124c42998532062a6aea8 100644 (file)
@@ -58,7 +58,7 @@ push_notification_event_messageappend_event(struct push_notification_txn *ptxn,
     struct push_notification_event_messageappend_data *data;
     const char *value;
 
-    if (!config->flags) {
+    if (config->flags == 0) {
         return;
     }
 
@@ -70,25 +70,25 @@ push_notification_event_messageappend_event(struct push_notification_txn *ptxn,
     }
 
     if ((data->to == NULL) &&
-        (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_TO) &&
+        (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_TO) != 0 &&
         (mail_get_first_header(mail, "To", &value) >= 0)) {
         data->to = p_strdup(ptxn->pool, value);
     }
 
     if ((data->from == NULL) &&
-        (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_FROM) &&
+        (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_FROM) != 0 &&
         (mail_get_first_header(mail, "From", &value) >= 0)) {
         data->from = p_strdup(ptxn->pool, value);
     }
 
     if ((data->subject == NULL) &&
-        (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_SUBJECT) &&
+        (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_SUBJECT) != 0 &&
         (mail_get_first_header(mail, "Subject", &value) >= 0)) {
         data->subject = p_strdup(ptxn->pool, value);
     }
 
     if ((data->snippet == NULL) &&
-        (config->flags & PUSH_NOTIFICATION_MESSAGE_BODY_SNIPPET) &&
+        (config->flags & PUSH_NOTIFICATION_MESSAGE_BODY_SNIPPET) != 0 &&
         (mail_get_special(mail, MAIL_FETCH_BODY_SNIPPET, &value) >= 0)) {
         /* [0] contains the snippet algorithm, skip over it */
         i_assert(value[0] != '\0');
index 421cd97ffacddb9d8b0f170b52cc9eff192b1718..61c175906eae686294ab21b3de9c9fd0d6e67171 100644 (file)
@@ -70,7 +70,7 @@ push_notification_event_messagenew_event(struct push_notification_txn *ptxn,
     int tz;
     const char *value;
 
-    if (!config->flags) {
+    if (config->flags == 0) {
         return;
     }
 
@@ -84,32 +84,32 @@ push_notification_event_messagenew_event(struct push_notification_txn *ptxn,
     }
 
     if ((data->to == NULL) &&
-        (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_TO) &&
+        (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_TO) != 0 &&
         (mail_get_first_header(mail, "To", &value) >= 0)) {
         data->to = p_strdup(ptxn->pool, value);
     }
 
     if ((data->from == NULL) &&
-        (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_FROM) &&
+        (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_FROM) != 0 &&
         (mail_get_first_header(mail, "From", &value) >= 0)) {
         data->from = p_strdup(ptxn->pool, value);
     }
 
     if ((data->subject == NULL) &&
-        (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_SUBJECT) &&
+        (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_SUBJECT) != 0 &&
         (mail_get_first_header(mail, "Subject", &value) >= 0)) {
         data->subject = p_strdup(ptxn->pool, value);
     }
 
     if ((data->date == -1) &&
-        (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_DATE) &&
+        (config->flags & PUSH_NOTIFICATION_MESSAGE_HDR_DATE) != 0 &&
         (mail_get_date(mail, &date, &tz) >= 0)) {
         data->date = date;
         data->date_tz = tz;
     }
 
     if ((data->snippet == NULL) &&
-        (config->flags & PUSH_NOTIFICATION_MESSAGE_BODY_SNIPPET) &&
+        (config->flags & PUSH_NOTIFICATION_MESSAGE_BODY_SNIPPET) != 0 &&
         (mail_get_special(mail, MAIL_FETCH_BODY_SNIPPET, &value) >= 0)) {
         /* [0] contains the snippet algorithm, skip over it */
         i_assert(value[0] != '\0');
index 11e07d016d399a8214a3d0e9277ace39bef084f4..c2358040fe5b0b7fab654c6f4977aeff128d3d9f 100644 (file)
@@ -31,9 +31,9 @@ static void push_notification_event_messageread_event(
 
     /* If data struct exists, that means the read flag was changed. */
     data = push_notification_txn_msg_get_eventdata(msg, EVENT_NAME);
-    if ((data == NULL) && !(old_flags & MAIL_SEEN)) {
+    if ((data == NULL) && (old_flags & MAIL_SEEN) == 0) {
         flags = mail_get_flags(mail);
-        if (flags & MAIL_SEEN) {
+        if ((flags & MAIL_SEEN) != 0) {
             data = p_new(ptxn->pool,
                          struct push_notification_event_messageread_data, 1);
             data->read = TRUE;
index 5056db29c345303a753a5bc6e272a0df15099a0a..6a93c10c563dd075dc53df12bbfb5c64c46f4108 100644 (file)
@@ -31,9 +31,9 @@ static void push_notification_event_messagetrash_event(
 
     /* If data struct exists, that means the deleted flag was changed. */
     data = push_notification_txn_msg_get_eventdata(msg, EVENT_NAME);
-    if ((data == NULL) && !(old_flags & MAIL_DELETED)) {
+    if ((data == NULL) && (old_flags & MAIL_DELETED) == 0) {
         flags = mail_get_flags(mail);
-        if (flags & MAIL_DELETED) {
+        if ((flags & MAIL_DELETED) != 0) {
             data = p_new(ptxn->pool,
                          struct push_notification_event_messagetrash_data, 1);
             data->trash = TRUE;
index 4d7f319a0add9b93ff07637acf572fc1f9bd7383..98c8e48148e9730be4ba20dd68bcb7ae0a6893d4 100644 (file)
@@ -158,7 +158,7 @@ static void push_notification_mail_save(void *txn, struct mail *mail)
     push_notification_transaction_init(ptxn);
 
     /* POST_SESSION means MTA delivery. */
-    if (mail->box->flags & MAILBOX_FLAG_POST_SESSION) {
+    if ((mail->box->flags & MAILBOX_FLAG_POST_SESSION) != 0) {
         push_notification_trigger_msg_save_new(ptxn, mail, NULL);
     } else {
         push_notification_trigger_msg_save_append(ptxn, mail, NULL);
index cdc06c7bfbcecd15b2f352961ff69399bec29fee..f8b31175dff23638b9494c2bf19420632f54f507 100644 (file)
@@ -81,6 +81,7 @@ rquota_xdr.c: Makefile rquota.h
         echo '#include <rpc/rpc.h>'; \
         $(RPCGEN) -c $(top_builddir)/src/plugins/quota/rquota.x | \
          sed -e 's/IXDR_PUT/(void)IXDR_PUT/g' \
+           -e 's,!xdr_,0 == xdr_,' \
            -e 's,/usr/include/rpcsvc/rquota.h,rquota.h,' \
            -e 's/int32_t \*buf/int32_t *buf ATTR_UNUSED/' \
            -e 's/^static char rcsid.*//' ) > rquota_xdr.c
index e34b6d191d53072042b5380c060c08650bca3e07..24c9c12fe0df9175096257624b06b502113a242d 100644 (file)
@@ -505,8 +505,8 @@ static const char *client_build_uidl_change_string(struct client *client)
                        new_hash ^= crc32_str(client->message_uidls[i]);
        } else {
                for (i = 0, new_hash = 0; i < client->messages_count; i++) {
-                       if (client->deleted_bitmask[i / CHAR_BIT] &
-                           (1 << (i % CHAR_BIT)))
+                       if ((client->deleted_bitmask[i / CHAR_BIT] &
+                            (1 << (i % CHAR_BIT))) != 0)
                                continue;
                        new_hash ^= crc32_str(client->message_uidls[i]);
                }
index 75582c8ccdedd2e8bc9dda0379d3d30df391421a..27e596045e05b63288c3d988f945137c7d4badc6 100644 (file)
@@ -53,8 +53,8 @@ static const char *get_msgnum(struct client *client, const char *args,
        num--;
 
        if (client->deleted) {
-               if (client->deleted_bitmask[num / CHAR_BIT] &
-                   (1 << (num % CHAR_BIT))) {
+               if ((client->deleted_bitmask[num / CHAR_BIT] &
+                    (1 << (num % CHAR_BIT))) != 0) {
                        client_send_line(client, "-ERR Message is deleted.");
                        return NULL;
                }
@@ -134,8 +134,8 @@ static void cmd_list_callback(struct client *client)
                }
 
                if (client->deleted) {
-                       if (client->deleted_bitmask[ctx->msgnum / CHAR_BIT] &
-                           (1 << (ctx->msgnum % CHAR_BIT)))
+                       if ((client->deleted_bitmask[ctx->msgnum / CHAR_BIT] &
+                            (1 << (ctx->msgnum % CHAR_BIT))) != 0)
                                continue;
                }
 
@@ -656,8 +656,8 @@ list_uidls_saved_iter(struct client *client, struct cmd_uidl_context *ctx)
                uint32_t msgnum = ctx->msgnum++;
 
                if (client->deleted) {
-                       if (client->deleted_bitmask[msgnum / CHAR_BIT] &
-                           (1 << (msgnum % CHAR_BIT)))
+                       if ((client->deleted_bitmask[msgnum / CHAR_BIT] &
+                            (1 << (msgnum % CHAR_BIT))) != 0)
                                continue;
                }
                found = TRUE;
@@ -700,8 +700,8 @@ static bool list_uids_iter(struct client *client, struct cmd_uidl_context *ctx)
                        break;
                }
                if (client->deleted) {
-                       if (client->deleted_bitmask[msgnum / CHAR_BIT] &
-                           (1 << (msgnum % CHAR_BIT)))
+                       if ((client->deleted_bitmask[msgnum / CHAR_BIT] &
+                            (1 << (msgnum % CHAR_BIT))) != 0)
                                continue;
                }
                found = TRUE;