diff options
37 files changed, 305 insertions, 289 deletions
diff --git a/include/grpc/support/alloc.h b/include/grpc/support/alloc.h index ae725700dc..f5cdadea4b 100644 --- a/include/grpc/support/alloc.h +++ b/include/grpc/support/alloc.h @@ -41,9 +41,9 @@ extern "C" { #endif typedef struct gpr_allocation_functions { - void *(*malloc_fn)(size_t size); - void *(*realloc_fn)(void *ptr, size_t size); - void (*free_fn)(void *ptr); + void *(*malloc_fn)(size_t size); + void *(*realloc_fn)(void *ptr, size_t size); + void (*free_fn)(void *ptr); } gpr_allocation_functions; /* malloc, never returns NULL */ diff --git a/src/core/census/context.h b/src/core/census/context.h index 02b3ec2545..700bcf86cf 100644 --- a/src/core/census/context.h +++ b/src/core/census/context.h @@ -41,7 +41,7 @@ /* census_context is the in-memory representation of information needed to * maintain tracing, RPC statistics and resource usage information. */ struct census_context { - census_tag_set *tags; /* Opaque data structure for census tags. */ + census_tag_set *tags; /* Opaque data structure for census tags. */ }; #endif /* GRPC_INTERNAL_CORE_CENSUS_CONTEXT_H */ diff --git a/src/core/compression/message_compress.c b/src/core/compression/message_compress.c index e72347118f..edc21a9eb7 100644 --- a/src/core/compression/message_compress.c +++ b/src/core/compression/message_compress.c @@ -91,13 +91,11 @@ error: return 0; } -static void *zalloc_gpr(void* opaque, unsigned int items, unsigned int size) { +static void* zalloc_gpr(void* opaque, unsigned int items, unsigned int size) { return gpr_malloc(items * size); } -static void zfree_gpr(void* opaque, void *address) { - gpr_free(address); -} +static void zfree_gpr(void* opaque, void* address) { gpr_free(address); } static int zlib_compress(gpr_slice_buffer* input, gpr_slice_buffer* output, int gzip) { @@ -157,7 +155,7 @@ static int copy(gpr_slice_buffer* input, gpr_slice_buffer* output) { } static int compress_inner(grpc_compression_algorithm algorithm, - gpr_slice_buffer* input, gpr_slice_buffer* output) { + gpr_slice_buffer* input, gpr_slice_buffer* output) { switch (algorithm) { case GRPC_COMPRESS_NONE: /* the fallback path always needs to be send uncompressed: we simply diff --git a/src/core/iomgr/pollset_posix.c b/src/core/iomgr/pollset_posix.c index b303f9d5bd..9195344758 100644 --- a/src/core/iomgr/pollset_posix.c +++ b/src/core/iomgr/pollset_posix.c @@ -624,9 +624,8 @@ static void basic_pollset_destroy(grpc_pollset *pollset) { } static const grpc_pollset_vtable basic_pollset = { - basic_pollset_add_fd, - basic_pollset_maybe_work_and_unlock, basic_pollset_destroy, - basic_pollset_destroy}; + basic_pollset_add_fd, basic_pollset_maybe_work_and_unlock, + basic_pollset_destroy, basic_pollset_destroy}; static void become_basic_pollset(grpc_pollset *pollset, grpc_fd *fd_or_null) { pollset->vtable = &basic_pollset; diff --git a/src/core/iomgr/tcp_windows.c b/src/core/iomgr/tcp_windows.c index 6915cb2f49..cc7f7ff8d2 100644 --- a/src/core/iomgr/tcp_windows.c +++ b/src/core/iomgr/tcp_windows.c @@ -197,7 +197,8 @@ static void win_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, tcp->read_slice = gpr_slice_malloc(8192); - buffer.len = (ULONG)GPR_SLICE_LENGTH(tcp->read_slice); // we know slice size fits in 32bit. + buffer.len = (ULONG)GPR_SLICE_LENGTH( + tcp->read_slice); // we know slice size fits in 32bit. buffer.buf = (char *)GPR_SLICE_START_PTR(tcp->read_slice); TCP_REF(tcp, "read"); @@ -291,7 +292,7 @@ static void win_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, for (i = 0; i < tcp->write_slices->count; i++) { len = GPR_SLICE_LENGTH(tcp->write_slices->slices[i]); GPR_ASSERT(len <= ULONG_MAX); - buffers[i].len = (ULONG) len; + buffers[i].len = (ULONG)len; buffers[i].buf = (char *)GPR_SLICE_START_PTR(tcp->write_slices->slices[i]); } diff --git a/src/core/json/json_reader.c b/src/core/json/json_reader.c index 358e0f6c1d..256995240a 100644 --- a/src/core/json/json_reader.c +++ b/src/core/json/json_reader.c @@ -232,7 +232,7 @@ grpc_json_reader_status grpc_json_reader_run(grpc_json_reader *reader) { reader->state = GRPC_JSON_STATE_END; break; default: - GPR_UNREACHABLE_CODE(return GRPC_JSON_INTERNAL_ERROR); + GPR_UNREACHABLE_CODE(return GRPC_JSON_INTERNAL_ERROR); } } break; diff --git a/src/core/security/credentials.c b/src/core/security/credentials.c index 15cc8e6c0e..a0054741ad 100644 --- a/src/core/security/credentials.c +++ b/src/core/security/credentials.c @@ -512,8 +512,9 @@ grpc_call_credentials *grpc_service_account_jwt_access_credentials_create( "token_lifetime=" "gpr_timespec { tv_sec: %lld, tv_nsec: %d, clock_type: %d }, " "reserved=%p)", - 5, (json_key, (long long)token_lifetime.tv_sec, (int)token_lifetime.tv_nsec, - (int)token_lifetime.clock_type, reserved)); + 5, + (json_key, (long long)token_lifetime.tv_sec, (int)token_lifetime.tv_nsec, + (int)token_lifetime.clock_type, reserved)); GPR_ASSERT(reserved == NULL); return grpc_service_account_jwt_access_credentials_create_from_auth_json_key( grpc_auth_json_key_create_from_string(json_key), token_lifetime); diff --git a/src/core/support/time_posix.c b/src/core/support/time_posix.c index 05d6cc0ca8..ba72572e05 100644 --- a/src/core/support/time_posix.c +++ b/src/core/support/time_posix.c @@ -47,7 +47,7 @@ static struct timespec timespec_from_gpr(gpr_timespec gts) { struct timespec rv; if (sizeof(time_t) < sizeof(gpr_int64)) { /* fine to assert, as this is only used in gpr_sleep_until */ - GPR_ASSERT(gts.tv_sec <= INT32_MAX && gts.tv_sec >= INT32_MIN); + GPR_ASSERT(gts.tv_sec <= INT32_MAX && gts.tv_sec >= INT32_MIN); } rv.tv_sec = (time_t)gts.tv_sec; rv.tv_nsec = gts.tv_nsec; diff --git a/src/core/surface/call_log_batch.c b/src/core/surface/call_log_batch.c index f4cd8375c2..46756f418b 100644 --- a/src/core/surface/call_log_batch.c +++ b/src/core/surface/call_log_batch.c @@ -116,4 +116,3 @@ void grpc_call_log_batch(char *file, int line, gpr_log_severity severity, gpr_free(tmp); } } - diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c index a873c39441..d0a8b0be09 100644 --- a/src/core/surface/channel.c +++ b/src/core/surface/channel.c @@ -198,8 +198,8 @@ grpc_call *grpc_channel_create_call(grpc_channel *channel, "deadline=gpr_timespec { tv_sec: %lld, tv_nsec: %d, clock_type: %d }, " "reserved=%p)", 10, (channel, parent_call, (unsigned)propagation_mask, cq, method, host, - (long long)deadline.tv_sec, (int)deadline.tv_nsec, (int)deadline.clock_type, - reserved)); + (long long)deadline.tv_sec, (int)deadline.tv_nsec, + (int)deadline.clock_type, reserved)); GPR_ASSERT(!reserved); return grpc_channel_create_call_internal( channel, parent_call, propagation_mask, cq, @@ -242,8 +242,8 @@ grpc_call *grpc_channel_create_registered_call( "deadline=gpr_timespec { tv_sec: %lld, tv_nsec: %d, clock_type: %d }, " "reserved=%p)", 9, (channel, parent_call, (unsigned)propagation_mask, completion_queue, - registered_call_handle, (long long)deadline.tv_sec, (int)deadline.tv_nsec, - (int)deadline.clock_type, reserved)); + registered_call_handle, (long long)deadline.tv_sec, + (int)deadline.tv_nsec, (int)deadline.clock_type, reserved)); GPR_ASSERT(!reserved); return grpc_channel_create_call_internal( channel, parent_call, propagation_mask, completion_queue, diff --git a/src/core/surface/completion_queue.c b/src/core/surface/completion_queue.c index c71b9b02b0..7704a83e12 100644 --- a/src/core/surface/completion_queue.c +++ b/src/core/surface/completion_queue.c @@ -249,8 +249,8 @@ grpc_event grpc_completion_queue_next(grpc_completion_queue *cc, "cc=%p, " "deadline=gpr_timespec { tv_sec: %lld, tv_nsec: %d, clock_type: %d }, " "reserved=%p)", - 5, (cc, (long long)deadline.tv_sec, (int)deadline.tv_nsec, (int)deadline.clock_type, - reserved)); + 5, (cc, (long long)deadline.tv_sec, (int)deadline.tv_nsec, + (int)deadline.clock_type, reserved)); GPR_ASSERT(!reserved); deadline = gpr_convert_clock_type(deadline, GPR_CLOCK_MONOTONIC); diff --git a/src/core/surface/server_create.c b/src/core/surface/server_create.c index e362bb4376..f30093e06b 100644 --- a/src/core/surface/server_create.c +++ b/src/core/surface/server_create.c @@ -47,6 +47,5 @@ grpc_server *grpc_server_create(const grpc_channel_args *args, void *reserved) { filters[num_filters++] = &grpc_server_census_filter; } GRPC_API_TRACE("grpc_server_create(%p, %p)", 2, (args, reserved)); - return grpc_server_create_from_filters(filters, num_filters, - args); + return grpc_server_create_from_filters(filters, num_filters, args); } diff --git a/src/core/transport/chttp2/frame_data.c b/src/core/transport/chttp2/frame_data.c index 38fa990758..732124b7c9 100644 --- a/src/core/transport/chttp2/frame_data.c +++ b/src/core/transport/chttp2/frame_data.c @@ -118,7 +118,7 @@ void grpc_chttp2_encode_data(gpr_uint32 id, gpr_slice_buffer *inbuf, hdr = gpr_slice_malloc(9); p = GPR_SLICE_START_PTR(hdr); - GPR_ASSERT(write_bytes < (1<<24)); + GPR_ASSERT(write_bytes < (1 << 24)); *p++ = (gpr_uint8)(write_bytes >> 16); *p++ = (gpr_uint8)(write_bytes >> 8); *p++ = (gpr_uint8)(write_bytes); diff --git a/src/core/transport/chttp2/frame_settings.c b/src/core/transport/chttp2/frame_settings.c index f03fb45908..383b6e7f93 100644 --- a/src/core/transport/chttp2/frame_settings.c +++ b/src/core/transport/chttp2/frame_settings.c @@ -44,7 +44,7 @@ #include "src/core/transport/chttp2/http2_errors.h" #include "src/core/transport/chttp2_transport.h" -#define MAX_MAX_HEADER_LIST_SIZE (1024*1024*1024) +#define MAX_MAX_HEADER_LIST_SIZE (1024 * 1024 * 1024) /* HTTP/2 mandated initial connection settings */ const grpc_chttp2_setting_parameters @@ -62,8 +62,9 @@ const grpc_chttp2_setting_parameters GRPC_CHTTP2_FLOW_CONTROL_ERROR}, {"MAX_FRAME_SIZE", 16384, 16384, 16777215, GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE, GRPC_CHTTP2_PROTOCOL_ERROR}, - {"MAX_HEADER_LIST_SIZE", MAX_MAX_HEADER_LIST_SIZE, 0, MAX_MAX_HEADER_LIST_SIZE, - GRPC_CHTTP2_CLAMP_INVALID_VALUE, GRPC_CHTTP2_PROTOCOL_ERROR}, + {"MAX_HEADER_LIST_SIZE", MAX_MAX_HEADER_LIST_SIZE, 0, + MAX_MAX_HEADER_LIST_SIZE, GRPC_CHTTP2_CLAMP_INVALID_VALUE, + GRPC_CHTTP2_PROTOCOL_ERROR}, }; static gpr_uint8 *fill_header(gpr_uint8 *out, gpr_uint32 length, diff --git a/src/core/transport/chttp2/hpack_encoder.c b/src/core/transport/chttp2/hpack_encoder.c index 06f603db9c..6c558bc1cb 100644 --- a/src/core/transport/chttp2/hpack_encoder.c +++ b/src/core/transport/chttp2/hpack_encoder.c @@ -366,8 +366,9 @@ static void hpack_enc(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem, if (GPR_SLICE_START_PTR(elem->key->slice)[0] != ':') { /* regular header */ st->seen_regular_header = 1; } else { - GPR_ASSERT(st->seen_regular_header == 0 && - "Reserved header (colon-prefixed) happening after regular ones."); + GPR_ASSERT( + st->seen_regular_header == 0 && + "Reserved header (colon-prefixed) happening after regular ones."); } inc_filter(HASH_FRAGMENT_1(elem_hash), &c->filter_elems_sum, c->filter_elems); diff --git a/src/core/transport/chttp2/varint.h b/src/core/transport/chttp2/varint.h index 970d1e17e2..5acb15d032 100644 --- a/src/core/transport/chttp2/varint.h +++ b/src/core/transport/chttp2/varint.h @@ -66,7 +66,8 @@ void grpc_chttp2_hpack_write_varint_tail(gpr_uint32 tail_value, if ((length) == 1u) { \ (tgt)[0] = (gpr_uint8)((prefix_or) | (n)); \ } else { \ - (tgt)[0] = (prefix_or) | (gpr_uint8)GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \ + (tgt)[0] = \ + (prefix_or) | (gpr_uint8)GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \ grpc_chttp2_hpack_write_varint_tail( \ (n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits), (tgt) + 1, (length)-1); \ } \ diff --git a/test/core/bad_client/tests/badreq.c b/test/core/bad_client/tests/badreq.c index bc6acd788f..f0d7dac0f5 100644 --- a/test/core/bad_client/tests/badreq.c +++ b/test/core/bad_client/tests/badreq.c @@ -38,8 +38,8 @@ #include "test/core/end2end/cq_verifier.h" #include "src/core/surface/server.h" -#define PFX_STR \ - "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ +#define PFX_STR \ + "PRI * HTTP/2.0\r\n\r\nSM\r\n\r\n" \ "\x00\x00\x00\x04\x00\x00\x00\x00\x00" /* settings frame */ static void verifier(grpc_server *server, grpc_completion_queue *cq) { @@ -54,76 +54,86 @@ int main(int argc, char **argv) { grpc_test_init(argc, argv); /* invalid content type */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR - "\x00\x00\xc2\x01\x04\x00\x00\x00\x01" - "\x10\x05:path\x08/foo/bar" - "\x10\x07:scheme\x04http" - "\x10\x07:method\x04POST" - "\x10\x0a:authority\x09localhost" - "\x10\x0c""content-type\x09text/html" - "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" - "\x10\x02te\x08trailers" - "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", - GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST( + verifier, PFX_STR + "\x00\x00\xc2\x01\x04\x00\x00\x00\x01" + "\x10\x05:path\x08/foo/bar" + "\x10\x07:scheme\x04http" + "\x10\x07:method\x04POST" + "\x10\x0a:authority\x09localhost" + "\x10\x0c" + "content-type\x09text/html" + "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" + "\x10\x02te\x08trailers" + "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", + GRPC_BAD_CLIENT_DISCONNECT); /* invalid te */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR - "\x00\x00\xcb\x01\x04\x00\x00\x00\x01" - "\x10\x05:path\x08/foo/bar" - "\x10\x07:scheme\x04http" - "\x10\x07:method\x04POST" - "\x10\x0a:authority\x09localhost" - "\x10\x0c""content-type\x10""application/grpc" - "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" - "\x10\x02te\x0a""frobnicate" - "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", - GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST( + verifier, PFX_STR + "\x00\x00\xcb\x01\x04\x00\x00\x00\x01" + "\x10\x05:path\x08/foo/bar" + "\x10\x07:scheme\x04http" + "\x10\x07:method\x04POST" + "\x10\x0a:authority\x09localhost" + "\x10\x0c" + "content-type\x10" + "application/grpc" + "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" + "\x10\x02te\x0a" + "frobnicate" + "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", + GRPC_BAD_CLIENT_DISCONNECT); /* two path headers */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR - "\x00\x00\xd9\x01\x04\x00\x00\x00\x01" - "\x10\x05:path\x08/foo/bar" - "\x10\x05:path\x08/foo/bah" - "\x10\x07:scheme\x04http" - "\x10\x07:method\x04POST" - "\x10\x0a:authority\x09localhost" - "\x10\x0c""content-type\x10""application/grpc" - "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" - "\x10\x02te\x08trailers" - "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", - GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST( + verifier, PFX_STR + "\x00\x00\xd9\x01\x04\x00\x00\x00\x01" + "\x10\x05:path\x08/foo/bar" + "\x10\x05:path\x08/foo/bah" + "\x10\x07:scheme\x04http" + "\x10\x07:method\x04POST" + "\x10\x0a:authority\x09localhost" + "\x10\x0c" + "content-type\x10" + "application/grpc" + "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" + "\x10\x02te\x08trailers" + "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", + GRPC_BAD_CLIENT_DISCONNECT); /* bad accept-encoding algorithm */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR - "\x00\x00\xd2\x01\x04\x00\x00\x00\x01" - "\x10\x05:path\x08/foo/bar" - "\x10\x07:scheme\x04http" - "\x10\x07:method\x04POST" - "\x10\x0a:authority\x09localhost" - "\x10\x0c""content-type\x10""application/grpc" - "\x10\x14grpc-accept-encoding\x1enobody-knows-the-trouble-i-see" - "\x10\x02te\x08trailers" - "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", - GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST( + verifier, PFX_STR + "\x00\x00\xd2\x01\x04\x00\x00\x00\x01" + "\x10\x05:path\x08/foo/bar" + "\x10\x07:scheme\x04http" + "\x10\x07:method\x04POST" + "\x10\x0a:authority\x09localhost" + "\x10\x0c" + "content-type\x10" + "application/grpc" + "\x10\x14grpc-accept-encoding\x1enobody-knows-the-trouble-i-see" + "\x10\x02te\x08trailers" + "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", + GRPC_BAD_CLIENT_DISCONNECT); /* bad grpc-encoding algorithm */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR - "\x00\x00\xf5\x01\x04\x00\x00\x00\x01" - "\x10\x05:path\x08/foo/bar" - "\x10\x07:scheme\x04http" - "\x10\x07:method\x04POST" - "\x10\x0a:authority\x09localhost" - "\x10\x0c""content-type\x10""application/grpc" - "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" - "\x10\x0dgrpc-encoding\x1cyou-dont-know-how-to-do-this" - "\x10\x02te\x08trailers" - "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", - GRPC_BAD_CLIENT_DISCONNECT); + GRPC_RUN_BAD_CLIENT_TEST( + verifier, PFX_STR + "\x00\x00\xf5\x01\x04\x00\x00\x00\x01" + "\x10\x05:path\x08/foo/bar" + "\x10\x07:scheme\x04http" + "\x10\x07:method\x04POST" + "\x10\x0a:authority\x09localhost" + "\x10\x0c" + "content-type\x10" + "application/grpc" + "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" + "\x10\x0dgrpc-encoding\x1cyou-dont-know-how-to-do-this" + "\x10\x02te\x08trailers" + "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)", + GRPC_BAD_CLIENT_DISCONNECT); return 0; } diff --git a/test/core/bad_client/tests/headers.c b/test/core/bad_client/tests/headers.c index abd2826111..c404fd2d67 100644 --- a/test/core/bad_client/tests/headers.c +++ b/test/core/bad_client/tests/headers.c @@ -40,9 +40,9 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq) { while (grpc_server_has_open_connections(server)) { - GPR_ASSERT(grpc_completion_queue_next( - cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), NULL) - .type == GRPC_QUEUE_TIMEOUT); + GPR_ASSERT(grpc_completion_queue_next(cq, + GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), + NULL).type == GRPC_QUEUE_TIMEOUT); } } @@ -126,24 +126,29 @@ int main(int argc, char **argv) { 0); GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x04\x01\x04\x00\x00\x00\x01" - "\x7f\x7f\x01""a", + "\x7f\x7f\x01" + "a", 0); GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x04\x01\x04\x00\x00\x00\x01" - "\x0f\x7f\x01""a", + "\x0f\x7f\x01" + "a", 0); GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x04\x01\x04\x00\x00\x00\x01" - "\x1f\x7f\x01""a", + "\x1f\x7f\x01" + "a", 0); /* test nvr, not indexed in static table */ GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x03\x01\x04\x00\x00\x00\x01" - "\x01\x01""a", + "\x01\x01" + "a", GRPC_BAD_CLIENT_DISCONNECT); GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x03\x01\x04\x00\x00\x00\x01" - "\x11\x01""a", + "\x11\x01" + "a", GRPC_BAD_CLIENT_DISCONNECT); /* illegal op code */ GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR @@ -228,14 +233,12 @@ int main(int argc, char **argv) { GRPC_BAD_CLIENT_DISCONNECT); /* dynamic table size update: set to default */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x03\x01\x04\x00\x00\x00\x01" "\x3f\xe1\x1f", GRPC_BAD_CLIENT_DISCONNECT); /* dynamic table size update: set too large */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x03\x01\x04\x00\x00\x00\x01" "\x3f\xf1\x1f", 0); @@ -251,42 +254,35 @@ int main(int argc, char **argv) { 0); /* non-ending header followed by continuation frame */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x00\x01\x00\x00\x00\x00\x01" "\x00\x00\x00\x09\x04\x00\x00\x00\x01", GRPC_BAD_CLIENT_DISCONNECT); /* non-ending header followed by non-continuation frame */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x00\x01\x00\x00\x00\x00\x01" "\x00\x00\x00\x00\x04\x00\x00\x00\x01", 0); - /* non-ending header followed by a continuation frame for a different stream */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR + /* non-ending header followed by a continuation frame for a different stream + */ + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x00\x01\x04\x00\x00\x00\x01" "\x00\x00\x00\x01\x00\x00\x00\x00\x03" "\x00\x00\x00\x09\x04\x00\x00\x00\x01", 0); /* opening with a continuation frame */ GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR - "\x00\x00\x00\x09\x04\x00\x00\x00\x01", - 0); + PFX_STR "\x00\x00\x00\x09\x04\x00\x00\x00\x01", 0); /* three header frames */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x00\x01\x04\x00\x00\x00\x01" "\x00\x00\x00\x01\x04\x00\x00\x00\x01" "\x00\x00\x00\x01\x04\x00\x00\x00\x01", GRPC_BAD_CLIENT_DISCONNECT); - /* an invalid header found with fuzzing */ GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR - "\x00\x00\x00\x01\x39\x67\xed\x1d\x64", + PFX_STR "\x00\x00\x00\x01\x39\x67\xed\x1d\x64", GRPC_BAD_CLIENT_DISCONNECT); /* a badly encoded timeout value */ diff --git a/test/core/bad_client/tests/initial_settings_frame.c b/test/core/bad_client/tests/initial_settings_frame.c index 5b17c08df2..cd8771e88e 100644 --- a/test/core/bad_client/tests/initial_settings_frame.c +++ b/test/core/bad_client/tests/initial_settings_frame.c @@ -97,24 +97,23 @@ int main(int argc, char **argv) { PFX_STR ONE_SETTING_HDR "\x00\x05\x00\x00\x00\x00", GRPC_BAD_CLIENT_DISCONNECT); GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR ONE_SETTING_HDR "\x00\x06\xff\xff\xff\xff", + PFX_STR ONE_SETTING_HDR "\x00\x06\xff\xff\xff\xff", GRPC_BAD_CLIENT_DISCONNECT); /* update intiial window size */ GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR ONE_SETTING_HDR "\x00\x04\x00\x01\x00\x00", + PFX_STR ONE_SETTING_HDR "\x00\x04\x00\x01\x00\x00", GRPC_BAD_CLIENT_DISCONNECT); /* ack with data */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR + GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR "\x00\x00\x00\x04\x00\x00\x00\x00\x00" - "\x00\x00\x01\x04\x01\x00\x00\x00\x00", 0); + "\x00\x00\x01\x04\x01\x00\x00\x00\x00", + 0); /* settings frame with invalid flags */ GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR - "\x00\x00\x00\x04\x10\x00\x00\x00\x00", 0); + PFX_STR "\x00\x00\x00\x04\x10\x00\x00\x00\x00", 0); /* unknown settings should be ignored */ GRPC_RUN_BAD_CLIENT_TEST(verifier, - PFX_STR ONE_SETTING_HDR "\x00\x99\x00\x00\x00\x00", + PFX_STR ONE_SETTING_HDR "\x00\x99\x00\x00\x00\x00", GRPC_BAD_CLIENT_DISCONNECT); return 0; diff --git a/test/core/bad_client/tests/simple_request.c b/test/core/bad_client/tests/simple_request.c index b3cd556421..125a9fa1f2 100644 --- a/test/core/bad_client/tests/simple_request.c +++ b/test/core/bad_client/tests/simple_request.c @@ -51,7 +51,8 @@ "\x10\x0c" \ "content-type\x10" \ "application/grpc" \ - "\x10\x14grpc-accept-encoding\x15""deflate,identity,gzip" \ + "\x10\x14grpc-accept-encoding\x15" \ + "deflate,identity,gzip" \ "\x10\x02te\x08trailers" \ "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)" @@ -65,12 +66,16 @@ "\x10\x07:scheme\x04http" \ "\x10\x07:method\x04POST" \ "\x10\x04host\x09localhost" \ - "\x10\x0c""content-type\x1e""application/grpc+this-is-valid" \ + "\x10\x0c" \ + "content-type\x1e" \ + "application/grpc+this-is-valid" \ "\x10\x14grpc-accept-encoding\x15identity,deflate,gzip" \ "\x10\x02te\x08trailers" \ "\x10\x0auser-agent\"bad-client grpc-c/0.12.0.0 (linux)" \ - "\x10\x0cgrpc-timeout\x03""10S" \ - "\x10\x0cgrpc-timeout\x02""5S" + "\x10\x0cgrpc-timeout\x03" \ + "10S" \ + "\x10\x0cgrpc-timeout\x02" \ + "5S" static void *tag(gpr_intptr t) { return (void *)t; } @@ -130,8 +135,10 @@ int main(int argc, char **argv) { GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, PFX_STR "\x00\x00\x00\x08\x10\x00\x00\x00\x01", 0); /* push a window update with bad data */ - GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, - PFX_STR "\x00\x00\x04\x08\x00\x00\x00\x00\x01" "\xff\xff\xff\xff", 0); + GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, PFX_STR + "\x00\x00\x04\x08\x00\x00\x00\x00\x01" + "\xff\xff\xff\xff", + 0); /* push a short goaway */ GRPC_RUN_BAD_CLIENT_TEST(failure_verifier, PFX_STR "\x00\x00\x04\x07\x00\x00\x00\x00\x00", 0); diff --git a/test/core/bad_client/tests/unknown_frame.c b/test/core/bad_client/tests/unknown_frame.c index 8ea81390c9..3f8658b337 100644 --- a/test/core/bad_client/tests/unknown_frame.c +++ b/test/core/bad_client/tests/unknown_frame.c @@ -40,9 +40,9 @@ static void verifier(grpc_server *server, grpc_completion_queue *cq) { while (grpc_server_has_open_connections(server)) { - GPR_ASSERT(grpc_completion_queue_next( - cq, GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), NULL) - .type == GRPC_QUEUE_TIMEOUT); + GPR_ASSERT(grpc_completion_queue_next(cq, + GRPC_TIMEOUT_MILLIS_TO_DEADLINE(20), + NULL).type == GRPC_QUEUE_TIMEOUT); } } @@ -50,8 +50,8 @@ int main(int argc, char **argv) { grpc_test_init(argc, argv); /* test adding prioritization data */ - GRPC_RUN_BAD_CLIENT_TEST(verifier, PFX_STR - "\x00\x00\x00\x88\x00\x00\x00\x00\x01", + GRPC_RUN_BAD_CLIENT_TEST(verifier, + PFX_STR "\x00\x00\x00\x88\x00\x00\x00\x00\x01", GRPC_BAD_CLIENT_DISCONNECT); return 0; diff --git a/test/core/client_config/lb_policies_test.c b/test/core/client_config/lb_policies_test.c index 401cafdc08..190bed0b41 100644 --- a/test/core/client_config/lb_policies_test.c +++ b/test/core/client_config/lb_policies_test.c @@ -716,7 +716,8 @@ int main(int argc, char **argv) { grpc_test_init(argc, argv); grpc_init(); - GPR_ASSERT(grpc_lb_policy_create("this-lb-policy-does-not-exist", NULL) == NULL); + GPR_ASSERT(grpc_lb_policy_create("this-lb-policy-does-not-exist", NULL) == + NULL); GPR_ASSERT(grpc_lb_policy_create(NULL, NULL) == NULL); /* everything is fine, all servers stay up the whole time and life's peachy */ diff --git a/test/core/client_config/resolvers/dns_resolver_test.c b/test/core/client_config/resolvers/dns_resolver_test.c index 478da5c3f4..38e76d5342 100644 --- a/test/core/client_config/resolvers/dns_resolver_test.c +++ b/test/core/client_config/resolvers/dns_resolver_test.c @@ -41,28 +41,27 @@ #include "test/core/util/test_config.h" static void subchannel_factory_ref(grpc_subchannel_factory *scv) {} -static void subchannel_factory_unref(grpc_exec_ctx *exec_ctx, +static void subchannel_factory_unref(grpc_exec_ctx *exec_ctx, grpc_subchannel_factory *scv) {} -static grpc_subchannel *subchannel_factory_create_subchannel(grpc_exec_ctx *exec_ctx, - grpc_subchannel_factory *factory, - grpc_subchannel_args *args) { +static grpc_subchannel *subchannel_factory_create_subchannel( + grpc_exec_ctx *exec_ctx, grpc_subchannel_factory *factory, + grpc_subchannel_args *args) { GPR_UNREACHABLE_CODE(return NULL); } static const grpc_subchannel_factory_vtable sc_vtable = { - subchannel_factory_ref, - subchannel_factory_unref, - subchannel_factory_create_subchannel -}; + subchannel_factory_ref, subchannel_factory_unref, + subchannel_factory_create_subchannel}; -static grpc_subchannel_factory sc_factory = { &sc_vtable }; +static grpc_subchannel_factory sc_factory = {&sc_vtable}; static void test_succeeds(grpc_resolver_factory *factory, const char *string) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_uri *uri = grpc_uri_parse(string, 0); grpc_resolver_args args; grpc_resolver *resolver; - gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, factory->vtable->scheme); + gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, + factory->vtable->scheme); GPR_ASSERT(uri); memset(&args, 0, sizeof(args)); args.uri = uri; @@ -79,7 +78,8 @@ static void test_fails(grpc_resolver_factory *factory, const char *string) { grpc_uri *uri = grpc_uri_parse(string, 0); grpc_resolver_args args; grpc_resolver *resolver; - gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, factory->vtable->scheme); + gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, + factory->vtable->scheme); GPR_ASSERT(uri); memset(&args, 0, sizeof(args)); args.uri = uri; diff --git a/test/core/client_config/resolvers/sockaddr_resolver_test.c b/test/core/client_config/resolvers/sockaddr_resolver_test.c index c94e46a2c7..8856c85449 100644 --- a/test/core/client_config/resolvers/sockaddr_resolver_test.c +++ b/test/core/client_config/resolvers/sockaddr_resolver_test.c @@ -41,28 +41,27 @@ #include "test/core/util/test_config.h" static void subchannel_factory_ref(grpc_subchannel_factory *scv) {} -static void subchannel_factory_unref(grpc_exec_ctx *exec_ctx, +static void subchannel_factory_unref(grpc_exec_ctx *exec_ctx, grpc_subchannel_factory *scv) {} -static grpc_subchannel *subchannel_factory_create_subchannel(grpc_exec_ctx *exec_ctx, - grpc_subchannel_factory *factory, - grpc_subchannel_args *args) { +static grpc_subchannel *subchannel_factory_create_subchannel( + grpc_exec_ctx *exec_ctx, grpc_subchannel_factory *factory, + grpc_subchannel_args *args) { GPR_UNREACHABLE_CODE(return NULL); } static const grpc_subchannel_factory_vtable sc_vtable = { - subchannel_factory_ref, - subchannel_factory_unref, - subchannel_factory_create_subchannel -}; + subchannel_factory_ref, subchannel_factory_unref, + subchannel_factory_create_subchannel}; -static grpc_subchannel_factory sc_factory = { &sc_vtable }; +static grpc_subchannel_factory sc_factory = {&sc_vtable}; static void test_succeeds(grpc_resolver_factory *factory, const char *string) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_uri *uri = grpc_uri_parse(string, 0); grpc_resolver_args args; grpc_resolver *resolver; - gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, factory->vtable->scheme); + gpr_log(GPR_DEBUG, "test: '%s' should be valid for '%s'", string, + factory->vtable->scheme); GPR_ASSERT(uri); memset(&args, 0, sizeof(args)); args.uri = uri; @@ -79,7 +78,8 @@ static void test_fails(grpc_resolver_factory *factory, const char *string) { grpc_uri *uri = grpc_uri_parse(string, 0); grpc_resolver_args args; grpc_resolver *resolver; - gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, factory->vtable->scheme); + gpr_log(GPR_DEBUG, "test: '%s' should be invalid for '%s'", string, + factory->vtable->scheme); GPR_ASSERT(uri); memset(&args, 0, sizeof(args)); args.uri = uri; diff --git a/test/core/compression/compression_test.c b/test/core/compression/compression_test.c index 78266357c4..26d7b2b6cc 100644 --- a/test/core/compression/compression_test.c +++ b/test/core/compression/compression_test.c @@ -92,14 +92,14 @@ static void test_compression_algorithm_name(void) { /* the value of "name" is undefined upon failure */ } - static void test_compression_algorithm_for_level(void) { size_t i; grpc_compression_level levels[] = { GRPC_COMPRESS_LEVEL_NONE, GRPC_COMPRESS_LEVEL_LOW, GRPC_COMPRESS_LEVEL_MED, GRPC_COMPRESS_LEVEL_HIGH}; - grpc_compression_algorithm algorithms[] = {GRPC_COMPRESS_NONE, - GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_DEFLATE}; + grpc_compression_algorithm algorithms[] = { + GRPC_COMPRESS_NONE, GRPC_COMPRESS_DEFLATE, GRPC_COMPRESS_DEFLATE, + GRPC_COMPRESS_DEFLATE}; gpr_log(GPR_DEBUG, "test_compression_algorithm_for_level"); for (i = 0; i < GPR_ARRAY_SIZE(levels); i++) { @@ -115,19 +115,22 @@ static void test_compression_enable_disable_algorithm(void) { gpr_log(GPR_DEBUG, "test_compression_enable_disable_algorithm"); grpc_compression_options_init(&options); - for (algorithm = GRPC_COMPRESS_NONE; algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT; algorithm++) { + for (algorithm = GRPC_COMPRESS_NONE; + algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT; algorithm++) { /* all algorithms are enabled by default */ GPR_ASSERT(grpc_compression_options_is_algorithm_enabled(&options, algorithm) != 0); } /* disable one by one */ - for (algorithm = GRPC_COMPRESS_NONE; algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT; algorithm++) { + for (algorithm = GRPC_COMPRESS_NONE; + algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT; algorithm++) { grpc_compression_options_disable_algorithm(&options, algorithm); GPR_ASSERT(grpc_compression_options_is_algorithm_enabled(&options, algorithm) == 0); } /* re-enable one by one */ - for (algorithm = GRPC_COMPRESS_NONE; algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT; algorithm++) { + for (algorithm = GRPC_COMPRESS_NONE; + algorithm < GRPC_COMPRESS_ALGORITHMS_COUNT; algorithm++) { grpc_compression_options_enable_algorithm(&options, algorithm); GPR_ASSERT(grpc_compression_options_is_algorithm_enabled(&options, algorithm) != 0); diff --git a/test/core/compression/message_compress_test.c b/test/core/compression/message_compress_test.c index bd454099ce..e5a01ef69e 100644 --- a/test/core/compression/message_compress_test.c +++ b/test/core/compression/message_compress_test.c @@ -236,8 +236,8 @@ static void test_bad_compression_algorithm(void) { gpr_slice_buffer_init(&input); gpr_slice_buffer_init(&output); - gpr_slice_buffer_add(&input, gpr_slice_from_copied_string( - "Never gonna give you up")); + gpr_slice_buffer_add(&input, + gpr_slice_from_copied_string("Never gonna give you up")); was_compressed = grpc_msg_compress(GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output); GPR_ASSERT(0 == was_compressed); @@ -264,8 +264,8 @@ static void test_bad_decompression_algorithm(void) { grpc_msg_decompress(GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output); GPR_ASSERT(0 == was_decompressed); - was_decompressed = - grpc_msg_decompress(GRPC_COMPRESS_ALGORITHMS_COUNT + 123, &input, &output); + was_decompressed = grpc_msg_decompress(GRPC_COMPRESS_ALGORITHMS_COUNT + 123, + &input, &output); GPR_ASSERT(0 == was_decompressed); gpr_slice_buffer_destroy(&input); diff --git a/test/core/end2end/fixtures/h2_full+pipe.c b/test/core/end2end/fixtures/h2_full+pipe.c index 40f4cf1291..83cde49305 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.c +++ b/test/core/end2end/fixtures/h2_full+pipe.c @@ -51,7 +51,6 @@ #include "test/core/util/test_config.h" #include "src/core/iomgr/wakeup_fd_posix.h" - typedef struct fullstack_fixture_data { char *localaddr; } fullstack_fixture_data; diff --git a/test/core/end2end/invalid_call_argument_test.c b/test/core/end2end/invalid_call_argument_test.c index 58aeef18f7..1fd4c0145a 100644 --- a/test/core/end2end/invalid_call_argument_test.c +++ b/test/core/end2end/invalid_call_argument_test.c @@ -131,16 +131,15 @@ static void cleanup_test() { grpc_server_shutdown_and_notify(g_state.server, g_state.cq, tag(1000)); GPR_ASSERT(grpc_completion_queue_pluck(g_state.cq, tag(1000), GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5), - NULL) - .type == GRPC_OP_COMPLETE); + NULL).type == GRPC_OP_COMPLETE); grpc_server_destroy(g_state.server); grpc_call_details_destroy(&g_state.call_details); grpc_metadata_array_destroy(&g_state.server_initial_metadata_recv); } grpc_completion_queue_shutdown(g_state.cq); while (grpc_completion_queue_next(g_state.cq, - gpr_inf_future(GPR_CLOCK_REALTIME), NULL) - .type != GRPC_QUEUE_SHUTDOWN) + gpr_inf_future(GPR_CLOCK_REALTIME), + NULL).type != GRPC_QUEUE_SHUTDOWN) ; grpc_completion_queue_destroy(g_state.cq); } @@ -300,9 +299,9 @@ static void test_receive_initial_metadata_twice_at_client() { op->flags = 0; op->reserved = NULL; op++; - GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS == grpc_call_start_batch(g_state.call, g_state.ops, - (size_t)(op - g_state.ops), - tag(1), NULL)); + GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS == + grpc_call_start_batch(g_state.call, g_state.ops, + (size_t)(op - g_state.ops), tag(1), NULL)); cleanup_test(); } @@ -316,9 +315,9 @@ static void test_receive_message_with_invalid_flags() { op->flags = 1; op->reserved = NULL; op++; - GPR_ASSERT(GRPC_CALL_ERROR_INVALID_FLAGS == grpc_call_start_batch(g_state.call, g_state.ops, - (size_t)(op - g_state.ops), - tag(1), NULL)); + GPR_ASSERT(GRPC_CALL_ERROR_INVALID_FLAGS == + grpc_call_start_batch(g_state.call, g_state.ops, + (size_t)(op - g_state.ops), tag(1), NULL)); cleanup_test(); } @@ -337,9 +336,9 @@ static void test_receive_two_messages_at_the_same_time() { op->flags = 0; op->reserved = NULL; op++; - GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS == grpc_call_start_batch(g_state.call, g_state.ops, - (size_t)(op - g_state.ops), - tag(1), NULL)); + GPR_ASSERT(GRPC_CALL_ERROR_TOO_MANY_OPERATIONS == + grpc_call_start_batch(g_state.call, g_state.ops, + (size_t)(op - g_state.ops), tag(1), NULL)); cleanup_test(); } diff --git a/test/core/iomgr/sockaddr_utils_test.c b/test/core/iomgr/sockaddr_utils_test.c index 2596095bc9..5cf0994f39 100644 --- a/test/core/iomgr/sockaddr_utils_test.c +++ b/test/core/iomgr/sockaddr_utils_test.c @@ -244,14 +244,14 @@ static void test_sockaddr_set_get_port(void) { gpr_log(GPR_DEBUG, "test_sockaddr_set_get_port"); input4 = make_addr4(kIPv4, sizeof(kIPv4)); - GPR_ASSERT(grpc_sockaddr_get_port((struct sockaddr*)&input4) == 12345); - GPR_ASSERT(grpc_sockaddr_set_port((struct sockaddr*)&input4, 54321)); - GPR_ASSERT(grpc_sockaddr_get_port((struct sockaddr*)&input4) == 54321); + GPR_ASSERT(grpc_sockaddr_get_port((struct sockaddr *)&input4) == 12345); + GPR_ASSERT(grpc_sockaddr_set_port((struct sockaddr *)&input4, 54321)); + GPR_ASSERT(grpc_sockaddr_get_port((struct sockaddr *)&input4) == 54321); input6 = make_addr6(kIPv6, sizeof(kIPv6)); - GPR_ASSERT(grpc_sockaddr_get_port((struct sockaddr*)&input6) == 12345); - GPR_ASSERT(grpc_sockaddr_set_port((struct sockaddr*)&input6, 54321)); - GPR_ASSERT(grpc_sockaddr_get_port((struct sockaddr*)&input6) == 54321); + GPR_ASSERT(grpc_sockaddr_get_port((struct sockaddr *)&input6) == 12345); + GPR_ASSERT(grpc_sockaddr_set_port((struct sockaddr *)&input6, 54321)); + GPR_ASSERT(grpc_sockaddr_get_port((struct sockaddr *)&input6) == 54321); memset(&dummy, 0, sizeof(dummy)); dummy.sa_family = 123; diff --git a/test/core/json/json_stream_error_test.c b/test/core/json/json_stream_error_test.c index bac825dde2..3464eb2a9c 100644 --- a/test/core/json/json_stream_error_test.c +++ b/test/core/json/json_stream_error_test.c @@ -54,9 +54,8 @@ static gpr_uint32 read_char(void *userdata) { } static grpc_json_reader_vtable reader_vtable = { - string_clear, NULL, NULL, read_char, NULL, NULL, - NULL, NULL, NULL, NULL, NULL, NULL -}; + string_clear, NULL, NULL, read_char, NULL, NULL, + NULL, NULL, NULL, NULL, NULL, NULL}; static void read_error() { grpc_json_reader reader; diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.c index d3cdb07958..a32ddd2ec7 100644 --- a/test/core/security/credentials_test.c +++ b/test/core/security/credentials_test.c @@ -910,9 +910,7 @@ static int default_creds_gce_detection_httpcli_get_success_override( return 1; } -static char *null_well_known_creds_path_getter(void) { - return NULL; -} +static char *null_well_known_creds_path_getter(void) { return NULL; } static void test_google_default_creds_gce(void) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; diff --git a/test/core/support/alloc_test.c b/test/core/support/alloc_test.c index 289b2b0c87..b950f0ab49 100644 --- a/test/core/support/alloc_test.c +++ b/test/core/support/alloc_test.c @@ -35,17 +35,11 @@ #include <grpc/support/alloc.h> #include "test/core/util/test_config.h" -static void *fake_malloc(size_t size) { - return (void*)size; -} +static void *fake_malloc(size_t size) { return (void *)size; } -static void *fake_realloc(void *addr, size_t size) { - return (void*)size; -} +static void *fake_realloc(void *addr, size_t size) { return (void *)size; } -static void fake_free(void *addr) { - *((gpr_intptr*)addr) = 0xdeadd00d; -} +static void fake_free(void *addr) { *((gpr_intptr *)addr) = 0xdeadd00d; } static void test_custom_allocs() { const gpr_allocation_functions default_fns = gpr_get_allocation_functions(); @@ -54,16 +48,16 @@ static void test_custom_allocs() { gpr_allocation_functions fns = {fake_malloc, fake_realloc, fake_free}; gpr_set_allocation_functions(fns); - GPR_ASSERT((void*)0xdeadbeef == gpr_malloc(0xdeadbeef)); - GPR_ASSERT((void*)0xcafed00d == gpr_realloc(0, 0xcafed00d)); + GPR_ASSERT((void *)0xdeadbeef == gpr_malloc(0xdeadbeef)); + GPR_ASSERT((void *)0xcafed00d == gpr_realloc(0, 0xcafed00d)); gpr_free(&addr_to_free); GPR_ASSERT(addr_to_free == 0xdeadd00d); /* Restore and check we don't get funky values and that we don't leak */ gpr_set_allocation_functions(default_fns); - GPR_ASSERT((void*)1 != (i = gpr_malloc(sizeof(*i)))); - GPR_ASSERT((void*)2 != (i = gpr_realloc(i, 2))); + GPR_ASSERT((void *)1 != (i = gpr_malloc(sizeof(*i)))); + GPR_ASSERT((void *)2 != (i = gpr_realloc(i, 2))); gpr_free(i); } diff --git a/test/core/support/sync_test.c b/test/core/support/sync_test.c index e538af93f2..73f68e4dbd 100644 --- a/test/core/support/sync_test.c +++ b/test/core/support/sync_test.c @@ -430,7 +430,6 @@ static void refinc(void *v /*=m*/) { mark_thread_done(m); } - /* Wait until m->event is set to (void *)1, then decrement m->refcount by 1 (m->threads * m->iterations * m->incr_step) times, and ensure that the last decrement caused the counter to reach zero, then mark thread as done. */ diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.c index 1b1955fa0e..35b0212fcf 100644 --- a/test/core/surface/lame_client_test.c +++ b/test/core/surface/lame_client_test.c @@ -48,12 +48,12 @@ grpc_closure transport_op_cb; static void *tag(gpr_intptr x) { return (void *)x; } void verify_connectivity(grpc_exec_ctx *exec_ctx, void *arg, int success) { - grpc_transport_op* op = arg; + grpc_transport_op *op = arg; GPR_ASSERT(GRPC_CHANNEL_FATAL_FAILURE == *op->connectivity_state); GPR_ASSERT(success); } -void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, int success) { } +void do_nothing(grpc_exec_ctx *exec_ctx, void *arg, int success) {} void test_transport_op(grpc_channel *channel) { grpc_transport_op op; diff --git a/test/core/transport/chttp2/varint_test.c b/test/core/transport/chttp2/varint_test.c index e5c5d9a35e..31fcb7e182 100644 --- a/test/core/transport/chttp2/varint_test.c +++ b/test/core/transport/chttp2/varint_test.c @@ -47,14 +47,15 @@ static void test_varint(gpr_uint32 value, gpr_uint32 prefix_bits, gpr_log(GPR_DEBUG, "Test: 0x%08x", value); GPR_ASSERT(nbytes == expect_length); slice = gpr_slice_malloc(nbytes); - GRPC_CHTTP2_WRITE_VARINT(value, prefix_bits, prefix_or, GPR_SLICE_START_PTR(slice), nbytes); + GRPC_CHTTP2_WRITE_VARINT(value, prefix_bits, prefix_or, + GPR_SLICE_START_PTR(slice), nbytes); GPR_ASSERT(gpr_slice_cmp(expect, slice) == 0); gpr_slice_unref(expect); gpr_slice_unref(slice); } #define TEST_VARINT(value, prefix_bits, prefix_or, expect) \ - test_varint(value, prefix_bits, prefix_or, expect, sizeof(expect)-1) + test_varint(value, prefix_bits, prefix_or, expect, sizeof(expect) - 1) int main(int argc, char **argv) { grpc_test_init(argc, argv); diff --git a/test/core/transport/connectivity_state_test.c b/test/core/transport/connectivity_state_test.c index 6cb7937ebe..1f23221812 100644 --- a/test/core/transport/connectivity_state_test.c +++ b/test/core/transport/connectivity_state_test.c @@ -39,96 +39,107 @@ #include "test/core/util/test_config.h" -#define THE_ARG ((void*)0xcafebabe) +#define THE_ARG ((void *)0xcafebabe) int g_counter; static void must_succeed(grpc_exec_ctx *exec_ctx, void *arg, int success) { - GPR_ASSERT(success); - GPR_ASSERT(arg == THE_ARG); - g_counter++; + GPR_ASSERT(success); + GPR_ASSERT(arg == THE_ARG); + g_counter++; } static void must_fail(grpc_exec_ctx *exec_ctx, void *arg, int success) { - GPR_ASSERT(!success); - GPR_ASSERT(arg == THE_ARG); - g_counter++; + GPR_ASSERT(!success); + GPR_ASSERT(arg == THE_ARG); + g_counter++; } static void test_connectivity_state_name(void) { - gpr_log(GPR_DEBUG, "test_connectivity_state_name"); - GPR_ASSERT(0 == strcmp(grpc_connectivity_state_name(GRPC_CHANNEL_IDLE), "IDLE")); - GPR_ASSERT(0 == strcmp(grpc_connectivity_state_name(GRPC_CHANNEL_CONNECTING), "CONNECTING")); - GPR_ASSERT(0 == strcmp(grpc_connectivity_state_name(GRPC_CHANNEL_READY), "READY")); - GPR_ASSERT(0 == strcmp(grpc_connectivity_state_name(GRPC_CHANNEL_TRANSIENT_FAILURE), "TRANSIENT_FAILURE")); - GPR_ASSERT(0 == strcmp(grpc_connectivity_state_name(GRPC_CHANNEL_FATAL_FAILURE), "FATAL_FAILURE")); + gpr_log(GPR_DEBUG, "test_connectivity_state_name"); + GPR_ASSERT(0 == + strcmp(grpc_connectivity_state_name(GRPC_CHANNEL_IDLE), "IDLE")); + GPR_ASSERT(0 == strcmp(grpc_connectivity_state_name(GRPC_CHANNEL_CONNECTING), + "CONNECTING")); + GPR_ASSERT(0 == + strcmp(grpc_connectivity_state_name(GRPC_CHANNEL_READY), "READY")); + GPR_ASSERT( + 0 == strcmp(grpc_connectivity_state_name(GRPC_CHANNEL_TRANSIENT_FAILURE), + "TRANSIENT_FAILURE")); + GPR_ASSERT(0 == + strcmp(grpc_connectivity_state_name(GRPC_CHANNEL_FATAL_FAILURE), + "FATAL_FAILURE")); } static void test_check(void) { - grpc_connectivity_state_tracker tracker; - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - gpr_log(GPR_DEBUG, "test_check"); - grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx"); - GPR_ASSERT(grpc_connectivity_state_check(&tracker) == GRPC_CHANNEL_IDLE); - grpc_connectivity_state_destroy(&exec_ctx, &tracker); - grpc_exec_ctx_finish(&exec_ctx); + grpc_connectivity_state_tracker tracker; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + gpr_log(GPR_DEBUG, "test_check"); + grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx"); + GPR_ASSERT(grpc_connectivity_state_check(&tracker) == GRPC_CHANNEL_IDLE); + grpc_connectivity_state_destroy(&exec_ctx, &tracker); + grpc_exec_ctx_finish(&exec_ctx); } static void test_subscribe_then_unsubscribe(void) { - grpc_connectivity_state_tracker tracker; - grpc_closure *closure = grpc_closure_create(must_fail, THE_ARG); - grpc_connectivity_state state = GRPC_CHANNEL_IDLE; - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - gpr_log(GPR_DEBUG, "test_subscribe_then_unsubscribe"); - g_counter = 0; - grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx"); - GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker, &state, closure)); - grpc_exec_ctx_flush(&exec_ctx); - GPR_ASSERT(state == GRPC_CHANNEL_IDLE); - GPR_ASSERT(g_counter == 0); - grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker, NULL, closure); - grpc_exec_ctx_flush(&exec_ctx); - GPR_ASSERT(state == GRPC_CHANNEL_IDLE); - GPR_ASSERT(g_counter == 1); + grpc_connectivity_state_tracker tracker; + grpc_closure *closure = grpc_closure_create(must_fail, THE_ARG); + grpc_connectivity_state state = GRPC_CHANNEL_IDLE; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + gpr_log(GPR_DEBUG, "test_subscribe_then_unsubscribe"); + g_counter = 0; + grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx"); + GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker, + &state, closure)); + grpc_exec_ctx_flush(&exec_ctx); + GPR_ASSERT(state == GRPC_CHANNEL_IDLE); + GPR_ASSERT(g_counter == 0); + grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker, NULL, + closure); + grpc_exec_ctx_flush(&exec_ctx); + GPR_ASSERT(state == GRPC_CHANNEL_IDLE); + GPR_ASSERT(g_counter == 1); - grpc_connectivity_state_destroy(&exec_ctx, &tracker); - grpc_exec_ctx_finish(&exec_ctx); + grpc_connectivity_state_destroy(&exec_ctx, &tracker); + grpc_exec_ctx_finish(&exec_ctx); } static void test_subscribe_then_destroy(void) { - grpc_connectivity_state_tracker tracker; - grpc_closure *closure = grpc_closure_create(must_succeed, THE_ARG); - grpc_connectivity_state state = GRPC_CHANNEL_IDLE; - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - gpr_log(GPR_DEBUG, "test_subscribe_then_destroy"); - g_counter = 0; - grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx"); - GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker, &state, closure)); - grpc_exec_ctx_flush(&exec_ctx); - GPR_ASSERT(state == GRPC_CHANNEL_IDLE); - GPR_ASSERT(g_counter == 0); - grpc_connectivity_state_destroy(&exec_ctx, &tracker); - grpc_exec_ctx_finish(&exec_ctx); - GPR_ASSERT(state == GRPC_CHANNEL_FATAL_FAILURE); - GPR_ASSERT(g_counter == 1); + grpc_connectivity_state_tracker tracker; + grpc_closure *closure = grpc_closure_create(must_succeed, THE_ARG); + grpc_connectivity_state state = GRPC_CHANNEL_IDLE; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + gpr_log(GPR_DEBUG, "test_subscribe_then_destroy"); + g_counter = 0; + grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_IDLE, "xxx"); + GPR_ASSERT(grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker, + &state, closure)); + grpc_exec_ctx_flush(&exec_ctx); + GPR_ASSERT(state == GRPC_CHANNEL_IDLE); + GPR_ASSERT(g_counter == 0); + grpc_connectivity_state_destroy(&exec_ctx, &tracker); + grpc_exec_ctx_finish(&exec_ctx); + GPR_ASSERT(state == GRPC_CHANNEL_FATAL_FAILURE); + GPR_ASSERT(g_counter == 1); } static void test_subscribe_with_failure_then_destroy(void) { - grpc_connectivity_state_tracker tracker; - grpc_closure *closure = grpc_closure_create(must_fail, THE_ARG); - grpc_connectivity_state state = GRPC_CHANNEL_FATAL_FAILURE; - grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; - gpr_log(GPR_DEBUG, "test_subscribe_with_failure_then_destroy"); - g_counter = 0; - grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_FATAL_FAILURE, "xxx"); - GPR_ASSERT(0 == grpc_connectivity_state_notify_on_state_change(&exec_ctx, &tracker, &state, closure)); - grpc_exec_ctx_flush(&exec_ctx); - GPR_ASSERT(state == GRPC_CHANNEL_FATAL_FAILURE); - GPR_ASSERT(g_counter == 0); - grpc_connectivity_state_destroy(&exec_ctx, &tracker); - grpc_exec_ctx_finish(&exec_ctx); - GPR_ASSERT(state == GRPC_CHANNEL_FATAL_FAILURE); - GPR_ASSERT(g_counter == 1); + grpc_connectivity_state_tracker tracker; + grpc_closure *closure = grpc_closure_create(must_fail, THE_ARG); + grpc_connectivity_state state = GRPC_CHANNEL_FATAL_FAILURE; + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + gpr_log(GPR_DEBUG, "test_subscribe_with_failure_then_destroy"); + g_counter = 0; + grpc_connectivity_state_init(&tracker, GRPC_CHANNEL_FATAL_FAILURE, "xxx"); + GPR_ASSERT(0 == grpc_connectivity_state_notify_on_state_change( + &exec_ctx, &tracker, &state, closure)); + grpc_exec_ctx_flush(&exec_ctx); + GPR_ASSERT(state == GRPC_CHANNEL_FATAL_FAILURE); + GPR_ASSERT(g_counter == 0); + grpc_connectivity_state_destroy(&exec_ctx, &tracker); + grpc_exec_ctx_finish(&exec_ctx); + GPR_ASSERT(state == GRPC_CHANNEL_FATAL_FAILURE); + GPR_ASSERT(g_counter == 1); } int main(int argc, char **argv) { diff --git a/test/cpp/end2end/async_end2end_test.cc b/test/cpp/end2end/async_end2end_test.cc index 364aa417cd..279423a8cb 100644 --- a/test/cpp/end2end/async_end2end_test.cc +++ b/test/cpp/end2end/async_end2end_test.cc @@ -184,7 +184,7 @@ class AsyncEnd2endTest : public ::testing::TestWithParam<bool> { // in the same server, so first test that (for coverage) ServerBuilder build_bad; build_bad.AddListeningPort(server_address_.str(), - grpc::InsecureServerCredentials()); + grpc::InsecureServerCredentials()); build_bad.RegisterAsyncService(&service_); grpc::cpp::test::util::TestService::Service sync_service; build_bad.RegisterService(&sync_service); |