From baa14a975ef92ee6fb301f0e684f56f18f2c55a7 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Fri, 3 Nov 2017 09:09:36 -0700 Subject: Update clang-format to 5.0 --- src/core/lib/http/parser.cc | 76 ++++++++++++++++++++++----------------------- 1 file changed, 38 insertions(+), 38 deletions(-) (limited to 'src/core/lib/http/parser.cc') diff --git a/src/core/lib/http/parser.cc b/src/core/lib/http/parser.cc index 0950bd655e..99a4919401 100644 --- a/src/core/lib/http/parser.cc +++ b/src/core/lib/http/parser.cc @@ -27,17 +27,17 @@ grpc_tracer_flag grpc_http1_trace = GRPC_TRACER_INITIALIZER(false, "http1"); -static char *buf2str(void *buffer, size_t length) { - char *out = (char *)gpr_malloc(length + 1); +static char* buf2str(void* buffer, size_t length) { + char* out = (char*)gpr_malloc(length + 1); memcpy(out, buffer, length); out[length] = 0; return out; } -static grpc_error *handle_response_line(grpc_http_parser *parser) { - uint8_t *beg = parser->cur_line; - uint8_t *cur = beg; - uint8_t *end = beg + parser->cur_line_length; +static grpc_error* handle_response_line(grpc_http_parser* parser) { + uint8_t* beg = parser->cur_line; + uint8_t* cur = beg; + uint8_t* end = beg + parser->cur_line_length; if (cur == end || *cur++ != 'H') return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Expected 'H'"); @@ -75,10 +75,10 @@ static grpc_error *handle_response_line(grpc_http_parser *parser) { return GRPC_ERROR_NONE; } -static grpc_error *handle_request_line(grpc_http_parser *parser) { - uint8_t *beg = parser->cur_line; - uint8_t *cur = beg; - uint8_t *end = beg + parser->cur_line_length; +static grpc_error* handle_request_line(grpc_http_parser* parser) { + uint8_t* beg = parser->cur_line; + uint8_t* cur = beg; + uint8_t* end = beg + parser->cur_line_length; uint8_t vers_major = 0; uint8_t vers_minor = 0; @@ -137,7 +137,7 @@ static grpc_error *handle_request_line(grpc_http_parser *parser) { return GRPC_ERROR_NONE; } -static grpc_error *handle_first_line(grpc_http_parser *parser) { +static grpc_error* handle_first_line(grpc_http_parser* parser) { switch (parser->type) { case GRPC_HTTP_REQUEST: return handle_request_line(parser); @@ -148,14 +148,14 @@ static grpc_error *handle_first_line(grpc_http_parser *parser) { return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Should never reach here")); } -static grpc_error *add_header(grpc_http_parser *parser) { - uint8_t *beg = parser->cur_line; - uint8_t *cur = beg; - uint8_t *end = beg + parser->cur_line_length; - size_t *hdr_count = NULL; - grpc_http_header **hdrs = NULL; +static grpc_error* add_header(grpc_http_parser* parser) { + uint8_t* beg = parser->cur_line; + uint8_t* cur = beg; + uint8_t* end = beg + parser->cur_line_length; + size_t* hdr_count = NULL; + grpc_http_header** hdrs = NULL; grpc_http_header hdr = {NULL, NULL}; - grpc_error *error = GRPC_ERROR_NONE; + grpc_error* error = GRPC_ERROR_NONE; GPR_ASSERT(cur != end); @@ -197,7 +197,7 @@ 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 = (grpc_http_header *)gpr_realloc( + *hdrs = (grpc_http_header*)gpr_realloc( *hdrs, parser->hdr_capacity * sizeof(**hdrs)); } (*hdrs)[(*hdr_count)++] = hdr; @@ -210,9 +210,9 @@ done: return error; } -static grpc_error *finish_line(grpc_http_parser *parser, - bool *found_body_start) { - grpc_error *err; +static grpc_error* finish_line(grpc_http_parser* parser, + bool* found_body_start) { + grpc_error* err; switch (parser->state) { case GRPC_HTTP_FIRST_LINE: err = handle_first_line(parser); @@ -239,9 +239,9 @@ static grpc_error *finish_line(grpc_http_parser *parser, return GRPC_ERROR_NONE; } -static grpc_error *addbyte_body(grpc_http_parser *parser, uint8_t byte) { - size_t *body_length = NULL; - char **body = NULL; +static grpc_error* addbyte_body(grpc_http_parser* parser, uint8_t byte) { + size_t* body_length = NULL; + char** body = NULL; if (parser->type == GRPC_HTTP_RESPONSE) { body_length = &parser->http.response->body_length; @@ -256,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 = (char *)gpr_realloc((void *)*body, parser->body_capacity); + *body = (char*)gpr_realloc((void*)*body, parser->body_capacity); } (*body)[*body_length] = (char)byte; (*body_length)++; @@ -264,7 +264,7 @@ static grpc_error *addbyte_body(grpc_http_parser *parser, uint8_t byte) { return GRPC_ERROR_NONE; } -static bool check_line(grpc_http_parser *parser) { +static bool check_line(grpc_http_parser* parser) { if (parser->cur_line_length >= 2 && parser->cur_line[parser->cur_line_length - 2] == '\r' && parser->cur_line[parser->cur_line_length - 1] == '\n') { @@ -288,8 +288,8 @@ static bool check_line(grpc_http_parser *parser) { return false; } -static grpc_error *addbyte(grpc_http_parser *parser, uint8_t byte, - bool *found_body_start) { +static grpc_error* addbyte(grpc_http_parser* parser, uint8_t byte, + bool* found_body_start) { switch (parser->state) { case GRPC_HTTP_FIRST_LINE: case GRPC_HTTP_HEADERS: @@ -312,8 +312,8 @@ static grpc_error *addbyte(grpc_http_parser *parser, uint8_t byte, GPR_UNREACHABLE_CODE(return GRPC_ERROR_NONE); } -void grpc_http_parser_init(grpc_http_parser *parser, grpc_http_type type, - void *request_or_response) { +void grpc_http_parser_init(grpc_http_parser* parser, grpc_http_type type, + void* request_or_response) { memset(parser, 0, sizeof(*parser)); parser->state = GRPC_HTTP_FIRST_LINE; parser->type = type; @@ -321,9 +321,9 @@ void grpc_http_parser_init(grpc_http_parser *parser, grpc_http_type type, parser->cur_line_end_length = 2; } -void grpc_http_parser_destroy(grpc_http_parser *parser) {} +void grpc_http_parser_destroy(grpc_http_parser* parser) {} -void grpc_http_request_destroy(grpc_http_request *request) { +void grpc_http_request_destroy(grpc_http_request* request) { size_t i; gpr_free(request->body); for (i = 0; i < request->hdr_count; i++) { @@ -335,7 +335,7 @@ void grpc_http_request_destroy(grpc_http_request *request) { gpr_free(request->path); } -void grpc_http_response_destroy(grpc_http_response *response) { +void grpc_http_response_destroy(grpc_http_response* response) { size_t i; gpr_free(response->body); for (i = 0; i < response->hdr_count; i++) { @@ -345,11 +345,11 @@ void grpc_http_response_destroy(grpc_http_response *response) { gpr_free(response->hdrs); } -grpc_error *grpc_http_parser_parse(grpc_http_parser *parser, grpc_slice slice, - size_t *start_of_body) { +grpc_error* grpc_http_parser_parse(grpc_http_parser* parser, grpc_slice slice, + size_t* start_of_body) { for (size_t i = 0; i < GRPC_SLICE_LENGTH(slice); i++) { bool found_body_start = false; - grpc_error *err = + grpc_error* err = addbyte(parser, GRPC_SLICE_START_PTR(slice)[i], &found_body_start); if (err != GRPC_ERROR_NONE) return err; if (found_body_start && start_of_body != NULL) *start_of_body = i + 1; @@ -357,7 +357,7 @@ grpc_error *grpc_http_parser_parse(grpc_http_parser *parser, grpc_slice slice, return GRPC_ERROR_NONE; } -grpc_error *grpc_http_parser_eof(grpc_http_parser *parser) { +grpc_error* grpc_http_parser_eof(grpc_http_parser* parser) { if (parser->state != GRPC_HTTP_BODY) { return GRPC_ERROR_CREATE_FROM_STATIC_STRING("Did not finish headers"); } -- cgit v1.2.3