clang-format all core files

pull/3423/head
Craig Tiller 9 years ago
parent d9ccbbf6b9
commit af73d78b78
  1. 8
      src/core/channel/channel_args.c
  2. 4
      src/core/channel/channel_args.h
  3. 4
      src/core/channel/client_channel.c
  4. 3
      src/core/client_config/lb_policies/pick_first.c
  5. 6
      src/core/client_config/lb_policy_registry.c
  6. 7
      src/core/client_config/resolvers/sockaddr_resolver.c
  7. 3
      src/core/client_config/resolvers/zookeeper_resolver.c
  8. 2
      src/core/compression/algorithm.c
  9. 2
      src/core/iomgr/iocp_windows.c
  10. 2
      src/core/iomgr/pollset_windows.c
  11. 3
      src/core/iomgr/socket_windows.c
  12. 2
      src/core/iomgr/tcp_client_windows.c
  13. 9
      src/core/iomgr/tcp_server_windows.c
  14. 8
      src/core/iomgr/tcp_windows.c
  15. 8
      src/core/profiling/basic_timers.c
  16. 3
      src/core/security/credentials.c
  17. 1
      src/core/security/credentials.h
  18. 4
      src/core/security/server_auth_filter.c
  19. 2
      src/core/support/stack_lockfree.c
  20. 2
      src/core/support/sync_win32.c
  21. 2
      src/core/support/time_precise.h
  22. 2
      src/core/surface/server.c
  23. 4
      src/core/surface/version.c
  24. 2
      src/core/transport/chttp2/stream_encoder.c
  25. 1
      src/core/transport/connectivity_state.c
  26. 2
      test/core/client_config/uri_parser_test.c
  27. 18
      test/core/end2end/dualstack_socket_test.c
  28. 4
      test/core/end2end/fixtures/h2_oauth2.c
  29. 4
      test/core/end2end/fixtures/proxy.c
  30. 13
      test/core/iomgr/tcp_client_posix_test.c
  31. 4
      test/core/util/port_posix.c

@ -151,8 +151,8 @@ grpc_channel_args *grpc_channel_args_set_compression_algorithm(
/** Returns 1 if the argument for compression algorithm's enabled states bitset
* was found in \a a, returning the arg's value in \a states. Otherwise, returns
* 0. */
static int find_compression_algorithm_states_bitset(
const grpc_channel_args *a, int **states_arg) {
static int find_compression_algorithm_states_bitset(const grpc_channel_args *a,
int **states_arg) {
if (a != NULL) {
size_t i;
for (i = 0; i < a->num_args; ++i) {
@ -167,9 +167,7 @@ static int find_compression_algorithm_states_bitset(
}
grpc_channel_args *grpc_channel_args_compression_algorithm_set_state(
grpc_channel_args **a,
grpc_compression_algorithm algorithm,
int state) {
grpc_channel_args **a, grpc_compression_algorithm algorithm, int state) {
int *states_arg;
grpc_channel_args *result = *a;
const int states_arg_found =

@ -75,9 +75,7 @@ grpc_channel_args *grpc_channel_args_set_compression_algorithm(
* modified to point to the returned instance (which may be different from the
* input value of \a a). */
grpc_channel_args *grpc_channel_args_compression_algorithm_set_state(
grpc_channel_args **a,
grpc_compression_algorithm algorithm,
int enabled);
grpc_channel_args **a, grpc_compression_algorithm algorithm, int enabled);
/** Returns the bitset representing the support state (true for enabled, false
* for disabled) for compression algorithms.

@ -679,8 +679,8 @@ static void init_channel_elem(grpc_channel_element *elem, grpc_channel *master,
grpc_pollset_set_init(&chand->pollset_set);
grpc_closure_init(&chand->on_config_changed, cc_on_config_changed, chand);
grpc_connectivity_state_init(&chand->state_tracker,
GRPC_CHANNEL_IDLE, "client_channel");
grpc_connectivity_state_init(&chand->state_tracker, GRPC_CHANNEL_IDLE,
"client_channel");
}
/* Destructor for channel_data */

@ -337,7 +337,8 @@ static grpc_lb_policy *create_pick_first(grpc_lb_policy_factory *factory,
GPR_ASSERT(args->num_subchannels > 0);
memset(p, 0, sizeof(*p));
grpc_lb_policy_init(&p->base, &pick_first_lb_policy_vtable);
p->subchannels = gpr_malloc(sizeof(grpc_subchannel *) * args->num_subchannels);
p->subchannels =
gpr_malloc(sizeof(grpc_subchannel *) * args->num_subchannels);
p->num_subchannels = args->num_subchannels;
grpc_connectivity_state_init(&p->state_tracker, GRPC_CHANNEL_IDLE,
"pick_first");

@ -65,7 +65,7 @@ void grpc_register_lb_policy(grpc_lb_policy_factory *factory) {
g_all_of_the_lb_policies[g_number_of_lb_policies++] = factory;
}
static grpc_lb_policy_factory *lookup_factory(const char* name) {
static grpc_lb_policy_factory *lookup_factory(const char *name) {
int i;
if (name == NULL) return NULL;
@ -82,7 +82,7 @@ static grpc_lb_policy_factory *lookup_factory(const char* name) {
grpc_lb_policy *grpc_lb_policy_create(const char *name,
grpc_lb_policy_args *args) {
grpc_lb_policy_factory *factory = lookup_factory(name);
grpc_lb_policy *lb_policy = grpc_lb_policy_factory_create_lb_policy(
factory, args);
grpc_lb_policy *lb_policy =
grpc_lb_policy_factory_create_lb_policy(factory, args);
return lb_policy;
}

@ -146,8 +146,7 @@ static void sockaddr_maybe_finish_next_locked(sockaddr_resolver *r,
memset(&lb_policy_args, 0, sizeof(lb_policy_args));
lb_policy_args.subchannels = subchannels;
lb_policy_args.num_subchannels = r->num_addrs;
lb_policy =
grpc_lb_policy_create(r->lb_policy_name, &lb_policy_args);
lb_policy = grpc_lb_policy_create(r->lb_policy_name, &lb_policy_args);
gpr_free(subchannels);
grpc_client_config_set_lb_policy(cfg, lb_policy);
GRPC_LB_POLICY_UNREF(lb_policy, "sockaddr", closure_list);
@ -333,9 +332,9 @@ static grpc_resolver *sockaddr_create(
r->addrs = gpr_malloc(sizeof(struct sockaddr_storage) * r->num_addrs);
r->addrs_len = gpr_malloc(sizeof(*r->addrs_len) * r->num_addrs);
for(i = 0; i < r->num_addrs; i++) {
for (i = 0; i < r->num_addrs; i++) {
grpc_uri ith_uri = *args->uri;
char* part_str = gpr_dump_slice(path_parts.slices[i], GPR_DUMP_ASCII);
char *part_str = gpr_dump_slice(path_parts.slices[i], GPR_DUMP_ASCII);
ith_uri.path = part_str;
if (!parse(&ith_uri, &r->addrs[i], &r->addrs_len[i])) {
errors_found = 1; /* GPR_TRUE */

@ -202,8 +202,7 @@ static void zookeeper_on_resolved(void *arg,
}
lb_policy_args.subchannels = subchannels;
lb_policy_args.num_subchannels = addresses->naddrs;
lb_policy =
grpc_lb_policy_create(r->lb_policy_name, &lb_policy_args);
lb_policy = grpc_lb_policy_create(r->lb_policy_name, &lb_policy_args);
grpc_client_config_set_lb_policy(config, lb_policy);
GRPC_LB_POLICY_UNREF(lb_policy, "construction");
grpc_resolved_addresses_destroy(addresses);

@ -106,7 +106,7 @@ grpc_compression_level grpc_compression_level_for_algorithm(
}
void grpc_compression_options_init(grpc_compression_options *opts) {
opts->enabled_algorithms_bitset = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT)-1;
opts->enabled_algorithms_bitset = (1u << GRPC_COMPRESS_ALGORITHMS_COUNT) - 1;
opts->default_compression_algorithm = GRPC_COMPRESS_NONE;
}

@ -110,7 +110,7 @@ static void do_iocp_work() {
}
static void iocp_loop(void *p) {
while (gpr_atm_acq_load(&g_custom_events) ||
while (gpr_atm_acq_load(&g_custom_events) ||
!gpr_event_get(&g_shutdown_iocp)) {
do_iocp_work();
}

@ -99,7 +99,7 @@ void grpc_pollset_destroy(grpc_pollset *pollset) {
gpr_mu_destroy(&pollset->mu);
}
void grpc_pollset_work(grpc_pollset *pollset, grpc_pollset_worker *worker,
void grpc_pollset_work(grpc_pollset *pollset, grpc_pollset_worker *worker,
gpr_timespec now, gpr_timespec deadline) {
int added_worker = 0;
worker->next = worker->prev = NULL;

@ -82,7 +82,8 @@ void grpc_winsocket_shutdown(grpc_winsocket *winsocket) {
DisconnectEx(winsocket->socket, NULL, 0, 0);
} else {
char *utf8_message = gpr_format_message(WSAGetLastError());
gpr_log(GPR_ERROR, "Unable to retrieve DisconnectEx pointer : %s", utf8_message);
gpr_log(GPR_ERROR, "Unable to retrieve DisconnectEx pointer : %s",
utf8_message);
gpr_free(utf8_message);
}
closesocket(winsocket->socket);

@ -90,7 +90,7 @@ static void on_connect(void *acp, int from_iocp) {
grpc_winsocket_callback_info *info = &ac->socket->write_info;
void (*cb)(void *arg, grpc_endpoint *tcp) = ac->cb;
void *cb_arg = ac->cb_arg;
grpc_alarm_cancel(&ac->alarm);
gpr_mu_lock(&ac->mu);

@ -86,7 +86,7 @@ struct grpc_tcp_server {
size_t port_capacity;
/* shutdown callback */
void(*shutdown_complete)(void *);
void (*shutdown_complete)(void *);
void *shutdown_complete_arg;
};
@ -132,8 +132,8 @@ void grpc_tcp_server_destroy(grpc_tcp_server *s,
gpr_mu_lock(&s->mu);
s->shutdown_complete = shutdown_complete
? shutdown_complete
: dont_care_about_shutdown_completion;
? shutdown_complete
: dont_care_about_shutdown_completion;
s->shutdown_complete_arg = shutdown_complete_arg;
/* First, shutdown all fd's. This will queue abortion calls for all
@ -206,7 +206,8 @@ static void decrement_active_ports_and_notify(server_port *sp) {
sp->shutting_down = 0;
gpr_mu_lock(&sp->server->mu);
GPR_ASSERT(sp->server->active_ports > 0);
if (0 == --sp->server->active_ports && sp->server->shutdown_complete != NULL) {
if (0 == --sp->server->active_ports &&
sp->server->shutdown_complete != NULL) {
notify = 1;
}
gpr_mu_unlock(&sp->server->mu);

@ -108,18 +108,18 @@ static void tcp_free(grpc_tcp *tcp) {
#define TCP_UNREF(tcp, reason) tcp_unref((tcp), (reason), __FILE__, __LINE__)
#define TCP_REF(tcp, reason) tcp_ref((tcp), (reason), __FILE__, __LINE__)
static void tcp_unref(grpc_tcp *tcp, const char *reason, const char *file,
int line) {
int line) {
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "TCP unref %p : %s %d -> %d", tcp,
reason, tcp->refcount.count, tcp->refcount.count - 1);
reason, tcp->refcount.count, tcp->refcount.count - 1);
if (gpr_unref(&tcp->refcount)) {
tcp_free(tcp);
}
}
static void tcp_ref(grpc_tcp *tcp, const char *reason, const char *file,
int line) {
int line) {
gpr_log(file, line, GPR_LOG_SEVERITY_DEBUG, "TCP ref %p : %s %d -> %d", tcp,
reason, tcp->refcount.count, tcp->refcount.count + 1);
reason, tcp->refcount.count, tcp->refcount.count + 1);
gpr_ref(&tcp->refcount);
}
#else

@ -70,10 +70,10 @@ static void log_report() {
int i;
for (i = 0; i < count; i++) {
grpc_timer_entry* entry = &(log[i]);
printf("GRPC_LAT_PROF %ld.%09d %p %c %d(%s) %p %s %d\n",
entry->tm.tv_sec, entry->tm.tv_nsec,
(void*)(gpr_intptr)gpr_thd_currentid(), entry->type, entry->tag,
entry->tagstr, entry->id, entry->file, entry->line);
printf("GRPC_LAT_PROF %ld.%09d %p %c %d(%s) %p %s %d\n", entry->tm.tv_sec,
entry->tm.tv_nsec, (void*)(gpr_intptr)gpr_thd_currentid(),
entry->type, entry->tag, entry->tagstr, entry->id, entry->file,
entry->line);
}
/* Now clear out the log */

@ -712,8 +712,7 @@ static void refresh_token_fetch_oauth2(
gpr_free(body);
}
grpc_credentials *
grpc_refresh_token_credentials_create_from_auth_refresh_token(
grpc_credentials *grpc_refresh_token_credentials_create_from_auth_refresh_token(
grpc_auth_refresh_token refresh_token) {
grpc_google_refresh_token_credentials *c;
if (!grpc_auth_refresh_token_is_valid(&refresh_token)) {

@ -218,7 +218,6 @@ typedef struct {
grpc_server_credentials *c, grpc_security_connector **sc);
} grpc_server_credentials_vtable;
/* TODO(jboeuf): Add a refcount. */
struct grpc_server_credentials {
const grpc_server_credentials_vtable *vtable;

@ -136,8 +136,8 @@ static void on_md_processing_done(
gpr_slice message;
grpc_metadata_array_destroy(&calld->md);
error_details = error_details != NULL
? error_details
: "Authentication metadata processing failed.";
? error_details
: "Authentication metadata processing failed.";
message = gpr_slice_from_copied_string(error_details);
grpc_sopb_reset(calld->recv_ops);
grpc_transport_stream_op_add_close(&calld->transport_op, status, &message);

@ -67,7 +67,7 @@ typedef union lockfree_node {
#define ENTRY_ALIGNMENT_BITS 3 /* make sure that entries aligned to 8-bytes */
#define INVALID_ENTRY_INDEX \
((1 << 16) - 1) /* reserve this entry as invalid \
*/
*/
struct gpr_stack_lockfree {
lockfree_node *entries;

@ -90,7 +90,7 @@ int gpr_cv_wait(gpr_cv *cv, gpr_mu *mu, gpr_timespec abs_deadline) {
gpr_timespec now = gpr_now(abs_deadline.clock_type);
gpr_int64 now_ms = (gpr_int64)now.tv_sec * 1000 + now.tv_nsec / 1000000;
gpr_int64 deadline_ms =
(gpr_int64)abs_deadline.tv_sec * 1000 + abs_deadline.tv_nsec / 1000000;
(gpr_int64)abs_deadline.tv_sec * 1000 + abs_deadline.tv_nsec / 1000000;
if (now_ms >= deadline_ms) {
timeout = 1;
} else {

@ -83,7 +83,7 @@ static void gpr_precise_clock_now(gpr_timespec *clk) {
clk->tv_nsec = counter % cycles_per_second;
}
#else /* GRPC_TIMERS_RDTSC */
#else /* GRPC_TIMERS_RDTSC */
static void gpr_precise_clock_now(gpr_timespec *clk) {
*clk = gpr_now(GPR_CLOCK_REALTIME);
clk->clock_type = GPR_CLOCK_PRECISE;

@ -1012,7 +1012,7 @@ void grpc_server_setup_transport(grpc_server *s, grpc_transport *transport,
void done_published_shutdown(void *done_arg, grpc_cq_completion *storage,
grpc_closure_list *closure_list) {
(void) done_arg;
(void)done_arg;
gpr_free(storage);
}

@ -36,6 +36,4 @@
#include <grpc/grpc.h>
const char *grpc_version_string(void) {
return "0.11.0.0";
}
const char *grpc_version_string(void) { return "0.11.0.0"; }

@ -377,7 +377,7 @@ static grpc_mdelem *hpack_enc(grpc_chttp2_hpack_compressor *c,
gpr_uint32 indices_key;
int should_add_elem;
GPR_ASSERT (GPR_SLICE_LENGTH(elem->key->slice) > 0);
GPR_ASSERT(GPR_SLICE_LENGTH(elem->key->slice) > 0);
if (GPR_SLICE_START_PTR(elem->key->slice)[0] != ':') { /* regular header */
st->seen_regular_header = 1;
} else if (st->seen_regular_header != 0) { /* reserved header */

@ -137,4 +137,3 @@ void grpc_connectivity_state_set(grpc_connectivity_state_tracker *tracker,
gpr_free(w);
}
}

@ -41,7 +41,7 @@
static void test_succeeds(const char *uri_text, const char *scheme,
const char *authority, const char *path,
const char *query, const char* fragment) {
const char *query, const char *fragment) {
grpc_uri *uri = grpc_uri_parse(uri_text, 0);
GPR_ASSERT(uri);
GPR_ASSERT(0 == strcmp(scheme, uri->scheme));

@ -125,7 +125,7 @@ void test_connect(const char *server_host, const char *client_host, int port,
gpr_slice_new((char *)client_host, strlen(client_host), do_nothing);
gpr_slice_buffer_init(&uri_parts);
gpr_slice_split(uri_slice, ",", &uri_parts);
hosts_with_port = gpr_malloc(sizeof(char*) * uri_parts.count);
hosts_with_port = gpr_malloc(sizeof(char *) * uri_parts.count);
for (i = 0; i < uri_parts.count; i++) {
char *uri_part_str = gpr_dump_slice(uri_parts.slices[i], GPR_DUMP_ASCII);
gpr_asprintf(&hosts_with_port[i], "%s:%d", uri_part_str, port);
@ -322,19 +322,19 @@ int main(int argc, char **argv) {
if (!external_dns_works("loopback46.unittest.grpc.io")) {
gpr_log(GPR_INFO, "Skipping tests that depend on *.unittest.grpc.io.");
} else {
test_connect("loopback46.unittest.grpc.io",
"loopback4.unittest.grpc.io", 0, 1);
test_connect("loopback4.unittest.grpc.io",
"loopback46.unittest.grpc.io", 0, 1);
test_connect("loopback46.unittest.grpc.io", "loopback4.unittest.grpc.io",
0, 1);
test_connect("loopback4.unittest.grpc.io", "loopback46.unittest.grpc.io",
0, 1);
if (do_ipv6) {
test_connect("loopback46.unittest.grpc.io",
"loopback6.unittest.grpc.io", 0, 1);
test_connect("loopback6.unittest.grpc.io",
"loopback46.unittest.grpc.io", 0, 1);
test_connect("loopback4.unittest.grpc.io",
"loopback6.unittest.grpc.io", 0, 0);
test_connect("loopback6.unittest.grpc.io",
"loopback4.unittest.grpc.io", 0, 0);
test_connect("loopback4.unittest.grpc.io", "loopback6.unittest.grpc.io",
0, 0);
test_connect("loopback6.unittest.grpc.io", "loopback4.unittest.grpc.io",
0, 0);
}
}
}

@ -67,9 +67,7 @@ static const grpc_metadata *find_metadata(const grpc_metadata *md,
return NULL;
}
typedef struct {
size_t pseudo_refcount;
} test_processor_state;
typedef struct { size_t pseudo_refcount; } test_processor_state;
static void process_oauth2_success(void *state, grpc_auth_context *ctx,
const grpc_metadata *md, size_t md_count,

@ -157,9 +157,7 @@ static void unrefpc(proxy_call *pc, const char *reason) {
}
}
static void refpc(proxy_call *pc, const char *reason) {
gpr_ref(&pc->refs);
}
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;

@ -227,16 +227,17 @@ void test_times_out(void) {
gpr_timespec continue_verifying_time =
gpr_time_from_seconds(5, GPR_TIMESPAN);
gpr_timespec grace_time = gpr_time_from_seconds(3, GPR_TIMESPAN);
gpr_timespec finish_time = gpr_time_add(connect_deadline, continue_verifying_time);
gpr_timespec restart_verifying_time = gpr_time_add(connect_deadline, grace_time);
gpr_timespec finish_time =
gpr_time_add(connect_deadline, continue_verifying_time);
gpr_timespec restart_verifying_time =
gpr_time_add(connect_deadline, grace_time);
int is_after_deadline = gpr_time_cmp(now, connect_deadline) > 0;
if (gpr_time_cmp(now, finish_time) > 0) {
break;
}
gpr_log(GPR_DEBUG, "now=%d.%09d connect_deadline=%d.%09d",
now.tv_sec, now.tv_nsec, connect_deadline.tv_sec, connect_deadline.tv_nsec);
if (is_after_deadline &&
gpr_time_cmp(now, restart_verifying_time) <= 0) {
gpr_log(GPR_DEBUG, "now=%d.%09d connect_deadline=%d.%09d", now.tv_sec,
now.tv_nsec, connect_deadline.tv_sec, connect_deadline.tv_nsec);
if (is_after_deadline && gpr_time_cmp(now, restart_verifying_time) <= 0) {
/* allow some slack before insisting that things be done */
} else {
GPR_ASSERT(g_connections_complete ==

@ -127,7 +127,7 @@ static void free_port_using_server(char *server, int port) {
gpr_free(path);
}
static void free_chosen_ports() {
static void free_chosen_ports() {
char *env = gpr_getenv("GRPC_TEST_PORT_SERVER");
if (env != NULL) {
size_t i;
@ -137,7 +137,7 @@ static void free_chosen_ports() {
gpr_free(env);
}
gpr_free(chosen_ports);
gpr_free(chosen_ports);
}
static void chose_port(int port) {

Loading…
Cancel
Save