diff --git a/source/s3.c b/source/s3.c index 38020b087..e6390b485 100644 --- a/source/s3.c +++ b/source/s3.c @@ -121,13 +121,17 @@ AWS_STATIC_STRING_FROM_LITERAL(s_CopyObject_str, "CopyObject"); AWS_STATIC_STRING_FROM_LITERAL(s_PutObject_str, "PutObject"); AWS_STATIC_STRING_FROM_LITERAL(s_CreateSession_str, "CreateSession"); +static bool s_byte_cursor_eq_ignore_case(const void *a, const void *b) { + return aws_byte_cursor_eq_ignore_case(a, b); +} + static void s_s3_request_type_info_init(struct aws_allocator *allocator) { int err = aws_hash_table_init( &s_s3_operation_name_to_request_type_table, allocator, AWS_ARRAY_SIZE(s_s3_request_type_info_array) /*initial_size*/, aws_hash_byte_cursor_ptr_ignore_case, - (aws_hash_callback_eq_fn *)aws_byte_cursor_eq_ignore_case, + s_byte_cursor_eq_ignore_case, NULL /*destroy_key*/, NULL /*destroy_value*/); AWS_FATAL_ASSERT(!err); diff --git a/source/s3_checksum_stream.c b/source/s3_checksum_stream.c index 8f4f575c8..6d11df32d 100644 --- a/source/s3_checksum_stream.c +++ b/source/s3_checksum_stream.c @@ -105,6 +105,10 @@ static void s_aws_input_checksum_stream_destroy(struct aws_checksum_stream *impl aws_mem_release(impl->allocator, impl); } +static void s_aws_input_checksum_stream_destroy_wrap(void *user_data) { + s_aws_input_checksum_stream_destroy(user_data); +} + static struct aws_input_stream_vtable s_aws_input_checksum_stream_vtable = { .seek = s_aws_input_checksum_stream_seek, .read = s_aws_input_checksum_stream_read, @@ -129,7 +133,7 @@ static struct aws_checksum_stream *s_aws_checksum_input_checksum_stream_new( aws_byte_buf_init(&impl->checksum_result, allocator, impl->checksum->digest_size); impl->old_stream = aws_input_stream_acquire(existing_stream); aws_ref_count_init( - &impl->base.ref_count, impl, (aws_simple_completion_callback *)s_aws_input_checksum_stream_destroy); + &impl->base.ref_count, impl, s_aws_input_checksum_stream_destroy_wrap); return impl; on_error: aws_mem_release(impl->allocator, impl); diff --git a/source/s3_chunk_stream.c b/source/s3_chunk_stream.c index afea50b40..07bea1141 100644 --- a/source/s3_chunk_stream.c +++ b/source/s3_chunk_stream.c @@ -167,6 +167,10 @@ static void s_aws_input_chunk_stream_destroy(struct aws_chunk_stream *impl) { } } +static void s_aws_input_chunk_stream_destroy_wrap(void *user_data) { + s_aws_input_chunk_stream_destroy(user_data); +} + static struct aws_input_stream_vtable s_aws_input_chunk_stream_vtable = { .seek = s_aws_input_chunk_stream_seek, .read = s_aws_input_chunk_stream_read, @@ -257,7 +261,7 @@ struct aws_input_stream *aws_chunk_stream_new( checksum_context->encoded_checksum_size + post_trailer_len; AWS_ASSERT(impl->current_stream); - aws_ref_count_init(&impl->base.ref_count, impl, (aws_simple_completion_callback *)s_aws_input_chunk_stream_destroy); + aws_ref_count_init(&impl->base.ref_count, impl, s_aws_input_chunk_stream_destroy_wrap); return &impl->base; error: diff --git a/source/s3_default_buffer_pool.c b/source/s3_default_buffer_pool.c index 074f09476..c7456cf2b 100644 --- a/source/s3_default_buffer_pool.c +++ b/source/s3_default_buffer_pool.c @@ -185,6 +185,10 @@ static void s_destroy_special_block_list(void *val) { aws_mem_release(special_list->allocator, special_list); } +static void s_aws_s3_default_buffer_pool_destroy_wrap(void *user_data) { + aws_s3_default_buffer_pool_destroy(user_data); +} + struct aws_s3_buffer_pool *aws_s3_default_buffer_pool_new( struct aws_allocator *allocator, struct aws_s3_buffer_pool_config config) { @@ -295,7 +299,7 @@ struct aws_s3_buffer_pool *aws_s3_default_buffer_pool_new( struct aws_s3_buffer_pool *pool = aws_mem_calloc(buffer_pool->base_allocator, 1, sizeof(struct aws_s3_buffer_pool)); pool->impl = buffer_pool; pool->vtable = &s_default_pool_vtable; - aws_ref_count_init(&pool->ref_count, pool, (aws_simple_completion_callback *)aws_s3_default_buffer_pool_destroy); + aws_ref_count_init(&pool->ref_count, pool, s_aws_s3_default_buffer_pool_destroy_wrap); return pool; } diff --git a/source/s3_parallel_input_stream.c b/source/s3_parallel_input_stream.c index c7a730b52..211994ec4 100644 --- a/source/s3_parallel_input_stream.c +++ b/source/s3_parallel_input_stream.c @@ -17,6 +17,11 @@ AWS_STATIC_STRING_FROM_LITERAL(s_readonly_bytes_mode, "rb"); +static void s_parallel_stream_vtable_destroy_wrap(void *user_data) { + struct aws_parallel_input_stream *stream = user_data; + stream->vtable->destroy(stream); +} + void aws_parallel_input_stream_init_base( struct aws_parallel_input_stream *stream, struct aws_allocator *alloc, @@ -28,7 +33,7 @@ void aws_parallel_input_stream_init_base( stream->vtable = vtable; stream->impl = impl; stream->shutdown_future = aws_future_void_new(alloc); - aws_ref_count_init(&stream->ref_count, stream, (aws_simple_completion_callback *)vtable->destroy); + aws_ref_count_init(&stream->ref_count, stream, s_parallel_stream_vtable_destroy_wrap); } struct aws_parallel_input_stream *aws_parallel_input_stream_acquire(struct aws_parallel_input_stream *stream) { diff --git a/source/s3_platform_info.c b/source/s3_platform_info.c index fd0694ec4..0b4d49f86 100644 --- a/source/s3_platform_info.c +++ b/source/s3_platform_info.c @@ -152,6 +152,10 @@ static void s_destroy_loader(void *arg) { aws_mem_release(loader->allocator, loader); } +static bool s_byte_cursor_eq_ignore_case(const void *a, const void *b) { + return aws_byte_cursor_eq_ignore_case(a, b); +} + struct aws_s3_platform_info_loader *aws_s3_platform_info_loader_new(struct aws_allocator *allocator) { struct aws_s3_platform_info_loader *loader = aws_mem_calloc(allocator, 1, sizeof(struct aws_s3_platform_info_loader)); @@ -175,7 +179,7 @@ struct aws_s3_platform_info_loader *aws_s3_platform_info_loader_new(struct aws_a allocator, 32, aws_hash_byte_cursor_ptr_ignore_case, - (aws_hash_callback_eq_fn *)aws_byte_cursor_eq_ignore_case, + s_byte_cursor_eq_ignore_case, NULL, NULL) && "Hash table init failed!"); diff --git a/source/s3express_credentials_provider.c b/source/s3express_credentials_provider.c index 7afb5aca3..ee1001fb4 100644 --- a/source/s3express_credentials_provider.c +++ b/source/s3express_credentials_provider.c @@ -914,6 +914,11 @@ static void s_bg_refresh_task(struct aws_task *task, void *arg, enum aws_task_st } } +static void s_provider_vtable_destroy_wrap(void *user_data) { + struct aws_s3express_credentials_provider *provider = user_data; + provider->vtable->destroy(provider); +} + void aws_s3express_credentials_provider_init_base( struct aws_s3express_credentials_provider *provider, struct aws_allocator *allocator, @@ -926,7 +931,19 @@ void aws_s3express_credentials_provider_init_base( provider->allocator = allocator; provider->vtable = vtable; provider->impl = impl; - aws_ref_count_init(&provider->ref_count, provider, (aws_simple_completion_callback *)provider->vtable->destroy); + aws_ref_count_init(&provider->ref_count, provider, s_provider_vtable_destroy_wrap); +} + +static bool s_string_eq(const void *a, const void *b) { + return aws_string_eq(a, b); +} + +static void s_s3express_session_destroy(void *value) { + s_aws_s3express_session_destroy(value); +} + +static void s_finish_provider_destroy_wrap(void *user_data) { + s_finish_provider_destroy(user_data); } struct aws_s3express_credentials_provider *aws_s3express_credentials_provider_new_default( @@ -969,9 +986,9 @@ struct aws_s3express_credentials_provider *aws_s3express_credentials_provider_ne impl->synced_data.cache = aws_cache_new_lru( allocator, aws_hash_string, - (aws_hash_callback_eq_fn *)aws_string_eq, + s_string_eq, NULL, - (aws_hash_callback_destroy_fn *)s_aws_s3express_session_destroy, + s_s3express_session_destroy, s_default_cache_capacity); AWS_ASSERT(impl->synced_data.cache); @@ -989,7 +1006,7 @@ struct aws_s3express_credentials_provider *aws_s3express_credentials_provider_ne provider->shutdown_complete_callback = options->shutdown_complete_callback; provider->shutdown_user_data = options->shutdown_user_data; aws_mutex_init(&impl->synced_data.lock); - aws_ref_count_init(&impl->internal_ref, provider, (aws_simple_completion_callback *)s_finish_provider_destroy); + aws_ref_count_init(&impl->internal_ref, provider, s_finish_provider_destroy_wrap); /* Init the background refresh task */ impl->bg_refresh_task = aws_mem_calloc(provider->allocator, 1, sizeof(struct aws_task)); diff --git a/tests/s3_data_plane_tests.c b/tests/s3_data_plane_tests.c index 8323647aa..ba3a2c813 100644 --- a/tests/s3_data_plane_tests.c +++ b/tests/s3_data_plane_tests.c @@ -3448,6 +3448,10 @@ void s_failing_pool_destroy(struct aws_s3_buffer_pool *buffer_pool_wrapper) { aws_mem_release((struct aws_allocator *)buffer_pool_wrapper->impl, buffer_pool_wrapper); } +static void s_failing_pool_destroy_wrap(void *user_data) { + s_failing_pool_destroy(user_data); +} + struct aws_s3_buffer_pool *s_always_error_buffer_pool_fn( struct aws_allocator *allocator, struct aws_s3_buffer_pool_config config, @@ -3457,7 +3461,7 @@ struct aws_s3_buffer_pool *s_always_error_buffer_pool_fn( struct aws_s3_buffer_pool *pool = aws_mem_calloc(allocator, 1, sizeof(struct aws_s3_buffer_pool)); pool->impl = allocator; pool->vtable = &s_failing_pool_vtable; - aws_ref_count_init(&pool->ref_count, pool, (aws_simple_completion_callback *)s_failing_pool_destroy); + aws_ref_count_init(&pool->ref_count, pool, s_failing_pool_destroy_wrap); return pool; } diff --git a/tests/s3_s3express_client_test.c b/tests/s3_s3express_client_test.c index eb3b6cb05..a6ccb2460 100644 --- a/tests/s3_s3express_client_test.c +++ b/tests/s3_s3express_client_test.c @@ -35,6 +35,10 @@ struct aws_s3express_client_tester { static struct aws_s3express_client_tester s_tester; +static void s_credentials_release_wrap(void *value) { + aws_credentials_release(value); +} + static int s_s3express_client_tester_init(struct aws_allocator *allocator) { s_tester.allocator = allocator; aws_hash_table_init( @@ -44,7 +48,7 @@ static int s_s3express_client_tester_init(struct aws_allocator *allocator) { aws_hash_string, aws_hash_callback_string_eq, aws_hash_callback_string_destroy, - (aws_hash_callback_destroy_fn *)aws_credentials_release); + s_credentials_release_wrap); aws_atomic_init_int(&s_tester.provider_requests_made, 0); return AWS_OP_SUCCESS; } diff --git a/tests/s3_test_input_stream.c b/tests/s3_test_input_stream.c index 1d4e5e020..7566bc0bc 100644 --- a/tests/s3_test_input_stream.c +++ b/tests/s3_test_input_stream.c @@ -93,6 +93,10 @@ static void s_aws_s3_test_input_stream_destroy(struct aws_s3_test_input_stream_i aws_mem_release(test_input_stream->allocator, test_input_stream); } +static void s_aws_s3_test_input_stream_destroy_wrap(void *user_data) { + s_aws_s3_test_input_stream_destroy(user_data); +} + static struct aws_input_stream_vtable s_aws_s3_test_input_stream_vtable_1 = { .seek = s_aws_s3_test_input_stream_seek, .read = s_aws_s3_test_input_stream_read_1, @@ -121,7 +125,7 @@ struct aws_input_stream *aws_s3_test_input_stream_new_with_value_type( aws_ref_count_init( &test_input_stream->base.ref_count, test_input_stream, - (aws_simple_completion_callback *)s_aws_s3_test_input_stream_destroy); + s_aws_s3_test_input_stream_destroy_wrap); struct aws_input_stream *input_stream = &test_input_stream->base;