Merge pull request #11062 from ctiller/c++compat3

Add some casts for C++ compatibility
pull/11010/head
Craig Tiller 8 years ago committed by GitHub
commit 9341519b83
  1. 4
      test/core/end2end/cq_verifier.c
  2. 15
      test/core/end2end/fake_resolver.c
  3. 27
      test/core/end2end/fixtures/http_proxy_fixture.c
  4. 6
      test/core/security/oauth2_utils.c

@ -77,7 +77,7 @@ struct cq_verifier {
}; };
cq_verifier *cq_verifier_create(grpc_completion_queue *cq) { 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->cq = cq;
v->first_expectation = NULL; v->first_expectation = NULL;
return v; 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, static void add(cq_verifier *v, const char *file, int line,
grpc_completion_type type, void *tag, bool success) { 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->type = type;
e->file = file; e->file = file;
e->line = line; e->line = line;

@ -136,7 +136,7 @@ struct grpc_fake_resolver_response_generator {
grpc_fake_resolver_response_generator* grpc_fake_resolver_response_generator*
grpc_fake_resolver_response_generator_create() { grpc_fake_resolver_response_generator_create() {
grpc_fake_resolver_response_generator* generator = 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); gpr_ref_init(&generator->refcount, 1);
return generator; 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, static void set_response_cb(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) { 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; fake_resolver* r = generator->resolver;
if (r->next_results != NULL) { if (r->next_results != NULL) {
grpc_channel_args_destroy(exec_ctx, r->next_results); 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) { 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) { 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); } 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 = const grpc_arg* arg =
grpc_channel_args_find(args, GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR); grpc_channel_args_find(args, GRPC_ARG_FAKE_RESOLVER_RESPONSE_GENERATOR);
if (arg == NULL || arg->type != GRPC_ARG_POINTER) return NULL; 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, static grpc_resolver* fake_resolver_create(grpc_exec_ctx* exec_ctx,
grpc_resolver_factory* factory, grpc_resolver_factory* factory,
grpc_resolver_args* args) { 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); r->channel_args = grpc_channel_args_copy(args->args);
grpc_resolver_init(&r->base, &fake_resolver_vtable, args->combiner); grpc_resolver_init(&r->base, &fake_resolver_vtable, args->combiner);
grpc_fake_resolver_response_generator* response_generator = grpc_fake_resolver_response_generator* response_generator =

@ -156,7 +156,7 @@ static void proxy_connection_failed(grpc_exec_ctx* exec_ctx,
// Callback for writing proxy data to the client. // Callback for writing proxy data to the client.
static void on_client_write_done(grpc_exec_ctx* exec_ctx, void* arg, static void on_client_write_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) { grpc_error* error) {
proxy_connection* conn = arg; proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) { if (error != GRPC_ERROR_NONE) {
proxy_connection_failed(exec_ctx, conn, true /* is_client */, proxy_connection_failed(exec_ctx, conn, true /* is_client */,
"HTTP proxy client write", error); "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. // Callback for writing proxy data to the backend server.
static void on_server_write_done(grpc_exec_ctx* exec_ctx, void* arg, static void on_server_write_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) { grpc_error* error) {
proxy_connection* conn = arg; proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) { if (error != GRPC_ERROR_NONE) {
proxy_connection_failed(exec_ctx, conn, false /* is_client */, proxy_connection_failed(exec_ctx, conn, false /* is_client */,
"HTTP proxy server write", error); "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. // the backend server.
static void on_client_read_done(grpc_exec_ctx* exec_ctx, void* arg, static void on_client_read_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) { grpc_error* error) {
proxy_connection* conn = arg; proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) { if (error != GRPC_ERROR_NONE) {
proxy_connection_failed(exec_ctx, conn, true /* is_client */, proxy_connection_failed(exec_ctx, conn, true /* is_client */,
"HTTP proxy client read", error); "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. // proxied to the client.
static void on_server_read_done(grpc_exec_ctx* exec_ctx, void* arg, static void on_server_read_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) { grpc_error* error) {
proxy_connection* conn = arg; proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) { if (error != GRPC_ERROR_NONE) {
proxy_connection_failed(exec_ctx, conn, false /* is_client */, proxy_connection_failed(exec_ctx, conn, false /* is_client */,
"HTTP proxy server read", error); "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. // Callback to write the HTTP response for the CONNECT request.
static void on_write_response_done(grpc_exec_ctx* exec_ctx, void* arg, static void on_write_response_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) { grpc_error* error) {
proxy_connection* conn = arg; proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) { if (error != GRPC_ERROR_NONE) {
proxy_connection_failed(exec_ctx, conn, true /* is_client */, proxy_connection_failed(exec_ctx, conn, true /* is_client */,
"HTTP proxy write response", error); "HTTP proxy write response", error);
@ -294,7 +294,7 @@ static void on_write_response_done(grpc_exec_ctx* exec_ctx, void* arg,
// CONNECT request. // CONNECT request.
static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg, static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) { grpc_error* error) {
proxy_connection* conn = arg; proxy_connection* conn = (proxy_connection*)arg;
if (error != GRPC_ERROR_NONE) { if (error != GRPC_ERROR_NONE) {
// TODO(roth): Technically, in this case, we should handle the error // TODO(roth): Technically, in this case, we should handle the error
// by returning an HTTP response to the client indicating that the // 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. // which will cause the client connection to be dropped.
static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg, static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) { grpc_error* error) {
proxy_connection* conn = arg; proxy_connection* conn = (proxy_connection*)arg;
gpr_log(GPR_DEBUG, "on_read_request_done: %p %s", conn, gpr_log(GPR_DEBUG, "on_read_request_done: %p %s", conn,
grpc_error_string(error)); grpc_error_string(error));
if (error != GRPC_ERROR_NONE) { 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_endpoint* endpoint, grpc_pollset* accepting_pollset,
grpc_tcp_server_acceptor* acceptor) { grpc_tcp_server_acceptor* acceptor) {
gpr_free(acceptor); gpr_free(acceptor);
grpc_end2end_http_proxy* proxy = arg; grpc_end2end_http_proxy* proxy = (grpc_end2end_http_proxy*)arg;
// Instantiate proxy_connection. // Instantiate proxy_connection.
proxy_connection* conn = gpr_zalloc(sizeof(*conn)); proxy_connection* conn = (proxy_connection*)gpr_zalloc(sizeof(*conn));
gpr_ref(&proxy->users); gpr_ref(&proxy->users);
conn->client_endpoint = endpoint; conn->client_endpoint = endpoint;
conn->proxy = proxy; conn->proxy = proxy;
@ -430,7 +430,7 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg,
// //
static void thread_main(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; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT;
do { do {
gpr_ref(&proxy->users); 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_end2end_http_proxy* grpc_end2end_http_proxy_create(void) {
grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; 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)); memset(proxy, 0, sizeof(*proxy));
gpr_ref_init(&proxy->users, 1); gpr_ref_init(&proxy->users, 1);
// Construct proxy address. // 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(error == GRPC_ERROR_NONE);
GPR_ASSERT(port == proxy_port); GPR_ASSERT(port == proxy_port);
// Start server. // 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_pollset_init(proxy->pollset, &proxy->mu);
grpc_tcp_server_start(&exec_ctx, proxy->server, &proxy->pollset, 1, on_accept, grpc_tcp_server_start(&exec_ctx, proxy->server, &proxy->pollset, 1, on_accept,
proxy); 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, static void destroy_pollset(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) { grpc_error* error) {
grpc_pollset* pollset = arg; grpc_pollset* pollset = (grpc_pollset*)arg;
grpc_pollset_destroy(pollset); grpc_pollset_destroy(pollset);
gpr_free(pollset); gpr_free(pollset);
} }

@ -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_md *md_elems, size_t num_md,
grpc_credentials_status status, grpc_credentials_status status,
const char *error_details) { const char *error_details) {
oauth2_request *request = user_data; oauth2_request *request = (oauth2_request *)user_data;
char *token = NULL; char *token = NULL;
grpc_slice token_slice; grpc_slice token_slice;
if (status == GRPC_CREDENTIALS_ERROR) { if (status == GRPC_CREDENTIALS_ERROR) {
@ -63,7 +63,7 @@ static void on_oauth2_response(grpc_exec_ctx *exec_ctx, void *user_data,
} else { } else {
GPR_ASSERT(num_md == 1); GPR_ASSERT(num_md == 1);
token_slice = md_elems[0].value; 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), memcpy(token, GRPC_SLICE_START_PTR(token_slice),
GRPC_SLICE_LENGTH(token_slice)); GRPC_SLICE_LENGTH(token_slice));
token[GRPC_SLICE_LENGTH(token_slice)] = '\0'; 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_closure do_nothing_closure;
grpc_auth_metadata_context null_ctx = {"", "", NULL, NULL}; 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); grpc_pollset_init(pollset, &request.mu);
request.pops = grpc_polling_entity_create_from_pollset(pollset); request.pops = grpc_polling_entity_create_from_pollset(pollset);
request.is_done = 0; request.is_done = 0;

Loading…
Cancel
Save