Merge pull request #12464 from yashykt/ctocc2

Adding more pointer type conversions for C to C++ compilation
pull/12414/merge
Yash Tibrewal 7 years ago committed by GitHub
commit 9c87eda766
  1. 5
      src/core/ext/filters/client_channel/resolver/fake/fake_resolver.c
  2. 4
      src/core/ext/filters/client_channel/subchannel_index.c
  3. 66
      src/core/ext/transport/chttp2/transport/chttp2_transport.c
  4. 18
      src/core/lib/channel/channel_args.c
  5. 6
      src/core/lib/channel/channel_stack_builder.c
  6. 25
      src/core/lib/channel/connected_channel.c
  7. 14
      src/core/lib/channel/handshaker.c
  8. 2
      src/core/lib/channel/handshaker_registry.c
  9. 2
      src/core/lib/debug/stats.c
  10. 2
      src/core/lib/http/format_request.c
  11. 13
      src/core/lib/http/httpcli.c
  12. 7
      src/core/lib/http/parser.c
  13. 4
      src/core/lib/iomgr/closure.c
  14. 14
      src/core/lib/iomgr/error.c
  15. 6
      src/core/lib/iomgr/ev_epoll1_linux.c
  16. 36
      test/core/end2end/fixtures/proxy.c
  17. 2
      test/core/end2end/tests/connectivity.c
  18. 6
      test/core/end2end/tests/filter_causes_close.c
  19. 2
      test/core/end2end/tests/filter_latency.c
  20. 2
      test/core/end2end/tests/payload.c
  21. 15
      test/core/end2end/tests/resource_quota_server.c
  22. 2
      test/core/end2end/tests/shutdown_finishes_tags.c
  23. 2
      test/core/end2end/tests/stream_compression_payload.c
  24. 8
      test/core/iomgr/endpoint_tests.c
  25. 8
      test/core/util/memory_counters.c
  26. 2
      test/core/util/mock_endpoint.c
  27. 2
      test/core/util/passthru_endpoint.c
  28. 3
      test/core/util/port.c
  29. 10
      test/core/util/port_server_client.c
  30. 9
      test/core/util/slice_splitter.c
  31. 4
      test/core/util/trickle_endpoint.c

@ -159,7 +159,7 @@ typedef struct set_response_closure_arg {
static void set_response_closure_fn(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) {
set_response_closure_arg* closure_arg = arg;
set_response_closure_arg* closure_arg = (set_response_closure_arg*)arg;
grpc_fake_resolver_response_generator* generator = closure_arg->generator;
fake_resolver* r = generator->resolver;
if (r->next_results != NULL) {
@ -178,7 +178,8 @@ void grpc_fake_resolver_response_generator_set_response(
grpc_exec_ctx* exec_ctx, grpc_fake_resolver_response_generator* generator,
grpc_channel_args* next_response) {
GPR_ASSERT(generator->resolver != NULL);
set_response_closure_arg* closure_arg = gpr_zalloc(sizeof(*closure_arg));
set_response_closure_arg* closure_arg =
(set_response_closure_arg*)gpr_zalloc(sizeof(*closure_arg));
closure_arg->generator = generator;
closure_arg->next_response = grpc_channel_args_copy(next_response);
GRPC_CLOSURE_SCHED(exec_ctx,

@ -136,8 +136,8 @@ grpc_subchannel *grpc_subchannel_index_find(grpc_exec_ctx *exec_ctx,
gpr_avl index = gpr_avl_ref(g_subchannel_index, exec_ctx);
gpr_mu_unlock(&g_mu);
grpc_subchannel *c = (grpc_subchannel *)GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(
gpr_avl_get(index, key, exec_ctx), "index_find");
grpc_subchannel *c = GRPC_SUBCHANNEL_REF_FROM_WEAK_REF(
(grpc_subchannel *)gpr_avl_get(index, key, exec_ctx), "index_find");
gpr_avl_unref(index, exec_ctx);
return c;

@ -589,7 +589,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
static void destroy_transport_locked(grpc_exec_ctx *exec_ctx, void *tp,
grpc_error *error) {
grpc_chttp2_transport *t = tp;
grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
t->destroying = 1;
close_transport_locked(
exec_ctx, t,
@ -715,7 +715,7 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt,
static void destroy_stream_locked(grpc_exec_ctx *exec_ctx, void *sp,
grpc_error *error) {
grpc_chttp2_stream *s = sp;
grpc_chttp2_stream *s = (grpc_chttp2_stream *)sp;
grpc_chttp2_transport *t = s->t;
GPR_TIMER_BEGIN("destroy_stream", 0);
@ -897,7 +897,7 @@ void grpc_chttp2_become_writable(
static void write_action_begin_locked(grpc_exec_ctx *exec_ctx, void *gt,
grpc_error *error_ignored) {
GPR_TIMER_BEGIN("write_action_begin_locked", 0);
grpc_chttp2_transport *t = gt;
grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
GPR_ASSERT(t->write_state != GRPC_CHTTP2_WRITE_STATE_IDLE);
switch (t->closed ? GRPC_CHTTP2_NOTHING_TO_WRITE
: grpc_chttp2_begin_write(exec_ctx, t)) {
@ -921,7 +921,7 @@ static void write_action_begin_locked(grpc_exec_ctx *exec_ctx, void *gt,
}
static void write_action(grpc_exec_ctx *exec_ctx, void *gt, grpc_error *error) {
grpc_chttp2_transport *t = gt;
grpc_chttp2_transport *t = (grpc_chttp2_transport *)gt;
GPR_TIMER_BEGIN("write_action", 0);
grpc_endpoint_write(
exec_ctx, t->ep, &t->outbuf,
@ -933,7 +933,7 @@ static void write_action(grpc_exec_ctx *exec_ctx, void *gt, grpc_error *error) {
static void write_action_end_locked(grpc_exec_ctx *exec_ctx, void *tp,
grpc_error *error) {
GPR_TIMER_BEGIN("terminate_writing_with_lock", 0);
grpc_chttp2_transport *t = tp;
grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
if (error != GRPC_ERROR_NONE) {
close_transport_locked(exec_ctx, t, GRPC_ERROR_REF(error));
@ -1191,7 +1191,7 @@ static void continue_fetching_send_locked(grpc_exec_ctx *exec_ctx,
} else {
grpc_chttp2_write_cb *cb = t->write_cb_pool;
if (cb == NULL) {
cb = gpr_malloc(sizeof(*cb));
cb = (grpc_chttp2_write_cb *)gpr_malloc(sizeof(*cb));
} else {
t->write_cb_pool = cb->next;
}
@ -1219,7 +1219,7 @@ static void continue_fetching_send_locked(grpc_exec_ctx *exec_ctx,
static void complete_fetch_locked(grpc_exec_ctx *exec_ctx, void *gs,
grpc_error *error) {
grpc_chttp2_stream *s = gs;
grpc_chttp2_stream *s = (grpc_chttp2_stream *)gs;
grpc_chttp2_transport *t = s->t;
if (error == GRPC_ERROR_NONE) {
error = grpc_byte_stream_pull(exec_ctx, s->fetching_send_message,
@ -1254,8 +1254,9 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
grpc_error *error_ignored) {
GPR_TIMER_BEGIN("perform_stream_op_locked", 0);
grpc_transport_stream_op_batch *op = stream_op;
grpc_chttp2_stream *s = op->handler_private.extra_arg;
grpc_transport_stream_op_batch *op =
(grpc_transport_stream_op_batch *)stream_op;
grpc_chttp2_stream *s = (grpc_chttp2_stream *)op->handler_private.extra_arg;
grpc_transport_stream_op_batch_payload *op_payload = op->payload;
grpc_chttp2_transport *t = s->t;
@ -1308,7 +1309,8 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op,
if ((s->stream_compression_send_enabled =
(op_payload->send_initial_metadata.send_initial_metadata->idx.named
.content_encoding != NULL)) == true) {
s->compressed_data_buffer = gpr_malloc(sizeof(grpc_slice_buffer));
s->compressed_data_buffer =
(grpc_slice_buffer *)gpr_malloc(sizeof(grpc_slice_buffer));
grpc_slice_buffer_init(s->compressed_data_buffer);
}
@ -1599,7 +1601,7 @@ static void send_ping_locked(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
static void retry_initiate_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
grpc_error *error) {
grpc_chttp2_transport *t = tp;
grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
t->ping_state.is_delayed_ping_timer_set = false;
grpc_chttp2_initiate_write(exec_ctx, t, "retry_send_ping");
}
@ -1651,8 +1653,9 @@ void grpc_chttp2_add_ping_strike(grpc_exec_ctx *exec_ctx,
static void perform_transport_op_locked(grpc_exec_ctx *exec_ctx,
void *stream_op,
grpc_error *error_ignored) {
grpc_transport_op *op = stream_op;
grpc_chttp2_transport *t = op->handler_private.extra_arg;
grpc_transport_op *op = (grpc_transport_op *)stream_op;
grpc_chttp2_transport *t =
(grpc_chttp2_transport *)op->handler_private.extra_arg;
grpc_error *close_transport = op->disconnect_with_error;
if (op->goaway_error) {
@ -1864,7 +1867,8 @@ void grpc_chttp2_maybe_complete_recv_trailing_metadata(grpc_exec_ctx *exec_ctx,
static void remove_stream(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t,
uint32_t id, grpc_error *error) {
grpc_chttp2_stream *s = grpc_chttp2_stream_map_delete(&t->stream_map, id);
grpc_chttp2_stream *s =
(grpc_chttp2_stream *)grpc_chttp2_stream_map_delete(&t->stream_map, id);
GPR_ASSERT(s);
if (t->incoming_stream == s) {
t->incoming_stream = NULL;
@ -2242,8 +2246,8 @@ typedef struct {
} cancel_stream_cb_args;
static void cancel_stream_cb(void *user_data, uint32_t key, void *stream) {
cancel_stream_cb_args *args = user_data;
grpc_chttp2_stream *s = stream;
cancel_stream_cb_args *args = (cancel_stream_cb_args *)user_data;
grpc_chttp2_stream *s = (grpc_chttp2_stream *)stream;
grpc_chttp2_cancel_stream(args->exec_ctx, args->t, s,
GRPC_ERROR_REF(args->error));
}
@ -2345,7 +2349,7 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp,
grpc_error *error) {
GPR_TIMER_BEGIN("reading_action_locked", 0);
grpc_chttp2_transport *t = tp;
grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
GRPC_ERROR_REF(error);
@ -2430,7 +2434,7 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp,
static void start_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
grpc_error *error) {
grpc_chttp2_transport *t = tp;
grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
if (GRPC_TRACER_ON(grpc_http_trace)) {
gpr_log(GPR_DEBUG, "%s: Start BDP ping", t->peer_string);
}
@ -2443,7 +2447,7 @@ static void start_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
static void finish_bdp_ping_locked(grpc_exec_ctx *exec_ctx, void *tp,
grpc_error *error) {
grpc_chttp2_transport *t = tp;
grpc_chttp2_transport *t = (grpc_chttp2_transport *)tp;
if (GRPC_TRACER_ON(grpc_http_trace)) {
gpr_log(GPR_DEBUG, "%s: Complete BDP ping", t->peer_string);
}
@ -2492,7 +2496,7 @@ void grpc_chttp2_config_default_keepalive_args(grpc_channel_args *args,
static void init_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
grpc_chttp2_transport *t = arg;
grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
GPR_ASSERT(t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_WAITING);
if (t->destroying || t->closed) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING;
@ -2524,7 +2528,7 @@ static void init_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
static void start_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
grpc_chttp2_transport *t = arg;
grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
GRPC_CHTTP2_REF_TRANSPORT(t, "keepalive watchdog");
grpc_timer_init(
exec_ctx, &t->keepalive_watchdog_timer,
@ -2534,7 +2538,7 @@ static void start_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
static void finish_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
grpc_chttp2_transport *t = arg;
grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) {
if (error == GRPC_ERROR_NONE) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_WAITING;
@ -2551,7 +2555,7 @@ static void finish_keepalive_ping_locked(grpc_exec_ctx *exec_ctx, void *arg,
static void keepalive_watchdog_fired_locked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
grpc_chttp2_transport *t = arg;
grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
if (t->keepalive_state == GRPC_CHTTP2_KEEPALIVE_STATE_PINGING) {
if (error == GRPC_ERROR_NONE) {
t->keepalive_state = GRPC_CHTTP2_KEEPALIVE_STATE_DYING;
@ -2632,7 +2636,8 @@ static void incoming_byte_stream_unref(grpc_exec_ctx *exec_ctx,
static void incoming_byte_stream_next_locked(grpc_exec_ctx *exec_ctx,
void *argp,
grpc_error *error_ignored) {
grpc_chttp2_incoming_byte_stream *bs = argp;
grpc_chttp2_incoming_byte_stream *bs =
(grpc_chttp2_incoming_byte_stream *)argp;
grpc_chttp2_transport *t = bs->transport;
grpc_chttp2_stream *s = bs->stream;
@ -2842,7 +2847,8 @@ static const grpc_byte_stream_vtable grpc_chttp2_incoming_byte_stream_vtable = {
static void incoming_byte_stream_destroy_locked(grpc_exec_ctx *exec_ctx,
void *byte_stream,
grpc_error *error_ignored) {
grpc_chttp2_incoming_byte_stream *bs = byte_stream;
grpc_chttp2_incoming_byte_stream *bs =
(grpc_chttp2_incoming_byte_stream *)byte_stream;
grpc_chttp2_stream *s = bs->stream;
grpc_chttp2_transport *t = s->t;
@ -2898,7 +2904,7 @@ static void post_destructive_reclaimer(grpc_exec_ctx *exec_ctx,
static void benign_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
grpc_chttp2_transport *t = arg;
grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
if (error == GRPC_ERROR_NONE &&
grpc_chttp2_stream_map_size(&t->stream_map) == 0) {
/* Channel with no active streams: send a goaway to try and make it
@ -2928,11 +2934,12 @@ static void benign_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *arg,
static void destructive_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
grpc_chttp2_transport *t = arg;
grpc_chttp2_transport *t = (grpc_chttp2_transport *)arg;
size_t n = grpc_chttp2_stream_map_size(&t->stream_map);
t->destructive_reclaimer_registered = false;
if (error == GRPC_ERROR_NONE && n > 0) {
grpc_chttp2_stream *s = grpc_chttp2_stream_map_rand(&t->stream_map);
grpc_chttp2_stream *s =
(grpc_chttp2_stream *)grpc_chttp2_stream_map_rand(&t->stream_map);
if (GRPC_TRACER_ON(grpc_resource_quota_trace)) {
gpr_log(GPR_DEBUG, "HTTP2: %s - abandon stream id %d", t->peer_string,
s->id);
@ -2979,7 +2986,8 @@ static const grpc_transport_vtable vtable = {sizeof(grpc_chttp2_stream),
grpc_transport *grpc_create_chttp2_transport(
grpc_exec_ctx *exec_ctx, const grpc_channel_args *channel_args,
grpc_endpoint *ep, int is_client) {
grpc_chttp2_transport *t = gpr_zalloc(sizeof(grpc_chttp2_transport));
grpc_chttp2_transport *t =
(grpc_chttp2_transport *)gpr_zalloc(sizeof(grpc_chttp2_transport));
init_transport(exec_ctx, t, channel_args, ep, is_client != 0);
return &t->base;
}

@ -86,13 +86,14 @@ grpc_channel_args *grpc_channel_args_copy_and_add_and_remove(
}
}
// Create result.
grpc_channel_args *dst = gpr_malloc(sizeof(grpc_channel_args));
grpc_channel_args *dst =
(grpc_channel_args *)gpr_malloc(sizeof(grpc_channel_args));
dst->num_args = num_args_to_copy + num_to_add;
if (dst->num_args == 0) {
dst->args = NULL;
return dst;
}
dst->args = gpr_malloc(sizeof(grpc_arg) * dst->num_args);
dst->args = (grpc_arg *)gpr_malloc(sizeof(grpc_arg) * dst->num_args);
// Copy args from src that are not being removed.
size_t dst_idx = 0;
if (src != NULL) {
@ -117,7 +118,7 @@ grpc_channel_args *grpc_channel_args_copy(const grpc_channel_args *src) {
grpc_channel_args *grpc_channel_args_union(const grpc_channel_args *a,
const grpc_channel_args *b) {
const size_t max_out = (a->num_args + b->num_args);
grpc_arg *uniques = gpr_malloc(sizeof(*uniques) * max_out);
grpc_arg *uniques = (grpc_arg *)gpr_malloc(sizeof(*uniques) * max_out);
for (size_t i = 0; i < a->num_args; ++i) uniques[i] = a->args[i];
size_t uniques_idx = a->num_args;
@ -160,24 +161,25 @@ static int cmp_arg(const grpc_arg *a, const grpc_arg *b) {
/* stabilizing comparison function: since channel_args ordering matters for
* keys with the same name, we need to preserve that ordering */
static int cmp_key_stable(const void *ap, const void *bp) {
const grpc_arg *const *a = ap;
const grpc_arg *const *b = bp;
const grpc_arg *const *a = (const grpc_arg *const *)ap;
const grpc_arg *const *b = (const grpc_arg *const *)bp;
int c = strcmp((*a)->key, (*b)->key);
if (c == 0) c = GPR_ICMP(*a, *b);
return c;
}
grpc_channel_args *grpc_channel_args_normalize(const grpc_channel_args *a) {
grpc_arg **args = gpr_malloc(sizeof(grpc_arg *) * a->num_args);
grpc_arg **args = (grpc_arg **)gpr_malloc(sizeof(grpc_arg *) * a->num_args);
for (size_t i = 0; i < a->num_args; i++) {
args[i] = &a->args[i];
}
if (a->num_args > 1)
qsort(args, a->num_args, sizeof(grpc_arg *), cmp_key_stable);
grpc_channel_args *b = gpr_malloc(sizeof(grpc_channel_args));
grpc_channel_args *b =
(grpc_channel_args *)gpr_malloc(sizeof(grpc_channel_args));
b->num_args = a->num_args;
b->args = gpr_malloc(sizeof(grpc_arg) * b->num_args);
b->args = (grpc_arg *)gpr_malloc(sizeof(grpc_arg) * b->num_args);
for (size_t i = 0; i < a->num_args; i++) {
b->args[i] = copy_arg(args[i]);
}

@ -51,7 +51,8 @@ struct grpc_channel_stack_builder_iterator {
};
grpc_channel_stack_builder *grpc_channel_stack_builder_create(void) {
grpc_channel_stack_builder *b = gpr_zalloc(sizeof(*b));
grpc_channel_stack_builder *b =
(grpc_channel_stack_builder *)gpr_zalloc(sizeof(*b));
b->begin.filter = NULL;
b->end.filter = NULL;
@ -76,7 +77,8 @@ const char *grpc_channel_stack_builder_get_target(
static grpc_channel_stack_builder_iterator *create_iterator_at_filter_node(
grpc_channel_stack_builder *builder, filter_node *node) {
grpc_channel_stack_builder_iterator *it = gpr_malloc(sizeof(*it));
grpc_channel_stack_builder_iterator *it =
(grpc_channel_stack_builder_iterator *)gpr_malloc(sizeof(*it));
it->builder = builder;
it->node = node;
return it;

@ -100,8 +100,8 @@ static callback_state *get_state_for_batch(
static void con_start_transport_stream_op_batch(
grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_transport_stream_op_batch *batch) {
call_data *calld = elem->call_data;
channel_data *chand = elem->channel_data;
call_data *calld = (call_data *)elem->call_data;
channel_data *chand = (channel_data *)elem->channel_data;
if (batch->recv_initial_metadata) {
callback_state *state = &calld->recv_initial_metadata_ready;
intercept_callback(
@ -136,7 +136,7 @@ static void con_start_transport_stream_op_batch(
static void con_start_transport_op(grpc_exec_ctx *exec_ctx,
grpc_channel_element *elem,
grpc_transport_op *op) {
channel_data *chand = elem->channel_data;
channel_data *chand = (channel_data *)elem->channel_data;
grpc_transport_perform_op(exec_ctx, chand->transport, op);
}
@ -144,8 +144,8 @@ static void con_start_transport_op(grpc_exec_ctx *exec_ctx,
static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
grpc_call_element *elem,
const grpc_call_element_args *args) {
call_data *calld = elem->call_data;
channel_data *chand = elem->channel_data;
call_data *calld = (call_data *)elem->call_data;
channel_data *chand = (channel_data *)elem->channel_data;
calld->call_combiner = args->call_combiner;
int r = grpc_transport_init_stream(
exec_ctx, chand->transport, TRANSPORT_STREAM_FROM_CALL_DATA(calld),
@ -158,8 +158,8 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx,
static void set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
grpc_call_element *elem,
grpc_polling_entity *pollent) {
call_data *calld = elem->call_data;
channel_data *chand = elem->channel_data;
call_data *calld = (call_data *)elem->call_data;
channel_data *chand = (channel_data *)elem->channel_data;
grpc_transport_set_pops(exec_ctx, chand->transport,
TRANSPORT_STREAM_FROM_CALL_DATA(calld), pollent);
}
@ -168,8 +168,8 @@ static void set_pollset_or_pollset_set(grpc_exec_ctx *exec_ctx,
static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
const grpc_call_final_info *final_info,
grpc_closure *then_schedule_closure) {
call_data *calld = elem->call_data;
channel_data *chand = elem->channel_data;
call_data *calld = (call_data *)elem->call_data;
channel_data *chand = (channel_data *)elem->channel_data;
grpc_transport_destroy_stream(exec_ctx, chand->transport,
TRANSPORT_STREAM_FROM_CALL_DATA(calld),
then_schedule_closure);
@ -218,7 +218,7 @@ static void bind_transport(grpc_channel_stack *channel_stack,
channel_data *cd = (channel_data *)elem->channel_data;
GPR_ASSERT(elem->filter == &grpc_connected_filter);
GPR_ASSERT(cd->transport == NULL);
cd->transport = t;
cd->transport = (grpc_transport *)t;
/* HACK(ctiller): increase call stack size for the channel to make space
for channel data. We need a cleaner (but performant) way to do this,
@ -226,7 +226,8 @@ static void bind_transport(grpc_channel_stack *channel_stack,
This is only "safe" because call stacks place no additional data after
the last call element, and the last call element MUST be the connected
channel. */
channel_stack->call_stack_size += grpc_transport_stream_size(t);
channel_stack->call_stack_size +=
grpc_transport_stream_size((grpc_transport *)t);
}
bool grpc_add_connected_filter(grpc_exec_ctx *exec_ctx,
@ -240,6 +241,6 @@ bool grpc_add_connected_filter(grpc_exec_ctx *exec_ctx,
}
grpc_stream *grpc_connected_channel_get_stream(grpc_call_element *elem) {
call_data *calld = elem->call_data;
call_data *calld = (call_data *)elem->call_data;
return TRANSPORT_STREAM_FROM_CALL_DATA(calld);
}

@ -84,7 +84,8 @@ struct grpc_handshake_manager {
};
grpc_handshake_manager* grpc_handshake_manager_create() {
grpc_handshake_manager* mgr = gpr_zalloc(sizeof(grpc_handshake_manager));
grpc_handshake_manager* mgr =
(grpc_handshake_manager*)gpr_zalloc(sizeof(grpc_handshake_manager));
gpr_mu_init(&mgr->mu);
gpr_ref_init(&mgr->refs, 1);
return mgr;
@ -137,8 +138,8 @@ void grpc_handshake_manager_add(grpc_handshake_manager* mgr,
realloc_count = mgr->count * 2;
}
if (realloc_count > 0) {
mgr->handshakers =
gpr_realloc(mgr->handshakers, realloc_count * sizeof(grpc_handshaker*));
mgr->handshakers = (grpc_handshaker**)gpr_realloc(
mgr->handshakers, realloc_count * sizeof(grpc_handshaker*));
}
mgr->handshakers[mgr->count++] = handshaker;
gpr_mu_unlock(&mgr->mu);
@ -205,7 +206,7 @@ static bool call_next_handshaker_locked(grpc_exec_ctx* exec_ctx,
// handshakers together.
static void call_next_handshaker(grpc_exec_ctx* exec_ctx, void* arg,
grpc_error* error) {
grpc_handshake_manager* mgr = arg;
grpc_handshake_manager* mgr = (grpc_handshake_manager*)arg;
gpr_mu_lock(&mgr->mu);
bool done = call_next_handshaker_locked(exec_ctx, mgr, GRPC_ERROR_REF(error));
gpr_mu_unlock(&mgr->mu);
@ -219,7 +220,7 @@ static void call_next_handshaker(grpc_exec_ctx* exec_ctx, void* arg,
// Callback invoked when deadline is exceeded.
static void on_timeout(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {
grpc_handshake_manager* mgr = arg;
grpc_handshake_manager* mgr = (grpc_handshake_manager*)arg;
if (error == GRPC_ERROR_NONE) { // Timer fired, rather than being cancelled.
grpc_handshake_manager_shutdown(
exec_ctx, mgr,
@ -241,7 +242,8 @@ void grpc_handshake_manager_do_handshake(
mgr->args.endpoint = endpoint;
mgr->args.args = grpc_channel_args_copy(channel_args);
mgr->args.user_data = user_data;
mgr->args.read_buffer = gpr_malloc(sizeof(*mgr->args.read_buffer));
mgr->args.read_buffer =
(grpc_slice_buffer*)gpr_malloc(sizeof(*mgr->args.read_buffer));
grpc_slice_buffer_init(mgr->args.read_buffer);
// Initialize state needed for calling handshakers.
mgr->acceptor = acceptor;

@ -34,7 +34,7 @@ typedef struct {
static void grpc_handshaker_factory_list_register(
grpc_handshaker_factory_list* list, bool at_start,
grpc_handshaker_factory* factory) {
list->list = gpr_realloc(
list->list = (grpc_handshaker_factory**)gpr_realloc(
list->list, (list->num_factories + 1) * sizeof(grpc_handshaker_factory*));
if (at_start) {
memmove(list->list + 1, list->list,

@ -33,7 +33,7 @@ static size_t g_num_cores;
void grpc_stats_init(void) {
g_num_cores = GPR_MAX(1, gpr_cpu_num_cores());
grpc_stats_per_cpu_storage =
gpr_zalloc(sizeof(grpc_stats_data) * g_num_cores);
(grpc_stats_data *)gpr_zalloc(sizeof(grpc_stats_data) * g_num_cores);
}
void grpc_stats_shutdown(void) { gpr_free(grpc_stats_per_cpu_storage); }

@ -98,7 +98,7 @@ grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request,
gpr_strvec_destroy(&out);
if (body_bytes) {
tmp = gpr_realloc(tmp, out_len + body_size);
tmp = (char *)gpr_realloc(tmp, out_len + body_size);
memcpy(tmp + out_len, body_bytes, body_size);
out_len += body_size;
}

@ -130,7 +130,7 @@ static void do_read(grpc_exec_ctx *exec_ctx, internal_request *req) {
static void on_read(grpc_exec_ctx *exec_ctx, void *user_data,
grpc_error *error) {
internal_request *req = user_data;
internal_request *req = (internal_request *)user_data;
size_t i;
for (i = 0; i < req->incoming.count; i++) {
@ -159,7 +159,7 @@ static void on_written(grpc_exec_ctx *exec_ctx, internal_request *req) {
}
static void done_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
internal_request *req = arg;
internal_request *req = (internal_request *)arg;
if (error == GRPC_ERROR_NONE) {
on_written(exec_ctx, req);
} else {
@ -175,7 +175,7 @@ static void start_write(grpc_exec_ctx *exec_ctx, internal_request *req) {
static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
grpc_endpoint *ep) {
internal_request *req = arg;
internal_request *req = (internal_request *)arg;
if (!ep) {
next_address(exec_ctx, req, GRPC_ERROR_CREATE_FROM_STATIC_STRING(
@ -189,7 +189,7 @@ static void on_handshake_done(grpc_exec_ctx *exec_ctx, void *arg,
static void on_connected(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
internal_request *req = arg;
internal_request *req = (internal_request *)arg;
if (!req->ep) {
next_address(exec_ctx, req, GRPC_ERROR_REF(error));
@ -226,7 +226,7 @@ static void next_address(grpc_exec_ctx *exec_ctx, internal_request *req,
}
static void on_resolved(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {
internal_request *req = arg;
internal_request *req = (internal_request *)arg;
if (error != GRPC_ERROR_NONE) {
finish(exec_ctx, req, GRPC_ERROR_REF(error));
return;
@ -243,7 +243,8 @@ static void internal_request_begin(grpc_exec_ctx *exec_ctx,
gpr_timespec deadline, grpc_closure *on_done,
grpc_httpcli_response *response,
const char *name, grpc_slice request_text) {
internal_request *req = gpr_malloc(sizeof(internal_request));
internal_request *req =
(internal_request *)gpr_malloc(sizeof(internal_request));
memset(req, 0, sizeof(*req));
req->request_text = request_text;
grpc_http_parser_init(&req->parser, GRPC_HTTP_RESPONSE, response);

@ -28,7 +28,7 @@
grpc_tracer_flag grpc_http1_trace = GRPC_TRACER_INITIALIZER(false, "http1");
static char *buf2str(void *buffer, size_t length) {
char *out = gpr_malloc(length + 1);
char *out = (char *)gpr_malloc(length + 1);
memcpy(out, buffer, length);
out[length] = 0;
return out;
@ -197,7 +197,8 @@ static grpc_error *add_header(grpc_http_parser *parser) {
if (*hdr_count == parser->hdr_capacity) {
parser->hdr_capacity =
GPR_MAX(parser->hdr_capacity + 1, parser->hdr_capacity * 3 / 2);
*hdrs = gpr_realloc(*hdrs, parser->hdr_capacity * sizeof(**hdrs));
*hdrs = (grpc_http_header *)gpr_realloc(
*hdrs, parser->hdr_capacity * sizeof(**hdrs));
}
(*hdrs)[(*hdr_count)++] = hdr;
@ -255,7 +256,7 @@ static grpc_error *addbyte_body(grpc_http_parser *parser, uint8_t byte) {
if (*body_length == parser->body_capacity) {
parser->body_capacity = GPR_MAX(8, parser->body_capacity * 3 / 2);
*body = gpr_realloc((void *)*body, parser->body_capacity);
*body = (char *)gpr_realloc((void *)*body, parser->body_capacity);
}
(*body)[*body_length] = (char)byte;
(*body_length)++;

@ -109,7 +109,7 @@ typedef struct {
static void closure_wrapper(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
wrapped_closure *wc = arg;
wrapped_closure *wc = (wrapped_closure *)arg;
grpc_iomgr_cb_func cb = wc->cb;
void *cb_arg = wc->cb_arg;
gpr_free(wc);
@ -124,7 +124,7 @@ grpc_closure *grpc_closure_create(const char *file, int line,
grpc_closure *grpc_closure_create(grpc_iomgr_cb_func cb, void *cb_arg,
grpc_closure_scheduler *scheduler) {
#endif
wrapped_closure *wc = gpr_malloc(sizeof(*wc));
wrapped_closure *wc = (wrapped_closure *)gpr_malloc(sizeof(*wc));
wc->cb = cb;
wc->cb_arg = cb_arg;
#ifndef NDEBUG

@ -211,7 +211,7 @@ static uint8_t get_placement(grpc_error **err, size_t size) {
#ifndef NDEBUG
grpc_error *orig = *err;
#endif
*err = gpr_realloc(
*err = (grpc_error *)gpr_realloc(
*err, sizeof(grpc_error) + (*err)->arena_capacity * sizeof(intptr_t));
#ifndef NDEBUG
if (GRPC_TRACER_ON(grpc_trace_error_refcount)) {
@ -406,7 +406,8 @@ static grpc_error *copy_error_and_unref(grpc_error *in) {
if (in->arena_capacity - in->arena_size < (uint8_t)SLOTS_PER_STR) {
new_arena_capacity = (uint8_t)(3 * new_arena_capacity / 2);
}
out = gpr_malloc(sizeof(*in) + new_arena_capacity * sizeof(intptr_t));
out = (grpc_error *)gpr_malloc(sizeof(*in) +
new_arena_capacity * sizeof(intptr_t));
#ifndef NDEBUG
if (GRPC_TRACER_ON(grpc_trace_error_refcount)) {
gpr_log(GPR_DEBUG, "%p create copying %p", out, in);
@ -530,7 +531,7 @@ typedef struct {
static void append_chr(char c, char **s, size_t *sz, size_t *cap) {
if (*sz == *cap) {
*cap = GPR_MAX(8, 3 * *cap / 2);
*s = gpr_realloc(*s, *cap);
*s = (char *)gpr_realloc(*s, *cap);
}
(*s)[(*sz)++] = c;
}
@ -582,7 +583,8 @@ static void append_esc_str(const uint8_t *str, size_t len, char **s, size_t *sz,
static void append_kv(kv_pairs *kvs, char *key, char *value) {
if (kvs->num_kvs == kvs->cap_kvs) {
kvs->cap_kvs = GPR_MAX(3 * kvs->cap_kvs / 2, 4);
kvs->kvs = gpr_realloc(kvs->kvs, sizeof(*kvs->kvs) * kvs->cap_kvs);
kvs->kvs =
(kv_pair *)gpr_realloc(kvs->kvs, sizeof(*kvs->kvs) * kvs->cap_kvs);
}
kvs->kvs[kvs->num_kvs].key = key;
kvs->kvs[kvs->num_kvs].value = value;
@ -695,8 +697,8 @@ static char *errs_string(grpc_error *err) {
}
static int cmp_kvs(const void *a, const void *b) {
const kv_pair *ka = a;
const kv_pair *kb = b;
const kv_pair *ka = (const kv_pair *)a;
const kv_pair *kb = (const kv_pair *)b;
return strcmp(ka->key, kb->key);
}

@ -260,7 +260,7 @@ static grpc_fd *fd_create(int fd, const char *name) {
gpr_mu_unlock(&fd_freelist_mu);
if (new_fd == NULL) {
new_fd = gpr_malloc(sizeof(grpc_fd));
new_fd = (grpc_fd *)gpr_malloc(sizeof(grpc_fd));
}
new_fd->fd = fd;
@ -442,8 +442,8 @@ static grpc_error *pollset_global_init(void) {
return GRPC_OS_ERROR(errno, "epoll_ctl");
}
g_num_neighbourhoods = GPR_CLAMP(gpr_cpu_num_cores(), 1, MAX_NEIGHBOURHOODS);
g_neighbourhoods =
gpr_zalloc(sizeof(*g_neighbourhoods) * g_num_neighbourhoods);
g_neighbourhoods = (pollset_neighbourhood *)gpr_zalloc(
sizeof(*g_neighbourhoods) * g_num_neighbourhoods);
for (size_t i = 0; i < g_num_neighbourhoods; i++) {
gpr_mu_init(&g_neighbourhoods[i].mu);
}

@ -80,7 +80,7 @@ grpc_end2end_proxy *grpc_end2end_proxy_create(const grpc_end2end_proxy_def *def,
int proxy_port = grpc_pick_unused_port_or_die();
int server_port = grpc_pick_unused_port_or_die();
grpc_end2end_proxy *proxy = gpr_malloc(sizeof(*proxy));
grpc_end2end_proxy *proxy = (grpc_end2end_proxy *)gpr_malloc(sizeof(*proxy));
memset(proxy, 0, sizeof(*proxy));
gpr_join_host_port(&proxy->proxy_port, "localhost", proxy_port);
@ -106,14 +106,14 @@ grpc_end2end_proxy *grpc_end2end_proxy_create(const grpc_end2end_proxy_def *def,
}
static closure *new_closure(void (*func)(void *arg, int success), void *arg) {
closure *cl = gpr_malloc(sizeof(*cl));
closure *cl = (closure *)gpr_malloc(sizeof(*cl));
cl->func = func;
cl->arg = arg;
return cl;
}
static void shutdown_complete(void *arg, int success) {
grpc_end2end_proxy *proxy = arg;
grpc_end2end_proxy *proxy = (grpc_end2end_proxy *)arg;
proxy->shutdown = 1;
grpc_completion_queue_shutdown(proxy->cq);
}
@ -146,12 +146,12 @@ static void unrefpc(proxy_call *pc, const char *reason) {
static void refpc(proxy_call *pc, const char *reason) { gpr_ref(&pc->refs); }
static void on_c2p_sent_initial_metadata(void *arg, int success) {
proxy_call *pc = arg;
proxy_call *pc = (proxy_call *)arg;
unrefpc(pc, "on_c2p_sent_initial_metadata");
}
static void on_p2s_recv_initial_metadata(void *arg, int success) {
proxy_call *pc = arg;
proxy_call *pc = (proxy_call *)arg;
grpc_op op;
grpc_call_error err;
@ -172,14 +172,14 @@ static void on_p2s_recv_initial_metadata(void *arg, int success) {
}
static void on_p2s_sent_initial_metadata(void *arg, int success) {
proxy_call *pc = arg;
proxy_call *pc = (proxy_call *)arg;
unrefpc(pc, "on_p2s_sent_initial_metadata");
}
static void on_c2p_recv_msg(void *arg, int success);
static void on_p2s_sent_message(void *arg, int success) {
proxy_call *pc = arg;
proxy_call *pc = (proxy_call *)arg;
grpc_op op;
grpc_call_error err;
@ -199,12 +199,12 @@ static void on_p2s_sent_message(void *arg, int success) {
}
static void on_p2s_sent_close(void *arg, int success) {
proxy_call *pc = arg;
proxy_call *pc = (proxy_call *)arg;
unrefpc(pc, "on_p2s_sent_close");
}
static void on_c2p_recv_msg(void *arg, int success) {
proxy_call *pc = arg;
proxy_call *pc = (proxy_call *)arg;
grpc_op op;
grpc_call_error err;
@ -235,7 +235,7 @@ static void on_c2p_recv_msg(void *arg, int success) {
static void on_p2s_recv_msg(void *arg, int success);
static void on_c2p_sent_message(void *arg, int success) {
proxy_call *pc = arg;
proxy_call *pc = (proxy_call *)arg;
grpc_op op;
grpc_call_error err;
@ -255,7 +255,7 @@ static void on_c2p_sent_message(void *arg, int success) {
}
static void on_p2s_recv_msg(void *arg, int success) {
proxy_call *pc = arg;
proxy_call *pc = (proxy_call *)arg;
grpc_op op;
grpc_call_error err;
@ -275,12 +275,12 @@ static void on_p2s_recv_msg(void *arg, int success) {
}
static void on_c2p_sent_status(void *arg, int success) {
proxy_call *pc = arg;
proxy_call *pc = (proxy_call *)arg;
unrefpc(pc, "on_c2p_sent_status");
}
static void on_p2s_status(void *arg, int success) {
proxy_call *pc = arg;
proxy_call *pc = (proxy_call *)arg;
grpc_op op;
grpc_call_error err;
@ -305,18 +305,18 @@ static void on_p2s_status(void *arg, int success) {
}
static void on_c2p_closed(void *arg, int success) {
proxy_call *pc = arg;
proxy_call *pc = (proxy_call *)arg;
unrefpc(pc, "on_c2p_closed");
}
static void on_new_call(void *arg, int success) {
grpc_end2end_proxy *proxy = arg;
grpc_end2end_proxy *proxy = (grpc_end2end_proxy *)arg;
grpc_call_error err;
if (success) {
grpc_op op;
memset(&op, 0, sizeof(op));
proxy_call *pc = gpr_malloc(sizeof(*pc));
proxy_call *pc = (proxy_call *)gpr_malloc(sizeof(*pc));
memset(pc, 0, sizeof(*pc));
pc->proxy = proxy;
GPR_SWAP(grpc_metadata_array, pc->c2p_initial_metadata,
@ -404,7 +404,7 @@ static void request_call(grpc_end2end_proxy *proxy) {
}
static void thread_main(void *arg) {
grpc_end2end_proxy *proxy = arg;
grpc_end2end_proxy *proxy = (grpc_end2end_proxy *)arg;
closure *cl;
for (;;) {
grpc_event ev = grpc_completion_queue_next(
@ -416,7 +416,7 @@ static void thread_main(void *arg) {
case GRPC_QUEUE_SHUTDOWN:
return;
case GRPC_OP_COMPLETE:
cl = ev.tag;
cl = (closure *)ev.tag;
cl->func(cl->arg, ev.success);
gpr_free(cl);
break;

@ -34,7 +34,7 @@ typedef struct {
} child_events;
static void child_thread(void *arg) {
child_events *ce = arg;
child_events *ce = (child_events *)arg;
grpc_event ev;
gpr_event_set(&ce->started, (void *)1);
gpr_log(GPR_DEBUG, "verifying");

@ -195,8 +195,8 @@ typedef struct { uint8_t unused; } channel_data;
static void recv_im_ready(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
grpc_call_element *elem = arg;
call_data *calld = elem->call_data;
grpc_call_element *elem = (grpc_call_element *)arg;
call_data *calld = (call_data *)elem->call_data;
GRPC_CLOSURE_RUN(
exec_ctx, calld->recv_im_ready,
grpc_error_set_int(GRPC_ERROR_CREATE_REFERENCING_FROM_STATIC_STRING(
@ -208,7 +208,7 @@ static void recv_im_ready(grpc_exec_ctx *exec_ctx, void *arg,
static void start_transport_stream_op_batch(
grpc_exec_ctx *exec_ctx, grpc_call_element *elem,
grpc_transport_stream_op_batch *op) {
call_data *calld = elem->call_data;
call_data *calld = (call_data *)elem->call_data;
if (op->recv_initial_metadata) {
calld->recv_im_ready =
op->payload->recv_initial_metadata.recv_initial_metadata_ready;

@ -312,7 +312,7 @@ static const grpc_channel_filter test_server_filter = {
static bool maybe_add_filter(grpc_exec_ctx *exec_ctx,
grpc_channel_stack_builder *builder, void *arg) {
grpc_channel_filter *filter = arg;
grpc_channel_filter *filter = (grpc_channel_filter *)arg;
if (g_enable_filter) {
// Want to add the filter as close to the end as possible, to make
// sure that all of the filters work well together. However, we

@ -91,7 +91,7 @@ static grpc_slice generate_random_slice() {
static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890";
char *output;
const size_t output_size = 1024 * 1024;
output = gpr_malloc(output_size);
output = (char *)gpr_malloc(output_size);
for (i = 0; i < output_size - 1; ++i) {
output[i] = chars[rand() % (int)(sizeof(chars) - 1)];
}

@ -91,7 +91,7 @@ static grpc_slice generate_random_slice() {
static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890";
char *output;
const size_t output_size = 1024 * 1024;
output = gpr_malloc(output_size);
output = (char *)gpr_malloc(output_size);
for (i = 0; i < output_size - 1; ++i) {
output[i] = chars[rand() % (int)(sizeof(chars) - 1)];
}
@ -131,8 +131,10 @@ void resource_quota_server(grpc_end2end_test_config config) {
* will be verified on completion. */
grpc_slice request_payload_slice = generate_random_slice();
grpc_call **client_calls = malloc(sizeof(grpc_call *) * NUM_CALLS);
grpc_call **server_calls = malloc(sizeof(grpc_call *) * NUM_CALLS);
grpc_call **client_calls =
(grpc_call **)malloc(sizeof(grpc_call *) * NUM_CALLS);
grpc_call **server_calls =
(grpc_call **)malloc(sizeof(grpc_call *) * NUM_CALLS);
grpc_metadata_array *initial_metadata_recv =
malloc(sizeof(grpc_metadata_array) * NUM_CALLS);
grpc_metadata_array *trailing_metadata_recv =
@ -141,13 +143,14 @@ void resource_quota_server(grpc_end2end_test_config config) {
malloc(sizeof(grpc_metadata_array) * NUM_CALLS);
grpc_call_details *call_details =
malloc(sizeof(grpc_call_details) * NUM_CALLS);
grpc_status_code *status = malloc(sizeof(grpc_status_code) * NUM_CALLS);
grpc_slice *details = malloc(sizeof(grpc_slice) * NUM_CALLS);
grpc_status_code *status =
(grpc_status_code *)malloc(sizeof(grpc_status_code) * NUM_CALLS);
grpc_slice *details = (grpc_slice *)malloc(sizeof(grpc_slice) * NUM_CALLS);
grpc_byte_buffer **request_payload =
malloc(sizeof(grpc_byte_buffer *) * NUM_CALLS);
grpc_byte_buffer **request_payload_recv =
malloc(sizeof(grpc_byte_buffer *) * NUM_CALLS);
int *was_cancelled = malloc(sizeof(int) * NUM_CALLS);
int *was_cancelled = (int *)malloc(sizeof(int) * NUM_CALLS);
grpc_call_error error;
int pending_client_calls = 0;
int pending_server_start_calls = 0;

@ -78,7 +78,7 @@ static void test_early_server_shutdown_finishes_tags(
grpc_end2end_test_fixture f = begin_test(
config, "test_early_server_shutdown_finishes_tags", NULL, NULL);
cq_verifier *cqv = cq_verifier_create(f.cq);
grpc_call *s = (void *)1;
grpc_call *s = (grpc_call *)(uintptr_t)1;
grpc_call_details call_details;
grpc_metadata_array request_metadata_recv;

@ -95,7 +95,7 @@ static grpc_slice generate_random_slice() {
static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890";
char *output;
const size_t output_size = 1024 * 1024;
output = gpr_malloc(output_size);
output = (char *)gpr_malloc(output_size);
for (i = 0; i < output_size - 1; ++i) {
output[i] = chars[rand() % (int)(sizeof(chars) - 1)];
}

@ -77,7 +77,7 @@ static void end_test(grpc_endpoint_test_config config) { config.clean_up(); }
static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size,
size_t *num_blocks, uint8_t *current_data) {
size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1 : 0);
grpc_slice *slices = gpr_malloc(sizeof(grpc_slice) * nslices);
grpc_slice *slices = (grpc_slice *)gpr_malloc(sizeof(grpc_slice) * nslices);
size_t num_bytes_left = num_bytes;
size_t i;
size_t j;
@ -117,7 +117,8 @@ struct read_and_write_test_state {
static void read_and_write_test_read_handler(grpc_exec_ctx *exec_ctx,
void *data, grpc_error *error) {
struct read_and_write_test_state *state = data;
struct read_and_write_test_state *state =
(struct read_and_write_test_state *)data;
state->bytes_read += count_slices(
state->incoming.slices, state->incoming.count, &state->current_read_data);
@ -135,7 +136,8 @@ static void read_and_write_test_read_handler(grpc_exec_ctx *exec_ctx,
static void read_and_write_test_write_handler(grpc_exec_ctx *exec_ctx,
void *data, grpc_error *error) {
struct read_and_write_test_state *state = data;
struct read_and_write_test_state *state =
(struct read_and_write_test_state *)data;
grpc_slice *slices = NULL;
size_t nslices;

@ -48,13 +48,13 @@ static void *guard_malloc(size_t size) {
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, (gpr_atm)size);
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_absolute, (gpr_atm)1);
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_relative, (gpr_atm)1);
ptr = g_old_allocs.malloc_fn(size + sizeof(size));
ptr = (size_t *)g_old_allocs.malloc_fn(size + sizeof(size));
*ptr++ = size;
return ptr;
}
static void *guard_realloc(void *vptr, size_t size) {
size_t *ptr = vptr;
size_t *ptr = (size_t *)vptr;
if (vptr == NULL) {
return guard_malloc(size);
}
@ -67,13 +67,13 @@ static void *guard_realloc(void *vptr, size_t size) {
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, -(gpr_atm)*ptr);
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, (gpr_atm)size);
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_allocs_absolute, (gpr_atm)1);
ptr = g_old_allocs.realloc_fn(ptr, size + sizeof(size));
ptr = (size_t *)g_old_allocs.realloc_fn(ptr, size + sizeof(size));
*ptr++ = size;
return ptr;
}
static void guard_free(void *vptr) {
size_t *ptr = vptr;
size_t *ptr = (size_t *)vptr;
if (!vptr) return;
--ptr;
NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, -(gpr_atm)*ptr);

@ -110,7 +110,7 @@ static const grpc_endpoint_vtable vtable = {
grpc_endpoint *grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice),
grpc_resource_quota *resource_quota) {
grpc_mock_endpoint *m = gpr_malloc(sizeof(*m));
grpc_mock_endpoint *m = (grpc_mock_endpoint *)gpr_malloc(sizeof(*m));
m->base.vtable = &vtable;
char *name;
gpr_asprintf(&name, "mock_endpoint_%" PRIxPTR, (intptr_t)m);

@ -183,7 +183,7 @@ void grpc_passthru_endpoint_create(grpc_endpoint **client,
grpc_endpoint **server,
grpc_resource_quota *resource_quota,
grpc_passthru_endpoint_stats *stats) {
passthru_endpoint *m = gpr_malloc(sizeof(*m));
passthru_endpoint *m = (passthru_endpoint *)gpr_malloc(sizeof(*m));
m->halves = 2;
m->shutdown = 0;
m->stats = stats == NULL ? &m->dummy_stats : stats;

@ -75,7 +75,8 @@ static void chose_port(int port) {
atexit(free_chosen_ports);
}
num_chosen_ports++;
chosen_ports = gpr_realloc(chosen_ports, sizeof(int) * num_chosen_ports);
chosen_ports =
(int *)gpr_realloc(chosen_ports, sizeof(int) * num_chosen_ports);
chosen_ports[num_chosen_ports - 1] = port;
}

@ -42,14 +42,14 @@ typedef struct freereq {
static void destroy_pops_and_shutdown(grpc_exec_ctx *exec_ctx, void *p,
grpc_error *error) {
grpc_pollset *pollset = grpc_polling_entity_pollset(p);
grpc_pollset *pollset = grpc_polling_entity_pollset((grpc_polling_entity *)p);
grpc_pollset_destroy(exec_ctx, pollset);
gpr_free(pollset);
}
static void freed_port_from_server(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
freereq *pr = arg;
freereq *pr = (freereq *)arg;
gpr_mu_lock(pr->mu);
pr->done = 1;
GRPC_LOG_IF_ERROR(
@ -73,7 +73,7 @@ void grpc_free_port_using_server(int port) {
memset(&req, 0, sizeof(req));
memset(&rsp, 0, sizeof(rsp));
grpc_pollset *pollset = gpr_zalloc(grpc_pollset_size());
grpc_pollset *pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size());
grpc_pollset_init(pollset, &pr.mu);
pr.pops = grpc_polling_entity_create_from_pollset(pollset);
shutdown_closure = GRPC_CLOSURE_CREATE(destroy_pops_and_shutdown, &pr.pops,
@ -130,7 +130,7 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
size_t i;
int port = 0;
portreq *pr = arg;
portreq *pr = (portreq *)arg;
int failed = 0;
grpc_httpcli_response *response = &pr->response;
@ -204,7 +204,7 @@ int grpc_pick_port_using_server(void) {
memset(&pr, 0, sizeof(pr));
memset(&req, 0, sizeof(req));
grpc_pollset *pollset = gpr_zalloc(grpc_pollset_size());
grpc_pollset *pollset = (grpc_pollset *)gpr_zalloc(grpc_pollset_size());
grpc_pollset_init(pollset, &pr.mu);
pr.pops = grpc_polling_entity_create_from_pollset(pollset);
shutdown_closure = GRPC_CLOSURE_CREATE(destroy_pops_and_shutdown, &pr.pops,

@ -44,7 +44,8 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices,
switch (mode) {
case GRPC_SLICE_SPLIT_IDENTITY:
*dst_slice_count = src_slice_count;
*dst_slices = gpr_malloc(sizeof(grpc_slice) * src_slice_count);
*dst_slices =
(grpc_slice *)gpr_malloc(sizeof(grpc_slice) * src_slice_count);
for (i = 0; i < src_slice_count; i++) {
(*dst_slices)[i] = src_slices[i];
grpc_slice_ref((*dst_slices)[i]);
@ -56,7 +57,7 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices,
for (i = 0; i < src_slice_count; i++) {
length += GRPC_SLICE_LENGTH(src_slices[i]);
}
*dst_slices = gpr_malloc(sizeof(grpc_slice));
*dst_slices = (grpc_slice *)gpr_malloc(sizeof(grpc_slice));
**dst_slices = grpc_slice_malloc(length);
length = 0;
for (i = 0; i < src_slice_count; i++) {
@ -72,7 +73,7 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices,
length += GRPC_SLICE_LENGTH(src_slices[i]);
}
*dst_slice_count = length;
*dst_slices = gpr_malloc(sizeof(grpc_slice) * length);
*dst_slices = (grpc_slice *)gpr_malloc(sizeof(grpc_slice) * length);
length = 0;
for (i = 0; i < src_slice_count; i++) {
for (j = 0; j < GRPC_SLICE_LENGTH(src_slices[i]); j++) {
@ -112,7 +113,7 @@ grpc_slice grpc_slice_merge(grpc_slice *slices, size_t nslices) {
for (i = 0; i < nslices; i++) {
if (GRPC_SLICE_LENGTH(slices[i]) + length > capacity) {
capacity = GPR_MAX(capacity * 2, GRPC_SLICE_LENGTH(slices[i]) + length);
out = gpr_realloc(out, capacity);
out = (uint8_t *)gpr_realloc(out, capacity);
}
memcpy(out + length, GRPC_SLICE_START_PTR(slices[i]),
GRPC_SLICE_LENGTH(slices[i]));

@ -128,7 +128,7 @@ static int te_get_fd(grpc_endpoint *ep) {
static void te_finish_write(grpc_exec_ctx *exec_ctx, void *arg,
grpc_error *error) {
trickle_endpoint *te = arg;
trickle_endpoint *te = (trickle_endpoint *)arg;
gpr_mu_lock(&te->mu);
te->writing = false;
grpc_slice_buffer_reset_and_unref(&te->writing_buffer);
@ -142,7 +142,7 @@ static const grpc_endpoint_vtable vtable = {
grpc_endpoint *grpc_trickle_endpoint_create(grpc_endpoint *wrap,
double bytes_per_second) {
trickle_endpoint *te = gpr_malloc(sizeof(*te));
trickle_endpoint *te = (trickle_endpoint *)gpr_malloc(sizeof(*te));
te->base.vtable = &vtable;
te->wrapped = wrap;
te->bytes_per_second = bytes_per_second;

Loading…
Cancel
Save