From 4d16f4dd1db5e0546a1f171496f1f3dba888eab1 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 10 May 2017 08:21:08 -0700 Subject: [PATCH] Add some casts for C++ compatibility --- test/core/end2end/cq_verifier.c | 4 +-- test/core/end2end/fake_resolver.c | 15 ++++++----- .../end2end/fixtures/http_proxy_fixture.c | 27 ++++++++++--------- test/core/security/oauth2_utils.c | 6 ++--- 4 files changed, 28 insertions(+), 24 deletions(-) diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c index 5eea5d43fe0..0fafb0c8c99 100644 --- a/test/core/end2end/cq_verifier.c +++ b/test/core/end2end/cq_verifier.c @@ -77,7 +77,7 @@ struct cq_verifier { }; cq_verifier *cq_verifier_create(grpc_completion_queue *cq) { - cq_verifier *v = gpr_malloc(sizeof(cq_verifier)); + cq_verifier *v = (cq_verifier *)gpr_malloc(sizeof(cq_verifier)); v->cq = cq; v->first_expectation = NULL; return v; @@ -314,7 +314,7 @@ void cq_verify_empty(cq_verifier *v) { cq_verify_empty_timeout(v, 1); } static void add(cq_verifier *v, const char *file, int line, grpc_completion_type type, void *tag, bool success) { - expectation *e = gpr_malloc(sizeof(expectation)); + expectation *e = (expectation *)gpr_malloc(sizeof(expectation)); e->type = type; e->file = file; e->line = line; diff --git a/test/core/end2end/fake_resolver.c b/test/core/end2end/fake_resolver.c index df902a24bff..736b224fd60 100644 --- a/test/core/end2end/fake_resolver.c +++ b/test/core/end2end/fake_resolver.c @@ -136,7 +136,7 @@ struct grpc_fake_resolver_response_generator { grpc_fake_resolver_response_generator* grpc_fake_resolver_response_generator_create() { grpc_fake_resolver_response_generator* generator = - gpr_zalloc(sizeof(*generator)); + (grpc_fake_resolver_response_generator*)gpr_zalloc(sizeof(*generator)); gpr_ref_init(&generator->refcount, 1); return generator; } @@ -157,7 +157,8 @@ void grpc_fake_resolver_response_generator_unref( static void set_response_cb(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { - grpc_fake_resolver_response_generator* generator = arg; + grpc_fake_resolver_response_generator* generator = + (grpc_fake_resolver_response_generator*)arg; fake_resolver* r = generator->resolver; if (r->next_results != NULL) { grpc_channel_args_destroy(exec_ctx, r->next_results); @@ -180,11 +181,13 @@ void grpc_fake_resolver_response_generator_set_response( } static void* response_generator_arg_copy(void* p) { - return grpc_fake_resolver_response_generator_ref(p); + return grpc_fake_resolver_response_generator_ref( + (grpc_fake_resolver_response_generator*)p); } static void response_generator_arg_destroy(grpc_exec_ctx* exec_ctx, void* p) { - grpc_fake_resolver_response_generator_unref(p); + grpc_fake_resolver_response_generator_unref( + (grpc_fake_resolver_response_generator*)p); } static int response_generator_cmp(void* a, void* b) { return GPR_ICMP(a, b); } @@ -208,7 +211,7 @@ grpc_fake_resolver_get_response_generator(const grpc_channel_args* args) { const grpc_arg* arg = grpc_channel_args_find(args, GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR); if (arg == NULL || arg->type != GRPC_ARG_POINTER) return NULL; - return arg->value.pointer.p; + return (grpc_fake_resolver_response_generator*)arg->value.pointer.p; } // @@ -222,7 +225,7 @@ static void fake_resolver_factory_unref(grpc_resolver_factory* factory) {} static grpc_resolver* fake_resolver_create(grpc_exec_ctx* exec_ctx, grpc_resolver_factory* factory, grpc_resolver_args* args) { - fake_resolver* r = gpr_zalloc(sizeof(*r)); + fake_resolver* r = (fake_resolver*)gpr_zalloc(sizeof(*r)); r->channel_args = grpc_channel_args_copy(args->args); grpc_resolver_init(&r->base, &fake_resolver_vtable, args->combiner); grpc_fake_resolver_response_generator* response_generator = diff --git a/test/core/end2end/fixtures/http_proxy_fixture.c b/test/core/end2end/fixtures/http_proxy_fixture.c index f0d09487c62..5df43b93847 100644 --- a/test/core/end2end/fixtures/http_proxy_fixture.c +++ b/test/core/end2end/fixtures/http_proxy_fixture.c @@ -156,7 +156,7 @@ static void proxy_connection_failed(grpc_exec_ctx* exec_ctx, // Callback for writing proxy data to the client. static void on_client_write_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { - proxy_connection* conn = arg; + proxy_connection* conn = (proxy_connection*)arg; if (error != GRPC_ERROR_NONE) { proxy_connection_failed(exec_ctx, conn, true /* is_client */, "HTTP proxy client write", error); @@ -181,7 +181,7 @@ static void on_client_write_done(grpc_exec_ctx* exec_ctx, void* arg, // Callback for writing proxy data to the backend server. static void on_server_write_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { - proxy_connection* conn = arg; + proxy_connection* conn = (proxy_connection*)arg; if (error != GRPC_ERROR_NONE) { proxy_connection_failed(exec_ctx, conn, false /* is_client */, "HTTP proxy server write", error); @@ -207,7 +207,7 @@ static void on_server_write_done(grpc_exec_ctx* exec_ctx, void* arg, // the backend server. static void on_client_read_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { - proxy_connection* conn = arg; + proxy_connection* conn = (proxy_connection*)arg; if (error != GRPC_ERROR_NONE) { proxy_connection_failed(exec_ctx, conn, true /* is_client */, "HTTP proxy client read", error); @@ -239,7 +239,7 @@ static void on_client_read_done(grpc_exec_ctx* exec_ctx, void* arg, // proxied to the client. static void on_server_read_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { - proxy_connection* conn = arg; + proxy_connection* conn = (proxy_connection*)arg; if (error != GRPC_ERROR_NONE) { proxy_connection_failed(exec_ctx, conn, false /* is_client */, "HTTP proxy server read", error); @@ -270,7 +270,7 @@ static void on_server_read_done(grpc_exec_ctx* exec_ctx, void* arg, // Callback to write the HTTP response for the CONNECT request. static void on_write_response_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { - proxy_connection* conn = arg; + proxy_connection* conn = (proxy_connection*)arg; if (error != GRPC_ERROR_NONE) { proxy_connection_failed(exec_ctx, conn, true /* is_client */, "HTTP proxy write response", error); @@ -294,7 +294,7 @@ static void on_write_response_done(grpc_exec_ctx* exec_ctx, void* arg, // CONNECT request. static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { - proxy_connection* conn = arg; + proxy_connection* conn = (proxy_connection*)arg; if (error != GRPC_ERROR_NONE) { // TODO(roth): Technically, in this case, we should handle the error // by returning an HTTP response to the client indicating that the @@ -324,7 +324,7 @@ static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg, // which will cause the client connection to be dropped. static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { - proxy_connection* conn = arg; + proxy_connection* conn = (proxy_connection*)arg; gpr_log(GPR_DEBUG, "on_read_request_done: %p %s", conn, grpc_error_string(error)); if (error != GRPC_ERROR_NONE) { @@ -389,9 +389,9 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* endpoint, grpc_pollset* accepting_pollset, grpc_tcp_server_acceptor* acceptor) { gpr_free(acceptor); - grpc_end2end_http_proxy* proxy = arg; + grpc_end2end_http_proxy* proxy = (grpc_end2end_http_proxy*)arg; // Instantiate proxy_connection. - proxy_connection* conn = gpr_zalloc(sizeof(*conn)); + proxy_connection* conn = (proxy_connection*)gpr_zalloc(sizeof(*conn)); gpr_ref(&proxy->users); conn->client_endpoint = endpoint; conn->proxy = proxy; @@ -430,7 +430,7 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg, // static void thread_main(void* arg) { - grpc_end2end_http_proxy* proxy = arg; + grpc_end2end_http_proxy* proxy = (grpc_end2end_http_proxy*)arg; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; do { gpr_ref(&proxy->users); @@ -450,7 +450,8 @@ static void thread_main(void* arg) { grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_end2end_http_proxy* proxy = gpr_malloc(sizeof(*proxy)); + grpc_end2end_http_proxy* proxy = + (grpc_end2end_http_proxy*)gpr_malloc(sizeof(*proxy)); memset(proxy, 0, sizeof(*proxy)); gpr_ref_init(&proxy->users, 1); // Construct proxy address. @@ -473,7 +474,7 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(void) { GPR_ASSERT(error == GRPC_ERROR_NONE); GPR_ASSERT(port == proxy_port); // Start server. - proxy->pollset = gpr_zalloc(grpc_pollset_size()); + proxy->pollset = (grpc_pollset*)gpr_zalloc(grpc_pollset_size()); grpc_pollset_init(proxy->pollset, &proxy->mu); grpc_tcp_server_start(&exec_ctx, proxy->server, &proxy->pollset, 1, on_accept, proxy); @@ -487,7 +488,7 @@ grpc_end2end_http_proxy* grpc_end2end_http_proxy_create(void) { static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) { - grpc_pollset* pollset = arg; + grpc_pollset* pollset = (grpc_pollset*)arg; grpc_pollset_destroy(pollset); gpr_free(pollset); } diff --git a/test/core/security/oauth2_utils.c b/test/core/security/oauth2_utils.c index f0550db1d06..838625705dd 100644 --- a/test/core/security/oauth2_utils.c +++ b/test/core/security/oauth2_utils.c @@ -55,7 +55,7 @@ static void on_oauth2_response(grpc_exec_ctx *exec_ctx, void *user_data, grpc_credentials_md *md_elems, size_t num_md, grpc_credentials_status status, const char *error_details) { - oauth2_request *request = user_data; + oauth2_request *request = (oauth2_request *)user_data; char *token = NULL; grpc_slice token_slice; if (status == GRPC_CREDENTIALS_ERROR) { @@ -63,7 +63,7 @@ static void on_oauth2_response(grpc_exec_ctx *exec_ctx, void *user_data, } else { GPR_ASSERT(num_md == 1); token_slice = md_elems[0].value; - token = gpr_malloc(GRPC_SLICE_LENGTH(token_slice) + 1); + token = (char *)gpr_malloc(GRPC_SLICE_LENGTH(token_slice) + 1); memcpy(token, GRPC_SLICE_START_PTR(token_slice), GRPC_SLICE_LENGTH(token_slice)); token[GRPC_SLICE_LENGTH(token_slice)] = '\0'; @@ -87,7 +87,7 @@ char *grpc_test_fetch_oauth2_token_with_credentials( grpc_closure do_nothing_closure; grpc_auth_metadata_context null_ctx = {"", "", NULL, NULL}; - grpc_pollset *pollset = gpr_zalloc(grpc_pollset_size()); + grpc_pollset *pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size()); grpc_pollset_init(pollset, &request.mu); request.pops = grpc_polling_entity_create_from_pollset(pollset); request.is_done = 0;