]> git.ipfire.org Git - thirdparty/dovecot/core.git/commitdiff
global: Avoid casting away const
authorTimo Sirainen <timo.sirainen@open-xchange.com>
Fri, 12 Mar 2021 00:58:37 +0000 (02:58 +0200)
committeraki.tuomi <aki.tuomi@open-xchange.com>
Fri, 19 Mar 2021 09:22:44 +0000 (09:22 +0000)
13 files changed:
src/auth/test-mech.c
src/doveadm/doveadm-dump-log.c
src/doveadm/dsync/dsync-ibc-pipe.c
src/imap-hibernate/imap-hibernate-client.c
src/imap/imap-master-client.c
src/lib-http/http-response-parser.c
src/lib-http/test-http-client.c
src/lib-ldap/ldap-search.c
src/lib-mail/test-message-address.c
src/lib-smtp/smtp-parser.c
src/lib-test/test-ostream.c
src/lib/test-array.c
src/lib/uri-util.c

index 7362d5b384589f48799be22892d8e84e5aa11e24..8a2c7b357bd2d99dfff39089574c6657bba87211 100644 (file)
@@ -92,7 +92,7 @@ static void test_mechs_init(void)
        process_start_time = time(NULL);
 
        /* Copy default settings */
-       set = *(struct auth_settings *) auth_setting_parser_info.defaults;
+       set = *(const struct auth_settings *)auth_setting_parser_info.defaults;
        global_auth_settings = &set;
        global_auth_settings->base_dir = ".";
        memset((&set)->username_chars_map, 1, sizeof((&set)->username_chars_map));
index fcfbfd8f80da0f2fa7e61cbdb824997ad5dc8b71..4c1f6eef3bce5aa9d25228e757691fa1f752104b 100644 (file)
@@ -354,7 +354,8 @@ static void log_record_print(const struct mail_transaction_header *hdr,
                record_size = (sizeof(*rec) + prev_intro.record_size + 3) & ~3U;
                while (rec < end) {
                        printf(" - uid=%u: ", rec->uid);
-                       if (prev_intro.record_size <= (char*)end - (char *)(rec+1))
+                       size_t bytes_left = (const char *)end - (const char *)(rec + 1);
+                       if (prev_intro.record_size <= bytes_left)
                                print_data(rec + 1, prev_intro.record_size);
                        else
                                printf("(record_size too large)");
index bb552dfa8b18e877f1544e9ac0e5aa6290f483eb..14b31ade0725711bb474580ad12c34f5c5b79426 100644 (file)
@@ -279,7 +279,7 @@ dsync_ibc_pipe_recv_mailbox_tree_node(struct dsync_ibc *ibc,
        if (item == NULL)
                return DSYNC_IBC_RECV_RET_TRYAGAIN;
 
-       *name_r = (void *)item->u.node.name;
+       *name_r = (const void *)item->u.node.name;
        item->u.node.name = NULL;
 
        *node_r = &item->u.node;
index 29992b0ca052e38d4358fbf9f3cddccebd89a5d9..4065adc5925819e1d68972db0671eced52ef7d13 100644 (file)
@@ -224,7 +224,8 @@ imap_hibernate_client_input_line(struct connection *conn, const char *line)
 
                pool = pool_alloconly_create("client cmd", 1024);
                args = p_strsplit_tabescaped(pool, line);
-               ret = imap_hibernate_client_input_args(conn, (void *)args, fd, pool);
+               ret = imap_hibernate_client_input_args(conn, (const void *)args,
+                                                      fd, pool);
                if (ret >= 0 && client->debug)
                        e_debug(conn->event, "Create client with input: %s", line);
                pool_unref(&pool);
index 0257fb2de892a421ea0ff921d6e41c2011650801..f3556de58149c9f52746015c9a152046a676acd4 100644 (file)
@@ -371,7 +371,8 @@ imap_master_client_input_line(struct connection *conn, const char *line)
 
        pool = pool_alloconly_create("imap master client cmd", 1024);
        args = p_strsplit_tabescaped(pool, line);
-       ret = imap_master_client_input_args(conn, (void *)args, fd_client, pool);
+       ret = imap_master_client_input_args(conn, (const void *)args,
+                                           fd_client, pool);
        pool_unref(&pool);
        return ret;
 }
index e7162ee45e82f7fa2cc0f9bee59a23c7c039887a..e381403337b4dc08878bc3d5fbfd250ba4602574 100644 (file)
@@ -303,7 +303,7 @@ http_response_parse_retry_after(const char *hdrval, time_t resp_time,
        }
 
        return (http_date_parse
-               ((unsigned char *)hdrval, strlen(hdrval), retry_after_r) ? 0 : -1);
+               ((const unsigned char *)hdrval, strlen(hdrval), retry_after_r) ? 0 : -1);
 }
 
 uoff_t http_response_parser_get_last_offset(struct http_response_parser *parser)
index ecde11ef74dcafba05f78e9c858fd4770ee0fe4c..fc24bfa50d066e649694dd7cd555a8cef8868a8e 100644 (file)
@@ -141,7 +141,7 @@ static void run_tests(struct http_client *http_client)
                "POST", "test.dovecot.org", "/http/post/index.php",
                got_request_response, test_req);
        post_payload = i_stream_create_from_data
-               ((unsigned char *)test_query1, strlen(test_query1));
+               ((const unsigned char *)test_query1, strlen(test_query1));
        http_client_request_set_payload(http_req, post_payload, FALSE);
        i_stream_unref(&post_payload);
        http_client_request_add_header(http_req,
@@ -153,7 +153,7 @@ static void run_tests(struct http_client *http_client)
                "POST", "test.dovecot.org", "/http/post/index.php",
                got_request_response, test_req);
        post_payload = i_stream_create_from_data
-               ((unsigned char *)test_query2, strlen(test_query2));
+               ((const unsigned char *)test_query2, strlen(test_query2));
        http_client_request_set_payload(http_req, post_payload, TRUE);
        i_stream_unref(&post_payload);
        http_client_request_add_header(http_req,
@@ -201,7 +201,7 @@ static void run_tests(struct http_client *http_client)
                "POST", "posttestserver.com", "/post.php",
                got_request_response, test_req);
        post_payload = i_stream_create_from_data
-               ((unsigned char *)test_query1, strlen(test_query1));
+               ((const unsigned char *)test_query1, strlen(test_query1));
        http_client_request_set_payload(http_req, post_payload, TRUE);
        i_stream_unref(&post_payload);
        http_client_request_set_ssl(http_req, TRUE);
@@ -212,7 +212,7 @@ static void run_tests(struct http_client *http_client)
                "POST", "posttestserver.com", "/post.php",
                got_request_response, test_req);
        post_payload = i_stream_create_from_data
-               ((unsigned char *)test_query1, strlen(test_query1));
+               ((const unsigned char *)test_query1, strlen(test_query1));
        http_client_request_set_payload(http_req, post_payload, TRUE);
        i_stream_unref(&post_payload);
        http_client_request_set_ssl(http_req, TRUE);
@@ -223,7 +223,7 @@ static void run_tests(struct http_client *http_client)
                "POST", "posttestserver.com", "/post.php",
                got_request_response, test_req);
        post_payload = i_stream_create_from_data
-               ((unsigned char *)test_query1, strlen(test_query1));
+               ((const unsigned char *)test_query1, strlen(test_query1));
        http_client_request_set_payload(http_req, post_payload, TRUE);
        i_stream_unref(&post_payload);
        http_client_request_set_ssl(http_req, TRUE);
@@ -246,7 +246,7 @@ static void run_tests(struct http_client *http_client)
                "POST", "jigsaw.w3.org", "/HTTP/300/Go_307",
                got_request_response, test_req);
        post_payload = i_stream_create_from_data
-               ((unsigned char *)test_query3, strlen(test_query3));
+               ((const unsigned char *)test_query3, strlen(test_query3));
        http_client_request_set_payload(http_req, post_payload, FALSE);
        i_stream_unref(&post_payload);
        http_client_request_submit(http_req);
@@ -256,7 +256,7 @@ static void run_tests(struct http_client *http_client)
                "POST", "jigsaw.w3.org", "/HTTP/300/Go_307",
                got_request_response, test_req);
        post_payload = i_stream_create_from_data
-               ((unsigned char *)test_query3, strlen(test_query3));
+               ((const unsigned char *)test_query3, strlen(test_query3));
        http_client_request_set_payload(http_req, post_payload, FALSE);
        i_stream_unref(&post_payload);
        http_client_request_submit(http_req);
@@ -266,7 +266,7 @@ static void run_tests(struct http_client *http_client)
                "POST", "jigsaw.w3.org", "/HTTP/300/Go_307",
                got_request_response, test_req);
        post_payload = i_stream_create_from_data
-               ((unsigned char *)test_query3, strlen(test_query3));
+               ((const unsigned char *)test_query3, strlen(test_query3));
        http_client_request_set_payload(http_req, post_payload, FALSE);
        i_stream_unref(&post_payload);
        http_client_request_submit(http_req);
index 962fd08bca52faf1c850024b19f1004941e04dae..694fd6dfaf01597b7a849c55064a3c587c9fb2fc 100644 (file)
@@ -152,7 +152,7 @@ void ldap_connection_search_start(struct ldap_connection *conn,
        if (input->attributes != NULL) {
                ARRAY_TYPE(const_string) arr;
                p_array_init(&arr, req->pool, 8);
-               for(const char **ptr = (const char**)input->attributes; *ptr != NULL; ptr++) {
+               for (const char *const *ptr = input->attributes; *ptr != NULL; ptr++) {
                        const char *tmp = p_strdup(req->pool, *ptr);
                        array_push_back(&arr, &tmp);
                }
index 2488114cc7dbf9c1ceebdf72fed06e3e7bb8dc1f..e6204bb058852eb194e1e3109ccf0b3875210096 100644 (file)
@@ -405,7 +405,7 @@ test_parse_path(const char *input, const struct message_address **addr_r)
        if (input_len > 0)
                input = input_dup = i_memdup(input, input_len);
        ret = message_address_parse_path(pool_datastack_create(),
-                                        (unsigned char *)input, input_len,
+                                        (const unsigned char *)input, input_len,
                                         &addr);
        if (input_len > 0)
                i_free(input_dup);
index a704698b11c3c5b6836c706985ceb0d88a6e2c9c..5672ff0c4813963e82446717e2f73cf9a5862ff2 100644 (file)
@@ -121,8 +121,8 @@ void smtp_parser_init(struct smtp_parser *parser,
        pool_t pool, const char *data)
 {
        parser->pool = pool;
-       parser->begin = parser->cur = (unsigned char *)data;
-       parser->end = (unsigned char *)data + strlen(data);
+       parser->begin = parser->cur = (const unsigned char *)data;
+       parser->end = parser->begin + strlen(data);
        parser->error = NULL;
 }
 
index ea42e7a7fb90d12b4786d68c91120da2c08ece8a..4ca3a4a00888cdbccd0a1f13e033e6c486d6a2d0 100644 (file)
@@ -133,7 +133,8 @@ o_stream_test_flush_pending(struct ostream_private *stream, bool set)
 static size_t
 o_stream_test_get_buffer_used_size(const struct ostream_private *stream)
 {
-       struct test_ostream *tstream = (struct test_ostream *)stream;
+       const struct test_ostream *tstream =
+               (const struct test_ostream *)stream;
 
        return tstream->internal_buf == NULL ? 0 :
                tstream->internal_buf->used;
index eddf52406bd0f4f3029f3a3f28550b6976d12567..73f6ae55bb1d2ceef772f68ad39c34a28b705087 100644 (file)
@@ -84,7 +84,7 @@ static void test_array_foreach_elem_string(void)
        t_array_init(&cblurbs, 32);
        for (i = 0; i < 10; i++) {
                cstring = t_strdup_printf("x%iy", i);
-               string = (char *)cstring;
+               string = t_strdup_noconst(cstring);
                array_push_back(&blurbs, &string);
                array_push_back(&cblurbs, &cstring);
        }
index 02a8d622c6b97f119c051f6c77fcc4ad0bf94a78..498bc88e4829f00d09613ad11e6268371845f186 100644 (file)
@@ -1177,7 +1177,7 @@ int uri_check(const char *uri, enum uri_parse_flags flags,
        const char **error_r)
 {
        return uri_check_data
-               ((unsigned char *)uri, strlen(uri), flags, error_r);
+               ((const unsigned char *)uri, strlen(uri), flags, error_r);
 }
 
 /*