clang-format

pull/8617/head
Mark D. Roth 8 years ago
parent 6ad80579de
commit 47f1084ce8
  1. 12
      src/core/ext/client_channel/client_channel.c
  2. 6
      src/core/lib/json/json.c
  3. 22
      src/core/lib/json/json.h
  4. 4
      src/core/lib/support/string.c
  5. 2
      src/core/lib/support/string.h
  6. 8
      src/core/lib/transport/method_config.c
  7. 2
      test/core/end2end/connection_refused_test.c
  8. 2
      test/core/end2end/tests/cancel_after_accept.c
  9. 4
      test/core/end2end/tests/max_message_length.c

@ -86,21 +86,21 @@ static const grpc_mdstr_hash_table_vtable method_parameters_vtable = {
static void *method_parameters_create_from_json(const grpc_json *json) {
wait_for_ready_value wait_for_ready = WAIT_FOR_READY_UNSET;
gpr_timespec timeout = { 0, 0, GPR_TIMESPAN };
for (grpc_json* field = json->child; field != NULL; field = field->next) {
gpr_timespec timeout = {0, 0, GPR_TIMESPAN};
for (grpc_json *field = json->child; field != NULL; field = field->next) {
if (field->key == NULL) continue;
if (strcmp(field->key, "wait_for_ready") == 0) {
if (wait_for_ready != WAIT_FOR_READY_UNSET) return NULL; // Duplicate.
if (field->type != GRPC_JSON_TRUE && field->type != GRPC_JSON_FALSE) {
return NULL;
}
wait_for_ready = field->type == GRPC_JSON_TRUE
? WAIT_FOR_READY_TRUE : WAIT_FOR_READY_FALSE;
wait_for_ready = field->type == GRPC_JSON_TRUE ? WAIT_FOR_READY_TRUE
: WAIT_FOR_READY_FALSE;
} else if (strcmp(field->key, "timeout") == 0) {
if (timeout.tv_sec > 0 || timeout.tv_nsec > 0) return NULL; // Duplicate.
if (field->type != GRPC_JSON_OBJECT) return NULL;
if (field->child == NULL) return NULL;
for (grpc_json* subfield = field->child; subfield != NULL;
for (grpc_json *subfield = field->child; subfield != NULL;
subfield = subfield->next) {
if (subfield->key == NULL) return NULL;
if (strcmp(subfield->key, "seconds") == 0) {
@ -303,7 +303,7 @@ static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg,
grpc_channel_args_find(lb_policy_args.args, GRPC_ARG_SERVICE_CONFIG);
if (channel_arg != NULL) {
GPR_ASSERT(channel_arg->type == GRPC_ARG_POINTER);
grpc_json_tree* json_tree = channel_arg->value.pointer.p;
grpc_json_tree *json_tree = channel_arg->value.pointer.p;
method_params_table = grpc_method_config_table_create_from_json(
json_tree->root, method_parameters_create_from_json,
&method_parameters_vtable);

@ -39,15 +39,15 @@
#include "src/core/lib/json/json.h"
grpc_json *grpc_json_create(grpc_json_type type) {
grpc_json *json = gpr_malloc(sizeof(*json));
grpc_json* grpc_json_create(grpc_json_type type) {
grpc_json* json = gpr_malloc(sizeof(*json));
memset(json, 0, sizeof(*json));
json->type = type;
return json;
}
void grpc_json_destroy(grpc_json *json) {
void grpc_json_destroy(grpc_json* json) {
while (json->child) {
grpc_json_destroy(json->child);
}

@ -44,14 +44,14 @@
* are not owned by it.
*/
typedef struct grpc_json {
struct grpc_json *next;
struct grpc_json *prev;
struct grpc_json *child;
struct grpc_json *parent;
struct grpc_json* next;
struct grpc_json* prev;
struct grpc_json* child;
struct grpc_json* parent;
grpc_json_type type;
const char *key;
const char *value;
const char* key;
const char* value;
} grpc_json;
/* The next two functions are going to parse the input string, and
@ -67,8 +67,8 @@ typedef struct grpc_json {
*
* Delete the allocated tree afterward using grpc_json_destroy().
*/
grpc_json *grpc_json_parse_string_with_len(char *input, size_t size);
grpc_json *grpc_json_parse_string(char *input);
grpc_json* grpc_json_parse_string_with_len(char* input, size_t size);
grpc_json* grpc_json_parse_string(char* input);
/* This function will create a new string using gpr_realloc, and will
* deserialize the grpc_json tree into it. It'll be zero-terminated,
@ -78,14 +78,14 @@ grpc_json *grpc_json_parse_string(char *input);
* If indent is 0, then newlines will be suppressed as well, and the
* output will be condensed at its maximum.
*/
char *grpc_json_dump_to_string(grpc_json *json, int indent);
char* grpc_json_dump_to_string(grpc_json* json, int indent);
/* Use these to create or delete a grpc_json object.
* Deletion is recursive. We will not attempt to free any of the strings
* in any of the objects of that tree.
*/
grpc_json *grpc_json_create(grpc_json_type type);
void grpc_json_destroy(grpc_json *json);
grpc_json* grpc_json_create(grpc_json_type type);
void grpc_json_destroy(grpc_json* json);
/* Compares two JSON trees. */
int grpc_json_cmp(const grpc_json* json1, const grpc_json* json2);

@ -196,8 +196,8 @@ int int64_ttoa(int64_t value, char *string) {
return i;
}
int gpr_parse_nonnegative_number(const char* value) {
char* end;
int gpr_parse_nonnegative_number(const char *value) {
char *end;
long result = strtol(value, &end, 0);
if (*end != '\0' || result < 0 || result > INT_MAX) return -1;
return (int)result;

@ -81,7 +81,7 @@ where long is 32bit is size.*/
int int64_ttoa(int64_t value, char *output);
// Parses a non-negative number from a value string. Returns -1 on error.
int gpr_parse_nonnegative_number(const char* value);
int gpr_parse_nonnegative_number(const char *value);
/* Reverse a run of bytes */
void gpr_reverse_bytes(char *str, int len);

@ -80,10 +80,9 @@ static char* parse_json_method_name(grpc_json* json) {
// Parses the method config from \a json. Adds an entry to \a entries for
// each name found, incrementing \a idx for each entry added.
static bool parse_json_method_config(
grpc_json* json,
void* (*create_value)(const grpc_json* method_config_json),
grpc_json* json, void* (*create_value)(const grpc_json* method_config_json),
const grpc_mdstr_hash_table_vtable* vtable,
grpc_mdstr_hash_table_entry* entries, size_t *idx) {
grpc_mdstr_hash_table_entry* entries, size_t* idx) {
// Construct value.
void* method_config = create_value(json);
if (method_config == NULL) return NULL;
@ -135,8 +134,7 @@ grpc_mdstr_hash_table* grpc_method_config_table_create_from_json(
num_entries += count_names_in_method_config_json(method);
}
// Populate method config table entries.
entries =
gpr_malloc(num_entries * sizeof(grpc_mdstr_hash_table_entry));
entries = gpr_malloc(num_entries * sizeof(grpc_mdstr_hash_table_entry));
size_t idx = 0;
for (grpc_json* method = field->child; method != NULL;
method = method->next) {

@ -76,7 +76,7 @@ static void run_test(bool wait_for_ready, bool use_service_config) {
grpc_channel_args *args = NULL;
if (use_service_config) {
GPR_ASSERT(wait_for_ready);
grpc_json_tree* service_config_json = grpc_json_tree_create(
grpc_json_tree *service_config_json = grpc_json_tree_create(
"{\n"
" \"method_config\": [ {\n"
" \"name\": [\n"

@ -132,7 +132,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config,
grpc_channel_args *args = NULL;
if (use_service_config) {
grpc_json_tree* service_config_json = grpc_json_tree_create(
grpc_json_tree *service_config_json = grpc_json_tree_create(
"{\n"
" \"method_config\": [ {\n"
" \"name\": [\n"

@ -137,7 +137,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config,
if (use_service_config) {
// We don't currently support service configs on the server side.
GPR_ASSERT(send_limit);
grpc_json_tree* service_config_json = grpc_json_tree_create(
grpc_json_tree *service_config_json = grpc_json_tree_create(
"{\n"
" \"method_config\": [ {\n"
" \"name\": [\n"
@ -308,7 +308,7 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config,
if (use_service_config) {
// We don't currently support service configs on the server side.
GPR_ASSERT(!send_limit);
grpc_json_tree* service_config_json = grpc_json_tree_create(
grpc_json_tree *service_config_json = grpc_json_tree_create(
"{\n"
" \"method_config\": [ {\n"
" \"name\": [\n"

Loading…
Cancel
Save