diff options
Diffstat (limited to 'test/core/util')
23 files changed, 267 insertions, 265 deletions
diff --git a/test/core/util/debugger_macros.cc b/test/core/util/debugger_macros.cc index 72384f2dd7..5985fcfb83 100644 --- a/test/core/util/debugger_macros.cc +++ b/test/core/util/debugger_macros.cc @@ -31,12 +31,12 @@ extern "C" void grpc_summon_debugger_macros() {} -grpc_stream *grpc_transport_stream_from_call(grpc_call *call) { - grpc_call_stack *cs = grpc_call_get_call_stack(call); +grpc_stream* grpc_transport_stream_from_call(grpc_call* call) { + grpc_call_stack* cs = grpc_call_get_call_stack(call); for (;;) { - grpc_call_element *el = grpc_call_stack_element(cs, cs->count - 1); + grpc_call_element* el = grpc_call_stack_element(cs, cs->count - 1); if (el->filter == &grpc_client_channel_filter) { - grpc_subchannel_call *scc = grpc_client_channel_get_subchannel_call(el); + grpc_subchannel_call* scc = grpc_client_channel_get_subchannel_call(el); if (scc == NULL) { fprintf(stderr, "No subchannel-call"); return NULL; @@ -51,6 +51,6 @@ grpc_stream *grpc_transport_stream_from_call(grpc_call *call) { } } -grpc_chttp2_stream *grpc_chttp2_stream_from_call(grpc_call *call) { - return (grpc_chttp2_stream *)grpc_transport_stream_from_call(call); +grpc_chttp2_stream* grpc_chttp2_stream_from_call(grpc_call* call) { + return (grpc_chttp2_stream*)grpc_transport_stream_from_call(call); } diff --git a/test/core/util/grpc_profiler.c b/test/core/util/grpc_profiler.c index 47b0270e29..88f233598b 100644 --- a/test/core/util/grpc_profiler.c +++ b/test/core/util/grpc_profiler.c @@ -21,13 +21,13 @@ #if GRPC_HAVE_PERFTOOLS #include <gperftools/profiler.h> -void grpc_profiler_start(const char *filename) { ProfilerStart(filename); } +void grpc_profiler_start(const char* filename) { ProfilerStart(filename); } void grpc_profiler_stop() { ProfilerStop(); } #else #include <grpc/support/log.h> -void grpc_profiler_start(const char *filename) { +void grpc_profiler_start(const char* filename) { static int printed_warning = 0; if (!printed_warning) { gpr_log(GPR_DEBUG, diff --git a/test/core/util/grpc_profiler.h b/test/core/util/grpc_profiler.h index 8809f55207..0c35822f88 100644 --- a/test/core/util/grpc_profiler.h +++ b/test/core/util/grpc_profiler.h @@ -23,7 +23,7 @@ extern "C" { #endif /* __cplusplus */ -void grpc_profiler_start(const char *filename); +void grpc_profiler_start(const char* filename); void grpc_profiler_stop(); #ifdef __cplusplus diff --git a/test/core/util/memory_counters.c b/test/core/util/memory_counters.c index 9fb3ffe095..ff85a63803 100644 --- a/test/core/util/memory_counters.c +++ b/test/core/util/memory_counters.c @@ -27,9 +27,9 @@ static struct grpc_memory_counters g_memory_counters; static gpr_allocation_functions g_old_allocs; -static void *guard_malloc(size_t size); -static void *guard_realloc(void *vptr, size_t size); -static void guard_free(void *vptr); +static void* guard_malloc(size_t size); +static void* guard_realloc(void* vptr, size_t size); +static void guard_free(void* vptr); #ifdef GPR_LOW_LEVEL_COUNTERS /* hide these from the microbenchmark atomic stats */ @@ -41,20 +41,20 @@ static void guard_free(void *vptr); #define NO_BARRIER_LOAD(x) gpr_atm_no_barrier_load(x) #endif -static void *guard_malloc(size_t size) { - size_t *ptr; +static void* guard_malloc(size_t size) { + size_t* ptr; if (!size) return NULL; NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_absolute, (gpr_atm)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 = (size_t *)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 = (size_t *)vptr; +static void* guard_realloc(void* vptr, size_t size) { + 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 = (size_t *)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 = (size_t *)vptr; +static void guard_free(void* vptr) { + size_t* ptr = (size_t*)vptr; if (!vptr) return; --ptr; NO_BARRIER_FETCH_ADD(&g_memory_counters.total_size_relative, -(gpr_atm)*ptr); diff --git a/test/core/util/mock_endpoint.c b/test/core/util/mock_endpoint.c index 7cae5c045e..a467dcdc18 100644 --- a/test/core/util/mock_endpoint.c +++ b/test/core/util/mock_endpoint.c @@ -35,14 +35,14 @@ typedef struct grpc_mock_endpoint { gpr_mu mu; void (*on_write)(grpc_slice slice); grpc_slice_buffer read_buffer; - grpc_slice_buffer *on_read_out; - grpc_closure *on_read; - grpc_resource_user *resource_user; + grpc_slice_buffer* on_read_out; + grpc_closure* on_read; + grpc_resource_user* resource_user; } grpc_mock_endpoint; -static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_slice_buffer *slices, grpc_closure *cb) { - grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep; +static void me_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_slice_buffer* slices, grpc_closure* cb) { + grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep; gpr_mu_lock(&m->mu); if (m->read_buffer.count > 0) { grpc_slice_buffer_swap(&m->read_buffer, slices); @@ -54,28 +54,28 @@ static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, gpr_mu_unlock(&m->mu); } -static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_slice_buffer *slices, grpc_closure *cb) { - grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep; +static void me_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_slice_buffer* slices, grpc_closure* cb) { + grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep; for (size_t i = 0; i < slices->count; i++) { m->on_write(slices->slices[i]); } GRPC_CLOSURE_SCHED(exec_ctx, cb, GRPC_ERROR_NONE); } -static void me_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_pollset *pollset) {} +static void me_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_pollset* pollset) {} -static void me_add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_pollset_set *pollset) {} +static void me_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_pollset_set* pollset) {} -static void me_delete_from_pollset_set(grpc_exec_ctx *exec_ctx, - grpc_endpoint *ep, - grpc_pollset_set *pollset) {} +static void me_delete_from_pollset_set(grpc_exec_ctx* exec_ctx, + grpc_endpoint* ep, + grpc_pollset_set* pollset) {} -static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_error *why) { - grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep; +static void me_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_error* why) { + grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep; gpr_mu_lock(&m->mu); if (m->on_read) { GRPC_CLOSURE_SCHED(exec_ctx, m->on_read, @@ -88,23 +88,23 @@ static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, GRPC_ERROR_UNREF(why); } -static void me_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { - grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep; +static void me_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) { + grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep; grpc_slice_buffer_destroy(&m->read_buffer); grpc_resource_user_unref(exec_ctx, m->resource_user); gpr_free(m); } -static char *me_get_peer(grpc_endpoint *ep) { +static char* me_get_peer(grpc_endpoint* ep) { return gpr_strdup("fake:mock_endpoint"); } -static grpc_resource_user *me_get_resource_user(grpc_endpoint *ep) { - grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep; +static grpc_resource_user* me_get_resource_user(grpc_endpoint* ep) { + grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep; return m->resource_user; } -static int me_get_fd(grpc_endpoint *ep) { return -1; } +static int me_get_fd(grpc_endpoint* ep) { return -1; } static const grpc_endpoint_vtable vtable = { me_read, @@ -119,11 +119,11 @@ static const grpc_endpoint_vtable vtable = { me_get_fd, }; -grpc_endpoint *grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice), - grpc_resource_quota *resource_quota) { - grpc_mock_endpoint *m = (grpc_mock_endpoint *)gpr_malloc(sizeof(*m)); +grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice), + grpc_resource_quota* resource_quota) { + grpc_mock_endpoint* m = (grpc_mock_endpoint*)gpr_malloc(sizeof(*m)); m->base.vtable = &vtable; - char *name; + char* name; gpr_asprintf(&name, "mock_endpoint_%" PRIxPTR, (intptr_t)m); m->resource_user = grpc_resource_user_create(resource_quota, name); gpr_free(name); @@ -134,9 +134,9 @@ grpc_endpoint *grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice), return &m->base; } -void grpc_mock_endpoint_put_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, +void grpc_mock_endpoint_put_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, grpc_slice slice) { - grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep; + grpc_mock_endpoint* m = (grpc_mock_endpoint*)ep; gpr_mu_lock(&m->mu); if (m->on_read != NULL) { grpc_slice_buffer_add(m->on_read_out, slice); diff --git a/test/core/util/mock_endpoint.h b/test/core/util/mock_endpoint.h index 73b08dca31..ccabaf7c3b 100644 --- a/test/core/util/mock_endpoint.h +++ b/test/core/util/mock_endpoint.h @@ -21,10 +21,10 @@ #include "src/core/lib/iomgr/endpoint.h" -grpc_endpoint *grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice), - grpc_resource_quota *resource_quota); -void grpc_mock_endpoint_put_read(grpc_exec_ctx *exec_ctx, - grpc_endpoint *mock_endpoint, +grpc_endpoint* grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice), + grpc_resource_quota* resource_quota); +void grpc_mock_endpoint_put_read(grpc_exec_ctx* exec_ctx, + grpc_endpoint* mock_endpoint, grpc_slice slice); #endif diff --git a/test/core/util/one_corpus_entry_fuzzer.c b/test/core/util/one_corpus_entry_fuzzer.c index 42467390f2..cfd5a1099f 100644 --- a/test/core/util/one_corpus_entry_fuzzer.c +++ b/test/core/util/one_corpus_entry_fuzzer.c @@ -21,12 +21,12 @@ #include <grpc/support/log.h> #include "src/core/lib/iomgr/load_file.h" -extern int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size); +extern int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size); extern bool squelch; extern bool leak_check; -int main(int argc, char **argv) { +int main(int argc, char** argv) { grpc_slice buffer; squelch = false; leak_check = false; diff --git a/test/core/util/parse_hexstring.c b/test/core/util/parse_hexstring.c index 346b871b67..6dee0f163a 100644 --- a/test/core/util/parse_hexstring.c +++ b/test/core/util/parse_hexstring.c @@ -19,10 +19,10 @@ #include "test/core/util/parse_hexstring.h" #include <grpc/support/log.h> -grpc_slice parse_hexstring(const char *hexstring) { +grpc_slice parse_hexstring(const char* hexstring) { size_t nibbles = 0; - const char *p = 0; - uint8_t *out; + const char* p = 0; + uint8_t* out; uint8_t temp; grpc_slice slice; diff --git a/test/core/util/parse_hexstring.h b/test/core/util/parse_hexstring.h index deab747dd1..b7d54c1711 100644 --- a/test/core/util/parse_hexstring.h +++ b/test/core/util/parse_hexstring.h @@ -21,6 +21,6 @@ #include <grpc/slice.h> -grpc_slice parse_hexstring(const char *hexstring); +grpc_slice parse_hexstring(const char* hexstring); #endif /* GRPC_TEST_CORE_UTIL_PARSE_HEXSTRING_H */ diff --git a/test/core/util/passthru_endpoint.c b/test/core/util/passthru_endpoint.c index ed39255294..acce902010 100644 --- a/test/core/util/passthru_endpoint.c +++ b/test/core/util/passthru_endpoint.c @@ -37,17 +37,17 @@ typedef struct passthru_endpoint passthru_endpoint; typedef struct { grpc_endpoint base; - passthru_endpoint *parent; + passthru_endpoint* parent; grpc_slice_buffer read_buffer; - grpc_slice_buffer *on_read_out; - grpc_closure *on_read; - grpc_resource_user *resource_user; + grpc_slice_buffer* on_read_out; + grpc_closure* on_read; + grpc_resource_user* resource_user; } half; struct passthru_endpoint { gpr_mu mu; int halves; - grpc_passthru_endpoint_stats *stats; + grpc_passthru_endpoint_stats* stats; grpc_passthru_endpoint_stats dummy_stats; // used if constructor stats == NULL bool shutdown; @@ -55,9 +55,9 @@ struct passthru_endpoint { half server; }; -static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_slice_buffer *slices, grpc_closure *cb) { - half *m = (half *)ep; +static void me_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_slice_buffer* slices, grpc_closure* cb) { + half* m = (half*)ep; gpr_mu_lock(&m->parent->mu); if (m->parent->shutdown) { GRPC_CLOSURE_SCHED( @@ -72,16 +72,16 @@ static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, gpr_mu_unlock(&m->parent->mu); } -static half *other_half(half *h) { +static half* other_half(half* h) { if (h == &h->parent->client) return &h->parent->server; return &h->parent->client; } -static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_slice_buffer *slices, grpc_closure *cb) { - half *m = other_half((half *)ep); +static void me_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_slice_buffer* slices, grpc_closure* cb) { + half* m = other_half((half*)ep); gpr_mu_lock(&m->parent->mu); - grpc_error *error = GRPC_ERROR_NONE; + grpc_error* error = GRPC_ERROR_NONE; gpr_atm_no_barrier_fetch_add(&m->parent->stats->num_writes, (gpr_atm)1); if (m->parent->shutdown) { error = GRPC_ERROR_CREATE_FROM_STATIC_STRING("Endpoint already shutdown"); @@ -101,19 +101,19 @@ static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, GRPC_CLOSURE_SCHED(exec_ctx, cb, error); } -static void me_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_pollset *pollset) {} +static void me_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_pollset* pollset) {} -static void me_add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_pollset_set *pollset) {} +static void me_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_pollset_set* pollset) {} -static void me_delete_from_pollset_set(grpc_exec_ctx *exec_ctx, - grpc_endpoint *ep, - grpc_pollset_set *pollset) {} +static void me_delete_from_pollset_set(grpc_exec_ctx* exec_ctx, + grpc_endpoint* ep, + grpc_pollset_set* pollset) {} -static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_error *why) { - half *m = (half *)ep; +static void me_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_error* why) { + half* m = (half*)ep; gpr_mu_lock(&m->parent->mu); m->parent->shutdown = true; if (m->on_read) { @@ -134,8 +134,8 @@ static void me_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, GRPC_ERROR_UNREF(why); } -static void me_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { - passthru_endpoint *p = ((half *)ep)->parent; +static void me_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) { + passthru_endpoint* p = ((half*)ep)->parent; gpr_mu_lock(&p->mu); if (0 == --p->halves) { gpr_mu_unlock(&p->mu); @@ -150,16 +150,16 @@ static void me_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { } } -static char *me_get_peer(grpc_endpoint *ep) { - passthru_endpoint *p = ((half *)ep)->parent; - return ((half *)ep) == &p->client ? gpr_strdup("fake:mock_client_endpoint") - : gpr_strdup("fake:mock_server_endpoint"); +static char* me_get_peer(grpc_endpoint* ep) { + passthru_endpoint* p = ((half*)ep)->parent; + return ((half*)ep) == &p->client ? gpr_strdup("fake:mock_client_endpoint") + : gpr_strdup("fake:mock_server_endpoint"); } -static int me_get_fd(grpc_endpoint *ep) { return -1; } +static int me_get_fd(grpc_endpoint* ep) { return -1; } -static grpc_resource_user *me_get_resource_user(grpc_endpoint *ep) { - half *m = (half *)ep; +static grpc_resource_user* me_get_resource_user(grpc_endpoint* ep) { + half* m = (half*)ep; return m->resource_user; } @@ -176,25 +176,25 @@ static const grpc_endpoint_vtable vtable = { me_get_fd, }; -static void half_init(half *m, passthru_endpoint *parent, - grpc_resource_quota *resource_quota, - const char *half_name) { +static void half_init(half* m, passthru_endpoint* parent, + grpc_resource_quota* resource_quota, + const char* half_name) { m->base.vtable = &vtable; m->parent = parent; grpc_slice_buffer_init(&m->read_buffer); m->on_read = NULL; - char *name; + char* name; gpr_asprintf(&name, "passthru_endpoint_%s_%" PRIxPTR, half_name, (intptr_t)parent); m->resource_user = grpc_resource_user_create(resource_quota, name); gpr_free(name); } -void grpc_passthru_endpoint_create(grpc_endpoint **client, - grpc_endpoint **server, - grpc_resource_quota *resource_quota, - grpc_passthru_endpoint_stats *stats) { - passthru_endpoint *m = (passthru_endpoint *)gpr_malloc(sizeof(*m)); +void grpc_passthru_endpoint_create(grpc_endpoint** client, + grpc_endpoint** server, + grpc_resource_quota* resource_quota, + grpc_passthru_endpoint_stats* stats) { + passthru_endpoint* m = (passthru_endpoint*)gpr_malloc(sizeof(*m)); m->halves = 2; m->shutdown = 0; m->stats = stats == NULL ? &m->dummy_stats : stats; diff --git a/test/core/util/passthru_endpoint.h b/test/core/util/passthru_endpoint.h index 23d21c6061..bddd8ea6a2 100644 --- a/test/core/util/passthru_endpoint.h +++ b/test/core/util/passthru_endpoint.h @@ -23,11 +23,13 @@ #include "src/core/lib/iomgr/endpoint.h" -typedef struct { gpr_atm num_writes; } grpc_passthru_endpoint_stats; +typedef struct { + gpr_atm num_writes; +} grpc_passthru_endpoint_stats; -void grpc_passthru_endpoint_create(grpc_endpoint **client, - grpc_endpoint **server, - grpc_resource_quota *resource_quota, - grpc_passthru_endpoint_stats *stats); +void grpc_passthru_endpoint_create(grpc_endpoint** client, + grpc_endpoint** server, + grpc_resource_quota* resource_quota, + grpc_passthru_endpoint_stats* stats); #endif diff --git a/test/core/util/port.c b/test/core/util/port.c index 61f2e5018f..c5bebe08e7 100644 --- a/test/core/util/port.c +++ b/test/core/util/port.c @@ -36,7 +36,7 @@ #include "src/core/lib/iomgr/sockaddr_utils.h" #include "test/core/util/port_server_client.h" -static int *chosen_ports = NULL; +static int* chosen_ports = NULL; static size_t num_chosen_ports = 0; static int free_chosen_port(int port) { @@ -76,7 +76,7 @@ static void chose_port(int port) { } num_chosen_ports++; chosen_ports = - (int *)gpr_realloc(chosen_ports, sizeof(int) * num_chosen_ports); + (int*)gpr_realloc(chosen_ports, sizeof(int) * num_chosen_ports); chosen_ports[num_chosen_ports - 1] = port; } diff --git a/test/core/util/port_server_client.c b/test/core/util/port_server_client.c index 7b94ac4ada..988a5384b9 100644 --- a/test/core/util/port_server_client.c +++ b/test/core/util/port_server_client.c @@ -35,21 +35,21 @@ #include "src/core/lib/http/httpcli.h" typedef struct freereq { - gpr_mu *mu; + gpr_mu* mu; grpc_polling_entity pops; int done; } freereq; -static void destroy_pops_and_shutdown(grpc_exec_ctx *exec_ctx, void *p, - grpc_error *error) { - grpc_pollset *pollset = grpc_polling_entity_pollset((grpc_polling_entity *)p); +static void destroy_pops_and_shutdown(grpc_exec_ctx* exec_ctx, void* p, + grpc_error* error) { + 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 = (freereq *)arg; +static void freed_port_from_server(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + freereq* pr = (freereq*)arg; gpr_mu_lock(pr->mu); pr->done = 1; GRPC_LOG_IF_ERROR( @@ -64,9 +64,9 @@ void grpc_free_port_using_server(int port) { grpc_httpcli_request req; grpc_httpcli_response rsp; freereq pr; - char *path; + char* path; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_closure *shutdown_closure; + grpc_closure* shutdown_closure; grpc_init(); @@ -74,7 +74,7 @@ void grpc_free_port_using_server(int port) { memset(&req, 0, sizeof(req)); memset(&rsp, 0, sizeof(rsp)); - grpc_pollset *pollset = (grpc_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, @@ -85,7 +85,7 @@ void grpc_free_port_using_server(int port) { req.http.path = path; grpc_httpcli_context_init(&context); - grpc_resource_quota *resource_quota = + grpc_resource_quota* resource_quota = grpc_resource_quota_create("port_server_client/free"); grpc_httpcli_get(&exec_ctx, &context, &pr.pops, resource_quota, &req, grpc_exec_ctx_now(&exec_ctx) + 30 * GPR_MS_PER_SEC, @@ -96,7 +96,7 @@ void grpc_free_port_using_server(int port) { grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(pr.mu); while (!pr.done) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; if (!GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&pr.pops), @@ -118,26 +118,26 @@ void grpc_free_port_using_server(int port) { } typedef struct portreq { - gpr_mu *mu; + gpr_mu* mu; grpc_polling_entity pops; int port; int retries; - char *server; - grpc_httpcli_context *ctx; + char* server; + grpc_httpcli_context* ctx; grpc_httpcli_response response; } portreq; -static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void got_port_from_server(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { size_t i; int port = 0; - portreq *pr = (portreq *)arg; + portreq* pr = (portreq*)arg; int failed = 0; - grpc_httpcli_response *response = &pr->response; + grpc_httpcli_response* response = &pr->response; if (error != GRPC_ERROR_NONE) { failed = 1; - const char *msg = grpc_error_string(error); + const char* msg = grpc_error_string(error); gpr_log(GPR_DEBUG, "failed port pick from server: retrying [%s]", msg); } else if (response->status != 200) { @@ -170,7 +170,7 @@ static void got_port_from_server(grpc_exec_ctx *exec_ctx, void *arg, req.http.path = "/get"; grpc_http_response_destroy(&pr->response); memset(&pr->response, 0, sizeof(pr->response)); - grpc_resource_quota *resource_quota = + grpc_resource_quota* resource_quota = grpc_resource_quota_create("port_server_client/pick_retry"); grpc_httpcli_get(exec_ctx, pr->ctx, &pr->pops, resource_quota, &req, grpc_exec_ctx_now(exec_ctx) + 30 * GPR_MS_PER_SEC, @@ -201,13 +201,13 @@ int grpc_pick_port_using_server(void) { grpc_httpcli_request req; portreq pr; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - grpc_closure *shutdown_closure; + grpc_closure* shutdown_closure; grpc_init(); memset(&pr, 0, sizeof(pr)); memset(&req, 0, sizeof(req)); - grpc_pollset *pollset = (grpc_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, @@ -220,7 +220,7 @@ int grpc_pick_port_using_server(void) { req.http.path = "/get"; grpc_httpcli_context_init(&context); - grpc_resource_quota *resource_quota = + grpc_resource_quota* resource_quota = grpc_resource_quota_create("port_server_client/pick"); grpc_httpcli_get( &exec_ctx, &context, &pr.pops, resource_quota, &req, @@ -231,7 +231,7 @@ int grpc_pick_port_using_server(void) { grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(pr.mu); while (pr.port == -1) { - grpc_pollset_worker *worker = NULL; + grpc_pollset_worker* worker = NULL; if (!GRPC_LOG_IF_ERROR( "pollset_work", grpc_pollset_work(&exec_ctx, grpc_polling_entity_pollset(&pr.pops), diff --git a/test/core/util/reconnect_server.c b/test/core/util/reconnect_server.c index 9c56e02e8e..742bcf560e 100644 --- a/test/core/util/reconnect_server.c +++ b/test/core/util/reconnect_server.c @@ -31,11 +31,11 @@ #include "test/core/util/port.h" #include "test/core/util/test_tcp_server.h" -static void pretty_print_backoffs(reconnect_server *server) { +static void pretty_print_backoffs(reconnect_server* server) { gpr_timespec diff; int i = 1; double expected_backoff = 1000.0, backoff; - timestamp_list *head = server->head; + timestamp_list* head = server->head; gpr_log(GPR_INFO, "reconnect server: new connection"); for (head = server->head; head && head->next; head = head->next, i++) { diff = gpr_time_sub(head->next->timestamp, head->timestamp); @@ -55,15 +55,15 @@ static void pretty_print_backoffs(reconnect_server *server) { } } -static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, - grpc_pollset *accepting_pollset, - grpc_tcp_server_acceptor *acceptor) { +static void on_connect(grpc_exec_ctx* exec_ctx, void* arg, grpc_endpoint* tcp, + grpc_pollset* accepting_pollset, + grpc_tcp_server_acceptor* acceptor) { gpr_free(acceptor); - char *peer; - char *last_colon; - reconnect_server *server = (reconnect_server *)arg; + char* peer; + char* last_colon; + reconnect_server* server = (reconnect_server*)arg; gpr_timespec now = gpr_now(GPR_CLOCK_REALTIME); - timestamp_list *new_tail; + timestamp_list* new_tail; peer = grpc_endpoint_get_peer(tcp); grpc_endpoint_shutdown(exec_ctx, tcp, GRPC_ERROR_CREATE_FROM_STATIC_STRING("Connected")); @@ -95,7 +95,7 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, pretty_print_backoffs(server); } -void reconnect_server_init(reconnect_server *server) { +void reconnect_server_init(reconnect_server* server) { test_tcp_server_init(&server->tcp_server, on_connect, server); server->head = NULL; server->tail = NULL; @@ -103,16 +103,16 @@ void reconnect_server_init(reconnect_server *server) { server->max_reconnect_backoff_ms = 0; } -void reconnect_server_start(reconnect_server *server, int port) { +void reconnect_server_start(reconnect_server* server, int port) { test_tcp_server_start(&server->tcp_server, port); } -void reconnect_server_poll(reconnect_server *server, int seconds) { +void reconnect_server_poll(reconnect_server* server, int seconds) { test_tcp_server_poll(&server->tcp_server, seconds); } -void reconnect_server_clear_timestamps(reconnect_server *server) { - timestamp_list *new_head = server->head; +void reconnect_server_clear_timestamps(reconnect_server* server) { + timestamp_list* new_head = server->head; while (server->head) { new_head = server->head->next; gpr_free(server->head); @@ -123,7 +123,7 @@ void reconnect_server_clear_timestamps(reconnect_server *server) { server->peer = NULL; } -void reconnect_server_destroy(reconnect_server *server) { +void reconnect_server_destroy(reconnect_server* server) { reconnect_server_clear_timestamps(server); test_tcp_server_destroy(&server->tcp_server); } diff --git a/test/core/util/reconnect_server.h b/test/core/util/reconnect_server.h index 38db729108..5aec586ff6 100644 --- a/test/core/util/reconnect_server.h +++ b/test/core/util/reconnect_server.h @@ -29,22 +29,22 @@ extern "C" { typedef struct timestamp_list { gpr_timespec timestamp; - struct timestamp_list *next; + struct timestamp_list* next; } timestamp_list; typedef struct reconnect_server { test_tcp_server tcp_server; - timestamp_list *head; - timestamp_list *tail; - char *peer; + timestamp_list* head; + timestamp_list* tail; + char* peer; int max_reconnect_backoff_ms; } reconnect_server; -void reconnect_server_init(reconnect_server *server); -void reconnect_server_start(reconnect_server *server, int port); -void reconnect_server_poll(reconnect_server *server, int seconds); -void reconnect_server_destroy(reconnect_server *server); -void reconnect_server_clear_timestamps(reconnect_server *server); +void reconnect_server_init(reconnect_server* server); +void reconnect_server_start(reconnect_server* server, int port); +void reconnect_server_poll(reconnect_server* server, int seconds); +void reconnect_server_destroy(reconnect_server* server); +void reconnect_server_clear_timestamps(reconnect_server* server); #ifdef __cplusplus } diff --git a/test/core/util/slice_splitter.c b/test/core/util/slice_splitter.c index 6fcef9acce..e25e1d862a 100644 --- a/test/core/util/slice_splitter.c +++ b/test/core/util/slice_splitter.c @@ -23,7 +23,7 @@ #include <grpc/support/alloc.h> #include <grpc/support/useful.h> -const char *grpc_slice_split_mode_name(grpc_slice_split_mode mode) { +const char* grpc_slice_split_mode_name(grpc_slice_split_mode mode) { switch (mode) { case GRPC_SLICE_SPLIT_IDENTITY: return "identity"; @@ -35,9 +35,9 @@ const char *grpc_slice_split_mode_name(grpc_slice_split_mode mode) { return "error"; } -void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices, - size_t src_slice_count, grpc_slice **dst_slices, - size_t *dst_slice_count) { +void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice* src_slices, + size_t src_slice_count, grpc_slice** dst_slices, + size_t* dst_slice_count) { size_t i, j; size_t length; @@ -45,7 +45,7 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices, case GRPC_SLICE_SPLIT_IDENTITY: *dst_slice_count = src_slice_count; *dst_slices = - (grpc_slice *)gpr_malloc(sizeof(grpc_slice) * src_slice_count); + (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]); @@ -57,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 = (grpc_slice *)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++) { @@ -73,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 = (grpc_slice *)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++) { @@ -86,9 +86,9 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices, } void grpc_split_slices_to_buffer(grpc_slice_split_mode mode, - grpc_slice *src_slices, size_t src_slice_count, - grpc_slice_buffer *dst) { - grpc_slice *slices; + grpc_slice* src_slices, size_t src_slice_count, + grpc_slice_buffer* dst) { + grpc_slice* slices; size_t nslices; size_t i; grpc_split_slices(mode, src_slices, src_slice_count, &slices, &nslices); @@ -99,13 +99,13 @@ void grpc_split_slices_to_buffer(grpc_slice_split_mode mode, gpr_free(slices); } -void grpc_split_slice_buffer(grpc_slice_split_mode mode, grpc_slice_buffer *src, - grpc_slice_buffer *dst) { +void grpc_split_slice_buffer(grpc_slice_split_mode mode, grpc_slice_buffer* src, + grpc_slice_buffer* dst) { grpc_split_slices_to_buffer(mode, src->slices, src->count, dst); } -grpc_slice grpc_slice_merge(grpc_slice *slices, size_t nslices) { - uint8_t *out = NULL; +grpc_slice grpc_slice_merge(grpc_slice* slices, size_t nslices) { + uint8_t* out = NULL; size_t length = 0; size_t capacity = 0; size_t i; @@ -113,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 = (uint8_t *)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])); diff --git a/test/core/util/slice_splitter.h b/test/core/util/slice_splitter.h index 713eca93d2..65b9f6f7df 100644 --- a/test/core/util/slice_splitter.h +++ b/test/core/util/slice_splitter.h @@ -36,18 +36,18 @@ typedef enum { /* allocates *dst_slices; caller must unref all slices in dst_slices then free it */ -void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices, - size_t src_slice_count, grpc_slice **dst_slices, - size_t *dst_slice_count); +void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice* src_slices, + size_t src_slice_count, grpc_slice** dst_slices, + size_t* dst_slice_count); void grpc_split_slices_to_buffer(grpc_slice_split_mode mode, - grpc_slice *src_slices, size_t src_slice_count, - grpc_slice_buffer *dst); -void grpc_split_slice_buffer(grpc_slice_split_mode mode, grpc_slice_buffer *src, - grpc_slice_buffer *dst); + grpc_slice* src_slices, size_t src_slice_count, + grpc_slice_buffer* dst); +void grpc_split_slice_buffer(grpc_slice_split_mode mode, grpc_slice_buffer* src, + grpc_slice_buffer* dst); -grpc_slice grpc_slice_merge(grpc_slice *slices, size_t nslices); +grpc_slice grpc_slice_merge(grpc_slice* slices, size_t nslices); -const char *grpc_slice_split_mode_name(grpc_slice_split_mode mode); +const char* grpc_slice_split_mode_name(grpc_slice_split_mode mode); #endif /* GRPC_TEST_CORE_UTIL_SLICE_SPLITTER_H */ diff --git a/test/core/util/test_config.c b/test/core/util/test_config.c index 536045e1c3..ea3a4b5ca0 100644 --- a/test/core/util/test_config.c +++ b/test/core/util/test_config.c @@ -59,7 +59,7 @@ static unsigned seed(void) { return (unsigned)_getpid(); } static void print_current_stack() { typedef USHORT(WINAPI * CaptureStackBackTraceType)( - __in ULONG, __in ULONG, __out PVOID *, __out_opt PULONG); + __in ULONG, __in ULONG, __out PVOID*, __out_opt PULONG); CaptureStackBackTraceType func = (CaptureStackBackTraceType)(GetProcAddress( LoadLibrary(_T("kernel32.dll")), "RtlCaptureStackBackTrace")); @@ -71,15 +71,15 @@ static void print_current_stack() { // than 63. #define MAX_CALLERS 62 - void *callers_stack[MAX_CALLERS]; + void* callers_stack[MAX_CALLERS]; unsigned short frames; - SYMBOL_INFOW *symbol; + SYMBOL_INFOW* symbol; HANDLE process; process = GetCurrentProcess(); SymInitialize(process, NULL, TRUE); frames = (func)(0, MAX_CALLERS, callers_stack, NULL); symbol = - (SYMBOL_INFOW *)calloc(sizeof(SYMBOL_INFOW) + 256 * sizeof(wchar_t), 1); + (SYMBOL_INFOW*)calloc(sizeof(SYMBOL_INFOW) + 256 * sizeof(wchar_t), 1); symbol->MaxNameLen = 255; symbol->SizeOfStruct = sizeof(SYMBOL_INFOW); @@ -133,8 +133,8 @@ static void print_stack_from_context(CONTEXT c) { HANDLE process = GetCurrentProcess(); HANDLE thread = GetCurrentThread(); - SYMBOL_INFOW *symbol = - (SYMBOL_INFOW *)calloc(sizeof(SYMBOL_INFOW) + 256 * sizeof(wchar_t), 1); + SYMBOL_INFOW* symbol = + (SYMBOL_INFOW*)calloc(sizeof(SYMBOL_INFOW) + 256 * sizeof(wchar_t), 1); symbol->MaxNameLen = 255; symbol->SizeOfStruct = sizeof(SYMBOL_INFOW); @@ -151,7 +151,7 @@ static void print_stack_from_context(CONTEXT c) { free(symbol); } -static LONG crash_handler(struct _EXCEPTION_POINTERS *ex_info) { +static LONG crash_handler(struct _EXCEPTION_POINTERS* ex_info) { fprintf(stderr, "Exception handler called, dumping information\n"); bool try_to_print_stack = true; PEXCEPTION_RECORD exrec = ex_info->ExceptionRecord; @@ -202,7 +202,7 @@ static void install_crash_handler() { #define SIGNAL_NAMES_LENGTH 32 -static const char *const signal_names[] = { +static const char* const signal_names[] = { NULL, "SIGHUP", "SIGINT", "SIGQUIT", "SIGILL", "SIGTRAP", "SIGABRT", "SIGBUS", "SIGFPE", "SIGKILL", "SIGUSR1", "SIGSEGV", "SIGUSR2", "SIGPIPE", "SIGALRM", "SIGTERM", "SIGSTKFLT", "SIGCHLD", @@ -215,7 +215,7 @@ static char g_alt_stack[GPR_MAX(MINSIGSTKSZ, 65536)]; #define MAX_FRAMES 32 /* signal safe output */ -static void output_string(const char *string) { +static void output_string(const char* string) { size_t len = strlen(string); ssize_t r; @@ -230,8 +230,8 @@ static void output_num(long num) { output_string(buf); } -static void crash_handler(int signum, siginfo_t *info, void *data) { - void *addrlist[MAX_FRAMES + 1]; +static void crash_handler(int signum, siginfo_t* info, void* data) { + void* addrlist[MAX_FRAMES + 1]; int addrlen; output_string("\n\n\n*******************************\nCaught signal "); @@ -376,10 +376,10 @@ gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms) { GPR_TIMESPAN)); } -void grpc_test_init(int argc, char **argv) { +void grpc_test_init(int argc, char** argv) { install_crash_handler(); { /* poll-cv poll strategy runs much more slowly than anything else */ - char *s = gpr_getenv("GRPC_POLL_STRATEGY"); + char* s = gpr_getenv("GRPC_POLL_STRATEGY"); if (s != NULL && 0 == strcmp(s, "poll-cv")) { g_poller_slowdown_factor = 5; } diff --git a/test/core/util/test_config.h b/test/core/util/test_config.h index 051d7e9a3d..edc0fbad7c 100644 --- a/test/core/util/test_config.h +++ b/test/core/util/test_config.h @@ -41,7 +41,7 @@ gpr_timespec grpc_timeout_milliseconds_to_deadline(int64_t time_ms); #define GRPC_TEST_PICK_PORT #endif -void grpc_test_init(int argc, char **argv); +void grpc_test_init(int argc, char** argv); #ifdef __cplusplus } diff --git a/test/core/util/test_tcp_server.c b/test/core/util/test_tcp_server.c index 611ecb330c..d97f2c7bda 100644 --- a/test/core/util/test_tcp_server.c +++ b/test/core/util/test_tcp_server.c @@ -33,14 +33,14 @@ #include "test/core/util/port.h" #include "test/core/util/test_config.h" -static void on_server_destroyed(grpc_exec_ctx *exec_ctx, void *data, - grpc_error *error) { - test_tcp_server *server = data; +static void on_server_destroyed(grpc_exec_ctx* exec_ctx, void* data, + grpc_error* error) { + test_tcp_server* server = data; server->shutdown = 1; } -void test_tcp_server_init(test_tcp_server *server, - grpc_tcp_server_cb on_connect, void *user_data) { +void test_tcp_server_init(test_tcp_server* server, + grpc_tcp_server_cb on_connect, void* user_data) { grpc_init(); server->tcp_server = NULL; GRPC_CLOSURE_INIT(&server->shutdown_complete, on_server_destroyed, server, @@ -52,9 +52,9 @@ void test_tcp_server_init(test_tcp_server *server, server->cb_data = user_data; } -void test_tcp_server_start(test_tcp_server *server, int port) { +void test_tcp_server_start(test_tcp_server* server, int port) { grpc_resolved_address resolved_addr; - struct sockaddr_in *addr = (struct sockaddr_in *)resolved_addr.addr; + struct sockaddr_in* addr = (struct sockaddr_in*)resolved_addr.addr; int port_added; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -62,7 +62,7 @@ void test_tcp_server_start(test_tcp_server *server, int port) { addr->sin_port = htons((uint16_t)port); memset(&addr->sin_addr, 0, sizeof(addr->sin_addr)); - grpc_error *error = grpc_tcp_server_create( + grpc_error* error = grpc_tcp_server_create( &exec_ctx, &server->shutdown_complete, NULL, &server->tcp_server); GPR_ASSERT(error == GRPC_ERROR_NONE); error = @@ -77,8 +77,8 @@ void test_tcp_server_start(test_tcp_server *server, int port) { grpc_exec_ctx_finish(&exec_ctx); } -void test_tcp_server_poll(test_tcp_server *server, int seconds) { - grpc_pollset_worker *worker = NULL; +void test_tcp_server_poll(test_tcp_server* server, int seconds) { + grpc_pollset_worker* worker = NULL; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_millis deadline = grpc_timespec_to_millis_round_up( grpc_timeout_seconds_to_deadline(seconds)); @@ -90,13 +90,13 @@ void test_tcp_server_poll(test_tcp_server *server, int seconds) { grpc_exec_ctx_finish(&exec_ctx); } -static void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) {} -static void finish_pollset(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { +static void do_nothing(grpc_exec_ctx* exec_ctx, void* arg, grpc_error* error) {} +static void finish_pollset(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { grpc_pollset_destroy(exec_ctx, arg); } -void test_tcp_server_destroy(test_tcp_server *server) { +void test_tcp_server_destroy(test_tcp_server* server) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; gpr_timespec shutdown_deadline; grpc_closure do_nothing_cb; diff --git a/test/core/util/test_tcp_server.h b/test/core/util/test_tcp_server.h index bd62992a09..58140388da 100644 --- a/test/core/util/test_tcp_server.h +++ b/test/core/util/test_tcp_server.h @@ -23,19 +23,19 @@ #include "src/core/lib/iomgr/tcp_server.h" typedef struct test_tcp_server { - grpc_tcp_server *tcp_server; + grpc_tcp_server* tcp_server; grpc_closure shutdown_complete; int shutdown; - gpr_mu *mu; - grpc_pollset *pollset; + gpr_mu* mu; + grpc_pollset* pollset; grpc_tcp_server_cb on_connect; - void *cb_data; + void* cb_data; } test_tcp_server; -void test_tcp_server_init(test_tcp_server *server, - grpc_tcp_server_cb on_connect, void *user_data); -void test_tcp_server_start(test_tcp_server *server, int port); -void test_tcp_server_poll(test_tcp_server *server, int seconds); -void test_tcp_server_destroy(test_tcp_server *server); +void test_tcp_server_init(test_tcp_server* server, + grpc_tcp_server_cb on_connect, void* user_data); +void test_tcp_server_start(test_tcp_server* server, int port); +void test_tcp_server_poll(test_tcp_server* server, int seconds); +void test_tcp_server_destroy(test_tcp_server* server); #endif /* GRPC_TEST_CORE_UTIL_TEST_TCP_SERVER_H */ diff --git a/test/core/util/trickle_endpoint.c b/test/core/util/trickle_endpoint.c index d761f72297..c8b54b481d 100644 --- a/test/core/util/trickle_endpoint.c +++ b/test/core/util/trickle_endpoint.c @@ -34,25 +34,25 @@ typedef struct { grpc_endpoint base; double bytes_per_second; - grpc_endpoint *wrapped; + grpc_endpoint* wrapped; gpr_timespec last_write; gpr_mu mu; grpc_slice_buffer write_buffer; grpc_slice_buffer writing_buffer; - grpc_error *error; + grpc_error* error; bool writing; - grpc_closure *write_cb; + grpc_closure* write_cb; } trickle_endpoint; -static void te_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_slice_buffer *slices, grpc_closure *cb) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static void te_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_slice_buffer* slices, grpc_closure* cb) { + trickle_endpoint* te = (trickle_endpoint*)ep; grpc_endpoint_read(exec_ctx, te->wrapped, slices, cb); } -static void maybe_call_write_cb_locked(grpc_exec_ctx *exec_ctx, - trickle_endpoint *te) { +static void maybe_call_write_cb_locked(grpc_exec_ctx* exec_ctx, + trickle_endpoint* te) { if (te->write_cb != NULL && (te->error != GRPC_ERROR_NONE || te->write_buffer.length <= WRITE_BUFFER_SIZE)) { GRPC_CLOSURE_SCHED(exec_ctx, te->write_cb, GRPC_ERROR_REF(te->error)); @@ -60,9 +60,9 @@ static void maybe_call_write_cb_locked(grpc_exec_ctx *exec_ctx, } } -static void te_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_slice_buffer *slices, grpc_closure *cb) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static void te_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_slice_buffer* slices, grpc_closure* cb) { + trickle_endpoint* te = (trickle_endpoint*)ep; gpr_mu_lock(&te->mu); GPR_ASSERT(te->write_cb == NULL); if (te->write_buffer.length == 0) { @@ -77,28 +77,28 @@ static void te_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, gpr_mu_unlock(&te->mu); } -static void te_add_to_pollset(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_pollset *pollset) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static void te_add_to_pollset(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_pollset* pollset) { + trickle_endpoint* te = (trickle_endpoint*)ep; grpc_endpoint_add_to_pollset(exec_ctx, te->wrapped, pollset); } -static void te_add_to_pollset_set(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_pollset_set *pollset_set) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static void te_add_to_pollset_set(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_pollset_set* pollset_set) { + trickle_endpoint* te = (trickle_endpoint*)ep; grpc_endpoint_add_to_pollset_set(exec_ctx, te->wrapped, pollset_set); } -static void te_delete_from_pollset_set(grpc_exec_ctx *exec_ctx, - grpc_endpoint *ep, - grpc_pollset_set *pollset_set) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static void te_delete_from_pollset_set(grpc_exec_ctx* exec_ctx, + grpc_endpoint* ep, + grpc_pollset_set* pollset_set) { + trickle_endpoint* te = (trickle_endpoint*)ep; grpc_endpoint_delete_from_pollset_set(exec_ctx, te->wrapped, pollset_set); } -static void te_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - grpc_error *why) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static void te_shutdown(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, + grpc_error* why) { + trickle_endpoint* te = (trickle_endpoint*)ep; gpr_mu_lock(&te->mu); if (te->error == GRPC_ERROR_NONE) { te->error = GRPC_ERROR_REF(why); @@ -108,8 +108,8 @@ static void te_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, grpc_endpoint_shutdown(exec_ctx, te->wrapped, why); } -static void te_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static void te_destroy(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep) { + trickle_endpoint* te = (trickle_endpoint*)ep; grpc_endpoint_destroy(exec_ctx, te->wrapped); gpr_mu_destroy(&te->mu); grpc_slice_buffer_destroy_internal(exec_ctx, &te->write_buffer); @@ -118,24 +118,24 @@ static void te_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { gpr_free(te); } -static grpc_resource_user *te_get_resource_user(grpc_endpoint *ep) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static grpc_resource_user* te_get_resource_user(grpc_endpoint* ep) { + trickle_endpoint* te = (trickle_endpoint*)ep; return grpc_endpoint_get_resource_user(te->wrapped); } -static char *te_get_peer(grpc_endpoint *ep) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static char* te_get_peer(grpc_endpoint* ep) { + trickle_endpoint* te = (trickle_endpoint*)ep; return grpc_endpoint_get_peer(te->wrapped); } -static int te_get_fd(grpc_endpoint *ep) { - trickle_endpoint *te = (trickle_endpoint *)ep; +static int te_get_fd(grpc_endpoint* ep) { + trickle_endpoint* te = (trickle_endpoint*)ep; return grpc_endpoint_get_fd(te->wrapped); } -static void te_finish_write(grpc_exec_ctx *exec_ctx, void *arg, - grpc_error *error) { - trickle_endpoint *te = (trickle_endpoint *)arg; +static void te_finish_write(grpc_exec_ctx* exec_ctx, void* arg, + grpc_error* error) { + trickle_endpoint* te = (trickle_endpoint*)arg; gpr_mu_lock(&te->mu); te->writing = false; grpc_slice_buffer_reset_and_unref(&te->writing_buffer); @@ -153,9 +153,9 @@ static const grpc_endpoint_vtable vtable = {te_read, te_get_peer, te_get_fd}; -grpc_endpoint *grpc_trickle_endpoint_create(grpc_endpoint *wrap, +grpc_endpoint* grpc_trickle_endpoint_create(grpc_endpoint* wrap, double bytes_per_second) { - trickle_endpoint *te = (trickle_endpoint *)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; @@ -172,9 +172,9 @@ static double ts2dbl(gpr_timespec s) { return (double)s.tv_sec + 1e-9 * (double)s.tv_nsec; } -size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx *exec_ctx, - grpc_endpoint *ep) { - trickle_endpoint *te = (trickle_endpoint *)ep; +size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx* exec_ctx, + grpc_endpoint* ep) { + trickle_endpoint* te = (trickle_endpoint*)ep; gpr_mu_lock(&te->mu); if (!te->writing && te->write_buffer.length > 0) { gpr_timespec now = gpr_now(GPR_CLOCK_MONOTONIC); @@ -198,8 +198,8 @@ size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx *exec_ctx, return backlog; } -size_t grpc_trickle_get_backlog(grpc_endpoint *ep) { - trickle_endpoint *te = (trickle_endpoint *)ep; +size_t grpc_trickle_get_backlog(grpc_endpoint* ep) { + trickle_endpoint* te = (trickle_endpoint*)ep; gpr_mu_lock(&te->mu); size_t backlog = te->write_buffer.length; gpr_mu_unlock(&te->mu); diff --git a/test/core/util/trickle_endpoint.h b/test/core/util/trickle_endpoint.h index ca39638ba0..de87a1f4ab 100644 --- a/test/core/util/trickle_endpoint.h +++ b/test/core/util/trickle_endpoint.h @@ -25,14 +25,14 @@ extern "C" { #endif // __cplusplus -grpc_endpoint *grpc_trickle_endpoint_create(grpc_endpoint *wrap, +grpc_endpoint* grpc_trickle_endpoint_create(grpc_endpoint* wrap, double bytes_per_second); /* Allow up to \a bytes through the endpoint. Returns the new backlog. */ -size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx *exec_ctx, - grpc_endpoint *endpoint); +size_t grpc_trickle_endpoint_trickle(grpc_exec_ctx* exec_ctx, + grpc_endpoint* endpoint); -size_t grpc_trickle_get_backlog(grpc_endpoint *endpoint); +size_t grpc_trickle_get_backlog(grpc_endpoint* endpoint); #ifdef __cplusplus } |