From 6d686451627122eeb5a07da2ede2cebc1c289acd Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 19 Sep 2016 16:48:36 -0700 Subject: Update unit tests and fixtures with AUTHORITY_HEADER support option --- test/core/end2end/tests/call_creds.c | 11 ++++++++--- test/core/end2end/tests/cancel_after_accept.c | 5 ++++- test/core/end2end/tests/cancel_after_client_done.c | 5 ++++- test/core/end2end/tests/cancel_after_invoke.c | 5 ++++- test/core/end2end/tests/cancel_before_invoke.c | 5 ++++- test/core/end2end/tests/cancel_in_a_vacuum.c | 5 ++++- test/core/end2end/tests/cancel_with_status.c | 5 ++++- test/core/end2end/tests/compressed_payload.c | 15 +++++++++++---- test/core/end2end/tests/disappearing_server.c | 9 +++++++-- test/core/end2end/tests/empty_batch.c | 5 ++++- test/core/end2end/tests/filter_call_init_fails.c | 5 ++++- test/core/end2end/tests/filter_causes_close.c | 5 ++++- test/core/end2end/tests/graceful_server_shutdown.c | 9 +++++++-- test/core/end2end/tests/high_initial_seqno.c | 9 +++++++-- test/core/end2end/tests/hpack_size.c | 9 +++++++-- test/core/end2end/tests/idempotent_request.c | 9 +++++++-- test/core/end2end/tests/invoke_large_request.c | 9 +++++++-- test/core/end2end/tests/large_metadata.c | 9 +++++++-- test/core/end2end/tests/load_reporting_hook.c | 5 ++++- test/core/end2end/tests/max_concurrent_streams.c | 13 +++++++++---- test/core/end2end/tests/max_message_length.c | 9 +++++++-- test/core/end2end/tests/negative_deadline.c | 5 ++++- test/core/end2end/tests/network_status_change.c | 9 +++++++-- test/core/end2end/tests/no_logging.c | 9 +++++++-- test/core/end2end/tests/payload.c | 9 +++++++-- test/core/end2end/tests/ping_pong_streaming.c | 5 ++++- test/core/end2end/tests/registered_call.c | 11 ++++++++--- test/core/end2end/tests/request_with_flags.c | 5 ++++- test/core/end2end/tests/request_with_payload.c | 9 +++++++-- test/core/end2end/tests/server_finishes_request.c | 9 +++++++-- test/core/end2end/tests/shutdown_finishes_calls.c | 9 +++++++-- test/core/end2end/tests/simple_cacheable_request.c | 9 +++++++-- test/core/end2end/tests/simple_delayed_request.c | 9 +++++++-- test/core/end2end/tests/simple_metadata.c | 9 +++++++-- test/core/end2end/tests/simple_request.c | 10 +++++++--- test/core/end2end/tests/streaming_error_response.c | 9 +++++++-- test/core/end2end/tests/trailing_metadata.c | 9 +++++++-- 37 files changed, 228 insertions(+), 68 deletions(-) (limited to 'test/core/end2end/tests') diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index 981c0fcc8c..ab8efa488b 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -51,6 +51,8 @@ static const char iam_selector[] = "selector"; static const char overridden_iam_token[] = "overridden_token"; static const char overridden_iam_selector[] = "overridden_selector"; +static char *authority; + typedef enum { NONE, OVERRIDE, DESTROY } override_mode; static void *tag(intptr_t t) { return (void *)t; } @@ -165,7 +167,7 @@ static void request_response_with_payload_and_call_creds( cqv = cq_verifier_create(f.cq); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); creds = grpc_google_iam_credentials_create(iam_token, iam_selector, NULL); GPR_ASSERT(creds != NULL); @@ -294,7 +296,9 @@ static void request_response_with_payload_and_call_creds( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); @@ -398,7 +402,7 @@ static void test_request_with_server_rejecting_client_creds( cqv = cq_verifier_create(f.cq); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); creds = grpc_google_iam_credentials_create(iam_token, iam_selector, NULL); @@ -471,6 +475,7 @@ static void test_request_with_server_rejecting_client_creds( void call_creds(grpc_end2end_test_config config) { if (config.feature_mask & FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS) { + authority = validate_host_override_string("foo.test.google.fr", config); test_request_response_with_payload_and_call_creds(config); test_request_response_with_payload_and_overridden_call_creds(config); test_request_response_with_payload_and_deleted_call_creds(config); diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index b4ac3b3249..dd1d5bcf46 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -44,6 +44,8 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" +static void *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -126,7 +128,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -229,6 +231,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, void cancel_after_accept(grpc_end2end_test_config config) { unsigned i; + authority = validate_host_override_string("foo.test.google.fr", config); for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { test_cancel_after_accept(config, cancellation_modes[i]); } diff --git a/test/core/end2end/tests/cancel_after_client_done.c b/test/core/end2end/tests/cancel_after_client_done.c index 5adc71e255..90a84d1d0f 100644 --- a/test/core/end2end/tests/cancel_after_client_done.c +++ b/test/core/end2end/tests/cancel_after_client_done.c @@ -44,6 +44,8 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -126,7 +128,7 @@ static void test_cancel_after_accept_and_writes_closed( int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -233,6 +235,7 @@ static void test_cancel_after_accept_and_writes_closed( void cancel_after_client_done(grpc_end2end_test_config config) { unsigned i; + authority = validate_host_override_string("foo.test.google.fr", config); for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { test_cancel_after_accept_and_writes_closed(config, cancellation_modes[i]); } diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index 85d8799f36..346e41edae 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -44,6 +44,8 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -121,7 +123,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, grpc_raw_byte_buffer_create(&request_payload_slice, 1); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -192,6 +194,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, void cancel_after_invoke(grpc_end2end_test_config config) { unsigned i, j; + authority = validate_host_override_string("foo.test.google.fr", config); for (j = 2; j < 6; j++) { for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { test_cancel_after_invoke(config, cancellation_modes[i], j); diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c index c57091476e..b446264f9d 100644 --- a/test/core/end2end/tests/cancel_before_invoke.c +++ b/test/core/end2end/tests/cancel_before_invoke.c @@ -43,6 +43,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -119,7 +121,7 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, grpc_raw_byte_buffer_create(&request_payload_slice, 1); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); GPR_ASSERT(GRPC_CALL_OK == grpc_call_cancel(c, NULL)); @@ -189,6 +191,7 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, void cancel_before_invoke(grpc_end2end_test_config config) { size_t i; + authority = validate_host_override_string("foo.test.google.fr", config); for (i = 1; i <= 6; i++) { test_cancel_before_invoke(config, i); } diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.c b/test/core/end2end/tests/cancel_in_a_vacuum.c index 3b03616b3b..02e5fa555d 100644 --- a/test/core/end2end/tests/cancel_in_a_vacuum.c +++ b/test/core/end2end/tests/cancel_in_a_vacuum.c @@ -44,6 +44,8 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -106,7 +108,7 @@ static void test_cancel_in_a_vacuum(grpc_end2end_test_config config, cq_verifier *v_client = cq_verifier_create(f.cq); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL)); @@ -121,6 +123,7 @@ static void test_cancel_in_a_vacuum(grpc_end2end_test_config config, void cancel_in_a_vacuum(grpc_end2end_test_config config) { unsigned i; + authority = validate_host_override_string("foo.test.google.fr", config); for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { test_cancel_in_a_vacuum(config, cancellation_modes[i]); } diff --git a/test/core/end2end/tests/cancel_with_status.c b/test/core/end2end/tests/cancel_with_status.c index e65390ac4a..b2da1099eb 100644 --- a/test/core/end2end/tests/cancel_with_status.c +++ b/test/core/end2end/tests/cancel_with_status.c @@ -45,6 +45,8 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -113,7 +115,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) { gpr_log(GPR_DEBUG, "test with %" PRIuPTR " ops", num_ops); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr:1234", deadline, + "/foo", authority, deadline, NULL); GPR_ASSERT(c); @@ -177,6 +179,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config, void cancel_with_status(grpc_end2end_test_config config) { size_t i; + authority = validate_host_override_string("foo.test.google.fr:1234", config); for (i = 1; i <= 4; i++) { test_invoke_simple_request(config, i); } diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index 1724da4d0c..7a9d9a706b 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -50,6 +50,8 @@ #include "src/core/lib/surface/call_test_only.h" #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -147,7 +149,7 @@ static void request_for_disabled_algorithm( cqv = cq_verifier_create(f.cq); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -242,7 +244,9 @@ static void request_for_disabled_algorithm( GPR_ASSERT(0 == strcmp(details, expected_details)); gpr_free(expected_details); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } gpr_free(details); grpc_metadata_array_destroy(&initial_metadata_recv); @@ -319,7 +323,7 @@ static void request_with_payload_template( cqv = cq_verifier_create(f.cq); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -491,7 +495,9 @@ static void request_with_payload_template( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 0); gpr_free(details); @@ -594,6 +600,7 @@ static void test_invoke_request_with_disabled_algorithm( } void compressed_payload(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); test_invoke_request_with_exceptionally_uncompressed_payload(config); test_invoke_request_with_uncompressed_payload(config); test_invoke_request_with_compressed_payload(config); diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c index a0059b9ad5..e761aa7d19 100644 --- a/test/core/end2end/tests/disappearing_server.c +++ b/test/core/end2end/tests/disappearing_server.c @@ -43,6 +43,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static gpr_timespec n_seconds_time(int n) { @@ -97,7 +99,7 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f, int was_cancelled = 2; c = grpc_channel_create_call(f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, - "/foo", "foo.test.google.fr:1234", deadline, + "/foo", authority, deadline, NULL); GPR_ASSERT(c); @@ -174,7 +176,9 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f, GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 1); gpr_free(details); @@ -210,6 +214,7 @@ static void disappearing_server_test(grpc_end2end_test_config config) { } void disappearing_server(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr:1234", config); GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); disappearing_server_test(config); } diff --git a/test/core/end2end/tests/empty_batch.c b/test/core/end2end/tests/empty_batch.c index ac53e1839b..230ee204f8 100644 --- a/test/core/end2end/tests/empty_batch.c +++ b/test/core/end2end/tests/empty_batch.c @@ -45,6 +45,8 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -105,7 +107,7 @@ static void empty_batch_body(grpc_end2end_test_fixture f) { grpc_op *op = NULL; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); error = grpc_call_start_batch(c, op, 0, tag(1), NULL); @@ -128,6 +130,7 @@ static void test_invoke_empty_body(grpc_end2end_test_config config) { } void empty_batch(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); test_invoke_empty_body(config); } diff --git a/test/core/end2end/tests/filter_call_init_fails.c b/test/core/end2end/tests/filter_call_init_fails.c index a70f50af98..6569110c67 100644 --- a/test/core/end2end/tests/filter_call_init_fails.c +++ b/test/core/end2end/tests/filter_call_init_fails.c @@ -49,6 +49,8 @@ enum { TIMEOUT = 200000 }; +static char *authority; + static bool g_enable_filter = false; static void *tag(intptr_t t) { return (void *)t; } @@ -128,7 +130,7 @@ static void test_request(grpc_end2end_test_config config) { size_t details_capacity = 0; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -263,6 +265,7 @@ static void init_plugin(void) { static void destroy_plugin(void) {} void filter_call_init_fails(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); g_enable_filter = true; test_request(config); g_enable_filter = false; diff --git a/test/core/end2end/tests/filter_causes_close.c b/test/core/end2end/tests/filter_causes_close.c index cdf868377a..c8a94c440c 100644 --- a/test/core/end2end/tests/filter_causes_close.c +++ b/test/core/end2end/tests/filter_causes_close.c @@ -46,6 +46,8 @@ #include "src/core/lib/surface/channel_init.h" #include "test/core/end2end/cq_verifier.h" +static char *authority; + static bool g_enable_filter = false; static void *tag(intptr_t t) { return (void *)t; } @@ -124,7 +126,7 @@ static void test_request(grpc_end2end_test_config config) { size_t details_capacity = 0; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -282,6 +284,7 @@ static void init_plugin(void) { static void destroy_plugin(void) {} void filter_causes_close(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); g_enable_filter = true; test_request(config); g_enable_filter = false; diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c index 29347a068a..4c5ecb9f5c 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.c +++ b/test/core/end2end/tests/graceful_server_shutdown.c @@ -43,6 +43,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -112,7 +114,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -190,7 +192,9 @@ static void test_early_server_shutdown_finishes_inflight_calls( GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 1); gpr_free(details); @@ -208,6 +212,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( } void graceful_server_shutdown(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); test_early_server_shutdown_finishes_inflight_calls(config); } diff --git a/test/core/end2end/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.c index dab527005c..dbd99e8feb 100644 --- a/test/core/end2end/tests/high_initial_seqno.c +++ b/test/core/end2end/tests/high_initial_seqno.c @@ -47,6 +47,8 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -117,7 +119,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr:1234", deadline, + "/foo", authority, deadline, NULL); GPR_ASSERT(c); @@ -189,7 +191,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) { GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 1); gpr_free(details); @@ -238,6 +242,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config, } void high_initial_seqno(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr:1234", config); test_invoke_10_simple_requests(config, 16777213); if (config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION) { test_invoke_10_simple_requests(config, 2147483645); diff --git a/test/core/end2end/tests/hpack_size.c b/test/core/end2end/tests/hpack_size.c index fb00ae4eaa..c207639f7b 100644 --- a/test/core/end2end/tests/hpack_size.c +++ b/test/core/end2end/tests/hpack_size.c @@ -47,6 +47,8 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } const char *hobbits[][2] = { @@ -269,7 +271,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t index) { extra_metadata[2].value_length = strlen(extra_metadata[2].value); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr:1234", deadline, + "/foo", authority, deadline, NULL); GPR_ASSERT(c); @@ -342,7 +344,9 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t index) { GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 1); gpr_free(details); @@ -395,6 +399,7 @@ void hpack_size(grpc_end2end_test_config config) { 1000, 32768, 4 * 1024 * 1024}; size_t i, j; + authority = validate_host_override_string("foo.test.google.fr:1234", config); for (i = 0; i < GPR_ARRAY_SIZE(interesting_sizes); i++) { for (j = 0; j < GPR_ARRAY_SIZE(interesting_sizes); j++) { test_size(config, interesting_sizes[i], interesting_sizes[j]); diff --git a/test/core/end2end/tests/idempotent_request.c b/test/core/end2end/tests/idempotent_request.c index 65f6dd08c5..700cb21207 100644 --- a/test/core/end2end/tests/idempotent_request.c +++ b/test/core/end2end/tests/idempotent_request.c @@ -45,6 +45,8 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -116,7 +118,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { char *peer; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr:1234", deadline, + "/foo", authority, deadline, NULL); GPR_ASSERT(c); @@ -202,7 +204,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) { GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST == call_details.flags); GPR_ASSERT(was_cancelled == 1); @@ -241,6 +245,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { void idempotent_request(grpc_end2end_test_config config) { int i; + authority = validate_host_override_string("foo.test.google.fr:1234", config); for (i = 0; i < 10; i++) { test_invoke_simple_request(config); } diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index 1df237cb6c..b807c94564 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -44,6 +44,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -145,7 +147,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config, int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -244,7 +246,9 @@ static void test_invoke_large_request(grpc_end2end_test_config config, GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 1); gpr_free(details); @@ -270,6 +274,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config, } void invoke_large_request(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); test_invoke_large_request(config, 16384, 65536); test_invoke_large_request(config, 32768, 65536); diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c index eb174a2dbb..c0819d090a 100644 --- a/test/core/end2end/tests/large_metadata.c +++ b/test/core/end2end/tests/large_metadata.c @@ -43,6 +43,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -126,7 +128,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); meta.key = "key"; @@ -227,7 +229,9 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); GPR_ASSERT(contains_metadata(&request_metadata_recv, "key", meta.value)); @@ -253,6 +257,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { } void large_metadata(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); test_request_with_large_metadata(config); } diff --git a/test/core/end2end/tests/load_reporting_hook.c b/test/core/end2end/tests/load_reporting_hook.c index 59d054cf87..62d0dad936 100644 --- a/test/core/end2end/tests/load_reporting_hook.c +++ b/test/core/end2end/tests/load_reporting_hook.c @@ -48,6 +48,8 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/transport/static_metadata.h" +static char *authority; + enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } @@ -152,7 +154,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f, int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - method_name, "foo.test.google.fr", deadline, + method_name, authority, deadline, NULL); GPR_ASSERT(c); @@ -315,6 +317,7 @@ static void test_load_reporting_hook(grpc_end2end_test_config config) { } void load_reporting_hook(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); test_load_reporting_hook(config); } diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index 65fa946838..925f45d42a 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -43,6 +43,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -113,7 +115,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr:1234", deadline, + "/foo", authority, deadline, NULL); GPR_ASSERT(c); @@ -185,7 +187,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) { GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 1); gpr_free(details); @@ -258,11 +262,11 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { the first completes */ deadline = n_seconds_time(1000); c1 = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/alpha", "foo.test.google.fr:1234", deadline, + "/alpha", authority, deadline, NULL); GPR_ASSERT(c1); c2 = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/beta", "foo.test.google.fr:1234", deadline, + "/beta", authority, deadline, NULL); GPR_ASSERT(c2); @@ -440,6 +444,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { } void max_concurrent_streams(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr:1234", config); test_max_concurrent_streams(config); } diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index cdca3e6748..6ce63bf0c6 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -43,6 +43,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -138,7 +140,7 @@ static void test_max_message_length(grpc_end2end_test_config config, cqv = cq_verifier_create(f.cq); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr:1234", + "/foo", authority, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(c); @@ -212,7 +214,9 @@ static void test_max_message_length(grpc_end2end_test_config config, cq_verify(cqv); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 1); done: @@ -240,6 +244,7 @@ done: } void max_message_length(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr:1234", config); test_max_message_length(config, true); test_max_message_length(config, false); } diff --git a/test/core/end2end/tests/negative_deadline.c b/test/core/end2end/tests/negative_deadline.c index c999ac116a..258d4a7168 100644 --- a/test/core/end2end/tests/negative_deadline.c +++ b/test/core/end2end/tests/negative_deadline.c @@ -45,6 +45,8 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -113,7 +115,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) { gpr_log(GPR_DEBUG, "test with %" PRIuPTR " ops", num_ops); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr:1234", deadline, + "/foo", authority, deadline, NULL); GPR_ASSERT(c); @@ -174,6 +176,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config, void negative_deadline(grpc_end2end_test_config config) { size_t i; + authority = validate_host_override_string("foo.test.google.fr:1234", config); for (i = 1; i <= 4; i++) { test_invoke_simple_request(config, i); } diff --git a/test/core/end2end/tests/network_status_change.c b/test/core/end2end/tests/network_status_change.c index 1d4b6dbb18..7bf003cb4a 100644 --- a/test/core/end2end/tests/network_status_change.c +++ b/test/core/end2end/tests/network_status_change.c @@ -43,6 +43,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + /* this is a private API but exposed here for testing*/ extern void grpc_network_status_shutdown_all_endpoints(); @@ -123,7 +125,7 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -212,7 +214,9 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) { // Expected behavior of a RPC when network is lost. GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 0); gpr_free(details); @@ -234,6 +238,7 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) { } void network_status_change(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); test_invoke_network_status_change(config); } diff --git a/test/core/end2end/tests/no_logging.c b/test/core/end2end/tests/no_logging.c index 3c40e5dbac..42fe5b70f7 100644 --- a/test/core/end2end/tests/no_logging.c +++ b/test/core/end2end/tests/no_logging.c @@ -47,6 +47,8 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" +static char *authority; + enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } @@ -137,7 +139,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { char *peer; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr:1234", deadline, + "/foo", authority, deadline, NULL); GPR_ASSERT(c); @@ -220,7 +222,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) { GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(0 == call_details.flags); GPR_ASSERT(was_cancelled == 1); @@ -286,6 +290,7 @@ static void test_no_logging_in_one_request(grpc_end2end_test_config config) { } void no_logging(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr:1234", config); test_no_logging_in_one_request(config); test_no_error_logging_in_entire_process(config); } diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c index c71704ff61..292a92eeb8 100644 --- a/test/core/end2end/tests/payload.c +++ b/test/core/end2end/tests/payload.c @@ -43,6 +43,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -121,7 +123,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -220,7 +222,9 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) { GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); @@ -266,6 +270,7 @@ static void test_invoke_10_request_response_with_payload( } void payload(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); test_invoke_request_response_with_payload(config); test_invoke_10_request_response_with_payload(config); } diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index 7e360c415b..372766f470 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -43,6 +43,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -124,7 +126,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr:1234", deadline, + "/foo", authority, deadline, NULL); GPR_ASSERT(c); @@ -276,6 +278,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, void ping_pong_streaming(grpc_end2end_test_config config) { int i; + authority = validate_host_override_string("foo.test.google.fr:1234", config); for (i = 1; i < 10; i++) { test_pingpong_streaming(config, i); } diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c index 9b2b42b558..1bbae56a0f 100644 --- a/test/core/end2end/tests/registered_call.c +++ b/test/core/end2end/tests/registered_call.c @@ -45,6 +45,8 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -186,7 +188,9 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) { GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 1); gpr_free(details); @@ -205,7 +209,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) { grpc_end2end_test_fixture f = begin_test(config, "test_invoke_simple_request", NULL, NULL); void *rc = grpc_channel_register_call(f.client, "/foo", - "foo.test.google.fr:1234", NULL); + authority, NULL); simple_request_body(f, rc); end_test(&f); @@ -217,7 +221,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { grpc_end2end_test_fixture f = begin_test(config, "test_invoke_10_simple_requests", NULL, NULL); void *rc = grpc_channel_register_call(f.client, "/foo", - "foo.test.google.fr:1234", NULL); + authority, NULL); for (i = 0; i < 10; i++) { simple_request_body(f, rc); @@ -228,6 +232,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { } void registered_call(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr:1234", config); test_invoke_simple_request(config); test_invoke_10_simple_requests(config); } diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c index 25150e6f2d..623def9fd3 100644 --- a/test/core/end2end/tests/request_with_flags.c +++ b/test/core/end2end/tests/request_with_flags.c @@ -44,6 +44,8 @@ #include "src/core/lib/transport/byte_stream.h" #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -121,7 +123,7 @@ static void test_invoke_request_with_flags( grpc_call_error expectation; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -186,6 +188,7 @@ static void test_invoke_request_with_flags( void request_with_flags(grpc_end2end_test_config config) { size_t i; + authority = validate_host_override_string("foo.test.google.fr", config); uint32_t flags_for_op[GRPC_OP_RECV_CLOSE_ON_SERVER + 1]; { diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index 67208c050c..a0da85496d 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -43,6 +43,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -120,7 +122,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -208,7 +210,9 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); @@ -231,6 +235,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { } void request_with_payload(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); test_invoke_request_with_payload(config); } diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c index 7fb9025aa3..ca8bf9278b 100644 --- a/test/core/end2end/tests/server_finishes_request.c +++ b/test/core/end2end/tests/server_finishes_request.c @@ -45,6 +45,8 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -115,7 +117,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr:1234", deadline, + "/foo", authority, deadline, NULL); GPR_ASSERT(c); @@ -183,7 +185,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) { GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 1); gpr_free(details); @@ -208,6 +212,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) { } void server_finishes_request(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr:1234", config); test_invoke_simple_request(config); } diff --git a/test/core/end2end/tests/shutdown_finishes_calls.c b/test/core/end2end/tests/shutdown_finishes_calls.c index dff2e6f280..f08d0f2e10 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.c +++ b/test/core/end2end/tests/shutdown_finishes_calls.c @@ -43,6 +43,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -105,7 +107,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -171,7 +173,9 @@ static void test_early_server_shutdown_finishes_inflight_calls( GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 1); gpr_free(details); @@ -190,6 +194,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( } void shutdown_finishes_calls(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); test_early_server_shutdown_finishes_inflight_calls(config); } diff --git a/test/core/end2end/tests/simple_cacheable_request.c b/test/core/end2end/tests/simple_cacheable_request.c index b52eb19315..997177cd4a 100644 --- a/test/core/end2end/tests/simple_cacheable_request.c +++ b/test/core/end2end/tests/simple_cacheable_request.c @@ -43,6 +43,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } @@ -134,7 +136,7 @@ static void test_cacheable_request_response_with_metadata_and_payload( int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -235,7 +237,9 @@ static void test_cacheable_request_response_with_metadata_and_payload( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } if (config.feature_mask & FEATURE_MASK_SUPPORTS_REQUEST_PROXYING) { // Our simple proxy does not support cacheable requests } else { @@ -270,6 +274,7 @@ static void test_cacheable_request_response_with_metadata_and_payload( } void simple_cacheable_request(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); test_cacheable_request_response_with_metadata_and_payload(config); } diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c index 74f1232d78..7f1a284739 100644 --- a/test/core/end2end/tests/simple_delayed_request.c +++ b/test/core/end2end/tests/simple_delayed_request.c @@ -43,6 +43,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static gpr_timespec n_seconds_time(int n) { @@ -107,7 +109,7 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, config.init_client(f, client_args); c = grpc_channel_create_call(f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -180,7 +182,9 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 1); gpr_free(details); @@ -217,6 +221,7 @@ static void test_simple_delayed_request_long(grpc_end2end_test_config config) { } void simple_delayed_request(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); test_simple_delayed_request_short(config); test_simple_delayed_request_long(config); diff --git a/test/core/end2end/tests/simple_metadata.c b/test/core/end2end/tests/simple_metadata.c index 13c77c033e..a115ae665c 100644 --- a/test/core/end2end/tests/simple_metadata.c +++ b/test/core/end2end/tests/simple_metadata.c @@ -43,6 +43,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -131,7 +133,7 @@ static void test_request_response_with_metadata_and_payload( int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -232,7 +234,9 @@ static void test_request_response_with_metadata_and_payload( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); @@ -262,6 +266,7 @@ static void test_request_response_with_metadata_and_payload( } void simple_metadata(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); test_request_response_with_metadata_and_payload(config); } diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c index ed7b850808..8c311d3e7a 100644 --- a/test/core/end2end/tests/simple_request.c +++ b/test/core/end2end/tests/simple_request.c @@ -45,6 +45,8 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -116,8 +118,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { char *peer; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr:1234", deadline, - NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); peer = grpc_call_get_peer(c); @@ -202,7 +203,9 @@ static void simple_request_body(grpc_end2end_test_fixture f) { GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); + } GPR_ASSERT(0 == call_details.flags); GPR_ASSERT(was_cancelled == 1); @@ -241,6 +244,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { void simple_request(grpc_end2end_test_config config) { int i; + authority = validate_host_override_string("foo.test.google.fr:1234", config); for (i = 0; i < 10; i++) { test_invoke_simple_request(config); } diff --git a/test/core/end2end/tests/streaming_error_response.c b/test/core/end2end/tests/streaming_error_response.c index 8285468321..13b7a372dd 100644 --- a/test/core/end2end/tests/streaming_error_response.c +++ b/test/core/end2end/tests/streaming_error_response.c @@ -43,6 +43,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -126,7 +128,7 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -245,7 +247,9 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { GPR_ASSERT(status == GRPC_STATUS_FAILED_PRECONDITION); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 1); gpr_free(details); @@ -269,6 +273,7 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { } void streaming_error_response(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); test(config, false); test(config, true); } diff --git a/test/core/end2end/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.c index d7093ae723..11af60ffdd 100644 --- a/test/core/end2end/tests/trailing_metadata.c +++ b/test/core/end2end/tests/trailing_metadata.c @@ -43,6 +43,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -134,7 +136,7 @@ static void test_request_response_with_metadata_and_payload( int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -236,7 +238,9 @@ static void test_request_response_with_metadata_and_payload( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); GPR_ASSERT(contains_metadata(&request_metadata_recv, "key1", "val1")); @@ -267,6 +271,7 @@ static void test_request_response_with_metadata_and_payload( } void trailing_metadata(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); test_request_response_with_metadata_and_payload(config); } -- cgit v1.2.3 From caa904486ee11d7dfc369a48db1bc6dee4f216c3 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 22 Sep 2016 16:23:10 -0700 Subject: Minor end2end test update --- test/core/end2end/tests/binary_metadata.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'test/core/end2end/tests') diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.c index 6b105def33..c5c862bbf2 100644 --- a/test/core/end2end/tests/binary_metadata.c +++ b/test/core/end2end/tests/binary_metadata.c @@ -43,6 +43,8 @@ #include #include "test/core/end2end/cq_verifier.h" +static char *authority; + static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -147,7 +149,7 @@ static void test_request_response_with_metadata_and_payload( int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", "foo.test.google.fr", deadline, NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -248,7 +250,9 @@ static void test_request_response_with_metadata_and_payload( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr")); + if (authority) { + GPR_ASSERT(0 == strcmp(call_details.host, authority)); + } GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); @@ -286,6 +290,7 @@ static void test_request_response_with_metadata_and_payload( } void binary_metadata(grpc_end2end_test_config config) { + authority = validate_host_override_string("foo.test.google.fr", config); test_request_response_with_metadata_and_payload(config); } -- cgit v1.2.3 From ed2be64d82d7cff11b6c2fb2bf127585fd5f1107 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Thu, 13 Oct 2016 14:04:39 -0700 Subject: Clean format with clang-format --- test/core/end2end/fixtures/h2_census.c | 4 ++-- test/core/end2end/fixtures/h2_compress.c | 4 ++-- test/core/end2end/fixtures/h2_full+pipe.c | 4 ++-- test/core/end2end/fixtures/h2_full+trace.c | 4 ++-- test/core/end2end/fixtures/h2_full.c | 4 ++-- test/core/end2end/fixtures/h2_http_proxy.c | 5 ++--- test/core/end2end/fixtures/h2_load_reporting.c | 3 ++- test/core/end2end/fixtures/h2_proxy.c | 7 +++---- test/core/end2end/fixtures/h2_sockpair+trace.c | 6 +++--- test/core/end2end/fixtures/h2_sockpair.c | 5 ++--- test/core/end2end/fixtures/h2_sockpair_1byte.c | 6 +++--- test/core/end2end/fixtures/h2_uds.c | 5 ++--- test/core/end2end/tests/cancel_with_status.c | 3 +-- test/core/end2end/tests/disappearing_server.c | 3 +-- test/core/end2end/tests/high_initial_seqno.c | 3 +-- test/core/end2end/tests/hpack_size.c | 3 +-- test/core/end2end/tests/idempotent_request.c | 3 +-- test/core/end2end/tests/load_reporting_hook.c | 3 +-- test/core/end2end/tests/max_concurrent_streams.c | 9 +++------ test/core/end2end/tests/negative_deadline.c | 3 +-- test/core/end2end/tests/no_logging.c | 3 +-- test/core/end2end/tests/ping_pong_streaming.c | 3 +-- test/core/end2end/tests/registered_call.c | 6 ++---- test/core/end2end/tests/server_finishes_request.c | 3 +-- 24 files changed, 42 insertions(+), 60 deletions(-) (limited to 'test/core/end2end/tests') diff --git a/test/core/end2end/fixtures/h2_census.c b/test/core/end2end/fixtures/h2_census.c index e81cf82af1..c06002deae 100644 --- a/test/core/end2end/fixtures/h2_census.c +++ b/test/core/end2end/fixtures/h2_census.c @@ -111,8 +111,8 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack+census", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack+census", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_compress.c b/test/core/end2end/fixtures/h2_compress.c index 41a48b920f..197b69e090 100644 --- a/test/core/end2end/fixtures/h2_compress.c +++ b/test/core/end2end/fixtures/h2_compress.c @@ -113,8 +113,8 @@ void chttp2_tear_down_fullstack_compression(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack_compression", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack_compression", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack_compression, chttp2_init_client_fullstack_compression, chttp2_init_server_fullstack_compression, diff --git a/test/core/end2end/fixtures/h2_full+pipe.c b/test/core/end2end/fixtures/h2_full+pipe.c index d67bf9f1bb..318e56992f 100644 --- a/test/core/end2end/fixtures/h2_full+pipe.c +++ b/test/core/end2end/fixtures/h2_full+pipe.c @@ -97,8 +97,8 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_full+trace.c b/test/core/end2end/fixtures/h2_full+trace.c index 6f2b4e37db..d7ee2ef3c6 100644 --- a/test/core/end2end/fixtures/h2_full+trace.c +++ b/test/core/end2end/fixtures/h2_full+trace.c @@ -97,8 +97,8 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_full.c b/test/core/end2end/fixtures/h2_full.c index d85669e021..f4dbb516f4 100644 --- a/test/core/end2end/fixtures/h2_full.c +++ b/test/core/end2end/fixtures/h2_full.c @@ -96,8 +96,8 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_http_proxy.c b/test/core/end2end/fixtures/h2_http_proxy.c index db4afe5c1c..0dd5d2aa8a 100644 --- a/test/core/end2end/fixtures/h2_http_proxy.c +++ b/test/core/end2end/fixtures/h2_http_proxy.c @@ -107,9 +107,8 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_load_reporting.c b/test/core/end2end/fixtures/h2_load_reporting.c index 6965418eef..63417adcc5 100644 --- a/test/core/end2end/fixtures/h2_load_reporting.c +++ b/test/core/end2end/fixtures/h2_load_reporting.c @@ -103,7 +103,8 @@ void chttp2_tear_down_load_reporting(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { {"chttp2/fullstack+load_reporting", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_load_reporting, chttp2_init_client_load_reporting, chttp2_init_server_load_reporting, chttp2_tear_down_load_reporting}, }; diff --git a/test/core/end2end/fixtures/h2_proxy.c b/test/core/end2end/fixtures/h2_proxy.c index 695d51a9c7..a2fefa7952 100644 --- a/test/core/end2end/fixtures/h2_proxy.c +++ b/test/core/end2end/fixtures/h2_proxy.c @@ -113,10 +113,9 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack+proxy", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_REQUEST_PROXYING | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack+proxy", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_REQUEST_PROXYING | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/fixtures/h2_sockpair+trace.c b/test/core/end2end/fixtures/h2_sockpair+trace.c index 674aee5b78..f65a688454 100644 --- a/test/core/end2end/fixtures/h2_sockpair+trace.c +++ b/test/core/end2end/fixtures/h2_sockpair+trace.c @@ -134,9 +134,9 @@ static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/socketpair", FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_socketpair, - chttp2_init_client_socketpair, chttp2_init_server_socketpair, - chttp2_tear_down_socketpair}, + {"chttp2/socketpair", FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + chttp2_create_fixture_socketpair, chttp2_init_client_socketpair, + chttp2_init_server_socketpair, chttp2_tear_down_socketpair}, }; int main(int argc, char **argv) { diff --git a/test/core/end2end/fixtures/h2_sockpair.c b/test/core/end2end/fixtures/h2_sockpair.c index 4164bc9cf3..24232bb051 100644 --- a/test/core/end2end/fixtures/h2_sockpair.c +++ b/test/core/end2end/fixtures/h2_sockpair.c @@ -134,9 +134,8 @@ static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { {"chttp2/socketpair", FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, - chttp2_create_fixture_socketpair, - chttp2_init_client_socketpair, chttp2_init_server_socketpair, - chttp2_tear_down_socketpair}, + chttp2_create_fixture_socketpair, chttp2_init_client_socketpair, + chttp2_init_server_socketpair, chttp2_tear_down_socketpair}, }; int main(int argc, char **argv) { diff --git a/test/core/end2end/fixtures/h2_sockpair_1byte.c b/test/core/end2end/fixtures/h2_sockpair_1byte.c index e8a33bb2d4..e3f3002af1 100644 --- a/test/core/end2end/fixtures/h2_sockpair_1byte.c +++ b/test/core/end2end/fixtures/h2_sockpair_1byte.c @@ -134,9 +134,9 @@ static void chttp2_tear_down_socketpair(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { {"chttp2/socketpair_one_byte_at_a_time", - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, - chttp2_create_fixture_socketpair, chttp2_init_client_socketpair, - chttp2_init_server_socketpair, chttp2_tear_down_socketpair}, + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_socketpair, + chttp2_init_client_socketpair, chttp2_init_server_socketpair, + chttp2_tear_down_socketpair}, }; int main(int argc, char **argv) { diff --git a/test/core/end2end/fixtures/h2_uds.c b/test/core/end2end/fixtures/h2_uds.c index d8892c0c88..c15b70ded4 100644 --- a/test/core/end2end/fixtures/h2_uds.c +++ b/test/core/end2end/fixtures/h2_uds.c @@ -101,9 +101,8 @@ void chttp2_tear_down_fullstack(grpc_end2end_test_fixture *f) { /* All test configurations */ static grpc_end2end_test_config configs[] = { - {"chttp2/fullstack_uds", - FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | - FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, + {"chttp2/fullstack_uds", FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION | + FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER, chttp2_create_fixture_fullstack, chttp2_init_client_fullstack, chttp2_init_server_fullstack, chttp2_tear_down_fullstack}, }; diff --git a/test/core/end2end/tests/cancel_with_status.c b/test/core/end2end/tests/cancel_with_status.c index b2da1099eb..4ab4f1e92f 100644 --- a/test/core/end2end/tests/cancel_with_status.c +++ b/test/core/end2end/tests/cancel_with_status.c @@ -115,8 +115,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) { gpr_log(GPR_DEBUG, "test with %" PRIuPTR " ops", num_ops); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, - NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c index e761aa7d19..624e148785 100644 --- a/test/core/end2end/tests/disappearing_server.c +++ b/test/core/end2end/tests/disappearing_server.c @@ -99,8 +99,7 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f, int was_cancelled = 2; c = grpc_channel_create_call(f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, - "/foo", authority, deadline, - NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); diff --git a/test/core/end2end/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.c index dbd99e8feb..4a0d59f326 100644 --- a/test/core/end2end/tests/high_initial_seqno.c +++ b/test/core/end2end/tests/high_initial_seqno.c @@ -119,8 +119,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, - NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); diff --git a/test/core/end2end/tests/hpack_size.c b/test/core/end2end/tests/hpack_size.c index c207639f7b..80513e764c 100644 --- a/test/core/end2end/tests/hpack_size.c +++ b/test/core/end2end/tests/hpack_size.c @@ -271,8 +271,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t index) { extra_metadata[2].value_length = strlen(extra_metadata[2].value); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, - NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); diff --git a/test/core/end2end/tests/idempotent_request.c b/test/core/end2end/tests/idempotent_request.c index 700cb21207..6582eaf034 100644 --- a/test/core/end2end/tests/idempotent_request.c +++ b/test/core/end2end/tests/idempotent_request.c @@ -118,8 +118,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { char *peer; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, - NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); peer = grpc_call_get_peer(c); diff --git a/test/core/end2end/tests/load_reporting_hook.c b/test/core/end2end/tests/load_reporting_hook.c index 62d0dad936..e8bbbd9725 100644 --- a/test/core/end2end/tests/load_reporting_hook.c +++ b/test/core/end2end/tests/load_reporting_hook.c @@ -154,8 +154,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f, int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - method_name, authority, deadline, - NULL); + method_name, authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index 925f45d42a..c6f634c457 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -115,8 +115,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, - NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -262,12 +261,10 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { the first completes */ deadline = n_seconds_time(1000); c1 = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/alpha", authority, deadline, - NULL); + "/alpha", authority, deadline, NULL); GPR_ASSERT(c1); c2 = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/beta", authority, deadline, - NULL); + "/beta", authority, deadline, NULL); GPR_ASSERT(c2); GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( diff --git a/test/core/end2end/tests/negative_deadline.c b/test/core/end2end/tests/negative_deadline.c index 258d4a7168..ec45841e5f 100644 --- a/test/core/end2end/tests/negative_deadline.c +++ b/test/core/end2end/tests/negative_deadline.c @@ -115,8 +115,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) { gpr_log(GPR_DEBUG, "test with %" PRIuPTR " ops", num_ops); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, - NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); diff --git a/test/core/end2end/tests/no_logging.c b/test/core/end2end/tests/no_logging.c index 32d357508b..0ddb4a5a05 100644 --- a/test/core/end2end/tests/no_logging.c +++ b/test/core/end2end/tests/no_logging.c @@ -146,8 +146,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { char *peer; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, - NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); peer = grpc_call_get_peer(c); diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index 372766f470..46fa0063f3 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -126,8 +126,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, - NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c index 1bbae56a0f..d710b9e56f 100644 --- a/test/core/end2end/tests/registered_call.c +++ b/test/core/end2end/tests/registered_call.c @@ -208,8 +208,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) { static void test_invoke_simple_request(grpc_end2end_test_config config) { grpc_end2end_test_fixture f = begin_test(config, "test_invoke_simple_request", NULL, NULL); - void *rc = grpc_channel_register_call(f.client, "/foo", - authority, NULL); + void *rc = grpc_channel_register_call(f.client, "/foo", authority, NULL); simple_request_body(f, rc); end_test(&f); @@ -220,8 +219,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { int i; grpc_end2end_test_fixture f = begin_test(config, "test_invoke_10_simple_requests", NULL, NULL); - void *rc = grpc_channel_register_call(f.client, "/foo", - authority, NULL); + void *rc = grpc_channel_register_call(f.client, "/foo", authority, NULL); for (i = 0; i < 10; i++) { simple_request_body(f, rc); diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c index ca8bf9278b..a824e6e1e4 100644 --- a/test/core/end2end/tests/server_finishes_request.c +++ b/test/core/end2end/tests/server_finishes_request.c @@ -117,8 +117,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, - NULL); + "/foo", authority, deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); -- cgit v1.2.3 From d41a4a720f76c6555b80f82ee771071e09d55e03 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 26 Oct 2016 16:16:06 -0700 Subject: s/gpr_slice/grpc_slice, and move around tests, impls --- Makefile | 32 +- build.yaml | 30 +- grpc.def | 56 ++-- include/grpc++/impl/codegen/core_codegen.h | 16 +- .../grpc++/impl/codegen/core_codegen_interface.h | 14 +- include/grpc++/impl/codegen/proto_utils.h | 26 +- include/grpc++/impl/codegen/thrift_serializer.h | 8 +- include/grpc++/support/slice.h | 12 +- include/grpc/byte_buffer.h | 10 +- include/grpc/impl/codegen/gpr_types.h | 65 ---- include/grpc/impl/codegen/grpc_types.h | 3 +- include/grpc/impl/codegen/slice.h | 66 ++++ include/grpc/slice.h | 128 ++++++++ include/grpc/slice_buffer.h | 87 +++++ include/grpc/support/slice.h | 128 -------- include/grpc/support/slice_buffer.h | 87 ----- src/core/ext/client_channel/connector.h | 2 +- .../default_initial_connect_string.c | 2 +- .../ext/client_channel/http_connect_handshaker.c | 30 +- .../ext/client_channel/initial_connect_string.c | 4 +- .../ext/client_channel/initial_connect_string.h | 4 +- src/core/ext/client_channel/subchannel.c | 4 +- src/core/ext/client_channel/uri_parser.c | 24 +- src/core/ext/lb_policy/grpclb/grpclb.c | 10 +- src/core/ext/lb_policy/grpclb/load_balancer_api.c | 10 +- src/core/ext/lb_policy/grpclb/load_balancer_api.h | 6 +- src/core/ext/resolver/sockaddr/sockaddr_resolver.c | 14 +- .../chttp2/client/insecure/channel_create.c | 8 +- .../chttp2/client/secure/secure_channel_create.c | 8 +- .../chttp2/server/insecure/server_chttp2.c | 2 +- .../chttp2/server/secure/server_secure_chttp2.c | 2 +- .../ext/transport/chttp2/transport/bin_decoder.c | 18 +- .../ext/transport/chttp2/transport/bin_decoder.h | 4 +- .../ext/transport/chttp2/transport/bin_encoder.c | 14 +- .../ext/transport/chttp2/transport/bin_encoder.h | 12 +- .../transport/chttp2/transport/chttp2_transport.c | 88 +++--- .../transport/chttp2/transport/chttp2_transport.h | 2 +- .../ext/transport/chttp2/transport/frame_data.c | 22 +- .../ext/transport/chttp2/transport/frame_data.h | 6 +- .../ext/transport/chttp2/transport/frame_goaway.c | 14 +- .../ext/transport/chttp2/transport/frame_goaway.h | 6 +- .../ext/transport/chttp2/transport/frame_ping.c | 8 +- .../ext/transport/chttp2/transport/frame_ping.h | 4 +- .../transport/chttp2/transport/frame_rst_stream.c | 8 +- .../transport/chttp2/transport/frame_rst_stream.h | 4 +- .../transport/chttp2/transport/frame_settings.c | 16 +- .../transport/chttp2/transport/frame_settings.h | 6 +- .../chttp2/transport/frame_window_update.c | 6 +- .../chttp2/transport/frame_window_update.h | 4 +- .../ext/transport/chttp2/transport/hpack_encoder.c | 36 +-- .../ext/transport/chttp2/transport/hpack_encoder.h | 2 +- .../ext/transport/chttp2/transport/hpack_parser.c | 2 +- .../ext/transport/chttp2/transport/hpack_parser.h | 2 +- src/core/ext/transport/chttp2/transport/internal.h | 28 +- src/core/ext/transport/chttp2/transport/parsing.c | 18 +- src/core/ext/transport/chttp2/transport/writing.c | 14 +- .../transport/cronet/transport/cronet_transport.c | 24 +- src/core/lib/channel/channel_stack.c | 4 +- src/core/lib/channel/channel_stack.h | 4 +- src/core/lib/channel/compress_filter.c | 22 +- src/core/lib/channel/deadline_filter.c | 4 +- src/core/lib/channel/handshaker.c | 8 +- src/core/lib/channel/handshaker.h | 6 +- src/core/lib/channel/http_client_filter.c | 16 +- src/core/lib/channel/http_server_filter.c | 8 +- src/core/lib/channel/message_size_filter.c | 2 +- src/core/lib/compression/message_compress.c | 32 +- src/core/lib/compression/message_compress.h | 4 +- src/core/lib/http/format_request.c | 12 +- src/core/lib/http/format_request.h | 6 +- src/core/lib/http/httpcli.c | 22 +- src/core/lib/http/httpcli_security_connector.c | 2 +- src/core/lib/http/parser.c | 2 +- src/core/lib/http/parser.h | 2 +- src/core/lib/iomgr/endpoint.c | 4 +- src/core/lib/iomgr/endpoint.h | 8 +- src/core/lib/iomgr/load_file.c | 6 +- src/core/lib/iomgr/load_file.h | 2 +- src/core/lib/iomgr/resource_quota.c | 12 +- src/core/lib/iomgr/resource_quota.h | 4 +- src/core/lib/iomgr/tcp_posix.c | 36 +-- src/core/lib/iomgr/tcp_windows.c | 24 +- src/core/lib/security/credentials/credentials.h | 6 +- .../security/credentials/credentials_metadata.c | 14 +- .../google_default/google_default_credentials.c | 4 +- .../lib/security/credentials/jwt/jwt_verifier.c | 40 +-- .../lib/security/credentials/jwt/jwt_verifier.h | 2 +- .../credentials/plugin/plugin_credentials.c | 8 +- .../lib/security/transport/client_auth_filter.c | 6 +- src/core/lib/security/transport/handshake.c | 38 +-- src/core/lib/security/transport/handshake.h | 2 +- src/core/lib/security/transport/secure_endpoint.c | 76 ++--- src/core/lib/security/transport/secure_endpoint.h | 2 +- .../lib/security/transport/security_connector.c | 22 +- .../lib/security/transport/security_connector.h | 10 +- .../lib/security/transport/server_auth_filter.c | 4 +- src/core/lib/security/util/b64.c | 8 +- src/core/lib/security/util/b64.h | 4 +- src/core/lib/slice/percent_encoding.c | 180 +++++++++++ src/core/lib/slice/percent_encoding.h | 78 +++++ src/core/lib/slice/slice.c | 350 +++++++++++++++++++++ src/core/lib/slice/slice_buffer.c | 282 +++++++++++++++++ src/core/lib/slice/slice_string_helpers.c | 81 +++++ src/core/lib/slice/slice_string_helpers.h | 58 ++++ src/core/lib/support/percent_encoding.c | 180 ----------- src/core/lib/support/percent_encoding.h | 78 ----- src/core/lib/support/slice.c | 350 --------------------- src/core/lib/support/slice_buffer.c | 282 ----------------- src/core/lib/support/string.c | 49 --- src/core/lib/support/string.h | 7 - src/core/lib/surface/byte_buffer.c | 18 +- src/core/lib/surface/byte_buffer_reader.c | 20 +- src/core/lib/surface/call.c | 20 +- src/core/lib/surface/server.c | 8 +- src/core/lib/transport/byte_stream.c | 8 +- src/core/lib/transport/byte_stream.h | 8 +- src/core/lib/transport/metadata.c | 22 +- src/core/lib/transport/metadata.h | 12 +- src/core/lib/transport/transport.c | 12 +- src/core/lib/transport/transport.h | 8 +- src/cpp/common/core_codegen.cc | 22 +- src/cpp/util/byte_buffer_cc.cc | 14 +- src/cpp/util/slice_cc.cc | 8 +- src/csharp/ext/grpc_csharp_ext.c | 8 +- src/node/ext/byte_buffer.cc | 8 +- src/objective-c/GRPCClient/private/NSData+GRPC.m | 12 +- src/php/ext/grpc/byte_buffer.c | 8 +- src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi | 26 +- .../grpcio/grpc/_cython/_cygrpc/records.pyx.pxi | 14 +- src/ruby/ext/grpc/rb_byte_buffer.c | 8 +- src/ruby/ext/grpc/rb_grpc_imports.generated.c | 112 +++---- src/ruby/ext/grpc/rb_grpc_imports.generated.h | 178 +++++------ test/core/bad_client/bad_client.c | 18 +- test/core/bad_client/bad_client.h | 2 +- test/core/bad_client/tests/large_metadata.c | 16 +- test/core/bad_ssl/servers/cert.c | 6 +- .../set_initial_connect_string_test.c | 24 +- test/core/compression/message_compress_test.c | 144 ++++----- test/core/end2end/bad_server_response_test.c | 18 +- test/core/end2end/cq_verifier.c | 18 +- test/core/end2end/cq_verifier.h | 2 +- test/core/end2end/dualstack_socket_test.c | 14 +- test/core/end2end/fake_resolver.c | 14 +- test/core/end2end/fixtures/http_proxy.c | 62 ++-- test/core/end2end/fuzzers/api_fuzzer.c | 4 +- test/core/end2end/fuzzers/client_fuzzer.c | 4 +- test/core/end2end/fuzzers/server_fuzzer.c | 4 +- test/core/end2end/invalid_call_argument_test.c | 2 +- test/core/end2end/tests/binary_metadata.c | 4 +- test/core/end2end/tests/call_creds.c | 6 +- test/core/end2end/tests/cancel_after_accept.c | 4 +- test/core/end2end/tests/cancel_after_client_done.c | 4 +- test/core/end2end/tests/cancel_after_invoke.c | 2 +- test/core/end2end/tests/cancel_before_invoke.c | 2 +- test/core/end2end/tests/compressed_payload.c | 16 +- test/core/end2end/tests/filter_call_init_fails.c | 2 +- test/core/end2end/tests/filter_causes_close.c | 6 +- test/core/end2end/tests/invoke_large_request.c | 12 +- test/core/end2end/tests/large_metadata.c | 2 +- test/core/end2end/tests/load_reporting_hook.c | 4 +- test/core/end2end/tests/max_message_length.c | 6 +- test/core/end2end/tests/network_status_change.c | 2 +- test/core/end2end/tests/payload.c | 10 +- test/core/end2end/tests/ping_pong_streaming.c | 8 +- test/core/end2end/tests/request_with_flags.c | 2 +- test/core/end2end/tests/request_with_payload.c | 2 +- test/core/end2end/tests/resource_quota_server.c | 10 +- test/core/end2end/tests/simple_cacheable_request.c | 4 +- test/core/end2end/tests/simple_metadata.c | 4 +- test/core/end2end/tests/streaming_error_response.c | 4 +- test/core/end2end/tests/trailing_metadata.c | 4 +- test/core/fling/client.c | 4 +- test/core/http/format_request_test.c | 24 +- test/core/http/parser_test.c | 32 +- test/core/http/request_fuzzer.c | 4 +- test/core/http/response_fuzzer.c | 4 +- test/core/internal_api_canaries/transport.c | 2 +- test/core/iomgr/endpoint_tests.c | 34 +- test/core/iomgr/load_file_test.c | 24 +- test/core/iomgr/resource_quota_test.c | 12 +- test/core/iomgr/tcp_posix_test.c | 32 +- test/core/nanopb/fuzzer_response.c | 4 +- test/core/nanopb/fuzzer_serverlist.c | 4 +- test/core/security/b64_test.c | 40 +-- test/core/security/create_jwt.c | 4 +- test/core/security/credentials_test.c | 40 +-- test/core/security/fetch_oauth2.c | 2 +- test/core/security/json_token_test.c | 8 +- test/core/security/jwt_verifier_test.c | 12 +- test/core/security/oauth2_utils.c | 2 +- test/core/security/secure_endpoint_test.c | 30 +- test/core/security/security_connector_test.c | 8 +- .../04cb8ccc553f9b2f5e52c421aff6d1c954d3dae6 | 1 + .../0dd8f3a63745b3a2d39791559b5c1b311447b537 | 1 + .../17eeaca784409adbe43365c32ac87915d736bba3 | 2 + .../2040c1ff65f52a7ae668c2c8f324de5dacc9d695 | 1 + .../26b0d1da23027ae54db96e125e4a9e98842d77fb | 1 + .../2a089c0db45acdb4c6ed8e7ff81ca7235792c0b9 | 1 + .../35b7b3bc3a740d5c3abca0d75b53f0e1e1ee998a | 1 + .../36367ba1adba47a1cbc3a88707fde8cc7abdc248 | 1 + .../39c2ba51548a0beaf0d6d1164531f1447dc311b5 | 1 + .../56d08fea787c041395c6697ce26cfbc0decbe688 | 1 + .../678d981fdabb9f0d6640235cf1719dd1e1e66ae9 | 1 + .../68751961609ec010565de0aa87521dcbf0722c5d | 1 + .../7875c06c6f03c9aa2f8e9c59f8d8957c8a32e759 | 2 + .../7b302090e090a5829b6d1dd7be30bd4e36a7e60f | 1 + .../875e1022169c9e4c541a9ad894e69e989df22ba1 | 1 + .../8c1051ce066f5a26de9a9d133180621d0da957b4 | 1 + .../8e084e628ab83a18ac7ca7cb3506525263655c63 | 1 + .../9d316c4675f40ddccaf8f1cc7aea94170b1e4223 | 1 + .../ad1c7c11d18a7d116e2c2ef4d4c5afb1270836ae | 1 + .../b471f94aa4facf502e622e4a248f1ba4063ae681 | 1 + .../bf52ece030f16136d46e0dc97f58d60a0d8a1f0b | 2 + .../d5b2a7177339ba2b7ce2f60e5f4459bef1e72758 | 2 + .../de867b64c54a7ed773dc611fc5cd2f17c5433113 | 2 + .../e3948dbe004950591630dd5c52f4e0fcbd5e388a | 1 + .../e7064f0b80f61dbc65915311032d27baa569ae2a | 1 + test/core/slice/percent_decode_corpus/xyz | 1 + test/core/slice/percent_decode_fuzzer.c | 66 ++++ .../0d3ee7fa54e6c66103965fd4409b044ba7db6c3f | 3 + .../2e7ccf75e27b9501e3b28cf1c50ed0c45ab7c226 | 1 + .../55bb859f3942c462b03b7cbcf22ab4a0ac9705cf | 1 + .../56070cecd54c845b6d4334953b17b712eb000d93 | 1 + .../61f50e891bf7ff5eb7a7af206f1e25d77f8756e7 | 3 + .../6e0c60cefc704c7940e475a87dd9ae423061cb5a | 3 + .../7271ebcc6d22a0f186f7bc3c1973a7ed1bec8d8e | 4 + .../74c83ece3e2920a67593a9be9c82468f16cbb969 | 1 + .../98e004fd2a9f141a7a019720820080e12d637c06 | 3 + .../ba2c1e98227aa21ea3bb2ca4d0e504119717da8b | 3 + .../c16b9fd45370d4afb5d3ebd307a6e263c25ffd45 | 2 + .../d58c3cd4eab9b6d2343abfa1c25c90a383fe0ec3 | 1 + .../e2619218ede30d2b7b8ecd601a9f0ae754b728b4 | 4 + .../f93b3653e453f0e3eea3198001be6ce46e64bd21 | 5 + .../fd41d029c7682ad3d1c40a9fd017a4c85b673a54 | 3 + test/core/slice/percent_encode_corpus/xyz | 1 + test/core/slice/percent_encode_fuzzer.c | 73 +++++ test/core/slice/percent_encoding_test.c | 157 +++++++++ test/core/slice/slice_buffer_test.c | 129 ++++++++ test/core/slice/slice_string_helpers_test.c | 148 +++++++++ test/core/slice/slice_test.c | 265 ++++++++++++++++ .../04cb8ccc553f9b2f5e52c421aff6d1c954d3dae6 | 1 - .../0dd8f3a63745b3a2d39791559b5c1b311447b537 | 1 - .../17eeaca784409adbe43365c32ac87915d736bba3 | 2 - .../2040c1ff65f52a7ae668c2c8f324de5dacc9d695 | 1 - .../26b0d1da23027ae54db96e125e4a9e98842d77fb | 1 - .../2a089c0db45acdb4c6ed8e7ff81ca7235792c0b9 | 1 - .../35b7b3bc3a740d5c3abca0d75b53f0e1e1ee998a | 1 - .../36367ba1adba47a1cbc3a88707fde8cc7abdc248 | 1 - .../39c2ba51548a0beaf0d6d1164531f1447dc311b5 | 1 - .../56d08fea787c041395c6697ce26cfbc0decbe688 | 1 - .../678d981fdabb9f0d6640235cf1719dd1e1e66ae9 | 1 - .../68751961609ec010565de0aa87521dcbf0722c5d | 1 - .../7875c06c6f03c9aa2f8e9c59f8d8957c8a32e759 | 2 - .../7b302090e090a5829b6d1dd7be30bd4e36a7e60f | 1 - .../875e1022169c9e4c541a9ad894e69e989df22ba1 | 1 - .../8c1051ce066f5a26de9a9d133180621d0da957b4 | 1 - .../8e084e628ab83a18ac7ca7cb3506525263655c63 | 1 - .../9d316c4675f40ddccaf8f1cc7aea94170b1e4223 | 1 - .../ad1c7c11d18a7d116e2c2ef4d4c5afb1270836ae | 1 - .../b471f94aa4facf502e622e4a248f1ba4063ae681 | 1 - .../bf52ece030f16136d46e0dc97f58d60a0d8a1f0b | 2 - .../d5b2a7177339ba2b7ce2f60e5f4459bef1e72758 | 2 - .../de867b64c54a7ed773dc611fc5cd2f17c5433113 | 2 - .../e3948dbe004950591630dd5c52f4e0fcbd5e388a | 1 - .../e7064f0b80f61dbc65915311032d27baa569ae2a | 1 - test/core/support/percent_decode_corpus/xyz | 1 - test/core/support/percent_decode_fuzzer.c | 66 ---- .../0d3ee7fa54e6c66103965fd4409b044ba7db6c3f | 3 - .../2e7ccf75e27b9501e3b28cf1c50ed0c45ab7c226 | 1 - .../55bb859f3942c462b03b7cbcf22ab4a0ac9705cf | 1 - .../56070cecd54c845b6d4334953b17b712eb000d93 | 1 - .../61f50e891bf7ff5eb7a7af206f1e25d77f8756e7 | 3 - .../6e0c60cefc704c7940e475a87dd9ae423061cb5a | 3 - .../7271ebcc6d22a0f186f7bc3c1973a7ed1bec8d8e | 4 - .../74c83ece3e2920a67593a9be9c82468f16cbb969 | 1 - .../98e004fd2a9f141a7a019720820080e12d637c06 | 3 - .../ba2c1e98227aa21ea3bb2ca4d0e504119717da8b | 3 - .../c16b9fd45370d4afb5d3ebd307a6e263c25ffd45 | 2 - .../d58c3cd4eab9b6d2343abfa1c25c90a383fe0ec3 | 1 - .../e2619218ede30d2b7b8ecd601a9f0ae754b728b4 | 4 - .../f93b3653e453f0e3eea3198001be6ce46e64bd21 | 5 - .../fd41d029c7682ad3d1c40a9fd017a4c85b673a54 | 3 - test/core/support/percent_encode_corpus/xyz | 1 - test/core/support/percent_encode_fuzzer.c | 73 ----- test/core/support/percent_encoding_test.c | 157 --------- test/core/support/slice_buffer_test.c | 129 -------- test/core/support/slice_test.c | 265 ---------------- test/core/support/string_test.c | 94 ------ test/core/surface/byte_buffer_reader_test.c | 92 +++--- test/core/transport/chttp2/bin_decoder_test.c | 34 +- test/core/transport/chttp2/bin_encoder_test.c | 44 +-- test/core/transport/chttp2/hpack_encoder_test.c | 22 +- test/core/transport/chttp2/hpack_parser_test.c | 12 +- test/core/transport/chttp2/hpack_table_test.c | 2 +- test/core/transport/chttp2/varint_test.c | 12 +- test/core/transport/metadata_test.c | 38 +-- test/core/util/mock_endpoint.c | 24 +- test/core/util/mock_endpoint.h | 4 +- test/core/util/one_corpus_entry_fuzzer.c | 4 +- test/core/util/parse_hexstring.c | 6 +- test/core/util/parse_hexstring.h | 2 +- test/core/util/passthru_endpoint.c | 20 +- test/core/util/slice_splitter.c | 32 +- test/core/util/slice_splitter.h | 14 +- test/cpp/grpclb/grpclb_api_test.cc | 14 +- test/cpp/grpclb/grpclb_test.cc | 20 +- test/cpp/qps/client.h | 2 +- test/cpp/qps/server_async.cc | 2 +- test/cpp/util/byte_buffer_proto_helper.cc | 2 +- test/cpp/util/byte_buffer_test.cc | 22 +- test/cpp/util/cli_call.cc | 2 +- test/cpp/util/slice_test.cc | 12 +- tools/run_tests/sources_and_headers.json | 4 +- tools/run_tests/tests.json | 4 +- vsprojects/buildtests_c.sln | 4 +- .../gpr_slice_buffer_test.vcxproj | 4 +- .../test/gpr_slice_test/gpr_slice_test.vcxproj | 4 +- 317 files changed, 3726 insertions(+), 3585 deletions(-) create mode 100644 include/grpc/slice.h create mode 100644 include/grpc/slice_buffer.h delete mode 100644 include/grpc/support/slice.h delete mode 100644 include/grpc/support/slice_buffer.h create mode 100644 src/core/lib/slice/percent_encoding.c create mode 100644 src/core/lib/slice/percent_encoding.h create mode 100644 src/core/lib/slice/slice.c create mode 100644 src/core/lib/slice/slice_buffer.c create mode 100644 src/core/lib/slice/slice_string_helpers.c create mode 100644 src/core/lib/slice/slice_string_helpers.h delete mode 100644 src/core/lib/support/percent_encoding.c delete mode 100644 src/core/lib/support/percent_encoding.h delete mode 100644 src/core/lib/support/slice.c delete mode 100644 src/core/lib/support/slice_buffer.c create mode 100644 test/core/slice/percent_decode_corpus/04cb8ccc553f9b2f5e52c421aff6d1c954d3dae6 create mode 100644 test/core/slice/percent_decode_corpus/0dd8f3a63745b3a2d39791559b5c1b311447b537 create mode 100644 test/core/slice/percent_decode_corpus/17eeaca784409adbe43365c32ac87915d736bba3 create mode 100644 test/core/slice/percent_decode_corpus/2040c1ff65f52a7ae668c2c8f324de5dacc9d695 create mode 100644 test/core/slice/percent_decode_corpus/26b0d1da23027ae54db96e125e4a9e98842d77fb create mode 100644 test/core/slice/percent_decode_corpus/2a089c0db45acdb4c6ed8e7ff81ca7235792c0b9 create mode 100644 test/core/slice/percent_decode_corpus/35b7b3bc3a740d5c3abca0d75b53f0e1e1ee998a create mode 100644 test/core/slice/percent_decode_corpus/36367ba1adba47a1cbc3a88707fde8cc7abdc248 create mode 100644 test/core/slice/percent_decode_corpus/39c2ba51548a0beaf0d6d1164531f1447dc311b5 create mode 100644 test/core/slice/percent_decode_corpus/56d08fea787c041395c6697ce26cfbc0decbe688 create mode 100644 test/core/slice/percent_decode_corpus/678d981fdabb9f0d6640235cf1719dd1e1e66ae9 create mode 100644 test/core/slice/percent_decode_corpus/68751961609ec010565de0aa87521dcbf0722c5d create mode 100644 test/core/slice/percent_decode_corpus/7875c06c6f03c9aa2f8e9c59f8d8957c8a32e759 create mode 100644 test/core/slice/percent_decode_corpus/7b302090e090a5829b6d1dd7be30bd4e36a7e60f create mode 100644 test/core/slice/percent_decode_corpus/875e1022169c9e4c541a9ad894e69e989df22ba1 create mode 100644 test/core/slice/percent_decode_corpus/8c1051ce066f5a26de9a9d133180621d0da957b4 create mode 100644 test/core/slice/percent_decode_corpus/8e084e628ab83a18ac7ca7cb3506525263655c63 create mode 100644 test/core/slice/percent_decode_corpus/9d316c4675f40ddccaf8f1cc7aea94170b1e4223 create mode 100644 test/core/slice/percent_decode_corpus/ad1c7c11d18a7d116e2c2ef4d4c5afb1270836ae create mode 100644 test/core/slice/percent_decode_corpus/b471f94aa4facf502e622e4a248f1ba4063ae681 create mode 100644 test/core/slice/percent_decode_corpus/bf52ece030f16136d46e0dc97f58d60a0d8a1f0b create mode 100644 test/core/slice/percent_decode_corpus/d5b2a7177339ba2b7ce2f60e5f4459bef1e72758 create mode 100644 test/core/slice/percent_decode_corpus/de867b64c54a7ed773dc611fc5cd2f17c5433113 create mode 100644 test/core/slice/percent_decode_corpus/e3948dbe004950591630dd5c52f4e0fcbd5e388a create mode 100644 test/core/slice/percent_decode_corpus/e7064f0b80f61dbc65915311032d27baa569ae2a create mode 100644 test/core/slice/percent_decode_corpus/xyz create mode 100644 test/core/slice/percent_decode_fuzzer.c create mode 100644 test/core/slice/percent_encode_corpus/0d3ee7fa54e6c66103965fd4409b044ba7db6c3f create mode 100644 test/core/slice/percent_encode_corpus/2e7ccf75e27b9501e3b28cf1c50ed0c45ab7c226 create mode 100644 test/core/slice/percent_encode_corpus/55bb859f3942c462b03b7cbcf22ab4a0ac9705cf create mode 100644 test/core/slice/percent_encode_corpus/56070cecd54c845b6d4334953b17b712eb000d93 create mode 100644 test/core/slice/percent_encode_corpus/61f50e891bf7ff5eb7a7af206f1e25d77f8756e7 create mode 100644 test/core/slice/percent_encode_corpus/6e0c60cefc704c7940e475a87dd9ae423061cb5a create mode 100644 test/core/slice/percent_encode_corpus/7271ebcc6d22a0f186f7bc3c1973a7ed1bec8d8e create mode 100644 test/core/slice/percent_encode_corpus/74c83ece3e2920a67593a9be9c82468f16cbb969 create mode 100644 test/core/slice/percent_encode_corpus/98e004fd2a9f141a7a019720820080e12d637c06 create mode 100644 test/core/slice/percent_encode_corpus/ba2c1e98227aa21ea3bb2ca4d0e504119717da8b create mode 100644 test/core/slice/percent_encode_corpus/c16b9fd45370d4afb5d3ebd307a6e263c25ffd45 create mode 100644 test/core/slice/percent_encode_corpus/d58c3cd4eab9b6d2343abfa1c25c90a383fe0ec3 create mode 100644 test/core/slice/percent_encode_corpus/e2619218ede30d2b7b8ecd601a9f0ae754b728b4 create mode 100644 test/core/slice/percent_encode_corpus/f93b3653e453f0e3eea3198001be6ce46e64bd21 create mode 100644 test/core/slice/percent_encode_corpus/fd41d029c7682ad3d1c40a9fd017a4c85b673a54 create mode 100644 test/core/slice/percent_encode_corpus/xyz create mode 100644 test/core/slice/percent_encode_fuzzer.c create mode 100644 test/core/slice/percent_encoding_test.c create mode 100644 test/core/slice/slice_buffer_test.c create mode 100644 test/core/slice/slice_string_helpers_test.c create mode 100644 test/core/slice/slice_test.c delete mode 100644 test/core/support/percent_decode_corpus/04cb8ccc553f9b2f5e52c421aff6d1c954d3dae6 delete mode 100644 test/core/support/percent_decode_corpus/0dd8f3a63745b3a2d39791559b5c1b311447b537 delete mode 100644 test/core/support/percent_decode_corpus/17eeaca784409adbe43365c32ac87915d736bba3 delete mode 100644 test/core/support/percent_decode_corpus/2040c1ff65f52a7ae668c2c8f324de5dacc9d695 delete mode 100644 test/core/support/percent_decode_corpus/26b0d1da23027ae54db96e125e4a9e98842d77fb delete mode 100644 test/core/support/percent_decode_corpus/2a089c0db45acdb4c6ed8e7ff81ca7235792c0b9 delete mode 100644 test/core/support/percent_decode_corpus/35b7b3bc3a740d5c3abca0d75b53f0e1e1ee998a delete mode 100644 test/core/support/percent_decode_corpus/36367ba1adba47a1cbc3a88707fde8cc7abdc248 delete mode 100644 test/core/support/percent_decode_corpus/39c2ba51548a0beaf0d6d1164531f1447dc311b5 delete mode 100644 test/core/support/percent_decode_corpus/56d08fea787c041395c6697ce26cfbc0decbe688 delete mode 100644 test/core/support/percent_decode_corpus/678d981fdabb9f0d6640235cf1719dd1e1e66ae9 delete mode 100644 test/core/support/percent_decode_corpus/68751961609ec010565de0aa87521dcbf0722c5d delete mode 100644 test/core/support/percent_decode_corpus/7875c06c6f03c9aa2f8e9c59f8d8957c8a32e759 delete mode 100644 test/core/support/percent_decode_corpus/7b302090e090a5829b6d1dd7be30bd4e36a7e60f delete mode 100644 test/core/support/percent_decode_corpus/875e1022169c9e4c541a9ad894e69e989df22ba1 delete mode 100644 test/core/support/percent_decode_corpus/8c1051ce066f5a26de9a9d133180621d0da957b4 delete mode 100644 test/core/support/percent_decode_corpus/8e084e628ab83a18ac7ca7cb3506525263655c63 delete mode 100644 test/core/support/percent_decode_corpus/9d316c4675f40ddccaf8f1cc7aea94170b1e4223 delete mode 100644 test/core/support/percent_decode_corpus/ad1c7c11d18a7d116e2c2ef4d4c5afb1270836ae delete mode 100644 test/core/support/percent_decode_corpus/b471f94aa4facf502e622e4a248f1ba4063ae681 delete mode 100644 test/core/support/percent_decode_corpus/bf52ece030f16136d46e0dc97f58d60a0d8a1f0b delete mode 100644 test/core/support/percent_decode_corpus/d5b2a7177339ba2b7ce2f60e5f4459bef1e72758 delete mode 100644 test/core/support/percent_decode_corpus/de867b64c54a7ed773dc611fc5cd2f17c5433113 delete mode 100644 test/core/support/percent_decode_corpus/e3948dbe004950591630dd5c52f4e0fcbd5e388a delete mode 100644 test/core/support/percent_decode_corpus/e7064f0b80f61dbc65915311032d27baa569ae2a delete mode 100644 test/core/support/percent_decode_corpus/xyz delete mode 100644 test/core/support/percent_decode_fuzzer.c delete mode 100644 test/core/support/percent_encode_corpus/0d3ee7fa54e6c66103965fd4409b044ba7db6c3f delete mode 100644 test/core/support/percent_encode_corpus/2e7ccf75e27b9501e3b28cf1c50ed0c45ab7c226 delete mode 100644 test/core/support/percent_encode_corpus/55bb859f3942c462b03b7cbcf22ab4a0ac9705cf delete mode 100644 test/core/support/percent_encode_corpus/56070cecd54c845b6d4334953b17b712eb000d93 delete mode 100644 test/core/support/percent_encode_corpus/61f50e891bf7ff5eb7a7af206f1e25d77f8756e7 delete mode 100644 test/core/support/percent_encode_corpus/6e0c60cefc704c7940e475a87dd9ae423061cb5a delete mode 100644 test/core/support/percent_encode_corpus/7271ebcc6d22a0f186f7bc3c1973a7ed1bec8d8e delete mode 100644 test/core/support/percent_encode_corpus/74c83ece3e2920a67593a9be9c82468f16cbb969 delete mode 100644 test/core/support/percent_encode_corpus/98e004fd2a9f141a7a019720820080e12d637c06 delete mode 100644 test/core/support/percent_encode_corpus/ba2c1e98227aa21ea3bb2ca4d0e504119717da8b delete mode 100644 test/core/support/percent_encode_corpus/c16b9fd45370d4afb5d3ebd307a6e263c25ffd45 delete mode 100644 test/core/support/percent_encode_corpus/d58c3cd4eab9b6d2343abfa1c25c90a383fe0ec3 delete mode 100644 test/core/support/percent_encode_corpus/e2619218ede30d2b7b8ecd601a9f0ae754b728b4 delete mode 100644 test/core/support/percent_encode_corpus/f93b3653e453f0e3eea3198001be6ce46e64bd21 delete mode 100644 test/core/support/percent_encode_corpus/fd41d029c7682ad3d1c40a9fd017a4c85b673a54 delete mode 100644 test/core/support/percent_encode_corpus/xyz delete mode 100644 test/core/support/percent_encode_fuzzer.c delete mode 100644 test/core/support/percent_encoding_test.c delete mode 100644 test/core/support/slice_buffer_test.c delete mode 100644 test/core/support/slice_test.c (limited to 'test/core/end2end/tests') diff --git a/Makefile b/Makefile index 19032419a6..c208c0b471 100644 --- a/Makefile +++ b/Makefile @@ -945,8 +945,8 @@ gpr_host_port_test: $(BINDIR)/$(CONFIG)/gpr_host_port_test gpr_log_test: $(BINDIR)/$(CONFIG)/gpr_log_test gpr_mpscq_test: $(BINDIR)/$(CONFIG)/gpr_mpscq_test gpr_percent_encoding_test: $(BINDIR)/$(CONFIG)/gpr_percent_encoding_test -gpr_slice_buffer_test: $(BINDIR)/$(CONFIG)/gpr_slice_buffer_test -gpr_slice_test: $(BINDIR)/$(CONFIG)/gpr_slice_test +grpc_slice_buffer_test: $(BINDIR)/$(CONFIG)/grpc_slice_buffer_test +grpc_slice_test: $(BINDIR)/$(CONFIG)/grpc_slice_test gpr_stack_lockfree_test: $(BINDIR)/$(CONFIG)/gpr_stack_lockfree_test gpr_string_test: $(BINDIR)/$(CONFIG)/gpr_string_test gpr_sync_test: $(BINDIR)/$(CONFIG)/gpr_sync_test @@ -1279,8 +1279,8 @@ buildtests_c: privatelibs_c \ $(BINDIR)/$(CONFIG)/gpr_log_test \ $(BINDIR)/$(CONFIG)/gpr_mpscq_test \ $(BINDIR)/$(CONFIG)/gpr_percent_encoding_test \ - $(BINDIR)/$(CONFIG)/gpr_slice_buffer_test \ - $(BINDIR)/$(CONFIG)/gpr_slice_test \ + $(BINDIR)/$(CONFIG)/grpc_slice_buffer_test \ + $(BINDIR)/$(CONFIG)/grpc_slice_test \ $(BINDIR)/$(CONFIG)/gpr_stack_lockfree_test \ $(BINDIR)/$(CONFIG)/gpr_string_test \ $(BINDIR)/$(CONFIG)/gpr_sync_test \ @@ -1631,10 +1631,10 @@ test_c: buildtests_c $(Q) $(BINDIR)/$(CONFIG)/gpr_mpscq_test || ( echo test gpr_mpscq_test failed ; exit 1 ) $(E) "[RUN] Testing gpr_percent_encoding_test" $(Q) $(BINDIR)/$(CONFIG)/gpr_percent_encoding_test || ( echo test gpr_percent_encoding_test failed ; exit 1 ) - $(E) "[RUN] Testing gpr_slice_buffer_test" - $(Q) $(BINDIR)/$(CONFIG)/gpr_slice_buffer_test || ( echo test gpr_slice_buffer_test failed ; exit 1 ) - $(E) "[RUN] Testing gpr_slice_test" - $(Q) $(BINDIR)/$(CONFIG)/gpr_slice_test || ( echo test gpr_slice_test failed ; exit 1 ) + $(E) "[RUN] Testing grpc_slice_buffer_test" + $(Q) $(BINDIR)/$(CONFIG)/grpc_slice_buffer_test || ( echo test grpc_slice_buffer_test failed ; exit 1 ) + $(E) "[RUN] Testing grpc_slice_test" + $(Q) $(BINDIR)/$(CONFIG)/grpc_slice_test || ( echo test grpc_slice_test failed ; exit 1 ) $(E) "[RUN] Testing gpr_stack_lockfree_test" $(Q) $(BINDIR)/$(CONFIG)/gpr_stack_lockfree_test || ( echo test gpr_stack_lockfree_test failed ; exit 1 ) $(E) "[RUN] Testing gpr_string_test" @@ -8288,22 +8288,22 @@ ifeq ($(NO_SECURE),true) # You can't build secure targets if you don't have OpenSSL. -$(BINDIR)/$(CONFIG)/gpr_slice_buffer_test: openssl_dep_error +$(BINDIR)/$(CONFIG)/grpc_slice_buffer_test: openssl_dep_error else -$(BINDIR)/$(CONFIG)/gpr_slice_buffer_test: $(GPR_SLICE_BUFFER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(BINDIR)/$(CONFIG)/grpc_slice_buffer_test: $(GPR_SLICE_BUFFER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_SLICE_BUFFER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_slice_buffer_test + $(Q) $(LD) $(LDFLAGS) $(GPR_SLICE_BUFFER_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_slice_buffer_test endif $(OBJDIR)/$(CONFIG)/test/core/support/slice_buffer_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a -deps_gpr_slice_buffer_test: $(GPR_SLICE_BUFFER_TEST_OBJS:.o=.dep) +deps_grpc_slice_buffer_test: $(GPR_SLICE_BUFFER_TEST_OBJS:.o=.dep) ifneq ($(NO_SECURE),true) ifneq ($(NO_DEPS),true) @@ -8320,22 +8320,22 @@ ifeq ($(NO_SECURE),true) # You can't build secure targets if you don't have OpenSSL. -$(BINDIR)/$(CONFIG)/gpr_slice_test: openssl_dep_error +$(BINDIR)/$(CONFIG)/grpc_slice_test: openssl_dep_error else -$(BINDIR)/$(CONFIG)/gpr_slice_test: $(GPR_SLICE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a +$(BINDIR)/$(CONFIG)/grpc_slice_test: $(GPR_SLICE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(E) "[LD] Linking $@" $(Q) mkdir -p `dirname $@` - $(Q) $(LD) $(LDFLAGS) $(GPR_SLICE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/gpr_slice_test + $(Q) $(LD) $(LDFLAGS) $(GPR_SLICE_TEST_OBJS) $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a $(LDLIBS) $(LDLIBS_SECURE) -o $(BINDIR)/$(CONFIG)/grpc_slice_test endif $(OBJDIR)/$(CONFIG)/test/core/support/slice_test.o: $(LIBDIR)/$(CONFIG)/libgpr_test_util.a $(LIBDIR)/$(CONFIG)/libgpr.a -deps_gpr_slice_test: $(GPR_SLICE_TEST_OBJS:.o=.dep) +deps_grpc_slice_test: $(GPR_SLICE_TEST_OBJS:.o=.dep) ifneq ($(NO_SECURE),true) ifneq ($(NO_DEPS),true) diff --git a/build.yaml b/build.yaml index c12595205d..d7cd82b9d9 100644 --- a/build.yaml +++ b/build.yaml @@ -64,8 +64,6 @@ filegroups: - include/grpc/support/log.h - include/grpc/support/log_windows.h - include/grpc/support/port_platform.h - - include/grpc/support/slice.h - - include/grpc/support/slice_buffer.h - include/grpc/support/string_util.h - include/grpc/support/subprocess.h - include/grpc/support/sync.h @@ -86,7 +84,6 @@ filegroups: - src/core/lib/support/env.h - src/core/lib/support/mpscq.h - src/core/lib/support/murmur_hash.h - - src/core/lib/support/percent_encoding.h - src/core/lib/support/stack_lockfree.h - src/core/lib/support/string.h - src/core/lib/support/string_windows.h @@ -116,9 +113,6 @@ filegroups: - src/core/lib/support/log_windows.c - src/core/lib/support/mpscq.c - src/core/lib/support/murmur_hash.c - - src/core/lib/support/percent_encoding.c - - src/core/lib/support/slice.c - - src/core/lib/support/slice_buffer.c - src/core/lib/support/stack_lockfree.c - src/core/lib/support/string.c - src/core/lib/support/string_posix.c @@ -165,6 +159,8 @@ filegroups: - include/grpc/grpc_posix.h - include/grpc/grpc_security_constants.h - include/grpc/status.h + - include/grpc/slice.h + - include/grpc/slice_buffer.h headers: - src/core/lib/channel/channel_args.h - src/core/lib/channel/channel_stack.h @@ -191,6 +187,7 @@ filegroups: - src/core/lib/iomgr/ev_epoll_linux.h - src/core/lib/iomgr/ev_poll_and_epoll_posix.h - src/core/lib/iomgr/ev_poll_posix.h + - src/core/lib/slice/percent_encoding.h - src/core/lib/iomgr/ev_posix.h - src/core/lib/iomgr/exec_ctx.h - src/core/lib/iomgr/executor.h @@ -204,6 +201,7 @@ filegroups: - src/core/lib/iomgr/pollset.h - src/core/lib/iomgr/pollset_set.h - src/core/lib/iomgr/pollset_set_windows.h + - src/core/lib/slice/slice_string_helpers.h - src/core/lib/iomgr/pollset_windows.h - src/core/lib/iomgr/resolve_address.h - src/core/lib/iomgr/resource_quota.h @@ -257,6 +255,10 @@ filegroups: - src/core/lib/channel/channel_stack.c - src/core/lib/channel/channel_stack_builder.c - src/core/lib/channel/compress_filter.c + - src/core/lib/slice/slice.c + - src/core/lib/slice/percent_encoding.c + - src/core/lib/slice/slice_buffer.c + - src/core/lib/slice/slice_string_helpers.c - src/core/lib/channel/connected_channel.c - src/core/lib/channel/deadline_filter.c - src/core/lib/channel/handshaker.c @@ -1748,19 +1750,19 @@ targets: deps: - gpr_test_util - gpr -- name: gpr_slice_buffer_test +- name: slice_buffer_test build: test language: c src: - - test/core/support/slice_buffer_test.c + - test/core/slice/slice_buffer_test.c deps: - gpr_test_util - gpr -- name: gpr_slice_test +- name: slice_test build: test language: c src: - - test/core/support/slice_test.c + - test/core/slice/slice_test.c deps: - gpr_test_util - gpr @@ -2313,27 +2315,27 @@ targets: build: fuzzer language: c src: - - test/core/support/percent_decode_fuzzer.c + - test/core/slice/percent_decode_fuzzer.c deps: - grpc_test_util - grpc - gpr_test_util - gpr corpus_dirs: - - test/core/support/percent_decode_corpus + - test/core/slice/percent_decode_corpus maxlen: 32 - name: percent_encode_fuzzer build: fuzzer language: c src: - - test/core/support/percent_encode_fuzzer.c + - test/core/slice/percent_encode_fuzzer.c deps: - grpc_test_util - grpc - gpr_test_util - gpr corpus_dirs: - - test/core/support/percent_encode_corpus + - test/core/slice/percent_encode_corpus maxlen: 32 - name: resolve_address_test build: test diff --git a/grpc.def b/grpc.def index 0b6db801d8..e2d6ce9b43 100644 --- a/grpc.def +++ b/grpc.def @@ -183,35 +183,35 @@ EXPORTS gpr_log_verbosity_init gpr_set_log_function gpr_format_message - gpr_slice_ref - gpr_slice_unref - gpr_slice_new - gpr_slice_new_with_user_data - gpr_slice_new_with_len - gpr_slice_malloc - gpr_slice_from_copied_string - gpr_slice_from_copied_buffer - gpr_slice_from_static_string - gpr_slice_sub - gpr_slice_sub_no_ref - gpr_slice_split_tail - gpr_slice_split_head + grpc_slice_ref + grpc_slice_unref + grpc_slice_new + grpc_slice_new_with_user_data + grpc_slice_new_with_len + grpc_slice_malloc + grpc_slice_from_copied_string + grpc_slice_from_copied_buffer + grpc_slice_from_static_string + grpc_slice_sub + grpc_slice_sub_no_ref + grpc_slice_split_tail + grpc_slice_split_head gpr_empty_slice - gpr_slice_cmp - gpr_slice_str_cmp - gpr_slice_buffer_init - gpr_slice_buffer_destroy - gpr_slice_buffer_add - gpr_slice_buffer_add_indexed - gpr_slice_buffer_addn - gpr_slice_buffer_tiny_add - gpr_slice_buffer_pop - gpr_slice_buffer_reset_and_unref - gpr_slice_buffer_swap - gpr_slice_buffer_move_into - gpr_slice_buffer_trim_end - gpr_slice_buffer_move_first - gpr_slice_buffer_take_first + grpc_slice_cmp + grpc_slice_str_cmp + grpc_slice_buffer_init + grpc_slice_buffer_destroy + grpc_slice_buffer_add + grpc_slice_buffer_add_indexed + grpc_slice_buffer_addn + grpc_slice_buffer_tiny_add + grpc_slice_buffer_pop + grpc_slice_buffer_reset_and_unref + grpc_slice_buffer_swap + grpc_slice_buffer_move_into + grpc_slice_buffer_trim_end + grpc_slice_buffer_move_first + grpc_slice_buffer_take_first gpr_strdup gpr_asprintf gpr_subprocess_binary_extension diff --git a/include/grpc++/impl/codegen/core_codegen.h b/include/grpc++/impl/codegen/core_codegen.h index 0ce009e69d..c2127a771a 100644 --- a/include/grpc++/impl/codegen/core_codegen.h +++ b/include/grpc++/impl/codegen/core_codegen.h @@ -73,17 +73,17 @@ class CoreCodegen : public CoreCodegenInterface { void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader* reader) GRPC_OVERRIDE; int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader, - gpr_slice* slice) GRPC_OVERRIDE; + grpc_slice* slice) GRPC_OVERRIDE; - grpc_byte_buffer* grpc_raw_byte_buffer_create(gpr_slice* slice, + grpc_byte_buffer* grpc_raw_byte_buffer_create(grpc_slice* slice, size_t nslices) GRPC_OVERRIDE; - gpr_slice gpr_slice_malloc(size_t length) GRPC_OVERRIDE; - void gpr_slice_unref(gpr_slice slice) GRPC_OVERRIDE; - gpr_slice gpr_slice_split_tail(gpr_slice* s, size_t split) GRPC_OVERRIDE; - void gpr_slice_buffer_add(gpr_slice_buffer* sb, - gpr_slice slice) GRPC_OVERRIDE; - void gpr_slice_buffer_pop(gpr_slice_buffer* sb) GRPC_OVERRIDE; + grpc_slice grpc_slice_malloc(size_t length) GRPC_OVERRIDE; + void grpc_slice_unref(grpc_slice slice) GRPC_OVERRIDE; + grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split) GRPC_OVERRIDE; + void grpc_slice_buffer_add(grpc_slice_buffer* sb, + grpc_slice slice) GRPC_OVERRIDE; + void grpc_slice_buffer_pop(grpc_slice_buffer* sb) GRPC_OVERRIDE; void grpc_metadata_array_init(grpc_metadata_array* array) GRPC_OVERRIDE; void grpc_metadata_array_destroy(grpc_metadata_array* array) GRPC_OVERRIDE; diff --git a/include/grpc++/impl/codegen/core_codegen_interface.h b/include/grpc++/impl/codegen/core_codegen_interface.h index 68851f15c6..743f528373 100644 --- a/include/grpc++/impl/codegen/core_codegen_interface.h +++ b/include/grpc++/impl/codegen/core_codegen_interface.h @@ -88,16 +88,16 @@ class CoreCodegenInterface { virtual void grpc_byte_buffer_reader_destroy( grpc_byte_buffer_reader* reader) = 0; virtual int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader, - gpr_slice* slice) = 0; + grpc_slice* slice) = 0; - virtual grpc_byte_buffer* grpc_raw_byte_buffer_create(gpr_slice* slice, + virtual grpc_byte_buffer* grpc_raw_byte_buffer_create(grpc_slice* slice, size_t nslices) = 0; - virtual gpr_slice gpr_slice_malloc(size_t length) = 0; - virtual void gpr_slice_unref(gpr_slice slice) = 0; - virtual gpr_slice gpr_slice_split_tail(gpr_slice* s, size_t split) = 0; - virtual void gpr_slice_buffer_add(gpr_slice_buffer* sb, gpr_slice slice) = 0; - virtual void gpr_slice_buffer_pop(gpr_slice_buffer* sb) = 0; + virtual grpc_slice grpc_slice_malloc(size_t length) = 0; + virtual void grpc_slice_unref(grpc_slice slice) = 0; + virtual grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split) = 0; + virtual void grpc_slice_buffer_add(grpc_slice_buffer* sb, grpc_slice slice) = 0; + virtual void grpc_slice_buffer_pop(grpc_slice_buffer* sb) = 0; virtual void grpc_metadata_array_init(grpc_metadata_array* array) = 0; virtual void grpc_metadata_array_destroy(grpc_metadata_array* array) = 0; diff --git a/include/grpc++/impl/codegen/proto_utils.h b/include/grpc++/impl/codegen/proto_utils.h index 6f4786b87b..4885ea0ee7 100644 --- a/include/grpc++/impl/codegen/proto_utils.h +++ b/include/grpc++/impl/codegen/proto_utils.h @@ -63,7 +63,7 @@ class GrpcBufferWriter GRPC_FINAL ~GrpcBufferWriter() GRPC_OVERRIDE { if (have_backup_) { - g_core_codegen_interface->gpr_slice_unref(backup_slice_); + g_core_codegen_interface->grpc_slice_unref(backup_slice_); } } @@ -72,24 +72,24 @@ class GrpcBufferWriter GRPC_FINAL slice_ = backup_slice_; have_backup_ = false; } else { - slice_ = g_core_codegen_interface->gpr_slice_malloc(block_size_); + slice_ = g_core_codegen_interface->grpc_slice_malloc(block_size_); } *data = GPR_SLICE_START_PTR(slice_); // On win x64, int is only 32bit GPR_CODEGEN_ASSERT(GPR_SLICE_LENGTH(slice_) <= INT_MAX); byte_count_ += * size = (int)GPR_SLICE_LENGTH(slice_); - g_core_codegen_interface->gpr_slice_buffer_add(slice_buffer_, slice_); + g_core_codegen_interface->grpc_slice_buffer_add(slice_buffer_, slice_); return true; } void BackUp(int count) GRPC_OVERRIDE { - g_core_codegen_interface->gpr_slice_buffer_pop(slice_buffer_); + g_core_codegen_interface->grpc_slice_buffer_pop(slice_buffer_); if (count == block_size_) { backup_slice_ = slice_; } else { - backup_slice_ = g_core_codegen_interface->gpr_slice_split_tail( + backup_slice_ = g_core_codegen_interface->grpc_slice_split_tail( &slice_, GPR_SLICE_LENGTH(slice_) - count); - g_core_codegen_interface->gpr_slice_buffer_add(slice_buffer_, slice_); + g_core_codegen_interface->grpc_slice_buffer_add(slice_buffer_, slice_); } have_backup_ = true; byte_count_ -= count; @@ -100,10 +100,10 @@ class GrpcBufferWriter GRPC_FINAL private: const int block_size_; int64_t byte_count_; - gpr_slice_buffer* slice_buffer_; + grpc_slice_buffer* slice_buffer_; bool have_backup_; - gpr_slice backup_slice_; - gpr_slice slice_; + grpc_slice backup_slice_; + grpc_slice slice_; }; class GrpcBufferReader GRPC_FINAL @@ -137,7 +137,7 @@ class GrpcBufferReader GRPC_FINAL &slice_)) { return false; } - g_core_codegen_interface->gpr_slice_unref(slice_); + g_core_codegen_interface->grpc_slice_unref(slice_); *data = GPR_SLICE_START_PTR(slice_); // On win x64, int is only 32bit GPR_CODEGEN_ASSERT(GPR_SLICE_LENGTH(slice_) <= INT_MAX); @@ -172,7 +172,7 @@ class GrpcBufferReader GRPC_FINAL int64_t byte_count_; int64_t backup_count_; grpc_byte_buffer_reader reader_; - gpr_slice slice_; + grpc_slice slice_; Status status_; }; } // namespace internal @@ -186,12 +186,12 @@ class SerializationTraitsgpr_slice_malloc(byte_size); + grpc_slice slice = g_core_codegen_interface->grpc_slice_malloc(byte_size); GPR_CODEGEN_ASSERT( GPR_SLICE_END_PTR(slice) == msg.SerializeWithCachedSizesToArray(GPR_SLICE_START_PTR(slice))); *bp = g_core_codegen_interface->grpc_raw_byte_buffer_create(&slice, 1); - g_core_codegen_interface->gpr_slice_unref(slice); + g_core_codegen_interface->grpc_slice_unref(slice); return g_core_codegen_interface->ok(); } else { internal::GrpcBufferWriter writer( diff --git a/include/grpc++/impl/codegen/thrift_serializer.h b/include/grpc++/impl/codegen/thrift_serializer.h index fd324a994f..691ce1af48 100644 --- a/include/grpc++/impl/codegen/thrift_serializer.h +++ b/include/grpc++/impl/codegen/thrift_serializer.h @@ -109,12 +109,12 @@ class ThriftSerializer { Serialize(fields, &byte_buffer, &byte_buffer_size); - gpr_slice slice = gpr_slice_from_copied_buffer( + grpc_slice slice = grpc_slice_from_copied_buffer( reinterpret_cast(byte_buffer), byte_buffer_size); *bp = grpc_raw_byte_buffer_create(&slice, 1); - gpr_slice_unref(slice); + grpc_slice_unref(slice); } // Deserialize the passed char array into the passed type, returns the number @@ -156,12 +156,12 @@ class ThriftSerializer { grpc_byte_buffer_reader reader; grpc_byte_buffer_reader_init(&reader, buffer); - gpr_slice slice = grpc_byte_buffer_reader_readall(&reader); + grpc_slice slice = grpc_byte_buffer_reader_readall(&reader); uint32_t len = Deserialize(GPR_SLICE_START_PTR(slice), GPR_SLICE_LENGTH(slice), msg); - gpr_slice_unref(slice); + grpc_slice_unref(slice); grpc_byte_buffer_reader_destroy(&reader); diff --git a/include/grpc++/support/slice.h b/include/grpc++/support/slice.h index 5874b4f5ae..b06b1b69e5 100644 --- a/include/grpc++/support/slice.h +++ b/include/grpc++/support/slice.h @@ -39,7 +39,7 @@ namespace grpc { -/// A wrapper around \a gpr_slice. +/// A wrapper around \a grpc_slice. /// /// A slice represents a contiguous reference counted array of bytes. /// It is cheap to take references to a slice, and it is cheap to create a @@ -53,11 +53,11 @@ class Slice GRPC_FINAL { enum AddRef { ADD_REF }; /// Construct a slice from \a slice, adding a reference. - Slice(gpr_slice slice, AddRef); + Slice(grpc_slice slice, AddRef); enum StealRef { STEAL_REF }; /// Construct a slice from \a slice, stealing a reference. - Slice(gpr_slice slice, StealRef); + Slice(grpc_slice slice, StealRef); /// Copy constructor, adds a reference. Slice(const Slice& other); @@ -77,13 +77,13 @@ class Slice GRPC_FINAL { /// Raw pointer to the end (one byte \em past the last element) of the slice. const uint8_t* end() const { return GPR_SLICE_END_PTR(slice_); } - /// Raw C slice. Caller needs to call gpr_slice_unref when done. - gpr_slice c_slice() const { return gpr_slice_ref(slice_); } + /// Raw C slice. Caller needs to call grpc_slice_unref when done. + grpc_slice c_slice() const { return grpc_slice_ref(slice_); } private: friend class ByteBuffer; - gpr_slice slice_; + grpc_slice slice_; }; } // namespace grpc diff --git a/include/grpc/byte_buffer.h b/include/grpc/byte_buffer.h index f25c1d51d6..3cf31df0df 100644 --- a/include/grpc/byte_buffer.h +++ b/include/grpc/byte_buffer.h @@ -45,7 +45,7 @@ extern "C" { * * Increases the reference count for all \a slices processed. The user is * responsible for invoking grpc_byte_buffer_destroy on the returned instance.*/ -GRPCAPI grpc_byte_buffer *grpc_raw_byte_buffer_create(gpr_slice *slices, +GRPCAPI grpc_byte_buffer *grpc_raw_byte_buffer_create(grpc_slice *slices, size_t nslices); /** Returns a *compressed* RAW byte buffer instance over the given slices (up to @@ -55,7 +55,7 @@ GRPCAPI grpc_byte_buffer *grpc_raw_byte_buffer_create(gpr_slice *slices, * Increases the reference count for all \a slices processed. The user is * responsible for invoking grpc_byte_buffer_destroy on the returned instance.*/ GRPCAPI grpc_byte_buffer *grpc_raw_compressed_byte_buffer_create( - gpr_slice *slices, size_t nslices, grpc_compression_algorithm compression); + grpc_slice *slices, size_t nslices, grpc_compression_algorithm compression); /** Copies input byte buffer \a bb. * @@ -83,12 +83,12 @@ GRPCAPI void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader); /** Updates \a slice with the next piece of data from from \a reader and returns * 1. Returns 0 at the end of the stream. Caller is responsible for calling - * gpr_slice_unref on the result. */ + * grpc_slice_unref on the result. */ GRPCAPI int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader, - gpr_slice *slice); + grpc_slice *slice); /** Merge all data from \a reader into single slice */ -GRPCAPI gpr_slice +GRPCAPI grpc_slice grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader *reader); /** Returns a RAW byte buffer instance from the output of \a reader. */ diff --git a/include/grpc/impl/codegen/gpr_types.h b/include/grpc/impl/codegen/gpr_types.h index c8f0815f0b..ed9976f429 100644 --- a/include/grpc/impl/codegen/gpr_types.h +++ b/include/grpc/impl/codegen/gpr_types.h @@ -68,71 +68,6 @@ typedef struct gpr_timespec { gpr_clock_type clock_type; } gpr_timespec; -/* Slice API - - A slice represents a contiguous reference counted array of bytes. - It is cheap to take references to a slice, and it is cheap to create a - slice pointing to a subset of another slice. - - The data-structure for slices is exposed here to allow non-gpr code to - build slices from whatever data they have available. - - When defining interfaces that handle slices, care should be taken to define - reference ownership semantics (who should call unref?) and mutability - constraints (is the callee allowed to modify the slice?) */ - -/* Reference count container for gpr_slice. Contains function pointers to - increment and decrement reference counts. Implementations should cleanup - when the reference count drops to zero. - Typically client code should not touch this, and use gpr_slice_malloc, - gpr_slice_new, or gpr_slice_new_with_len instead. */ -typedef struct gpr_slice_refcount { - void (*ref)(void *); - void (*unref)(void *); -} gpr_slice_refcount; - -#define GPR_SLICE_INLINED_SIZE (sizeof(size_t) + sizeof(uint8_t *) - 1) - -/* A gpr_slice s, if initialized, represents the byte range - s.bytes[0..s.length-1]. - - It can have an associated ref count which has a destruction routine to be run - when the ref count reaches zero (see gpr_slice_new() and grp_slice_unref()). - Multiple gpr_slice values may share a ref count. - - If the slice does not have a refcount, it represents an inlined small piece - of data that is copied by value. */ -typedef struct gpr_slice { - struct gpr_slice_refcount *refcount; - union { - struct { - uint8_t *bytes; - size_t length; - } refcounted; - struct { - uint8_t length; - uint8_t bytes[GPR_SLICE_INLINED_SIZE]; - } inlined; - } data; -} gpr_slice; - -#define GRPC_SLICE_BUFFER_INLINE_ELEMENTS 8 - -/* Represents an expandable array of slices, to be interpreted as a - single item. */ -typedef struct { - /* slices in the array */ - gpr_slice *slices; - /* the number of slices in the array */ - size_t count; - /* the number of slices allocated in the array */ - size_t capacity; - /* the combined length of all slices in the array */ - size_t length; - /* inlined elements to avoid allocations */ - gpr_slice inlined[GRPC_SLICE_BUFFER_INLINE_ELEMENTS]; -} gpr_slice_buffer; - #ifdef __cplusplus } #endif diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index d2dce0d511..cbd484ba33 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -35,6 +35,7 @@ #define GRPC_IMPL_CODEGEN_GRPC_TYPES_H #include +#include #include #include @@ -60,7 +61,7 @@ typedef struct grpc_byte_buffer { } reserved; struct { grpc_compression_algorithm compression; - gpr_slice_buffer slice_buffer; + grpc_slice_buffer slice_buffer; } raw; } data; } grpc_byte_buffer; diff --git a/include/grpc/impl/codegen/slice.h b/include/grpc/impl/codegen/slice.h index a2637eea62..79297ce23d 100644 --- a/include/grpc/impl/codegen/slice.h +++ b/include/grpc/impl/codegen/slice.h @@ -35,6 +35,72 @@ #define GRPC_IMPL_CODEGEN_SLICE_H #include +#include + +/* Slice API + + A slice represents a contiguous reference counted array of bytes. + It is cheap to take references to a slice, and it is cheap to create a + slice pointing to a subset of another slice. + + The data-structure for slices is exposed here to allow non-gpr code to + build slices from whatever data they have available. + + When defining interfaces that handle slices, care should be taken to define + reference ownership semantics (who should call unref?) and mutability + constraints (is the callee allowed to modify the slice?) */ + +/* Reference count container for grpc_slice. Contains function pointers to + increment and decrement reference counts. Implementations should cleanup + when the reference count drops to zero. + Typically client code should not touch this, and use grpc_slice_malloc, + grpc_slice_new, or grpc_slice_new_with_len instead. */ +typedef struct grpc_slice_refcount { + void (*ref)(void *); + void (*unref)(void *); +} grpc_slice_refcount; + +#define GPR_SLICE_INLINED_SIZE (sizeof(size_t) + sizeof(uint8_t *) - 1) + +/* A grpc_slice s, if initialized, represents the byte range + s.bytes[0..s.length-1]. + + It can have an associated ref count which has a destruction routine to be run + when the ref count reaches zero (see grpc_slice_new() and grp_slice_unref()). + Multiple grpc_slice values may share a ref count. + + If the slice does not have a refcount, it represents an inlined small piece + of data that is copied by value. */ +typedef struct grpc_slice { + struct grpc_slice_refcount *refcount; + union { + struct { + uint8_t *bytes; + size_t length; + } refcounted; + struct { + uint8_t length; + uint8_t bytes[GPR_SLICE_INLINED_SIZE]; + } inlined; + } data; +} grpc_slice; + +#define GRPC_SLICE_BUFFER_INLINE_ELEMENTS 8 + +/* Represents an expandable array of slices, to be interpreted as a + single item. */ +typedef struct { + /* slices in the array */ + grpc_slice *slices; + /* the number of slices in the array */ + size_t count; + /* the number of slices allocated in the array */ + size_t capacity; + /* the combined length of all slices in the array */ + size_t length; + /* inlined elements to avoid allocations */ + grpc_slice inlined[GRPC_SLICE_BUFFER_INLINE_ELEMENTS]; +} grpc_slice_buffer; #define GPR_SLICE_START_PTR(slice) \ ((slice).refcount ? (slice).data.refcounted.bytes \ diff --git a/include/grpc/slice.h b/include/grpc/slice.h new file mode 100644 index 0000000000..5953e0ccb7 --- /dev/null +++ b/include/grpc/slice.h @@ -0,0 +1,128 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_SUPPORT_SLICE_H +#define GRPC_SUPPORT_SLICE_H + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Increment the refcount of s. Requires slice is initialized. + Returns s. */ +GPRAPI grpc_slice grpc_slice_ref(grpc_slice s); + +/* Decrement the ref count of s. If the ref count of s reaches zero, all + slices sharing the ref count are destroyed, and considered no longer + initialized. If s is ultimately derived from a call to grpc_slice_new(start, + len, dest) where dest!=NULL , then (*dest)(start) is called, else if s is + ultimately derived from a call to grpc_slice_new_with_len(start, len, dest) + where dest!=NULL , then (*dest)(start, len). Requires s initialized. */ +GPRAPI void grpc_slice_unref(grpc_slice s); + +/* Create a slice pointing at some data. Calls malloc to allocate a refcount + for the object, and arranges that destroy will be called with the pointer + passed in at destruction. */ +GPRAPI grpc_slice grpc_slice_new(void *p, size_t len, void (*destroy)(void *)); + +/* Equivalent to grpc_slice_new, but with a separate pointer that is + passed to the destroy function. This function can be useful when + the data is part of a larger structure that must be destroyed when + the data is no longer needed. */ +GPRAPI grpc_slice grpc_slice_new_with_user_data(void *p, size_t len, + void (*destroy)(void *), + void *user_data); + +/* Equivalent to grpc_slice_new, but with a two argument destroy function that + also takes the slice length. */ +GPRAPI grpc_slice grpc_slice_new_with_len(void *p, size_t len, + void (*destroy)(void *, size_t)); + +/* Equivalent to grpc_slice_new(malloc(len), len, free), but saves one malloc() + call. + Aborts if malloc() fails. */ +GPRAPI grpc_slice grpc_slice_malloc(size_t length); + +/* Create a slice by copying a string. + Does not preserve null terminators. + Equivalent to: + size_t len = strlen(source); + grpc_slice slice = grpc_slice_malloc(len); + memcpy(slice->data, source, len); */ +GPRAPI grpc_slice grpc_slice_from_copied_string(const char *source); + +/* Create a slice by copying a buffer. + Equivalent to: + grpc_slice slice = grpc_slice_malloc(len); + memcpy(slice->data, source, len); */ +GPRAPI grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len); + +/* Create a slice pointing to constant memory */ +GPRAPI grpc_slice grpc_slice_from_static_string(const char *source); + +/* Return a result slice derived from s, which shares a ref count with s, where + result.data==s.data+begin, and result.length==end-begin. + The ref count of s is increased by one. + Requires s initialized, begin <= end, begin <= s.length, and + end <= source->length. */ +GPRAPI grpc_slice grpc_slice_sub(grpc_slice s, size_t begin, size_t end); + +/* The same as grpc_slice_sub, but without altering the ref count */ +GPRAPI grpc_slice grpc_slice_sub_no_ref(grpc_slice s, size_t begin, size_t end); + +/* Splits s into two: modifies s to be s[0:split], and returns a new slice, + sharing a refcount with s, that contains s[split:s.length]. + Requires s intialized, split <= s.length */ +GPRAPI grpc_slice grpc_slice_split_tail(grpc_slice *s, size_t split); + +/* Splits s into two: modifies s to be s[split:s.length], and returns a new + slice, sharing a refcount with s, that contains s[0:split]. + Requires s intialized, split <= s.length */ +GPRAPI grpc_slice grpc_slice_split_head(grpc_slice *s, size_t split); + +GPRAPI grpc_slice gpr_empty_slice(void); + +/* Returns <0 if a < b, ==0 if a == b, >0 if a > b + The order is arbitrary, and is not guaranteed to be stable across different + versions of the API. */ +GPRAPI int grpc_slice_cmp(grpc_slice a, grpc_slice b); +GPRAPI int grpc_slice_str_cmp(grpc_slice a, const char *b); + +#ifdef __cplusplus +} +#endif + +#endif /* GRPC_SUPPORT_SLICE_H */ diff --git a/include/grpc/slice_buffer.h b/include/grpc/slice_buffer.h new file mode 100644 index 0000000000..bff0d76914 --- /dev/null +++ b/include/grpc/slice_buffer.h @@ -0,0 +1,87 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_SUPPORT_SLICE_BUFFER_H +#define GRPC_SUPPORT_SLICE_BUFFER_H + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* initialize a slice buffer */ +GPRAPI void grpc_slice_buffer_init(grpc_slice_buffer *sb); +/* destroy a slice buffer - unrefs any held elements */ +GPRAPI void grpc_slice_buffer_destroy(grpc_slice_buffer *sb); +/* Add an element to a slice buffer - takes ownership of the slice. + This function is allowed to concatenate the passed in slice to the end of + some other slice if desired by the slice buffer. */ +GPRAPI void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice slice); +/* add an element to a slice buffer - takes ownership of the slice and returns + the index of the slice. + Guarantees that the slice will not be concatenated at the end of another + slice (i.e. the data for this slice will begin at the first byte of the + slice at the returned index in sb->slices) + The implementation MAY decide to concatenate data at the end of a small + slice added in this fashion. */ +GPRAPI size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer *sb, + grpc_slice slice); +GPRAPI void grpc_slice_buffer_addn(grpc_slice_buffer *sb, grpc_slice *slices, + size_t n); +/* add a very small (less than 8 bytes) amount of data to the end of a slice + buffer: returns a pointer into which to add the data */ +GPRAPI uint8_t *grpc_slice_buffer_tiny_add(grpc_slice_buffer *sb, size_t len); +/* pop the last buffer, but don't unref it */ +GPRAPI void grpc_slice_buffer_pop(grpc_slice_buffer *sb); +/* clear a slice buffer, unref all elements */ +GPRAPI void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer *sb); +/* swap the contents of two slice buffers */ +GPRAPI void grpc_slice_buffer_swap(grpc_slice_buffer *a, grpc_slice_buffer *b); +/* move all of the elements of src into dst */ +GPRAPI void grpc_slice_buffer_move_into(grpc_slice_buffer *src, + grpc_slice_buffer *dst); +/* remove n bytes from the end of a slice buffer */ +GPRAPI void grpc_slice_buffer_trim_end(grpc_slice_buffer *src, size_t n, + grpc_slice_buffer *garbage); +/* move the first n bytes of src into dst */ +GPRAPI void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n, + grpc_slice_buffer *dst); +/* take the first slice in the slice buffer */ +GPRAPI grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer *src); + +#ifdef __cplusplus +} +#endif + +#endif /* GRPC_SUPPORT_SLICE_BUFFER_H */ diff --git a/include/grpc/support/slice.h b/include/grpc/support/slice.h deleted file mode 100644 index b31fe6c0c5..0000000000 --- a/include/grpc/support/slice.h +++ /dev/null @@ -1,128 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPC_SUPPORT_SLICE_H -#define GRPC_SUPPORT_SLICE_H - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* Increment the refcount of s. Requires slice is initialized. - Returns s. */ -GPRAPI gpr_slice gpr_slice_ref(gpr_slice s); - -/* Decrement the ref count of s. If the ref count of s reaches zero, all - slices sharing the ref count are destroyed, and considered no longer - initialized. If s is ultimately derived from a call to gpr_slice_new(start, - len, dest) where dest!=NULL , then (*dest)(start) is called, else if s is - ultimately derived from a call to gpr_slice_new_with_len(start, len, dest) - where dest!=NULL , then (*dest)(start, len). Requires s initialized. */ -GPRAPI void gpr_slice_unref(gpr_slice s); - -/* Create a slice pointing at some data. Calls malloc to allocate a refcount - for the object, and arranges that destroy will be called with the pointer - passed in at destruction. */ -GPRAPI gpr_slice gpr_slice_new(void *p, size_t len, void (*destroy)(void *)); - -/* Equivalent to gpr_slice_new, but with a separate pointer that is - passed to the destroy function. This function can be useful when - the data is part of a larger structure that must be destroyed when - the data is no longer needed. */ -GPRAPI gpr_slice gpr_slice_new_with_user_data(void *p, size_t len, - void (*destroy)(void *), - void *user_data); - -/* Equivalent to gpr_slice_new, but with a two argument destroy function that - also takes the slice length. */ -GPRAPI gpr_slice gpr_slice_new_with_len(void *p, size_t len, - void (*destroy)(void *, size_t)); - -/* Equivalent to gpr_slice_new(malloc(len), len, free), but saves one malloc() - call. - Aborts if malloc() fails. */ -GPRAPI gpr_slice gpr_slice_malloc(size_t length); - -/* Create a slice by copying a string. - Does not preserve null terminators. - Equivalent to: - size_t len = strlen(source); - gpr_slice slice = gpr_slice_malloc(len); - memcpy(slice->data, source, len); */ -GPRAPI gpr_slice gpr_slice_from_copied_string(const char *source); - -/* Create a slice by copying a buffer. - Equivalent to: - gpr_slice slice = gpr_slice_malloc(len); - memcpy(slice->data, source, len); */ -GPRAPI gpr_slice gpr_slice_from_copied_buffer(const char *source, size_t len); - -/* Create a slice pointing to constant memory */ -GPRAPI gpr_slice gpr_slice_from_static_string(const char *source); - -/* Return a result slice derived from s, which shares a ref count with s, where - result.data==s.data+begin, and result.length==end-begin. - The ref count of s is increased by one. - Requires s initialized, begin <= end, begin <= s.length, and - end <= source->length. */ -GPRAPI gpr_slice gpr_slice_sub(gpr_slice s, size_t begin, size_t end); - -/* The same as gpr_slice_sub, but without altering the ref count */ -GPRAPI gpr_slice gpr_slice_sub_no_ref(gpr_slice s, size_t begin, size_t end); - -/* Splits s into two: modifies s to be s[0:split], and returns a new slice, - sharing a refcount with s, that contains s[split:s.length]. - Requires s intialized, split <= s.length */ -GPRAPI gpr_slice gpr_slice_split_tail(gpr_slice *s, size_t split); - -/* Splits s into two: modifies s to be s[split:s.length], and returns a new - slice, sharing a refcount with s, that contains s[0:split]. - Requires s intialized, split <= s.length */ -GPRAPI gpr_slice gpr_slice_split_head(gpr_slice *s, size_t split); - -GPRAPI gpr_slice gpr_empty_slice(void); - -/* Returns <0 if a < b, ==0 if a == b, >0 if a > b - The order is arbitrary, and is not guaranteed to be stable across different - versions of the API. */ -GPRAPI int gpr_slice_cmp(gpr_slice a, gpr_slice b); -GPRAPI int gpr_slice_str_cmp(gpr_slice a, const char *b); - -#ifdef __cplusplus -} -#endif - -#endif /* GRPC_SUPPORT_SLICE_H */ diff --git a/include/grpc/support/slice_buffer.h b/include/grpc/support/slice_buffer.h deleted file mode 100644 index 3920432b02..0000000000 --- a/include/grpc/support/slice_buffer.h +++ /dev/null @@ -1,87 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPC_SUPPORT_SLICE_BUFFER_H -#define GRPC_SUPPORT_SLICE_BUFFER_H - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/* initialize a slice buffer */ -GPRAPI void gpr_slice_buffer_init(gpr_slice_buffer *sb); -/* destroy a slice buffer - unrefs any held elements */ -GPRAPI void gpr_slice_buffer_destroy(gpr_slice_buffer *sb); -/* Add an element to a slice buffer - takes ownership of the slice. - This function is allowed to concatenate the passed in slice to the end of - some other slice if desired by the slice buffer. */ -GPRAPI void gpr_slice_buffer_add(gpr_slice_buffer *sb, gpr_slice slice); -/* add an element to a slice buffer - takes ownership of the slice and returns - the index of the slice. - Guarantees that the slice will not be concatenated at the end of another - slice (i.e. the data for this slice will begin at the first byte of the - slice at the returned index in sb->slices) - The implementation MAY decide to concatenate data at the end of a small - slice added in this fashion. */ -GPRAPI size_t gpr_slice_buffer_add_indexed(gpr_slice_buffer *sb, - gpr_slice slice); -GPRAPI void gpr_slice_buffer_addn(gpr_slice_buffer *sb, gpr_slice *slices, - size_t n); -/* add a very small (less than 8 bytes) amount of data to the end of a slice - buffer: returns a pointer into which to add the data */ -GPRAPI uint8_t *gpr_slice_buffer_tiny_add(gpr_slice_buffer *sb, size_t len); -/* pop the last buffer, but don't unref it */ -GPRAPI void gpr_slice_buffer_pop(gpr_slice_buffer *sb); -/* clear a slice buffer, unref all elements */ -GPRAPI void gpr_slice_buffer_reset_and_unref(gpr_slice_buffer *sb); -/* swap the contents of two slice buffers */ -GPRAPI void gpr_slice_buffer_swap(gpr_slice_buffer *a, gpr_slice_buffer *b); -/* move all of the elements of src into dst */ -GPRAPI void gpr_slice_buffer_move_into(gpr_slice_buffer *src, - gpr_slice_buffer *dst); -/* remove n bytes from the end of a slice buffer */ -GPRAPI void gpr_slice_buffer_trim_end(gpr_slice_buffer *src, size_t n, - gpr_slice_buffer *garbage); -/* move the first n bytes of src into dst */ -GPRAPI void gpr_slice_buffer_move_first(gpr_slice_buffer *src, size_t n, - gpr_slice_buffer *dst); -/* take the first slice in the slice buffer */ -GPRAPI gpr_slice gpr_slice_buffer_take_first(gpr_slice_buffer *src); - -#ifdef __cplusplus -} -#endif - -#endif /* GRPC_SUPPORT_SLICE_BUFFER_H */ diff --git a/src/core/ext/client_channel/connector.h b/src/core/ext/client_channel/connector.h index e08244b2c0..3c2cf7877f 100644 --- a/src/core/ext/client_channel/connector.h +++ b/src/core/ext/client_channel/connector.h @@ -52,7 +52,7 @@ typedef struct { const struct sockaddr *addr; size_t addr_len; /** initial connect string to send */ - gpr_slice initial_connect_string; + grpc_slice initial_connect_string; /** deadline for connection */ gpr_timespec deadline; /** channel arguments (to be passed to transport) */ diff --git a/src/core/ext/client_channel/default_initial_connect_string.c b/src/core/ext/client_channel/default_initial_connect_string.c index a70da4a84a..784173f0e2 100644 --- a/src/core/ext/client_channel/default_initial_connect_string.c +++ b/src/core/ext/client_channel/default_initial_connect_string.c @@ -36,4 +36,4 @@ void grpc_set_default_initial_connect_string(struct sockaddr **addr, size_t *addr_len, - gpr_slice *initial_str) {} + grpc_slice *initial_str) {} diff --git a/src/core/ext/client_channel/http_connect_handshaker.c b/src/core/ext/client_channel/http_connect_handshaker.c index ea2cbbdd97..9c175af09a 100644 --- a/src/core/ext/client_channel/http_connect_handshaker.c +++ b/src/core/ext/client_channel/http_connect_handshaker.c @@ -60,8 +60,8 @@ typedef struct http_connect_handshaker { void* user_data; // Objects for processing the HTTP CONNECT request and response. - gpr_slice_buffer write_buffer; - gpr_slice_buffer* read_buffer; // Ownership passes through this object. + grpc_slice_buffer write_buffer; + grpc_slice_buffer* read_buffer; // Ownership passes through this object. grpc_closure request_done_closure; grpc_closure response_read_closure; grpc_http_parser http_parser; @@ -76,7 +76,7 @@ static void http_connect_handshaker_unref(http_connect_handshaker* handshaker) { if (gpr_unref(&handshaker->refcount)) { gpr_free(handshaker->proxy_server); gpr_free(handshaker->server_name); - gpr_slice_buffer_destroy(&handshaker->write_buffer); + grpc_slice_buffer_destroy(&handshaker->write_buffer); grpc_http_parser_destroy(&handshaker->http_parser); grpc_http_response_destroy(&handshaker->http_response); gpr_free(handshaker); @@ -129,20 +129,20 @@ static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_timer_cancel(exec_ctx, &handshaker->timeout_timer); // Remove the data we've already read from the read buffer, // leaving only the leftover bytes (if any). - gpr_slice_buffer tmp_buffer; - gpr_slice_buffer_init(&tmp_buffer); + grpc_slice_buffer tmp_buffer; + grpc_slice_buffer_init(&tmp_buffer); if (body_start_offset < GPR_SLICE_LENGTH(handshaker->read_buffer->slices[i])) { - gpr_slice_buffer_add( + grpc_slice_buffer_add( &tmp_buffer, - gpr_slice_split_tail(&handshaker->read_buffer->slices[i], + grpc_slice_split_tail(&handshaker->read_buffer->slices[i], body_start_offset)); } - gpr_slice_buffer_addn(&tmp_buffer, + grpc_slice_buffer_addn(&tmp_buffer, &handshaker->read_buffer->slices[i + 1], handshaker->read_buffer->count - i - 1); - gpr_slice_buffer_swap(handshaker->read_buffer, &tmp_buffer); - gpr_slice_buffer_destroy(&tmp_buffer); + grpc_slice_buffer_swap(handshaker->read_buffer, &tmp_buffer); + grpc_slice_buffer_destroy(&tmp_buffer); break; } } @@ -159,7 +159,7 @@ static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg, // complete (e.g., handling chunked transfer encoding or looking // at the Content-Length: header). if (handshaker->http_parser.state != GRPC_HTTP_BODY) { - gpr_slice_buffer_reset_and_unref(handshaker->read_buffer); + grpc_slice_buffer_reset_and_unref(handshaker->read_buffer); grpc_endpoint_read(exec_ctx, handshaker->endpoint, handshaker->read_buffer, &handshaker->response_read_closure); return; @@ -195,7 +195,7 @@ static void http_connect_handshaker_shutdown(grpc_exec_ctx* exec_ctx, static void http_connect_handshaker_do_handshake( grpc_exec_ctx* exec_ctx, grpc_handshaker* handshaker_in, grpc_endpoint* endpoint, grpc_channel_args* args, - gpr_slice_buffer* read_buffer, gpr_timespec deadline, + grpc_slice_buffer* read_buffer, gpr_timespec deadline, grpc_tcp_server_acceptor* acceptor, grpc_handshaker_done_cb cb, void* user_data) { http_connect_handshaker* handshaker = (http_connect_handshaker*)handshaker_in; @@ -214,8 +214,8 @@ static void http_connect_handshaker_do_handshake( request.http.method = "CONNECT"; request.http.path = handshaker->server_name; request.handshaker = &grpc_httpcli_plaintext; - gpr_slice request_slice = grpc_httpcli_format_connect_request(&request); - gpr_slice_buffer_add(&handshaker->write_buffer, request_slice); + grpc_slice request_slice = grpc_httpcli_format_connect_request(&request); + grpc_slice_buffer_add(&handshaker->write_buffer, request_slice); grpc_endpoint_write(exec_ctx, endpoint, &handshaker->write_buffer, &handshaker->request_done_closure); // Set timeout timer. The timer gets a reference to the handshaker. @@ -239,7 +239,7 @@ grpc_handshaker* grpc_http_connect_handshaker_create(const char* proxy_server, grpc_handshaker_init(&http_connect_handshaker_vtable, &handshaker->base); handshaker->proxy_server = gpr_strdup(proxy_server); handshaker->server_name = gpr_strdup(server_name); - gpr_slice_buffer_init(&handshaker->write_buffer); + grpc_slice_buffer_init(&handshaker->write_buffer); grpc_closure_init(&handshaker->request_done_closure, on_write_done, handshaker); grpc_closure_init(&handshaker->response_read_closure, on_read_done, diff --git a/src/core/ext/client_channel/initial_connect_string.c b/src/core/ext/client_channel/initial_connect_string.c index fd8ddb83a8..8737b330a8 100644 --- a/src/core/ext/client_channel/initial_connect_string.c +++ b/src/core/ext/client_channel/initial_connect_string.c @@ -37,7 +37,7 @@ extern void grpc_set_default_initial_connect_string(struct sockaddr **addr, size_t *addr_len, - gpr_slice *initial_str); + grpc_slice *initial_str); static grpc_set_initial_connect_string_func g_set_initial_connect_string_func = grpc_set_default_initial_connect_string; @@ -48,6 +48,6 @@ void grpc_test_set_initial_connect_string_function( } void grpc_set_initial_connect_string(struct sockaddr **addr, size_t *addr_len, - gpr_slice *initial_str) { + grpc_slice *initial_str) { g_set_initial_connect_string_func(addr, addr_len, initial_str); } diff --git a/src/core/ext/client_channel/initial_connect_string.h b/src/core/ext/client_channel/initial_connect_string.h index 39f6465fc9..4cfe8b5fe7 100644 --- a/src/core/ext/client_channel/initial_connect_string.h +++ b/src/core/ext/client_channel/initial_connect_string.h @@ -39,12 +39,12 @@ typedef void (*grpc_set_initial_connect_string_func)(struct sockaddr **addr, size_t *addr_len, - gpr_slice *initial_str); + grpc_slice *initial_str); void grpc_test_set_initial_connect_string_function( grpc_set_initial_connect_string_func func); /** Set a string to be sent once connected. Optionally reset addr. */ void grpc_set_initial_connect_string(struct sockaddr **addr, size_t *addr_len, - gpr_slice *connect_string); + grpc_slice *connect_string); #endif /* GRPC_CORE_EXT_CLIENT_CHANNEL_INITIAL_CONNECT_STRING_H */ diff --git a/src/core/ext/client_channel/subchannel.c b/src/core/ext/client_channel/subchannel.c index 672e5c3a91..8d4a457e60 100644 --- a/src/core/ext/client_channel/subchannel.c +++ b/src/core/ext/client_channel/subchannel.c @@ -101,7 +101,7 @@ struct grpc_subchannel { grpc_subchannel_key *key; /** initial string to send to peer */ - gpr_slice initial_connect_string; + grpc_slice initial_connect_string; /** set during connection */ grpc_connect_out_args connecting_result; @@ -206,7 +206,7 @@ static void subchannel_destroy(grpc_exec_ctx *exec_ctx, void *arg, gpr_free((void *)c->filters); grpc_channel_args_destroy(c->args); gpr_free(c->addr); - gpr_slice_unref(c->initial_connect_string); + grpc_slice_unref(c->initial_connect_string); grpc_connectivity_state_destroy(exec_ctx, &c->state_tracker); grpc_connector_unref(exec_ctx, c->connector); grpc_pollset_set_destroy(c->pollset_set); diff --git a/src/core/ext/client_channel/uri_parser.c b/src/core/ext/client_channel/uri_parser.c index bcb6a1dee4..7bdc5373d9 100644 --- a/src/core/ext/client_channel/uri_parser.c +++ b/src/core/ext/client_channel/uri_parser.c @@ -148,20 +148,20 @@ static void parse_query_parts(grpc_uri *uri) { uri->num_query_parts = 0; return; } - gpr_slice query_slice = - gpr_slice_new(uri->query, strlen(uri->query), do_nothing); - gpr_slice_buffer query_parts; /* the &-separated elements of the query */ - gpr_slice_buffer query_param_parts; /* the =-separated subelements */ + grpc_slice query_slice = + grpc_slice_new(uri->query, strlen(uri->query), do_nothing); + grpc_slice_buffer query_parts; /* the &-separated elements of the query */ + grpc_slice_buffer query_param_parts; /* the =-separated subelements */ - gpr_slice_buffer_init(&query_parts); - gpr_slice_buffer_init(&query_param_parts); + grpc_slice_buffer_init(&query_parts); + grpc_slice_buffer_init(&query_param_parts); - gpr_slice_split(query_slice, QUERY_PARTS_SEPARATOR, &query_parts); + grpc_slice_split(query_slice, QUERY_PARTS_SEPARATOR, &query_parts); uri->query_parts = gpr_malloc(query_parts.count * sizeof(char *)); uri->query_parts_values = gpr_malloc(query_parts.count * sizeof(char *)); uri->num_query_parts = query_parts.count; for (size_t i = 0; i < query_parts.count; i++) { - gpr_slice_split(query_parts.slices[i], QUERY_PARTS_VALUE_SEPARATOR, + grpc_slice_split(query_parts.slices[i], QUERY_PARTS_VALUE_SEPARATOR, &query_param_parts); GPR_ASSERT(query_param_parts.count > 0); uri->query_parts[i] = @@ -175,11 +175,11 @@ static void parse_query_parts(grpc_uri *uri) { } else { uri->query_parts_values[i] = NULL; } - gpr_slice_buffer_reset_and_unref(&query_param_parts); + grpc_slice_buffer_reset_and_unref(&query_param_parts); } - gpr_slice_buffer_destroy(&query_parts); - gpr_slice_buffer_destroy(&query_param_parts); - gpr_slice_unref(query_slice); + grpc_slice_buffer_destroy(&query_parts); + grpc_slice_buffer_destroy(&query_param_parts); + grpc_slice_unref(query_slice); } grpc_uri *grpc_uri_parse(const char *uri_text, int suppress_errors) { diff --git a/src/core/ext/lb_policy/grpclb/grpclb.c b/src/core/ext/lb_policy/grpclb/grpclb.c index 412090158a..3c2b87f2cb 100644 --- a/src/core/ext/lb_policy/grpclb/grpclb.c +++ b/src/core/ext/lb_policy/grpclb/grpclb.c @@ -952,10 +952,10 @@ static lb_client_data *lb_client_data_create(glb_lb_policy *glb_policy) { grpc_grpclb_request *request = grpc_grpclb_request_create(glb_policy->server_name); - gpr_slice request_payload_slice = grpc_grpclb_request_encode(request); + grpc_slice request_payload_slice = grpc_grpclb_request_encode(request); lb_client->request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - gpr_slice_unref(request_payload_slice); + grpc_slice_unref(request_payload_slice); grpc_grpclb_request_destroy(request); lb_client->status_details = NULL; @@ -1072,12 +1072,12 @@ static void res_recv_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { * lb_client->response_payload, for a serverlist. */ grpc_byte_buffer_reader bbr; grpc_byte_buffer_reader_init(&bbr, lb_client->response_payload); - gpr_slice response_slice = grpc_byte_buffer_reader_readall(&bbr); + grpc_slice response_slice = grpc_byte_buffer_reader_readall(&bbr); grpc_byte_buffer_destroy(lb_client->response_payload); grpc_grpclb_serverlist *serverlist = grpc_grpclb_response_parse_serverlist(response_slice); if (serverlist != NULL) { - gpr_slice_unref(response_slice); + grpc_slice_unref(response_slice); if (grpc_lb_glb_trace) { gpr_log(GPR_INFO, "Serverlist with %lu servers received", (unsigned long)serverlist->num_servers); @@ -1136,7 +1136,7 @@ static void res_recv_cb(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { GPR_ASSERT(serverlist == NULL); gpr_log(GPR_ERROR, "Invalid LB response received: '%s'", gpr_dump_slice(response_slice, GPR_DUMP_ASCII)); - gpr_slice_unref(response_slice); + grpc_slice_unref(response_slice); /* Disconnect from server returning invalid response. */ op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; diff --git a/src/core/ext/lb_policy/grpclb/load_balancer_api.c b/src/core/ext/lb_policy/grpclb/load_balancer_api.c index a8881004a0..f3860d119d 100644 --- a/src/core/ext/lb_policy/grpclb/load_balancer_api.c +++ b/src/core/ext/lb_policy/grpclb/load_balancer_api.c @@ -90,16 +90,16 @@ grpc_grpclb_request *grpc_grpclb_request_create(const char *lb_service_name) { return req; } -gpr_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request) { +grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request) { size_t encoded_length; pb_ostream_t sizestream; pb_ostream_t outputstream; - gpr_slice slice; + grpc_slice slice; memset(&sizestream, 0, sizeof(pb_ostream_t)); pb_encode(&sizestream, grpc_lb_v1_LoadBalanceRequest_fields, request); encoded_length = sizestream.bytes_written; - slice = gpr_slice_malloc(encoded_length); + slice = grpc_slice_malloc(encoded_length); outputstream = pb_ostream_from_buffer(GPR_SLICE_START_PTR(slice), encoded_length); GPR_ASSERT(pb_encode(&outputstream, grpc_lb_v1_LoadBalanceRequest_fields, @@ -113,7 +113,7 @@ void grpc_grpclb_request_destroy(grpc_grpclb_request *request) { typedef grpc_lb_v1_LoadBalanceResponse grpc_grpclb_response; grpc_grpclb_initial_response *grpc_grpclb_initial_response_parse( - gpr_slice encoded_grpc_grpclb_response) { + grpc_slice encoded_grpc_grpclb_response) { pb_istream_t stream = pb_istream_from_buffer(GPR_SLICE_START_PTR(encoded_grpc_grpclb_response), GPR_SLICE_LENGTH(encoded_grpc_grpclb_response)); @@ -132,7 +132,7 @@ grpc_grpclb_initial_response *grpc_grpclb_initial_response_parse( } grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist( - gpr_slice encoded_grpc_grpclb_response) { + grpc_slice encoded_grpc_grpclb_response) { bool status; decode_serverlist_arg arg; pb_istream_t stream = diff --git a/src/core/ext/lb_policy/grpclb/load_balancer_api.h b/src/core/ext/lb_policy/grpclb/load_balancer_api.h index 079a64a3f3..235ccf6cb4 100644 --- a/src/core/ext/lb_policy/grpclb/load_balancer_api.h +++ b/src/core/ext/lb_policy/grpclb/load_balancer_api.h @@ -60,7 +60,7 @@ typedef struct grpc_grpclb_serverlist { grpc_grpclb_request *grpc_grpclb_request_create(const char *lb_service_name); /** Protocol Buffers v3-encode \a request */ -gpr_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request); +grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request); /** Destroy \a request */ void grpc_grpclb_request_destroy(grpc_grpclb_request *request); @@ -68,11 +68,11 @@ void grpc_grpclb_request_destroy(grpc_grpclb_request *request); /** Parse (ie, decode) the bytes in \a encoded_grpc_grpclb_response as a \a * grpc_grpclb_initial_response */ grpc_grpclb_initial_response *grpc_grpclb_initial_response_parse( - gpr_slice encoded_grpc_grpclb_response); + grpc_slice encoded_grpc_grpclb_response); /** Parse the list of servers from an encoded \a grpc_grpclb_response */ grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist( - gpr_slice encoded_grpc_grpclb_response); + grpc_slice encoded_grpc_grpclb_response); /** Return a copy of \a sl. The caller is responsible for calling \a * grpc_grpclb_destroy_serverlist on the returned copy. */ diff --git a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c index 9924fc6fec..cd0c45e407 100644 --- a/src/core/ext/resolver/sockaddr/sockaddr_resolver.c +++ b/src/core/ext/resolver/sockaddr/sockaddr_resolver.c @@ -169,11 +169,11 @@ static grpc_resolver *sockaddr_create(grpc_resolver_args *args, return NULL; } /* Construct addresses. */ - gpr_slice path_slice = - gpr_slice_new(args->uri->path, strlen(args->uri->path), do_nothing); - gpr_slice_buffer path_parts; - gpr_slice_buffer_init(&path_parts); - gpr_slice_split(path_slice, ",", &path_parts); + grpc_slice path_slice = + grpc_slice_new(args->uri->path, strlen(args->uri->path), do_nothing); + grpc_slice_buffer path_parts; + grpc_slice_buffer_init(&path_parts); + grpc_slice_split(path_slice, ",", &path_parts); grpc_lb_addresses *addresses = grpc_lb_addresses_create(path_parts.count); bool errors_found = false; for (size_t i = 0; i < addresses->num_addresses; i++) { @@ -189,8 +189,8 @@ static grpc_resolver *sockaddr_create(grpc_resolver_args *args, gpr_free(part_str); if (errors_found) break; } - gpr_slice_buffer_destroy(&path_parts); - gpr_slice_unref(path_slice); + grpc_slice_buffer_destroy(&path_parts); + grpc_slice_unref(path_slice); if (errors_found) { grpc_lb_addresses_destroy(addresses, NULL /* user_data_destroy */); return NULL; diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.c b/src/core/ext/transport/chttp2/client/insecure/channel_create.c index 41432b54a9..eee38a0b90 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create.c +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.c @@ -60,7 +60,7 @@ typedef struct { grpc_connect_in_args args; grpc_connect_out_args *result; grpc_closure initial_string_sent; - gpr_slice_buffer initial_string_buffer; + grpc_slice_buffer initial_string_buffer; grpc_endpoint *tcp; @@ -90,7 +90,7 @@ static void on_initial_connect_string_sent(grpc_exec_ctx *exec_ctx, void *arg, static void on_handshake_done(grpc_exec_ctx *exec_ctx, grpc_endpoint *endpoint, grpc_channel_args *args, - gpr_slice_buffer *read_buffer, void *user_data, + grpc_slice_buffer *read_buffer, void *user_data, grpc_error *error) { connector *c = user_data; if (error != GRPC_ERROR_NONE) { @@ -116,8 +116,8 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { if (!GPR_SLICE_IS_EMPTY(c->args.initial_connect_string)) { grpc_closure_init(&c->initial_string_sent, on_initial_connect_string_sent, c); - gpr_slice_buffer_init(&c->initial_string_buffer); - gpr_slice_buffer_add(&c->initial_string_buffer, + grpc_slice_buffer_init(&c->initial_string_buffer); + grpc_slice_buffer_add(&c->initial_string_buffer, c->args.initial_connect_string); connector_ref(arg); grpc_endpoint_write(exec_ctx, tcp, &c->initial_string_buffer, diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c index 2e6b3f2fc8..d396a1bc36 100644 --- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c @@ -64,7 +64,7 @@ typedef struct { grpc_connect_in_args args; grpc_connect_out_args *result; grpc_closure initial_string_sent; - gpr_slice_buffer initial_string_buffer; + grpc_slice_buffer initial_string_buffer; gpr_mu mu; grpc_endpoint *connecting_endpoint; @@ -127,7 +127,7 @@ static void on_secure_handshake_done(grpc_exec_ctx *exec_ctx, void *arg, static void on_handshake_done(grpc_exec_ctx *exec_ctx, grpc_endpoint *endpoint, grpc_channel_args *args, - gpr_slice_buffer *read_buffer, void *user_data, + grpc_slice_buffer *read_buffer, void *user_data, grpc_error *error) { connector *c = user_data; c->tmp_args = args; @@ -165,8 +165,8 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { if (!GPR_SLICE_IS_EMPTY(c->args.initial_connect_string)) { grpc_closure_init(&c->initial_string_sent, on_initial_connect_string_sent, c); - gpr_slice_buffer_init(&c->initial_string_buffer); - gpr_slice_buffer_add(&c->initial_string_buffer, + grpc_slice_buffer_init(&c->initial_string_buffer); + grpc_slice_buffer_add(&c->initial_string_buffer, c->args.initial_connect_string); grpc_endpoint_write(exec_ctx, tcp, &c->initial_string_buffer, &c->initial_string_sent); diff --git a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c index 2c64878c0c..e5b4025c5f 100644 --- a/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c +++ b/src/core/ext/transport/chttp2/server/insecure/server_chttp2.c @@ -56,7 +56,7 @@ typedef struct server_connect_state { static void on_handshake_done(grpc_exec_ctx *exec_ctx, grpc_endpoint *endpoint, grpc_channel_args *args, - gpr_slice_buffer *read_buffer, void *user_data, + grpc_slice_buffer *read_buffer, void *user_data, grpc_error *error) { server_connect_state *state = user_data; if (error != GRPC_ERROR_NONE) { diff --git a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c index 88afcb6dea..a998dddd37 100644 --- a/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c +++ b/src/core/ext/transport/chttp2/server/secure/server_secure_chttp2.c @@ -117,7 +117,7 @@ static void on_secure_handshake_done(grpc_exec_ctx *exec_ctx, void *statep, static void on_handshake_done(grpc_exec_ctx *exec_ctx, grpc_endpoint *endpoint, grpc_channel_args *args, - gpr_slice_buffer *read_buffer, void *user_data, + grpc_slice_buffer *read_buffer, void *user_data, grpc_error *error) { server_secure_connect *connection_state = user_data; if (error != GRPC_ERROR_NONE) { diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.c b/src/core/ext/transport/chttp2/transport/bin_decoder.c index 2d90b01cd8..d8948bdfdb 100644 --- a/src/core/ext/transport/chttp2/transport/bin_decoder.c +++ b/src/core/ext/transport/chttp2/transport/bin_decoder.c @@ -142,11 +142,11 @@ bool grpc_base64_decode_partial(struct grpc_base64_decode_context *ctx) { return true; } -gpr_slice grpc_chttp2_base64_decode(gpr_slice input) { +grpc_slice grpc_chttp2_base64_decode(grpc_slice input) { size_t input_length = GPR_SLICE_LENGTH(input); size_t output_length = input_length / 4 * 3; struct grpc_base64_decode_context ctx; - gpr_slice output; + grpc_slice output; if (input_length % 4 != 0) { gpr_log(GPR_ERROR, @@ -166,7 +166,7 @@ gpr_slice grpc_chttp2_base64_decode(gpr_slice input) { } } } - output = gpr_slice_malloc(output_length); + output = grpc_slice_malloc(output_length); ctx.input_cur = GPR_SLICE_START_PTR(input); ctx.input_end = GPR_SLICE_END_PTR(input); @@ -178,7 +178,7 @@ gpr_slice grpc_chttp2_base64_decode(gpr_slice input) { char *s = gpr_dump_slice(input, GPR_DUMP_ASCII); gpr_log(GPR_ERROR, "Base64 decoding failed, input string:\n%s\n", s); gpr_free(s); - gpr_slice_unref(output); + grpc_slice_unref(output); return gpr_empty_slice(); } GPR_ASSERT(ctx.output_cur == GPR_SLICE_END_PTR(output)); @@ -186,10 +186,10 @@ gpr_slice grpc_chttp2_base64_decode(gpr_slice input) { return output; } -gpr_slice grpc_chttp2_base64_decode_with_length(gpr_slice input, +grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input, size_t output_length) { size_t input_length = GPR_SLICE_LENGTH(input); - gpr_slice output = gpr_slice_malloc(output_length); + grpc_slice output = grpc_slice_malloc(output_length); struct grpc_base64_decode_context ctx; // The length of a base64 string cannot be 4 * n + 1 @@ -199,7 +199,7 @@ gpr_slice grpc_chttp2_base64_decode_with_length(gpr_slice input, "grpc_chttp2_base64_decode_with_length has a length of %d, which " "has a tail of 1 byte.\n", (int)input_length); - gpr_slice_unref(output); + grpc_slice_unref(output); return gpr_empty_slice(); } @@ -209,7 +209,7 @@ gpr_slice grpc_chttp2_base64_decode_with_length(gpr_slice input, "than the max possible output length %d.\n", (int)output_length, (int)(input_length / 4 * 3 + tail_xtra[input_length % 4])); - gpr_slice_unref(output); + grpc_slice_unref(output); return gpr_empty_slice(); } @@ -223,7 +223,7 @@ gpr_slice grpc_chttp2_base64_decode_with_length(gpr_slice input, char *s = gpr_dump_slice(input, GPR_DUMP_ASCII); gpr_log(GPR_ERROR, "Base64 decoding failed, input string:\n%s\n", s); gpr_free(s); - gpr_slice_unref(output); + grpc_slice_unref(output); return gpr_empty_slice(); } GPR_ASSERT(ctx.output_cur == GPR_SLICE_END_PTR(output)); diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.h b/src/core/ext/transport/chttp2/transport/bin_decoder.h index b9d40c9b74..c416608a0b 100644 --- a/src/core/ext/transport/chttp2/transport/bin_decoder.h +++ b/src/core/ext/transport/chttp2/transport/bin_decoder.h @@ -55,12 +55,12 @@ bool grpc_base64_decode_partial(struct grpc_base64_decode_context *ctx); /* base64 decode a slice with pad chars. Returns a new slice, does not take ownership of the input. Returns an empty slice if decoding is failed. */ -gpr_slice grpc_chttp2_base64_decode(gpr_slice input); +grpc_slice grpc_chttp2_base64_decode(grpc_slice input); /* base64 decode a slice without pad chars, data length is needed. Returns a new slice, does not take ownership of the input. Returns an empty slice if decoding is failed. */ -gpr_slice grpc_chttp2_base64_decode_with_length(gpr_slice input, +grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input, size_t output_length); #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H */ diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.c b/src/core/ext/transport/chttp2/transport/bin_encoder.c index 1b43c28be1..09b961533a 100644 --- a/src/core/ext/transport/chttp2/transport/bin_encoder.c +++ b/src/core/ext/transport/chttp2/transport/bin_encoder.c @@ -61,12 +61,12 @@ static const b64_huff_sym huff_alphabet[64] = { static const uint8_t tail_xtra[3] = {0, 2, 3}; -gpr_slice grpc_chttp2_base64_encode(gpr_slice input) { +grpc_slice grpc_chttp2_base64_encode(grpc_slice input) { size_t input_length = GPR_SLICE_LENGTH(input); size_t input_triplets = input_length / 3; size_t tail_case = input_length % 3; size_t output_length = input_triplets * 4 + tail_xtra[tail_case]; - gpr_slice output = gpr_slice_malloc(output_length); + grpc_slice output = grpc_slice_malloc(output_length); uint8_t *in = GPR_SLICE_START_PTR(input); char *out = (char *)GPR_SLICE_START_PTR(output); size_t i; @@ -105,11 +105,11 @@ gpr_slice grpc_chttp2_base64_encode(gpr_slice input) { return output; } -gpr_slice grpc_chttp2_huffman_compress(gpr_slice input) { +grpc_slice grpc_chttp2_huffman_compress(grpc_slice input) { size_t nbits; uint8_t *in; uint8_t *out; - gpr_slice output; + grpc_slice output; uint32_t temp = 0; uint32_t temp_length = 0; @@ -118,7 +118,7 @@ gpr_slice grpc_chttp2_huffman_compress(gpr_slice input) { nbits += grpc_chttp2_huffsyms[*in].length; } - output = gpr_slice_malloc(nbits / 8 + (nbits % 8 != 0)); + output = grpc_slice_malloc(nbits / 8 + (nbits % 8 != 0)); out = GPR_SLICE_START_PTR(output); for (in = GPR_SLICE_START_PTR(input); in != GPR_SLICE_END_PTR(input); ++in) { int sym = *in; @@ -175,14 +175,14 @@ static void enc_add1(huff_out *out, uint8_t a) { enc_flush_some(out); } -gpr_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(gpr_slice input) { +grpc_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(grpc_slice input) { size_t input_length = GPR_SLICE_LENGTH(input); size_t input_triplets = input_length / 3; size_t tail_case = input_length % 3; size_t output_syms = input_triplets * 4 + tail_xtra[tail_case]; size_t max_output_bits = 11 * output_syms; size_t max_output_length = max_output_bits / 8 + (max_output_bits % 8 != 0); - gpr_slice output = gpr_slice_malloc(max_output_length); + grpc_slice output = grpc_slice_malloc(max_output_length); uint8_t *in = GPR_SLICE_START_PTR(input); uint8_t *start_out = GPR_SLICE_START_PTR(output); huff_out out; diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.h b/src/core/ext/transport/chttp2/transport/bin_encoder.h index 61ebbafa9a..878390cde6 100644 --- a/src/core/ext/transport/chttp2/transport/bin_encoder.h +++ b/src/core/ext/transport/chttp2/transport/bin_encoder.h @@ -38,17 +38,17 @@ /* base64 encode a slice. Returns a new slice, does not take ownership of the input */ -gpr_slice grpc_chttp2_base64_encode(gpr_slice input); +grpc_slice grpc_chttp2_base64_encode(grpc_slice input); /* Compress a slice with the static huffman encoder detailed in the hpack standard. Returns a new slice, does not take ownership of the input */ -gpr_slice grpc_chttp2_huffman_compress(gpr_slice input); +grpc_slice grpc_chttp2_huffman_compress(grpc_slice input); /* equivalent to: - gpr_slice x = grpc_chttp2_base64_encode(input); - gpr_slice y = grpc_chttp2_huffman_compress(x); - gpr_slice_unref(x); + grpc_slice x = grpc_chttp2_base64_encode(input); + grpc_slice y = grpc_chttp2_huffman_compress(x); + grpc_slice_unref(x); return y; */ -gpr_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(gpr_slice input); +grpc_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(grpc_slice input); #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H */ diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 562f498d88..3a551d449b 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -143,12 +143,12 @@ static void destruct_transport(grpc_exec_ctx *exec_ctx, grpc_endpoint_destroy(exec_ctx, t->ep); - gpr_slice_buffer_destroy(&t->qbuf); + grpc_slice_buffer_destroy(&t->qbuf); - gpr_slice_buffer_destroy(&t->outbuf); + grpc_slice_buffer_destroy(&t->outbuf); grpc_chttp2_hpack_compressor_destroy(&t->hpack_compressor); - gpr_slice_buffer_destroy(&t->read_buffer); + grpc_slice_buffer_destroy(&t->read_buffer); grpc_chttp2_hpack_parser_destroy(&t->hpack_parser); grpc_chttp2_goaway_parser_destroy(&t->goaway_parser); @@ -243,9 +243,9 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, &t->channel_callback.state_tracker, GRPC_CHANNEL_READY, is_client ? "client_transport" : "server_transport"); - gpr_slice_buffer_init(&t->qbuf); + grpc_slice_buffer_init(&t->qbuf); - gpr_slice_buffer_init(&t->outbuf); + grpc_slice_buffer_init(&t->outbuf); grpc_chttp2_hpack_compressor_init(&t->hpack_compressor); grpc_closure_init(&t->write_action_begin_locked, write_action_begin_locked, @@ -264,7 +264,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_goaway_parser_init(&t->goaway_parser); grpc_chttp2_hpack_parser_init(&t->hpack_parser); - gpr_slice_buffer_init(&t->read_buffer); + grpc_slice_buffer_init(&t->read_buffer); /* 8 is a random stab in the dark as to a good initial size: it's small enough that it shouldn't waste memory for infrequently used connections, yet @@ -286,7 +286,7 @@ static void init_transport(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, t->sent_local_settings = 0; if (is_client) { - gpr_slice_buffer_add(&t->outbuf, gpr_slice_from_copied_string( + grpc_slice_buffer_add(&t->outbuf, grpc_slice_from_copied_string( GRPC_CHTTP2_CLIENT_CONNECT_STRING)); grpc_chttp2_initiate_write(exec_ctx, t, false, "initial_write"); } @@ -471,7 +471,7 @@ static int init_stream(grpc_exec_ctx *exec_ctx, grpc_transport *gt, grpc_chttp2_incoming_metadata_buffer_init(&s->metadata_buffer[0]); grpc_chttp2_incoming_metadata_buffer_init(&s->metadata_buffer[1]); grpc_chttp2_data_parser_init(&s->data_parser); - gpr_slice_buffer_init(&s->flow_controlled_buffer); + grpc_slice_buffer_init(&s->flow_controlled_buffer); s->deadline = gpr_inf_future(GPR_CLOCK_MONOTONIC); grpc_closure_init(&s->complete_fetch, complete_fetch, s); grpc_closure_init(&s->complete_fetch_locked, complete_fetch_locked, s); @@ -531,7 +531,7 @@ static void destroy_stream_locked(grpc_exec_ctx *exec_ctx, void *sp, grpc_chttp2_data_parser_destroy(exec_ctx, &s->data_parser); grpc_chttp2_incoming_metadata_buffer_destroy(&s->metadata_buffer[0]); grpc_chttp2_incoming_metadata_buffer_destroy(&s->metadata_buffer[1]); - gpr_slice_buffer_destroy(&s->flow_controlled_buffer); + grpc_slice_buffer_destroy(&s->flow_controlled_buffer); GRPC_ERROR_UNREF(s->read_closed_error); GRPC_ERROR_UNREF(s->write_closed_error); @@ -756,11 +756,11 @@ static void push_setting(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, uint32_t goaway_error, - gpr_slice goaway_text) { + grpc_slice goaway_text) { char *msg = gpr_dump_slice(goaway_text, GPR_DUMP_HEX | GPR_DUMP_ASCII); GRPC_CHTTP2_IF_TRACING( gpr_log(GPR_DEBUG, "got goaway [%d]: %s", goaway_error, msg)); - gpr_slice_unref(goaway_text); + grpc_slice_unref(goaway_text); t->seen_goaway = 1; /* lie: use transient failure from the transport to indicate goaway has been * received */ @@ -924,7 +924,7 @@ static void add_fetched_slice_locked(grpc_exec_ctx *exec_ctx, grpc_chttp2_stream *s) { s->fetched_send_message_length += (uint32_t)GPR_SLICE_LENGTH(s->fetching_slice); - gpr_slice_buffer_add(&s->flow_controlled_buffer, s->fetching_slice); + grpc_slice_buffer_add(&s->flow_controlled_buffer, s->fetching_slice); if (s->id != 0) { grpc_chttp2_become_writable(exec_ctx, t, s, true, "op.send_message"); } @@ -1052,7 +1052,7 @@ static void perform_stream_op_locked(grpc_exec_ctx *exec_ctx, void *stream_op, } else { GPR_ASSERT(s->fetching_send_message == NULL); uint8_t *frame_hdr = - gpr_slice_buffer_tiny_add(&s->flow_controlled_buffer, 5); + grpc_slice_buffer_tiny_add(&s->flow_controlled_buffer, 5); uint32_t flags = op->send_message->flags; frame_hdr[0] = (flags & GRPC_WRITE_INTERNAL_COMPRESS) != 0; size_t len = op->send_message->length; @@ -1192,7 +1192,7 @@ static void send_ping_locked(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, p->id[7] = (uint8_t)(t->ping_counter & 0xff); t->ping_counter++; p->on_recv = on_recv; - gpr_slice_buffer_add(&t->qbuf, grpc_chttp2_ping_create(0, p->id)); + grpc_slice_buffer_add(&t->qbuf, grpc_chttp2_ping_create(0, p->id)); grpc_chttp2_initiate_write(exec_ctx, t, true, "send_ping"); } @@ -1216,7 +1216,7 @@ void grpc_chttp2_ack_ping(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, } static void send_goaway(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, - grpc_chttp2_error_code error, gpr_slice data) { + grpc_chttp2_error_code error, grpc_slice data) { t->sent_goaway_state = GRPC_CHTTP2_GOAWAY_SEND_SCHEDULED; grpc_chttp2_goaway_append(t->last_new_stream_id, (uint32_t)error, data, &t->qbuf); @@ -1239,7 +1239,7 @@ static void perform_transport_op_locked(grpc_exec_ctx *exec_ctx, if (op->send_goaway) { send_goaway(exec_ctx, t, grpc_chttp2_grpc_status_to_http2_error(op->goaway_status), - gpr_slice_ref(*op->goaway_message)); + grpc_slice_ref(*op->goaway_message)); } if (op->set_accept_stream) { @@ -1428,7 +1428,7 @@ void grpc_chttp2_cancel_stream(grpc_exec_ctx *exec_ctx, &grpc_status); if (s->id != 0) { - gpr_slice_buffer_add( + grpc_slice_buffer_add( &t->qbuf, grpc_chttp2_rst_stream_create(s->id, (uint32_t)http_error, &s->stats.outgoing)); grpc_chttp2_initiate_write(exec_ctx, t, false, "rst_stream"); @@ -1441,7 +1441,7 @@ void grpc_chttp2_cancel_stream(grpc_exec_ctx *exec_ctx, free_msg = true; msg = grpc_error_string(due_to_error); } - gpr_slice msg_slice = gpr_slice_from_copied_string(msg); + grpc_slice msg_slice = grpc_slice_from_copied_string(msg); grpc_chttp2_fake_status(exec_ctx, t, s, grpc_status, &msg_slice); if (free_msg) grpc_error_free_string(msg); } @@ -1454,7 +1454,7 @@ void grpc_chttp2_cancel_stream(grpc_exec_ctx *exec_ctx, void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_stream *s, grpc_status_code status, - gpr_slice *slice) { + grpc_slice *slice) { if (status != GRPC_STATUS_OK) { s->seen_error = true; } @@ -1477,13 +1477,13 @@ void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, &s->metadata_buffer[1], grpc_mdelem_from_metadata_strings( GRPC_MDSTR_GRPC_MESSAGE, - grpc_mdstr_from_slice(gpr_slice_ref(*slice)))); + grpc_mdstr_from_slice(grpc_slice_ref(*slice)))); } s->published_metadata[1] = GRPC_METADATA_SYNTHESIZED_FROM_FAKE; grpc_chttp2_maybe_complete_recv_trailing_metadata(exec_ctx, t, s); } if (slice) { - gpr_slice_unref(*slice); + grpc_slice_unref(*slice); } } @@ -1580,9 +1580,9 @@ void grpc_chttp2_mark_stream_closed(grpc_exec_ctx *exec_ctx, static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_stream *s, grpc_error *error) { - gpr_slice hdr; - gpr_slice status_hdr; - gpr_slice message_pfx; + grpc_slice hdr; + grpc_slice status_hdr; + grpc_slice message_pfx; uint8_t *p; uint32_t len = 0; grpc_status_code grpc_status; @@ -1601,7 +1601,7 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, time we got around to sending this, so instead we ignore HPACK compression and just write the uncompressed bytes onto the wire. */ - status_hdr = gpr_slice_malloc(15 + (grpc_status >= 10)); + status_hdr = grpc_slice_malloc(15 + (grpc_status >= 10)); p = GPR_SLICE_START_PTR(status_hdr); *p++ = 0x40; /* literal header */ *p++ = 11; /* len(grpc-status) */ @@ -1633,7 +1633,7 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, if (optional_message != NULL) { size_t msg_len = strlen(optional_message); GPR_ASSERT(msg_len < 127); - message_pfx = gpr_slice_malloc(15); + message_pfx = grpc_slice_malloc(15); p = GPR_SLICE_START_PTR(message_pfx); *p++ = 0x40; *p++ = 12; /* len(grpc-message) */ @@ -1655,7 +1655,7 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, len += (uint32_t)msg_len; } - hdr = gpr_slice_malloc(9); + hdr = grpc_slice_malloc(9); p = GPR_SLICE_START_PTR(hdr); *p++ = (uint8_t)(len >> 16); *p++ = (uint8_t)(len >> 8); @@ -1668,14 +1668,14 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, *p++ = (uint8_t)(s->id); GPR_ASSERT(p == GPR_SLICE_END_PTR(hdr)); - gpr_slice_buffer_add(&t->qbuf, hdr); - gpr_slice_buffer_add(&t->qbuf, status_hdr); + grpc_slice_buffer_add(&t->qbuf, hdr); + grpc_slice_buffer_add(&t->qbuf, status_hdr); if (optional_message) { - gpr_slice_buffer_add(&t->qbuf, message_pfx); - gpr_slice_buffer_add(&t->qbuf, - gpr_slice_from_copied_string(optional_message)); + grpc_slice_buffer_add(&t->qbuf, message_pfx); + grpc_slice_buffer_add(&t->qbuf, + grpc_slice_from_copied_string(optional_message)); } - gpr_slice_buffer_add( + grpc_slice_buffer_add( &t->qbuf, grpc_chttp2_rst_stream_create(s->id, GRPC_CHTTP2_NO_ERROR, &s->stats.outgoing)); } @@ -1686,7 +1686,7 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, free_msg = true; msg = grpc_error_string(error); } - gpr_slice msg_slice = gpr_slice_from_copied_string(msg); + grpc_slice msg_slice = grpc_slice_from_copied_string(msg); grpc_chttp2_fake_status(exec_ctx, t, s, grpc_status, &msg_slice); if (free_msg) grpc_error_free_string(msg); @@ -1857,7 +1857,7 @@ static void read_action_locked(grpc_exec_ctx *exec_ctx, void *tp, keep_reading = true; GRPC_CHTTP2_REF_TRANSPORT(t, "keep_reading"); } - gpr_slice_buffer_reset_and_unref(&t->read_buffer); + grpc_slice_buffer_reset_and_unref(&t->read_buffer); if (keep_reading) { grpc_endpoint_read(exec_ctx, t->ep, &t->read_buffer, &t->read_action_begin); @@ -1911,7 +1911,7 @@ static void incoming_byte_stream_unref(grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs) { if (gpr_unref(&bs->refs)) { GRPC_ERROR_UNREF(bs->error); - gpr_slice_buffer_destroy(&bs->slices); + grpc_slice_buffer_destroy(&bs->slices); gpr_mu_destroy(&bs->slice_mu); gpr_free(bs); } @@ -1973,7 +1973,7 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx *exec_ctx, } gpr_mu_lock(&bs->slice_mu); if (bs->slices.count > 0) { - *bs->next_action.slice = gpr_slice_buffer_take_first(&bs->slices); + *bs->next_action.slice = grpc_slice_buffer_take_first(&bs->slices); grpc_closure_run(exec_ctx, bs->next_action.on_complete, GRPC_ERROR_NONE); } else if (bs->error != GRPC_ERROR_NONE) { grpc_closure_run(exec_ctx, bs->next_action.on_complete, @@ -1988,7 +1988,7 @@ static void incoming_byte_stream_next_locked(grpc_exec_ctx *exec_ctx, static int incoming_byte_stream_next(grpc_exec_ctx *exec_ctx, grpc_byte_stream *byte_stream, - gpr_slice *slice, size_t max_size_hint, + grpc_slice *slice, size_t max_size_hint, grpc_closure *on_complete) { GPR_TIMER_BEGIN("incoming_byte_stream_next", 0); grpc_chttp2_incoming_byte_stream *bs = @@ -2041,7 +2041,7 @@ static void incoming_byte_stream_publish_error( void grpc_chttp2_incoming_byte_stream_push(grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs, - gpr_slice slice) { + grpc_slice slice) { gpr_mu_lock(&bs->slice_mu); if (bs->remaining_bytes < GPR_SLICE_LENGTH(slice)) { incoming_byte_stream_publish_error( @@ -2053,7 +2053,7 @@ void grpc_chttp2_incoming_byte_stream_push(grpc_exec_ctx *exec_ctx, grpc_exec_ctx_sched(exec_ctx, bs->on_next, GRPC_ERROR_NONE, NULL); bs->on_next = NULL; } else { - gpr_slice_buffer_add(&bs->slices, slice); + grpc_slice_buffer_add(&bs->slices, slice); } } gpr_mu_unlock(&bs->slice_mu); @@ -2091,7 +2091,7 @@ grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create( incoming_byte_stream->transport = t; incoming_byte_stream->stream = s; gpr_ref(&incoming_byte_stream->stream->active_streams); - gpr_slice_buffer_init(&incoming_byte_stream->slices); + grpc_slice_buffer_init(&incoming_byte_stream->slices); incoming_byte_stream->on_next = NULL; incoming_byte_stream->is_tail = 1; incoming_byte_stream->error = GRPC_ERROR_NONE; @@ -2159,7 +2159,7 @@ static void benign_reclaimer_locked(grpc_exec_ctx *exec_ctx, void *arg, t->peer_string); } send_goaway(exec_ctx, t, GRPC_CHTTP2_ENHANCE_YOUR_CALM, - gpr_slice_from_static_string("Buffers full")); + grpc_slice_from_static_string("Buffers full")); } else if (error == GRPC_ERROR_NONE && grpc_resource_quota_trace) { gpr_log(GPR_DEBUG, "HTTP2: %s - skip benign reclamation, there are still %" PRIdPTR @@ -2310,12 +2310,12 @@ grpc_transport *grpc_create_chttp2_transport( void grpc_chttp2_transport_start_reading(grpc_exec_ctx *exec_ctx, grpc_transport *transport, - gpr_slice_buffer *read_buffer) { + grpc_slice_buffer *read_buffer) { grpc_chttp2_transport *t = (grpc_chttp2_transport *)transport; GRPC_CHTTP2_REF_TRANSPORT( t, "reading_action"); /* matches unref inside reading_action */ if (read_buffer != NULL) { - gpr_slice_buffer_move_into(read_buffer, &t->read_buffer); + grpc_slice_buffer_move_into(read_buffer, &t->read_buffer); gpr_free(read_buffer); } read_action_begin(exec_ctx, t, GRPC_ERROR_NONE); diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.h b/src/core/ext/transport/chttp2/transport/chttp2_transport.h index 4e2d0954bf..c372174f2d 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.h +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.h @@ -48,6 +48,6 @@ grpc_transport *grpc_create_chttp2_transport( /// leftover bytes previously read from the endpoint (e.g., by handshakers). void grpc_chttp2_transport_start_reading(grpc_exec_ctx *exec_ctx, grpc_transport *transport, - gpr_slice_buffer *read_buffer); + grpc_slice_buffer *read_buffer); #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_CHTTP2_TRANSPORT_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_data.c b/src/core/ext/transport/chttp2/transport/frame_data.c index 8668816930..3081a03929 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.c +++ b/src/core/ext/transport/chttp2/transport/frame_data.c @@ -112,15 +112,15 @@ grpc_byte_stream *grpc_chttp2_incoming_frame_queue_pop( return out; } -void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf, +void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer *inbuf, uint32_t write_bytes, int is_eof, grpc_transport_one_way_stats *stats, - gpr_slice_buffer *outbuf) { - gpr_slice hdr; + grpc_slice_buffer *outbuf) { + grpc_slice hdr; uint8_t *p; static const size_t header_size = 9; - hdr = gpr_slice_malloc(header_size); + hdr = grpc_slice_malloc(header_size); p = GPR_SLICE_START_PTR(hdr); GPR_ASSERT(write_bytes < (1 << 24)); *p++ = (uint8_t)(write_bytes >> 16); @@ -132,9 +132,9 @@ void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf, *p++ = (uint8_t)(id >> 16); *p++ = (uint8_t)(id >> 8); *p++ = (uint8_t)(id); - gpr_slice_buffer_add(outbuf, hdr); + grpc_slice_buffer_add(outbuf, hdr); - gpr_slice_buffer_move_first(inbuf, write_bytes, outbuf); + grpc_slice_buffer_move_first(inbuf, write_bytes, outbuf); stats->framing_bytes += header_size; stats->data_bytes += write_bytes; @@ -143,7 +143,7 @@ void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf, static grpc_error *parse_inner(grpc_exec_ctx *exec_ctx, grpc_chttp2_data_parser *p, grpc_chttp2_transport *t, grpc_chttp2_stream *s, - gpr_slice slice) { + grpc_slice slice) { uint8_t *const beg = GPR_SLICE_START_PTR(slice); uint8_t *const end = GPR_SLICE_END_PTR(slice); uint8_t *cur = beg; @@ -236,7 +236,7 @@ static grpc_error *parse_inner(grpc_exec_ctx *exec_ctx, s->stats.incoming.data_bytes += p->frame_size; grpc_chttp2_incoming_byte_stream_push( exec_ctx, p->parsing_frame, - gpr_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg))); + grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg))); grpc_chttp2_incoming_byte_stream_finished(exec_ctx, p->parsing_frame, GRPC_ERROR_NONE); p->parsing_frame = NULL; @@ -246,7 +246,7 @@ static grpc_error *parse_inner(grpc_exec_ctx *exec_ctx, s->stats.incoming.data_bytes += p->frame_size; grpc_chttp2_incoming_byte_stream_push( exec_ctx, p->parsing_frame, - gpr_slice_sub(slice, (size_t)(cur - beg), + grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(cur + p->frame_size - beg))); grpc_chttp2_incoming_byte_stream_finished(exec_ctx, p->parsing_frame, GRPC_ERROR_NONE); @@ -257,7 +257,7 @@ static grpc_error *parse_inner(grpc_exec_ctx *exec_ctx, GPR_ASSERT(remaining <= p->frame_size); grpc_chttp2_incoming_byte_stream_push( exec_ctx, p->parsing_frame, - gpr_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg))); + grpc_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg))); p->frame_size -= remaining; s->stats.incoming.data_bytes += remaining; return GRPC_ERROR_NONE; @@ -270,7 +270,7 @@ static grpc_error *parse_inner(grpc_exec_ctx *exec_ctx, grpc_error *grpc_chttp2_data_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t, grpc_chttp2_stream *s, - gpr_slice slice, int is_last) { + grpc_slice slice, int is_last) { grpc_chttp2_data_parser *p = parser; grpc_error *error = parse_inner(exec_ctx, p, t, s, slice); diff --git a/src/core/ext/transport/chttp2/transport/frame_data.h b/src/core/ext/transport/chttp2/transport/frame_data.h index eb2d97d898..471f615c67 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.h +++ b/src/core/ext/transport/chttp2/transport/frame_data.h @@ -94,11 +94,11 @@ grpc_error *grpc_chttp2_data_parser_begin_frame(grpc_chttp2_data_parser *parser, grpc_error *grpc_chttp2_data_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t, grpc_chttp2_stream *s, - gpr_slice slice, int is_last); + grpc_slice slice, int is_last); -void grpc_chttp2_encode_data(uint32_t id, gpr_slice_buffer *inbuf, +void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer *inbuf, uint32_t write_bytes, int is_eof, grpc_transport_one_way_stats *stats, - gpr_slice_buffer *outbuf); + grpc_slice_buffer *outbuf); #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_DATA_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.c b/src/core/ext/transport/chttp2/transport/frame_goaway.c index 33d2269169..16c6819aca 100644 --- a/src/core/ext/transport/chttp2/transport/frame_goaway.c +++ b/src/core/ext/transport/chttp2/transport/frame_goaway.c @@ -71,7 +71,7 @@ grpc_error *grpc_chttp2_goaway_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t, grpc_chttp2_stream *s, - gpr_slice slice, int is_last) { + grpc_slice slice, int is_last) { uint8_t *const beg = GPR_SLICE_START_PTR(slice); uint8_t *const end = GPR_SLICE_END_PTR(slice); uint8_t *cur = beg; @@ -151,7 +151,7 @@ grpc_error *grpc_chttp2_goaway_parser_parse(grpc_exec_ctx *exec_ctx, if (is_last) { grpc_chttp2_add_incoming_goaway( exec_ctx, t, (uint32_t)p->error_code, - gpr_slice_new(p->debug_data, p->debug_length, gpr_free)); + grpc_slice_new(p->debug_data, p->debug_length, gpr_free)); p->debug_data = NULL; } return GRPC_ERROR_NONE; @@ -160,9 +160,9 @@ grpc_error *grpc_chttp2_goaway_parser_parse(grpc_exec_ctx *exec_ctx, } void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code, - gpr_slice debug_data, - gpr_slice_buffer *slice_buffer) { - gpr_slice header = gpr_slice_malloc(9 + 4 + 4); + grpc_slice debug_data, + grpc_slice_buffer *slice_buffer) { + grpc_slice header = grpc_slice_malloc(9 + 4 + 4); uint8_t *p = GPR_SLICE_START_PTR(header); uint32_t frame_length; GPR_ASSERT(GPR_SLICE_LENGTH(debug_data) < UINT32_MAX - 4 - 4); @@ -192,6 +192,6 @@ void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code, *p++ = (uint8_t)(error_code >> 8); *p++ = (uint8_t)(error_code); GPR_ASSERT(p == GPR_SLICE_END_PTR(header)); - gpr_slice_buffer_add(slice_buffer, header); - gpr_slice_buffer_add(slice_buffer, debug_data); + grpc_slice_buffer_add(slice_buffer, header); + grpc_slice_buffer_add(slice_buffer, debug_data); } diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.h b/src/core/ext/transport/chttp2/transport/frame_goaway.h index 355104a5a7..c2b82d85b3 100644 --- a/src/core/ext/transport/chttp2/transport/frame_goaway.h +++ b/src/core/ext/transport/chttp2/transport/frame_goaway.h @@ -69,10 +69,10 @@ grpc_error *grpc_chttp2_goaway_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t, grpc_chttp2_stream *s, - gpr_slice slice, int is_last); + grpc_slice slice, int is_last); void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code, - gpr_slice debug_data, - gpr_slice_buffer *slice_buffer); + grpc_slice debug_data, + grpc_slice_buffer *slice_buffer); #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.c b/src/core/ext/transport/chttp2/transport/frame_ping.c index 624f42649d..f8d73539ae 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.c +++ b/src/core/ext/transport/chttp2/transport/frame_ping.c @@ -40,8 +40,8 @@ #include #include -gpr_slice grpc_chttp2_ping_create(uint8_t ack, uint8_t *opaque_8bytes) { - gpr_slice slice = gpr_slice_malloc(9 + 8); +grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint8_t *opaque_8bytes) { + grpc_slice slice = grpc_slice_malloc(9 + 8); uint8_t *p = GPR_SLICE_START_PTR(slice); *p++ = 0; @@ -76,7 +76,7 @@ grpc_error *grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser *parser, grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t, grpc_chttp2_stream *s, - gpr_slice slice, int is_last) { + grpc_slice slice, int is_last) { uint8_t *const beg = GPR_SLICE_START_PTR(slice); uint8_t *const end = GPR_SLICE_END_PTR(slice); uint8_t *cur = beg; @@ -93,7 +93,7 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, if (p->is_ack) { grpc_chttp2_ack_ping(exec_ctx, t, p->opaque_8bytes); } else { - gpr_slice_buffer_add(&t->qbuf, + grpc_slice_buffer_add(&t->qbuf, grpc_chttp2_ping_create(1, p->opaque_8bytes)); grpc_chttp2_initiate_write(exec_ctx, t, false, "ping response"); } diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.h b/src/core/ext/transport/chttp2/transport/frame_ping.h index 2071f647fb..dcc95db4ca 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.h +++ b/src/core/ext/transport/chttp2/transport/frame_ping.h @@ -44,13 +44,13 @@ typedef struct { uint8_t opaque_8bytes[8]; } grpc_chttp2_ping_parser; -gpr_slice grpc_chttp2_ping_create(uint8_t ack, uint8_t *opaque_8bytes); +grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint8_t *opaque_8bytes); grpc_error *grpc_chttp2_ping_parser_begin_frame(grpc_chttp2_ping_parser *parser, uint32_t length, uint8_t flags); grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t, grpc_chttp2_stream *s, - gpr_slice slice, int is_last); + grpc_slice slice, int is_last); #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_PING_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.c b/src/core/ext/transport/chttp2/transport/frame_rst_stream.c index 9eac050797..7def454915 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.c @@ -42,10 +42,10 @@ #include "src/core/ext/transport/chttp2/transport/http2_errors.h" #include "src/core/ext/transport/chttp2/transport/status_conversion.h" -gpr_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code, +grpc_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code, grpc_transport_one_way_stats *stats) { static const size_t frame_size = 13; - gpr_slice slice = gpr_slice_malloc(frame_size); + grpc_slice slice = grpc_slice_malloc(frame_size); stats->framing_bytes += frame_size; uint8_t *p = GPR_SLICE_START_PTR(slice); @@ -89,7 +89,7 @@ grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t, grpc_chttp2_stream *s, - gpr_slice slice, int is_last) { + grpc_slice slice, int is_last) { uint8_t *const beg = GPR_SLICE_START_PTR(slice); uint8_t *const end = GPR_SLICE_END_PTR(slice); uint8_t *cur = beg; @@ -117,7 +117,7 @@ grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx, char *status_details; gpr_asprintf(&status_details, "Received RST_STREAM with error code %d", reason); - gpr_slice slice_details = gpr_slice_from_copied_string(status_details); + grpc_slice slice_details = grpc_slice_from_copied_string(status_details); gpr_free(status_details); grpc_chttp2_fake_status(exec_ctx, t, s, status_code, &slice_details); } diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h index 5a1f578a29..d837e95da4 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h @@ -44,7 +44,7 @@ typedef struct { uint8_t reason_bytes[4]; } grpc_chttp2_rst_stream_parser; -gpr_slice grpc_chttp2_rst_stream_create(uint32_t stream_id, uint32_t code, +grpc_slice grpc_chttp2_rst_stream_create(uint32_t stream_id, uint32_t code, grpc_transport_one_way_stats *stats); grpc_error *grpc_chttp2_rst_stream_parser_begin_frame( @@ -53,6 +53,6 @@ grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t, grpc_chttp2_stream *s, - gpr_slice slice, int is_last); + grpc_slice slice, int is_last); #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_RST_STREAM_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.c b/src/core/ext/transport/chttp2/transport/frame_settings.c index 92022f90c9..d9ea1f91a7 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.c +++ b/src/core/ext/transport/chttp2/transport/frame_settings.c @@ -82,18 +82,18 @@ static uint8_t *fill_header(uint8_t *out, uint32_t length, uint8_t flags) { return out; } -gpr_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new, +grpc_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new, uint32_t force_mask, size_t count) { size_t i; uint32_t n = 0; - gpr_slice output; + grpc_slice output; uint8_t *p; for (i = 0; i < count; i++) { n += (new[i] != old[i] || (force_mask & (1u << i)) != 0); } - output = gpr_slice_malloc(9 + 6 * n); + output = grpc_slice_malloc(9 + 6 * n); p = fill_header(GPR_SLICE_START_PTR(output), 6 * n, 0); for (i = 0; i < count; i++) { @@ -114,8 +114,8 @@ gpr_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new, return output; } -gpr_slice grpc_chttp2_settings_ack_create(void) { - gpr_slice output = gpr_slice_malloc(9); +grpc_slice grpc_chttp2_settings_ack_create(void) { + grpc_slice output = grpc_slice_malloc(9); fill_header(GPR_SLICE_START_PTR(output), 0, GRPC_CHTTP2_FLAG_ACK); return output; } @@ -146,7 +146,7 @@ grpc_error *grpc_chttp2_settings_parser_begin_frame( grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p, grpc_chttp2_transport *t, grpc_chttp2_stream *s, - gpr_slice slice, int is_last) { + grpc_slice slice, int is_last) { grpc_chttp2_settings_parser *parser = p; const uint8_t *cur = GPR_SLICE_START_PTR(slice); const uint8_t *end = GPR_SLICE_END_PTR(slice); @@ -164,7 +164,7 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p, if (is_last) { memcpy(parser->target_settings, parser->incoming_settings, GRPC_CHTTP2_NUM_SETTINGS * sizeof(uint32_t)); - gpr_slice_buffer_add(&t->qbuf, grpc_chttp2_settings_ack_create()); + grpc_slice_buffer_add(&t->qbuf, grpc_chttp2_settings_ack_create()); } return GRPC_ERROR_NONE; } @@ -225,7 +225,7 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p, case GRPC_CHTTP2_DISCONNECT_ON_INVALID_VALUE: grpc_chttp2_goaway_append( t->last_new_stream_id, sp->error_value, - gpr_slice_from_static_string("HTTP2 settings error"), + grpc_slice_from_static_string("HTTP2 settings error"), &t->qbuf); gpr_asprintf(&msg, "invalid value %u passed for %s", parser->value, sp->name); diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.h b/src/core/ext/transport/chttp2/transport/frame_settings.h index 4bfa944cf1..cb2c8de0a0 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.h +++ b/src/core/ext/transport/chttp2/transport/frame_settings.h @@ -87,10 +87,10 @@ extern const grpc_chttp2_setting_parameters grpc_chttp2_settings_parameters[GRPC_CHTTP2_NUM_SETTINGS]; /* Create a settings frame by diffing old & new, and updating old to be new */ -gpr_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new, +grpc_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new, uint32_t force_mask, size_t count); /* Create an ack settings frame */ -gpr_slice grpc_chttp2_settings_ack_create(void); +grpc_slice grpc_chttp2_settings_ack_create(void); grpc_error *grpc_chttp2_settings_parser_begin_frame( grpc_chttp2_settings_parser *parser, uint32_t length, uint8_t flags, @@ -99,6 +99,6 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t, grpc_chttp2_stream *s, - gpr_slice slice, int is_last); + grpc_slice slice, int is_last); #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.c b/src/core/ext/transport/chttp2/transport/frame_window_update.c index 418166a6df..b32f1403e1 100644 --- a/src/core/ext/transport/chttp2/transport/frame_window_update.c +++ b/src/core/ext/transport/chttp2/transport/frame_window_update.c @@ -38,10 +38,10 @@ #include #include -gpr_slice grpc_chttp2_window_update_create( +grpc_slice grpc_chttp2_window_update_create( uint32_t id, uint32_t window_update, grpc_transport_one_way_stats *stats) { static const size_t frame_size = 13; - gpr_slice slice = gpr_slice_malloc(frame_size); + grpc_slice slice = grpc_slice_malloc(frame_size); stats->header_bytes += frame_size; uint8_t *p = GPR_SLICE_START_PTR(slice); @@ -81,7 +81,7 @@ grpc_error *grpc_chttp2_window_update_parser_begin_frame( grpc_error *grpc_chttp2_window_update_parser_parse( grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t, - grpc_chttp2_stream *s, gpr_slice slice, int is_last) { + grpc_chttp2_stream *s, grpc_slice slice, int is_last) { uint8_t *const beg = GPR_SLICE_START_PTR(slice); uint8_t *const end = GPR_SLICE_END_PTR(slice); uint8_t *cur = beg; diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.h b/src/core/ext/transport/chttp2/transport/frame_window_update.h index 6e62f31872..b0f6a0a9d0 100644 --- a/src/core/ext/transport/chttp2/transport/frame_window_update.h +++ b/src/core/ext/transport/chttp2/transport/frame_window_update.h @@ -45,13 +45,13 @@ typedef struct { uint32_t amount; } grpc_chttp2_window_update_parser; -gpr_slice grpc_chttp2_window_update_create(uint32_t id, uint32_t window_delta, +grpc_slice grpc_chttp2_window_update_create(uint32_t id, uint32_t window_delta, grpc_transport_one_way_stats *stats); grpc_error *grpc_chttp2_window_update_parser_begin_frame( grpc_chttp2_window_update_parser *parser, uint32_t length, uint8_t flags); grpc_error *grpc_chttp2_window_update_parser_parse( grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t, - grpc_chttp2_stream *s, gpr_slice slice, int is_last); + grpc_chttp2_stream *s, grpc_slice slice, int is_last); #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_WINDOW_UPDATE_H */ diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.c b/src/core/ext/transport/chttp2/transport/hpack_encoder.c index 581471ba02..d8de7d0719 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.c +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.c @@ -76,7 +76,7 @@ typedef struct { uint8_t seen_regular_header; /* output stream id */ uint32_t stream_id; - gpr_slice_buffer *output; + grpc_slice_buffer *output; grpc_transport_one_way_stats *stats; /* maximum size of a frame */ size_t max_frame_size; @@ -116,7 +116,7 @@ static void finish_frame(framer_state *st, int is_header_boundary, output before beginning */ static void begin_frame(framer_state *st) { st->header_idx = - gpr_slice_buffer_add_indexed(st->output, gpr_slice_malloc(9)); + grpc_slice_buffer_add_indexed(st->output, grpc_slice_malloc(9)); st->output_length_at_start_of_frame = st->output->length; } @@ -147,7 +147,7 @@ static void inc_filter(uint8_t idx, uint32_t *sum, uint8_t *elems) { } } -static void add_header_data(framer_state *st, gpr_slice slice) { +static void add_header_data(framer_state *st, grpc_slice slice) { size_t len = GPR_SLICE_LENGTH(slice); size_t remaining; if (len == 0) return; @@ -155,10 +155,10 @@ static void add_header_data(framer_state *st, gpr_slice slice) { st->output->length; if (len <= remaining) { st->stats->header_bytes += len; - gpr_slice_buffer_add(st->output, slice); + grpc_slice_buffer_add(st->output, slice); } else { st->stats->header_bytes += remaining; - gpr_slice_buffer_add(st->output, gpr_slice_split_head(&slice, remaining)); + grpc_slice_buffer_add(st->output, grpc_slice_split_head(&slice, remaining)); finish_frame(st, 0, 0); begin_frame(st); add_header_data(st, slice); @@ -167,7 +167,7 @@ static void add_header_data(framer_state *st, gpr_slice slice) { static uint8_t *add_tiny_header_data(framer_state *st, size_t len) { ensure_space(st, len); - return gpr_slice_buffer_tiny_add(st->output, len); + return grpc_slice_buffer_tiny_add(st->output, len); } static void evict_entry(grpc_chttp2_hpack_compressor *c) { @@ -268,7 +268,7 @@ static void emit_indexed(grpc_chttp2_hpack_compressor *c, uint32_t elem_index, len); } -static gpr_slice get_wire_value(grpc_mdelem *elem, uint8_t *huffman_prefix) { +static grpc_slice get_wire_value(grpc_mdelem *elem, uint8_t *huffman_prefix) { if (grpc_is_binary_header((const char *)GPR_SLICE_START_PTR(elem->key->slice), GPR_SLICE_LENGTH(elem->key->slice))) { *huffman_prefix = 0x80; @@ -284,7 +284,7 @@ static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c, framer_state *st) { uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2); uint8_t huffman_prefix; - gpr_slice value_slice = get_wire_value(elem, &huffman_prefix); + grpc_slice value_slice = get_wire_value(elem, &huffman_prefix); size_t len_val = GPR_SLICE_LENGTH(value_slice); uint32_t len_val_len; GPR_ASSERT(len_val <= UINT32_MAX); @@ -293,7 +293,7 @@ static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c, add_tiny_header_data(st, len_pfx), len_pfx); GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, huffman_prefix, add_tiny_header_data(st, len_val_len), len_val_len); - add_header_data(st, gpr_slice_ref(value_slice)); + add_header_data(st, grpc_slice_ref(value_slice)); } static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c, @@ -301,7 +301,7 @@ static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c, framer_state *st) { uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4); uint8_t huffman_prefix; - gpr_slice value_slice = get_wire_value(elem, &huffman_prefix); + grpc_slice value_slice = get_wire_value(elem, &huffman_prefix); size_t len_val = GPR_SLICE_LENGTH(value_slice); uint32_t len_val_len; GPR_ASSERT(len_val <= UINT32_MAX); @@ -310,14 +310,14 @@ static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c, add_tiny_header_data(st, len_pfx), len_pfx); GRPC_CHTTP2_WRITE_VARINT((uint32_t)len_val, 1, huffman_prefix, add_tiny_header_data(st, len_val_len), len_val_len); - add_header_data(st, gpr_slice_ref(value_slice)); + add_header_data(st, grpc_slice_ref(value_slice)); } static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem, framer_state *st) { uint32_t len_key = (uint32_t)GPR_SLICE_LENGTH(elem->key->slice); uint8_t huffman_prefix; - gpr_slice value_slice = get_wire_value(elem, &huffman_prefix); + grpc_slice value_slice = get_wire_value(elem, &huffman_prefix); uint32_t len_val = (uint32_t)GPR_SLICE_LENGTH(value_slice); uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); @@ -326,17 +326,17 @@ static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor *c, *add_tiny_header_data(st, 1) = 0x40; GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, add_tiny_header_data(st, len_key_len), len_key_len); - add_header_data(st, gpr_slice_ref(elem->key->slice)); + add_header_data(st, grpc_slice_ref(elem->key->slice)); GRPC_CHTTP2_WRITE_VARINT(len_val, 1, huffman_prefix, add_tiny_header_data(st, len_val_len), len_val_len); - add_header_data(st, gpr_slice_ref(value_slice)); + add_header_data(st, grpc_slice_ref(value_slice)); } static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem, framer_state *st) { uint32_t len_key = (uint32_t)GPR_SLICE_LENGTH(elem->key->slice); uint8_t huffman_prefix; - gpr_slice value_slice = get_wire_value(elem, &huffman_prefix); + grpc_slice value_slice = get_wire_value(elem, &huffman_prefix); uint32_t len_val = (uint32_t)GPR_SLICE_LENGTH(value_slice); uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); @@ -345,10 +345,10 @@ static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor *c, *add_tiny_header_data(st, 1) = 0x00; GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, add_tiny_header_data(st, len_key_len), len_key_len); - add_header_data(st, gpr_slice_ref(elem->key->slice)); + add_header_data(st, grpc_slice_ref(elem->key->slice)); GRPC_CHTTP2_WRITE_VARINT(len_val, 1, huffman_prefix, add_tiny_header_data(st, len_val_len), len_val_len); - add_header_data(st, gpr_slice_ref(value_slice)); + add_header_data(st, grpc_slice_ref(value_slice)); } static void emit_advertise_table_size_change(grpc_chttp2_hpack_compressor *c, @@ -546,7 +546,7 @@ void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor *c, grpc_metadata_batch *metadata, int is_eof, size_t max_frame_size, grpc_transport_one_way_stats *stats, - gpr_slice_buffer *outbuf) { + grpc_slice_buffer *outbuf) { framer_state st; grpc_linked_mdelem *l; gpr_timespec deadline; diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.h b/src/core/ext/transport/chttp2/transport/hpack_encoder.h index 4c3a931549..abbd514fc2 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.h +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.h @@ -93,6 +93,6 @@ void grpc_chttp2_encode_header(grpc_chttp2_hpack_compressor *c, uint32_t id, grpc_metadata_batch *metadata, int is_eof, size_t max_frame_size, grpc_transport_one_way_stats *stats, - gpr_slice_buffer *outbuf); + grpc_slice_buffer *outbuf); #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H */ diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.c b/src/core/ext/transport/chttp2/transport/hpack_parser.c index 8180f78fc0..0e721b181a 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.c +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.c @@ -1582,7 +1582,7 @@ grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx, void *hpack_parser, grpc_chttp2_transport *t, grpc_chttp2_stream *s, - gpr_slice slice, int is_last) { + grpc_slice slice, int is_last) { grpc_chttp2_hpack_parser *parser = hpack_parser; GPR_TIMER_BEGIN("grpc_chttp2_hpack_parser_parse", 0); if (s != NULL) { diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.h b/src/core/ext/transport/chttp2/transport/hpack_parser.h index 0290c78d5a..a39bf466cd 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.h +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.h @@ -116,6 +116,6 @@ grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx, void *hpack_parser, grpc_chttp2_transport *t, grpc_chttp2_stream *s, - gpr_slice slice, int is_last); + grpc_slice slice, int is_last); #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_PARSER_H */ diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index e0c4a1e925..18fa2b4890 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -170,14 +170,14 @@ struct grpc_chttp2_incoming_byte_stream { bool is_tail; gpr_mu slice_mu; // protects slices, on_next - gpr_slice_buffer slices; + grpc_slice_buffer slices; grpc_closure *on_next; - gpr_slice *next; + grpc_slice *next; uint32_t remaining_bytes; struct { grpc_closure closure; - gpr_slice *slice; + grpc_slice *slice; size_t max_size_hint; grpc_closure *on_complete; } next_action; @@ -219,7 +219,7 @@ struct grpc_chttp2_transport { grpc_closure read_action_locked; /** incoming read bytes */ - gpr_slice_buffer read_buffer; + grpc_slice_buffer read_buffer; /** address to place a newly accepted stream - set and unset by grpc_chttp2_parsing_accept_stream; used by init_stream to @@ -237,7 +237,7 @@ struct grpc_chttp2_transport { } channel_callback; /** data to write now */ - gpr_slice_buffer outbuf; + grpc_slice_buffer outbuf; /** hpack encoding */ grpc_chttp2_hpack_compressor hpack_compressor; int64_t outgoing_window; @@ -245,7 +245,7 @@ struct grpc_chttp2_transport { uint8_t is_client; /** data to write next write */ - gpr_slice_buffer qbuf; + grpc_slice_buffer qbuf; /** window available to announce to peer */ int64_t announce_incoming_window; @@ -314,12 +314,12 @@ struct grpc_chttp2_transport { grpc_chttp2_stream *incoming_stream; grpc_error *(*parser)(grpc_exec_ctx *exec_ctx, void *parser_user_data, grpc_chttp2_transport *t, grpc_chttp2_stream *s, - gpr_slice slice, int is_last); + grpc_slice slice, int is_last); /* goaway data */ grpc_status_code goaway_error; uint32_t goaway_last_stream_index; - gpr_slice goaway_text; + grpc_slice goaway_text; grpc_chttp2_write_cb *write_cb_pool; @@ -374,7 +374,7 @@ struct grpc_chttp2_stream { grpc_byte_stream *fetching_send_message; uint32_t fetched_send_message_length; - gpr_slice fetching_slice; + grpc_slice fetching_slice; int64_t next_message_end_offset; int64_t flow_controlled_bytes_written; bool complete_fetch_covered_by_poller; @@ -434,7 +434,7 @@ struct grpc_chttp2_stream { bool sent_trailing_metadata; /** how much window should we announce? */ uint32_t announce_window; - gpr_slice_buffer flow_controlled_buffer; + grpc_slice_buffer flow_controlled_buffer; grpc_chttp2_write_cb *on_write_finished_cbs; grpc_chttp2_write_cb *finish_after_write; @@ -466,7 +466,7 @@ void grpc_chttp2_end_write(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, /** Process one slice of incoming data; return 1 if the connection is still viable after reading, or 0 if the connection should be torn down */ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx, - grpc_chttp2_transport *t, gpr_slice slice); + grpc_chttp2_transport *t, grpc_slice slice); bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport *t, grpc_chttp2_stream *s); @@ -509,7 +509,7 @@ grpc_chttp2_stream *grpc_chttp2_parsing_accept_stream(grpc_exec_ctx *exec_ctx, void grpc_chttp2_add_incoming_goaway(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, uint32_t goaway_error, - gpr_slice goaway_text); + grpc_slice goaway_text); void grpc_chttp2_parsing_become_skip_parser(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t); @@ -611,7 +611,7 @@ void grpc_chttp2_flowctl_trace(const char *file, int line, const char *phase, void grpc_chttp2_fake_status(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_stream *stream, - grpc_status_code status, gpr_slice *details); + grpc_status_code status, grpc_slice *details); void grpc_chttp2_mark_stream_closed(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_stream *s, int close_reads, @@ -659,7 +659,7 @@ grpc_chttp2_incoming_byte_stream *grpc_chttp2_incoming_byte_stream_create( uint32_t frame_size, uint32_t flags); void grpc_chttp2_incoming_byte_stream_push(grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs, - gpr_slice slice); + grpc_slice slice); void grpc_chttp2_incoming_byte_stream_finished( grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs, grpc_error *error); diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index 8005350ae7..6941a1e397 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -67,12 +67,12 @@ static grpc_error *init_skip_frame_parser(grpc_exec_ctx *exec_ctx, int is_header); static grpc_error *parse_frame_slice(grpc_exec_ctx *exec_ctx, - grpc_chttp2_transport *t, gpr_slice slice, + grpc_chttp2_transport *t, grpc_slice slice, int is_last); grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, - gpr_slice slice) { + grpc_slice slice) { uint8_t *beg = GPR_SLICE_START_PTR(slice); uint8_t *end = GPR_SLICE_END_PTR(slice); uint8_t *cur = beg; @@ -230,7 +230,7 @@ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx, GPR_ASSERT(cur < end); if ((uint32_t)(end - cur) == t->incoming_frame_size) { err = parse_frame_slice(exec_ctx, t, - gpr_slice_sub_no_ref(slice, (size_t)(cur - beg), + grpc_slice_sub_no_ref(slice, (size_t)(cur - beg), (size_t)(end - beg)), 1); if (err != GRPC_ERROR_NONE) { @@ -243,7 +243,7 @@ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx, size_t cur_offset = (size_t)(cur - beg); err = parse_frame_slice( exec_ctx, t, - gpr_slice_sub_no_ref(slice, cur_offset, + grpc_slice_sub_no_ref(slice, cur_offset, cur_offset + t->incoming_frame_size), 1); if (err != GRPC_ERROR_NONE) { @@ -254,7 +254,7 @@ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx, goto dts_fh_0; /* loop */ } else { err = parse_frame_slice(exec_ctx, t, - gpr_slice_sub_no_ref(slice, (size_t)(cur - beg), + grpc_slice_sub_no_ref(slice, (size_t)(cur - beg), (size_t)(end - beg)), 0); if (err != GRPC_ERROR_NONE) { @@ -331,7 +331,7 @@ static grpc_error *init_frame_parser(grpc_exec_ctx *exec_ctx, static grpc_error *skip_parser(grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t, grpc_chttp2_stream *s, - gpr_slice slice, int is_last) { + grpc_slice slice, int is_last) { return GRPC_ERROR_NONE; } @@ -430,7 +430,7 @@ error_handler: if (s != NULL) { grpc_chttp2_mark_stream_closed(exec_ctx, t, s, true, false, err); } - gpr_slice_buffer_add( + grpc_slice_buffer_add( &t->qbuf, grpc_chttp2_rst_stream_create(t->incoming_stream_id, GRPC_CHTTP2_PROTOCOL_ERROR, &s->stats.outgoing)); @@ -722,7 +722,7 @@ static grpc_error *init_settings_frame_parser(grpc_exec_ctx *exec_ctx, } static grpc_error *parse_frame_slice(grpc_exec_ctx *exec_ctx, - grpc_chttp2_transport *t, gpr_slice slice, + grpc_chttp2_transport *t, grpc_slice slice, int is_last) { grpc_chttp2_stream *s = t->incoming_stream; grpc_error *err = t->parser(exec_ctx, t->parser_data, t, s, slice, is_last); @@ -737,7 +737,7 @@ static grpc_error *parse_frame_slice(grpc_exec_ctx *exec_ctx, grpc_chttp2_parsing_become_skip_parser(exec_ctx, t); if (s) { s->forced_close_error = err; - gpr_slice_buffer_add( + grpc_slice_buffer_add( &t->qbuf, grpc_chttp2_rst_stream_create(t->incoming_stream_id, GRPC_CHTTP2_PROTOCOL_ERROR, &s->stats.outgoing)); diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index b39695a1a5..1486a7edb4 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -80,7 +80,7 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, GPR_TIMER_BEGIN("grpc_chttp2_begin_write", 0); if (t->dirtied_local_settings && !t->sent_local_settings) { - gpr_slice_buffer_add( + grpc_slice_buffer_add( &t->outbuf, grpc_chttp2_settings_create( t->settings[GRPC_SENT_SETTINGS], t->settings[GRPC_LOCAL_SETTINGS], @@ -91,7 +91,7 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, } /* simple writes are queued to qbuf, and flushed here */ - gpr_slice_buffer_move_into(&t->qbuf, &t->outbuf); + grpc_slice_buffer_move_into(&t->qbuf, &t->outbuf); GPR_ASSERT(t->qbuf.count == 0); grpc_chttp2_hpack_compressor_set_max_table_size( @@ -130,7 +130,7 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, /* send any window updates */ if (s->announce_window > 0) { uint32_t announce = s->announce_window; - gpr_slice_buffer_add(&t->outbuf, + grpc_slice_buffer_add(&t->outbuf, grpc_chttp2_window_update_create( s->id, s->announce_window, &s->stats.outgoing)); GRPC_CHTTP2_FLOW_DEBIT_STREAM("write", t, s, announce_window, announce); @@ -162,7 +162,7 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, s->send_trailing_metadata = NULL; s->sent_trailing_metadata = true; if (!t->is_client && !s->read_closed) { - gpr_slice_buffer_add(&t->outbuf, grpc_chttp2_rst_stream_create( + grpc_slice_buffer_add(&t->outbuf, grpc_chttp2_rst_stream_create( s->id, GRPC_CHTTP2_NO_ERROR, &s->stats.outgoing)); } @@ -194,7 +194,7 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, s->send_trailing_metadata = NULL; s->sent_trailing_metadata = true; if (!t->is_client && !s->read_closed) { - gpr_slice_buffer_add( + grpc_slice_buffer_add( &t->outbuf, grpc_chttp2_rst_stream_create( s->id, GRPC_CHTTP2_NO_ERROR, &s->stats.outgoing)); } @@ -220,7 +220,7 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, GRPC_CHTTP2_FLOW_DEBIT_TRANSPORT("write", t, announce_incoming_window, announced); grpc_transport_one_way_stats throwaway_stats; - gpr_slice_buffer_add(&t->outbuf, grpc_chttp2_window_update_create( + grpc_slice_buffer_add(&t->outbuf, grpc_chttp2_window_update_create( 0, announced, &throwaway_stats)); } @@ -254,7 +254,7 @@ void grpc_chttp2_end_write(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, } GRPC_CHTTP2_STREAM_UNREF(exec_ctx, s, "chttp2_writing:end"); } - gpr_slice_buffer_reset_and_unref(&t->outbuf); + grpc_slice_buffer_reset_and_unref(&t->outbuf); GRPC_ERROR_UNREF(error); GPR_TIMER_END("grpc_chttp2_end_write", 0); } diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 25ad40b935..87b2c0880f 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -130,7 +130,7 @@ struct read_state { /* vars for holding data destined for the application */ struct grpc_slice_buffer_stream sbs; - gpr_slice_buffer read_slice_buffer; + grpc_slice_buffer read_slice_buffer; /* vars for trailing metadata */ grpc_chttp2_incoming_metadata_buffer trailing_metadata; @@ -517,10 +517,10 @@ static void on_response_trailers_received( Utility function that takes the data from s->write_slice_buffer and assembles into a contiguous byte stream with 5 byte gRPC header prepended. */ -static void create_grpc_frame(gpr_slice_buffer *write_slice_buffer, +static void create_grpc_frame(grpc_slice_buffer *write_slice_buffer, char **pp_write_buffer, size_t *p_write_buffer_size) { - gpr_slice slice = gpr_slice_buffer_take_first(write_slice_buffer); + grpc_slice slice = grpc_slice_buffer_take_first(write_slice_buffer); size_t length = GPR_SLICE_LENGTH(slice); *p_write_buffer_size = length + GRPC_HEADER_SIZE_IN_BYTES; /* This is freed in the on_write_completed callback */ @@ -817,9 +817,9 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, result = NO_ACTION_POSSIBLE; CRONET_LOG(GPR_DEBUG, "Stream is either cancelled or failed."); } else { - gpr_slice_buffer write_slice_buffer; - gpr_slice slice; - gpr_slice_buffer_init(&write_slice_buffer); + grpc_slice_buffer write_slice_buffer; + grpc_slice slice; + grpc_slice_buffer_init(&write_slice_buffer); grpc_byte_stream_next(NULL, stream_op->send_message, &slice, stream_op->send_message->length, NULL); /* Check that compression flag is OFF. We don't support compression yet. @@ -828,7 +828,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, gpr_log(GPR_ERROR, "Compression is not supported"); GPR_ASSERT(stream_op->send_message->flags == 0); } - gpr_slice_buffer_add(&write_slice_buffer, slice); + grpc_slice_buffer_add(&write_slice_buffer, slice); if (write_slice_buffer.count != 1) { /* Empty request not handled yet */ gpr_log(GPR_ERROR, "Empty request is not supported"); @@ -891,7 +891,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, } else { stream_state->rs.remaining_bytes = 0; CRONET_LOG(GPR_DEBUG, "read operation complete. Empty response."); - gpr_slice_buffer_init(&stream_state->rs.read_slice_buffer); + grpc_slice_buffer_init(&stream_state->rs.read_slice_buffer); grpc_slice_buffer_stream_init(&stream_state->rs.sbs, &stream_state->rs.read_slice_buffer, 0); *((grpc_byte_buffer **)stream_op->recv_message) = @@ -918,14 +918,14 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, } } else if (stream_state->rs.remaining_bytes == 0) { CRONET_LOG(GPR_DEBUG, "read operation complete"); - gpr_slice read_data_slice = - gpr_slice_malloc((uint32_t)stream_state->rs.length_field); + grpc_slice read_data_slice = + grpc_slice_malloc((uint32_t)stream_state->rs.length_field); uint8_t *dst_p = GPR_SLICE_START_PTR(read_data_slice); memcpy(dst_p, stream_state->rs.read_buffer, (size_t)stream_state->rs.length_field); free_read_buffer(s); - gpr_slice_buffer_init(&stream_state->rs.read_slice_buffer); - gpr_slice_buffer_add(&stream_state->rs.read_slice_buffer, + grpc_slice_buffer_init(&stream_state->rs.read_slice_buffer); + grpc_slice_buffer_add(&stream_state->rs.read_slice_buffer, read_data_slice); grpc_slice_buffer_stream_init(&stream_state->rs.sbs, &stream_state->rs.read_slice_buffer, 0); diff --git a/src/core/lib/channel/channel_stack.c b/src/core/lib/channel/channel_stack.c index 2c5367901d..9da81959e7 100644 --- a/src/core/lib/channel/channel_stack.c +++ b/src/core/lib/channel/channel_stack.c @@ -288,7 +288,7 @@ void grpc_call_element_send_cancel(grpc_exec_ctx *exec_ctx, void grpc_call_element_send_cancel_with_message(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, grpc_status_code status, - gpr_slice *optional_message) { + grpc_slice *optional_message) { grpc_transport_stream_op *op = gpr_malloc(sizeof(*op)); memset(op, 0, sizeof(*op)); op->on_complete = grpc_closure_create(destroy_op, op); @@ -300,7 +300,7 @@ void grpc_call_element_send_cancel_with_message(grpc_exec_ctx *exec_ctx, void grpc_call_element_send_close_with_message(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, grpc_status_code status, - gpr_slice *optional_message) { + grpc_slice *optional_message) { grpc_transport_stream_op *op = gpr_malloc(sizeof(*op)); memset(op, 0, sizeof(*op)); op->on_complete = grpc_closure_create(destroy_op, op); diff --git a/src/core/lib/channel/channel_stack.h b/src/core/lib/channel/channel_stack.h index 27f3be7b29..0d58994726 100644 --- a/src/core/lib/channel/channel_stack.h +++ b/src/core/lib/channel/channel_stack.h @@ -289,12 +289,12 @@ void grpc_call_element_send_cancel(grpc_exec_ctx *exec_ctx, void grpc_call_element_send_cancel_with_message(grpc_exec_ctx *exec_ctx, grpc_call_element *cur_elem, grpc_status_code status, - gpr_slice *optional_message); + grpc_slice *optional_message); void grpc_call_element_send_close_with_message(grpc_exec_ctx *exec_ctx, grpc_call_element *cur_elem, grpc_status_code status, - gpr_slice *optional_message); + grpc_slice *optional_message); extern int grpc_trace_channel; diff --git a/src/core/lib/channel/compress_filter.c b/src/core/lib/channel/compress_filter.c index 0981d59f63..f797d82eb9 100644 --- a/src/core/lib/channel/compress_filter.c +++ b/src/core/lib/channel/compress_filter.c @@ -50,7 +50,7 @@ int grpc_compression_trace = 0; typedef struct call_data { - gpr_slice_buffer slices; /**< Buffers up input slices to be compressed */ + grpc_slice_buffer slices; /**< Buffers up input slices to be compressed */ grpc_linked_mdelem compression_algorithm_storage; grpc_linked_mdelem accept_encoding_storage; uint32_t remaining_slice_bytes; @@ -63,7 +63,7 @@ typedef struct call_data { grpc_transport_stream_op *send_op; uint32_t send_length; uint32_t send_flags; - gpr_slice incoming_slice; + grpc_slice incoming_slice; grpc_slice_buffer_stream replacement_stream; grpc_closure *post_send; grpc_closure send_done; @@ -157,7 +157,7 @@ static void continue_send_message(grpc_exec_ctx *exec_ctx, static void send_done(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) { grpc_call_element *elem = elemp; call_data *calld = elem->call_data; - gpr_slice_buffer_reset_and_unref(&calld->slices); + grpc_slice_buffer_reset_and_unref(&calld->slices); calld->post_send->cb(exec_ctx, calld->post_send->cb_arg, error); } @@ -165,8 +165,8 @@ static void finish_send_message(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) { call_data *calld = elem->call_data; int did_compress; - gpr_slice_buffer tmp; - gpr_slice_buffer_init(&tmp); + grpc_slice_buffer tmp; + grpc_slice_buffer_init(&tmp); did_compress = grpc_msg_compress(calld->compression_algorithm, &calld->slices, &tmp); if (did_compress) { @@ -181,7 +181,7 @@ static void finish_send_message(grpc_exec_ctx *exec_ctx, " bytes (%.2f%% savings)", algo_name, before_size, after_size, 100 * savings_ratio); } - gpr_slice_buffer_swap(&calld->slices, &tmp); + grpc_slice_buffer_swap(&calld->slices, &tmp); calld->send_flags |= GRPC_WRITE_INTERNAL_COMPRESS; } else { if (grpc_compression_trace) { @@ -195,7 +195,7 @@ static void finish_send_message(grpc_exec_ctx *exec_ctx, } } - gpr_slice_buffer_destroy(&tmp); + grpc_slice_buffer_destroy(&tmp); grpc_slice_buffer_stream_init(&calld->replacement_stream, &calld->slices, calld->send_flags); @@ -209,7 +209,7 @@ static void finish_send_message(grpc_exec_ctx *exec_ctx, static void got_slice(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) { grpc_call_element *elem = elemp; call_data *calld = elem->call_data; - gpr_slice_buffer_add(&calld->slices, calld->incoming_slice); + grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); if (calld->send_length == calld->slices.length) { finish_send_message(exec_ctx, elem); } else { @@ -223,7 +223,7 @@ static void continue_send_message(grpc_exec_ctx *exec_ctx, while (grpc_byte_stream_next(exec_ctx, calld->send_op->send_message, &calld->incoming_slice, ~(size_t)0, &calld->got_slice)) { - gpr_slice_buffer_add(&calld->slices, calld->incoming_slice); + grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); if (calld->send_length == calld->slices.length) { finish_send_message(exec_ctx, elem); break; @@ -263,7 +263,7 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, call_data *calld = elem->call_data; /* initialize members */ - gpr_slice_buffer_init(&calld->slices); + grpc_slice_buffer_init(&calld->slices); calld->has_compression_algorithm = 0; grpc_closure_init(&calld->got_slice, got_slice, elem); grpc_closure_init(&calld->send_done, send_done, elem); @@ -277,7 +277,7 @@ static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, void *ignored) { /* grab pointers to our data from the call element */ call_data *calld = elem->call_data; - gpr_slice_buffer_destroy(&calld->slices); + grpc_slice_buffer_destroy(&calld->slices); } /* Constructor for channel_data */ diff --git a/src/core/lib/channel/deadline_filter.c b/src/core/lib/channel/deadline_filter.c index d2ea5250f6..449eb7b8d6 100644 --- a/src/core/lib/channel/deadline_filter.c +++ b/src/core/lib/channel/deadline_filter.c @@ -55,10 +55,10 @@ static void timer_callback(grpc_exec_ctx* exec_ctx, void* arg, deadline_state->timer_pending = false; gpr_mu_unlock(&deadline_state->timer_mu); if (error != GRPC_ERROR_CANCELLED) { - gpr_slice msg = gpr_slice_from_static_string("Deadline Exceeded"); + grpc_slice msg = grpc_slice_from_static_string("Deadline Exceeded"); grpc_call_element_send_cancel_with_message( exec_ctx, elem, GRPC_STATUS_DEADLINE_EXCEEDED, &msg); - gpr_slice_unref(msg); + grpc_slice_unref(msg); } GRPC_CALL_STACK_UNREF(exec_ctx, deadline_state->call_stack, "deadline_timer"); } diff --git a/src/core/lib/channel/handshaker.c b/src/core/lib/channel/handshaker.c index 0d759887bc..00d39764d7 100644 --- a/src/core/lib/channel/handshaker.c +++ b/src/core/lib/channel/handshaker.c @@ -62,7 +62,7 @@ void grpc_handshaker_do_handshake(grpc_exec_ctx* exec_ctx, grpc_handshaker* handshaker, grpc_endpoint* endpoint, grpc_channel_args* args, - gpr_slice_buffer* read_buffer, + grpc_slice_buffer* read_buffer, gpr_timespec deadline, grpc_tcp_server_acceptor* acceptor, grpc_handshaker_done_cb cb, void* user_data) { @@ -146,7 +146,7 @@ void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx, static void call_next_handshaker(grpc_exec_ctx* exec_ctx, grpc_endpoint* endpoint, grpc_channel_args* args, - gpr_slice_buffer* read_buffer, void* user_data, + grpc_slice_buffer* read_buffer, void* user_data, grpc_error* error) { grpc_handshake_manager* mgr = user_data; GPR_ASSERT(mgr->state != NULL); @@ -183,8 +183,8 @@ void grpc_handshake_manager_do_handshake( gpr_timespec deadline, grpc_tcp_server_acceptor* acceptor, grpc_handshaker_done_cb cb, void* user_data) { grpc_channel_args* args_copy = grpc_channel_args_copy(args); - gpr_slice_buffer* read_buffer = gpr_malloc(sizeof(*read_buffer)); - gpr_slice_buffer_init(read_buffer); + grpc_slice_buffer* read_buffer = gpr_malloc(sizeof(*read_buffer)); + grpc_slice_buffer_init(read_buffer); if (mgr->count == 0) { // No handshakers registered, so we just immediately call the done // callback with the passed-in endpoint. diff --git a/src/core/lib/channel/handshaker.h b/src/core/lib/channel/handshaker.h index d574b46242..f8a36c6473 100644 --- a/src/core/lib/channel/handshaker.h +++ b/src/core/lib/channel/handshaker.h @@ -59,7 +59,7 @@ typedef struct grpc_handshaker grpc_handshaker; typedef void (*grpc_handshaker_done_cb)(grpc_exec_ctx* exec_ctx, grpc_endpoint* endpoint, grpc_channel_args* args, - gpr_slice_buffer* read_buffer, + grpc_slice_buffer* read_buffer, void* user_data, grpc_error* error); struct grpc_handshaker_vtable { @@ -77,7 +77,7 @@ struct grpc_handshaker_vtable { /// \a acceptor will be NULL for client-side handshakers. void (*do_handshake)(grpc_exec_ctx* exec_ctx, grpc_handshaker* handshaker, grpc_endpoint* endpoint, grpc_channel_args* args, - gpr_slice_buffer* read_buffer, gpr_timespec deadline, + grpc_slice_buffer* read_buffer, gpr_timespec deadline, grpc_tcp_server_acceptor* acceptor, grpc_handshaker_done_cb cb, void* user_data); }; @@ -103,7 +103,7 @@ void grpc_handshaker_do_handshake(grpc_exec_ctx* exec_ctx, grpc_handshaker* handshaker, grpc_endpoint* endpoint, grpc_channel_args* args, - gpr_slice_buffer* read_buffer, + grpc_slice_buffer* read_buffer, gpr_timespec deadline, grpc_tcp_server_acceptor* acceptor, grpc_handshaker_done_cb cb, void* user_data); diff --git a/src/core/lib/channel/http_client_filter.c b/src/core/lib/channel/http_client_filter.c index 1dc05fb20d..110c1cb546 100644 --- a/src/core/lib/channel/http_client_filter.c +++ b/src/core/lib/channel/http_client_filter.c @@ -62,9 +62,9 @@ typedef struct call_data { grpc_transport_stream_op send_op; uint32_t send_length; uint32_t send_flags; - gpr_slice incoming_slice; + grpc_slice incoming_slice; grpc_slice_buffer_stream replacement_stream; - gpr_slice_buffer slices; + grpc_slice_buffer slices; /* flag that indicates that all slices of send_messages aren't availble */ bool send_message_blocked; @@ -101,7 +101,7 @@ static grpc_mdelem *client_recv_filter(void *user_data, grpc_mdelem *md) { char *message_string; gpr_asprintf(&message_string, "Received http2 header with status: %s", grpc_mdstr_as_c_string(md->value)); - gpr_slice message = gpr_slice_from_copied_string(message_string); + grpc_slice message = grpc_slice_from_copied_string(message_string); gpr_free(message_string); grpc_call_element_send_close_with_message(a->exec_ctx, a->elem, GRPC_STATUS_CANCELLED, &message); @@ -155,7 +155,7 @@ static void hc_on_complete(grpc_exec_ctx *exec_ctx, void *user_data, static void send_done(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) { grpc_call_element *elem = elemp; call_data *calld = elem->call_data; - gpr_slice_buffer_reset_and_unref(&calld->slices); + grpc_slice_buffer_reset_and_unref(&calld->slices); calld->post_send->cb(exec_ctx, calld->post_send->cb_arg, error); } @@ -179,7 +179,7 @@ static void continue_send_message(grpc_exec_ctx *exec_ctx, memcpy(wrptr, GPR_SLICE_START_PTR(calld->incoming_slice), GPR_SLICE_LENGTH(calld->incoming_slice)); wrptr += GPR_SLICE_LENGTH(calld->incoming_slice); - gpr_slice_buffer_add(&calld->slices, calld->incoming_slice); + grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); if (calld->send_length == calld->slices.length) { calld->send_message_blocked = false; break; @@ -191,7 +191,7 @@ static void got_slice(grpc_exec_ctx *exec_ctx, void *elemp, grpc_error *error) { grpc_call_element *elem = elemp; call_data *calld = elem->call_data; calld->send_message_blocked = false; - gpr_slice_buffer_add(&calld->slices, calld->incoming_slice); + grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); if (calld->send_length == calld->slices.length) { /* Pass down the original send_message op that was blocked.*/ grpc_slice_buffer_stream_init(&calld->replacement_stream, &calld->slices, @@ -311,7 +311,7 @@ static grpc_error *init_call_elem(grpc_exec_ctx *exec_ctx, calld->on_done_recv = NULL; calld->on_complete = NULL; calld->payload_bytes = NULL; - gpr_slice_buffer_init(&calld->slices); + grpc_slice_buffer_init(&calld->slices); grpc_closure_init(&calld->hc_on_recv, hc_on_recv, elem); grpc_closure_init(&calld->hc_on_complete, hc_on_complete, elem); grpc_closure_init(&calld->got_slice, got_slice, elem); @@ -324,7 +324,7 @@ static void destroy_call_elem(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, const grpc_call_final_info *final_info, void *ignored) { call_data *calld = elem->call_data; - gpr_slice_buffer_destroy(&calld->slices); + grpc_slice_buffer_destroy(&calld->slices); } static grpc_mdelem *scheme_from_args(const grpc_channel_args *args) { diff --git a/src/core/lib/channel/http_server_filter.c b/src/core/lib/channel/http_server_filter.c index f2221fb0fb..1a73a07b81 100644 --- a/src/core/lib/channel/http_server_filter.c +++ b/src/core/lib/channel/http_server_filter.c @@ -68,7 +68,7 @@ typedef struct call_data { grpc_closure *recv_message_ready; grpc_closure *on_complete; grpc_byte_stream **pp_recv_message; - gpr_slice_buffer read_slice_buffer; + grpc_slice_buffer read_slice_buffer; grpc_slice_buffer_stream read_stream; /** Receive closures are chained: we inject this closure as the on_done_recv @@ -162,9 +162,9 @@ static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) { /* Retrieve the payload from the value of the 'grpc-internal-payload-bin' header field */ calld->seen_payload_bin = 1; - gpr_slice_buffer_init(&calld->read_slice_buffer); - gpr_slice_buffer_add(&calld->read_slice_buffer, - gpr_slice_ref(md->value->slice)); + grpc_slice_buffer_init(&calld->read_slice_buffer); + grpc_slice_buffer_add(&calld->read_slice_buffer, + grpc_slice_ref(md->value->slice)); grpc_slice_buffer_stream_init(&calld->read_stream, &calld->read_slice_buffer, 0); return NULL; diff --git a/src/core/lib/channel/message_size_filter.c b/src/core/lib/channel/message_size_filter.c index b8b2546035..e25ca17646 100644 --- a/src/core/lib/channel/message_size_filter.c +++ b/src/core/lib/channel/message_size_filter.c @@ -141,7 +141,7 @@ static void start_transport_stream_op(grpc_exec_ctx* exec_ctx, char* message_string; gpr_asprintf(&message_string, "Sent message larger than max (%u vs. %d)", op->send_message->length, calld->max_send_size); - gpr_slice message = gpr_slice_from_copied_string(message_string); + grpc_slice message = grpc_slice_from_copied_string(message_string); gpr_free(message_string); grpc_call_element_send_close_with_message( exec_ctx, elem, GRPC_STATUS_INVALID_ARGUMENT, &message); diff --git a/src/core/lib/compression/message_compress.c b/src/core/lib/compression/message_compress.c index cbe0b5a285..501cb8be69 100644 --- a/src/core/lib/compression/message_compress.c +++ b/src/core/lib/compression/message_compress.c @@ -42,13 +42,13 @@ #define OUTPUT_BLOCK_SIZE 1024 -static int zlib_body(z_stream* zs, gpr_slice_buffer* input, - gpr_slice_buffer* output, +static int zlib_body(z_stream* zs, grpc_slice_buffer* input, + grpc_slice_buffer* output, int (*flate)(z_stream* zs, int flush)) { int r; int flush; size_t i; - gpr_slice outbuf = gpr_slice_malloc(OUTPUT_BLOCK_SIZE); + grpc_slice outbuf = grpc_slice_malloc(OUTPUT_BLOCK_SIZE); const uInt uint_max = ~(uInt)0; GPR_ASSERT(GPR_SLICE_LENGTH(outbuf) <= uint_max); @@ -62,8 +62,8 @@ static int zlib_body(z_stream* zs, gpr_slice_buffer* input, zs->next_in = GPR_SLICE_START_PTR(input->slices[i]); do { if (zs->avail_out == 0) { - gpr_slice_buffer_add_indexed(output, outbuf); - outbuf = gpr_slice_malloc(OUTPUT_BLOCK_SIZE); + grpc_slice_buffer_add_indexed(output, outbuf); + outbuf = grpc_slice_malloc(OUTPUT_BLOCK_SIZE); GPR_ASSERT(GPR_SLICE_LENGTH(outbuf) <= uint_max); zs->avail_out = (uInt)GPR_SLICE_LENGTH(outbuf); zs->next_out = GPR_SLICE_START_PTR(outbuf); @@ -82,12 +82,12 @@ static int zlib_body(z_stream* zs, gpr_slice_buffer* input, GPR_ASSERT(outbuf.refcount); outbuf.data.refcounted.length -= zs->avail_out; - gpr_slice_buffer_add_indexed(output, outbuf); + grpc_slice_buffer_add_indexed(output, outbuf); return 1; error: - gpr_slice_unref(outbuf); + grpc_slice_unref(outbuf); return 0; } @@ -97,7 +97,7 @@ static void* zalloc_gpr(void* opaque, unsigned int items, unsigned int size) { static void zfree_gpr(void* opaque, void* address) { gpr_free(address); } -static int zlib_compress(gpr_slice_buffer* input, gpr_slice_buffer* output, +static int zlib_compress(grpc_slice_buffer* input, grpc_slice_buffer* output, int gzip) { z_stream zs; int r; @@ -113,7 +113,7 @@ static int zlib_compress(gpr_slice_buffer* input, gpr_slice_buffer* output, r = zlib_body(&zs, input, output, deflate) && output->length < input->length; if (!r) { for (i = count_before; i < output->count; i++) { - gpr_slice_unref(output->slices[i]); + grpc_slice_unref(output->slices[i]); } output->count = count_before; output->length = length_before; @@ -122,7 +122,7 @@ static int zlib_compress(gpr_slice_buffer* input, gpr_slice_buffer* output, return r; } -static int zlib_decompress(gpr_slice_buffer* input, gpr_slice_buffer* output, +static int zlib_decompress(grpc_slice_buffer* input, grpc_slice_buffer* output, int gzip) { z_stream zs; int r; @@ -137,7 +137,7 @@ static int zlib_decompress(gpr_slice_buffer* input, gpr_slice_buffer* output, r = zlib_body(&zs, input, output, inflate); if (!r) { for (i = count_before; i < output->count; i++) { - gpr_slice_unref(output->slices[i]); + grpc_slice_unref(output->slices[i]); } output->count = count_before; output->length = length_before; @@ -146,16 +146,16 @@ static int zlib_decompress(gpr_slice_buffer* input, gpr_slice_buffer* output, return r; } -static int copy(gpr_slice_buffer* input, gpr_slice_buffer* output) { +static int copy(grpc_slice_buffer* input, grpc_slice_buffer* output) { size_t i; for (i = 0; i < input->count; i++) { - gpr_slice_buffer_add(output, gpr_slice_ref(input->slices[i])); + grpc_slice_buffer_add(output, grpc_slice_ref(input->slices[i])); } return 1; } static int compress_inner(grpc_compression_algorithm algorithm, - gpr_slice_buffer* input, gpr_slice_buffer* output) { + grpc_slice_buffer* input, grpc_slice_buffer* output) { switch (algorithm) { case GRPC_COMPRESS_NONE: /* the fallback path always needs to be send uncompressed: we simply @@ -173,7 +173,7 @@ static int compress_inner(grpc_compression_algorithm algorithm, } int grpc_msg_compress(grpc_compression_algorithm algorithm, - gpr_slice_buffer* input, gpr_slice_buffer* output) { + grpc_slice_buffer* input, grpc_slice_buffer* output) { if (!compress_inner(algorithm, input, output)) { copy(input, output); return 0; @@ -182,7 +182,7 @@ int grpc_msg_compress(grpc_compression_algorithm algorithm, } int grpc_msg_decompress(grpc_compression_algorithm algorithm, - gpr_slice_buffer* input, gpr_slice_buffer* output) { + grpc_slice_buffer* input, grpc_slice_buffer* output) { switch (algorithm) { case GRPC_COMPRESS_NONE: return copy(input, output); diff --git a/src/core/lib/compression/message_compress.h b/src/core/lib/compression/message_compress.h index c69eaaf006..d28b5a36b3 100644 --- a/src/core/lib/compression/message_compress.h +++ b/src/core/lib/compression/message_compress.h @@ -41,12 +41,12 @@ On success, appends compressed slices to output and returns 1. On failure, appends uncompressed slices to output and returns 0. */ int grpc_msg_compress(grpc_compression_algorithm algorithm, - gpr_slice_buffer* input, gpr_slice_buffer* output); + grpc_slice_buffer* input, grpc_slice_buffer* output); /* decompress 'input' to 'output' using 'algorithm'. On success, appends slices to output and returns 1. On failure, output is unchanged, and returns 0. */ int grpc_msg_decompress(grpc_compression_algorithm algorithm, - gpr_slice_buffer* input, gpr_slice_buffer* output); + grpc_slice_buffer* input, grpc_slice_buffer* output); #endif /* GRPC_CORE_LIB_COMPRESSION_MESSAGE_COMPRESS_H */ diff --git a/src/core/lib/http/format_request.c b/src/core/lib/http/format_request.c index e818b70113..03f705ee97 100644 --- a/src/core/lib/http/format_request.c +++ b/src/core/lib/http/format_request.c @@ -65,7 +65,7 @@ static void fill_common_header(const grpc_httpcli_request *request, } } -gpr_slice grpc_httpcli_format_get_request(const grpc_httpcli_request *request) { +grpc_slice grpc_httpcli_format_get_request(const grpc_httpcli_request *request) { gpr_strvec out; char *flat; size_t flat_len; @@ -78,10 +78,10 @@ gpr_slice grpc_httpcli_format_get_request(const grpc_httpcli_request *request) { flat = gpr_strvec_flatten(&out, &flat_len); gpr_strvec_destroy(&out); - return gpr_slice_new(flat, flat_len, gpr_free); + return grpc_slice_new(flat, flat_len, gpr_free); } -gpr_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request, +grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request, const char *body_bytes, size_t body_size) { gpr_strvec out; @@ -117,10 +117,10 @@ gpr_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request, out_len += body_size; } - return gpr_slice_new(tmp, out_len, gpr_free); + return grpc_slice_new(tmp, out_len, gpr_free); } -gpr_slice grpc_httpcli_format_connect_request( +grpc_slice grpc_httpcli_format_connect_request( const grpc_httpcli_request *request) { gpr_strvec out; gpr_strvec_init(&out); @@ -130,5 +130,5 @@ gpr_slice grpc_httpcli_format_connect_request( size_t flat_len; char *flat = gpr_strvec_flatten(&out, &flat_len); gpr_strvec_destroy(&out); - return gpr_slice_new(flat, flat_len, gpr_free); + return grpc_slice_new(flat, flat_len, gpr_free); } diff --git a/src/core/lib/http/format_request.h b/src/core/lib/http/format_request.h index 7abd55f2f7..939401be48 100644 --- a/src/core/lib/http/format_request.h +++ b/src/core/lib/http/format_request.h @@ -37,11 +37,11 @@ #include #include "src/core/lib/http/httpcli.h" -gpr_slice grpc_httpcli_format_get_request(const grpc_httpcli_request *request); -gpr_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request, +grpc_slice grpc_httpcli_format_get_request(const grpc_httpcli_request *request); +grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request, const char *body_bytes, size_t body_size); -gpr_slice grpc_httpcli_format_connect_request( +grpc_slice grpc_httpcli_format_connect_request( const grpc_httpcli_request *request); #endif /* GRPC_CORE_LIB_HTTP_FORMAT_REQUEST_H */ diff --git a/src/core/lib/http/httpcli.c b/src/core/lib/http/httpcli.c index 26baae1eab..d52c140405 100644 --- a/src/core/lib/http/httpcli.c +++ b/src/core/lib/http/httpcli.c @@ -51,7 +51,7 @@ #include "src/core/lib/support/string.h" typedef struct { - gpr_slice request_text; + grpc_slice request_text; grpc_http_parser parser; grpc_resolved_addresses *addresses; size_t next_address; @@ -65,8 +65,8 @@ typedef struct { grpc_httpcli_context *context; grpc_polling_entity *pollent; grpc_iomgr_object iomgr_obj; - gpr_slice_buffer incoming; - gpr_slice_buffer outgoing; + grpc_slice_buffer incoming; + grpc_slice_buffer outgoing; grpc_closure on_read; grpc_closure done_write; grpc_closure connected; @@ -112,12 +112,12 @@ static void finish(grpc_exec_ctx *exec_ctx, internal_request *req, if (req->ep != NULL) { grpc_endpoint_destroy(exec_ctx, req->ep); } - gpr_slice_unref(req->request_text); + grpc_slice_unref(req->request_text); gpr_free(req->host); gpr_free(req->ssl_host_override); grpc_iomgr_unregister_object(&req->iomgr_obj); - gpr_slice_buffer_destroy(&req->incoming); - gpr_slice_buffer_destroy(&req->outgoing); + grpc_slice_buffer_destroy(&req->incoming); + grpc_slice_buffer_destroy(&req->outgoing); GRPC_ERROR_UNREF(req->overall_error); grpc_resource_quota_internal_unref(exec_ctx, req->resource_quota); gpr_free(req); @@ -179,8 +179,8 @@ static void done_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { } static void start_write(grpc_exec_ctx *exec_ctx, internal_request *req) { - gpr_slice_ref(req->request_text); - gpr_slice_buffer_add(&req->outgoing, req->request_text); + grpc_slice_ref(req->request_text); + grpc_slice_buffer_add(&req->outgoing, req->request_text); grpc_endpoint_write(exec_ctx, req->ep, &req->outgoing, &req->done_write); } @@ -254,7 +254,7 @@ static void internal_request_begin(grpc_exec_ctx *exec_ctx, const grpc_httpcli_request *request, gpr_timespec deadline, grpc_closure *on_done, grpc_httpcli_response *response, - const char *name, gpr_slice request_text) { + const char *name, grpc_slice request_text) { internal_request *req = gpr_malloc(sizeof(internal_request)); memset(req, 0, sizeof(*req)); req->request_text = request_text; @@ -269,8 +269,8 @@ static void internal_request_begin(grpc_exec_ctx *exec_ctx, req->resource_quota = grpc_resource_quota_internal_ref(resource_quota); grpc_closure_init(&req->on_read, on_read, req); grpc_closure_init(&req->done_write, done_write, req); - gpr_slice_buffer_init(&req->incoming); - gpr_slice_buffer_init(&req->outgoing); + grpc_slice_buffer_init(&req->incoming); + grpc_slice_buffer_init(&req->outgoing); grpc_iomgr_register_object(&req->iomgr_obj, name); req->host = gpr_strdup(request->host); req->ssl_host_override = gpr_strdup(request->ssl_host_override); diff --git a/src/core/lib/http/httpcli_security_connector.c b/src/core/lib/http/httpcli_security_connector.c index 0006e809a6..24d264c32a 100644 --- a/src/core/lib/http/httpcli_security_connector.c +++ b/src/core/lib/http/httpcli_security_connector.c @@ -61,7 +61,7 @@ static void httpcli_ssl_destroy(grpc_security_connector *sc) { static void httpcli_ssl_do_handshake(grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc, grpc_endpoint *nonsecure_endpoint, - gpr_slice_buffer *read_buffer, + grpc_slice_buffer *read_buffer, gpr_timespec deadline, grpc_security_handshake_done_cb cb, void *user_data) { diff --git a/src/core/lib/http/parser.c b/src/core/lib/http/parser.c index be9e9b6b63..14abb1da69 100644 --- a/src/core/lib/http/parser.c +++ b/src/core/lib/http/parser.c @@ -333,7 +333,7 @@ void grpc_http_response_destroy(grpc_http_response *response) { gpr_free(response->hdrs); } -grpc_error *grpc_http_parser_parse(grpc_http_parser *parser, gpr_slice slice, +grpc_error *grpc_http_parser_parse(grpc_http_parser *parser, grpc_slice slice, size_t *start_of_body) { for (size_t i = 0; i < GPR_SLICE_LENGTH(slice); i++) { bool found_body_start = false; diff --git a/src/core/lib/http/parser.h b/src/core/lib/http/parser.h index fab42979cd..102ffba05d 100644 --- a/src/core/lib/http/parser.h +++ b/src/core/lib/http/parser.h @@ -114,7 +114,7 @@ void grpc_http_parser_init(grpc_http_parser *parser, grpc_http_type type, void grpc_http_parser_destroy(grpc_http_parser *parser); /* Sets \a start_of_body to the offset in \a slice of the start of the body. */ -grpc_error *grpc_http_parser_parse(grpc_http_parser *parser, gpr_slice slice, +grpc_error *grpc_http_parser_parse(grpc_http_parser *parser, grpc_slice slice, size_t *start_of_body); grpc_error *grpc_http_parser_eof(grpc_http_parser *parser); diff --git a/src/core/lib/iomgr/endpoint.c b/src/core/lib/iomgr/endpoint.c index 74fa9c45df..a4b6668276 100644 --- a/src/core/lib/iomgr/endpoint.c +++ b/src/core/lib/iomgr/endpoint.c @@ -34,12 +34,12 @@ #include "src/core/lib/iomgr/endpoint.h" void grpc_endpoint_read(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, - gpr_slice_buffer* slices, grpc_closure* cb) { + grpc_slice_buffer* slices, grpc_closure* cb) { ep->vtable->read(exec_ctx, ep, slices, cb); } void grpc_endpoint_write(grpc_exec_ctx* exec_ctx, grpc_endpoint* ep, - gpr_slice_buffer* slices, grpc_closure* cb) { + grpc_slice_buffer* slices, grpc_closure* cb) { ep->vtable->write(exec_ctx, ep, slices, cb); } diff --git a/src/core/lib/iomgr/endpoint.h b/src/core/lib/iomgr/endpoint.h index 0ac5486ff5..d05998ec85 100644 --- a/src/core/lib/iomgr/endpoint.h +++ b/src/core/lib/iomgr/endpoint.h @@ -49,9 +49,9 @@ typedef struct grpc_endpoint_vtable grpc_endpoint_vtable; struct grpc_endpoint_vtable { void (*read)(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - gpr_slice_buffer *slices, grpc_closure *cb); + grpc_slice_buffer *slices, grpc_closure *cb); void (*write)(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - gpr_slice_buffer *slices, grpc_closure *cb); + grpc_slice_buffer *slices, grpc_closure *cb); grpc_workqueue *(*get_workqueue)(grpc_endpoint *ep); void (*add_to_pollset)(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, grpc_pollset *pollset); @@ -69,7 +69,7 @@ struct grpc_endpoint_vtable { Valid slices may be placed into \a slices even when the callback is invoked with error != GRPC_ERROR_NONE. */ void grpc_endpoint_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - gpr_slice_buffer *slices, grpc_closure *cb); + grpc_slice_buffer *slices, grpc_closure *cb); char *grpc_endpoint_get_peer(grpc_endpoint *ep); @@ -87,7 +87,7 @@ grpc_workqueue *grpc_endpoint_get_workqueue(grpc_endpoint *ep); it is a valid slice buffer. */ void grpc_endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - gpr_slice_buffer *slices, grpc_closure *cb); + grpc_slice_buffer *slices, grpc_closure *cb); /* Causes any pending and future read/write callbacks to run immediately with success==0 */ diff --git a/src/core/lib/iomgr/load_file.c b/src/core/lib/iomgr/load_file.c index b62ecbc534..217bc5da59 100644 --- a/src/core/lib/iomgr/load_file.c +++ b/src/core/lib/iomgr/load_file.c @@ -44,10 +44,10 @@ #include "src/core/lib/support/string.h" grpc_error *grpc_load_file(const char *filename, int add_null_terminator, - gpr_slice *output) { + grpc_slice *output) { unsigned char *contents = NULL; size_t contents_size = 0; - gpr_slice result = gpr_empty_slice(); + grpc_slice result = gpr_empty_slice(); FILE *file; size_t bytes_read = 0; grpc_error *error = GRPC_ERROR_NONE; @@ -72,7 +72,7 @@ grpc_error *grpc_load_file(const char *filename, int add_null_terminator, if (add_null_terminator) { contents[contents_size++] = 0; } - result = gpr_slice_new(contents, contents_size, gpr_free); + result = grpc_slice_new(contents, contents_size, gpr_free); end: *output = result; diff --git a/src/core/lib/iomgr/load_file.h b/src/core/lib/iomgr/load_file.h index 9aac2225d1..31cec92cb1 100644 --- a/src/core/lib/iomgr/load_file.h +++ b/src/core/lib/iomgr/load_file.h @@ -47,7 +47,7 @@ extern "C" { /* Loads the content of a file into a slice. add_null_terminator will add a NULL terminator if non-zero. */ grpc_error *grpc_load_file(const char *filename, int add_null_terminator, - gpr_slice *slice); + grpc_slice *slice); #ifdef __cplusplus } diff --git a/src/core/lib/iomgr/resource_quota.c b/src/core/lib/iomgr/resource_quota.c index 4f0d16ca7e..f047f45b43 100644 --- a/src/core/lib/iomgr/resource_quota.c +++ b/src/core/lib/iomgr/resource_quota.c @@ -269,7 +269,7 @@ static bool rq_reclaim(grpc_exec_ctx *exec_ctx, */ typedef struct { - gpr_slice_refcount base; + grpc_slice_refcount base; gpr_refcount refs; grpc_resource_user *resource_user; size_t size; @@ -286,7 +286,7 @@ static void ru_slice_unref(void *p) { /* TODO(ctiller): this is dangerous, but I think safe for now: we have no guarantee here that we're at a safe point for creating an execution context, but we have no way of writing this code otherwise. - In the future: consider lifting gpr_slice to grpc, and offering an + In the future: consider lifting grpc_slice to grpc, and offering an internal_{ref,unref} pair that is execution context aware. Alternatively, make exec_ctx be thread local and 'do the right thing' (whatever that @@ -299,7 +299,7 @@ static void ru_slice_unref(void *p) { } } -static gpr_slice ru_slice_create(grpc_resource_user *resource_user, +static grpc_slice ru_slice_create(grpc_resource_user *resource_user, size_t size) { ru_slice_refcount *rc = gpr_malloc(sizeof(ru_slice_refcount) + size); rc->base.ref = ru_slice_ref; @@ -307,7 +307,7 @@ static gpr_slice ru_slice_create(grpc_resource_user *resource_user, gpr_ref_init(&rc->refs, 1); rc->resource_user = resource_user; rc->size = size; - gpr_slice slice; + grpc_slice slice; slice.refcount = &rc->base; slice.data.refcounted.bytes = (uint8_t *)(rc + 1); slice.data.refcounted.length = size; @@ -394,7 +394,7 @@ static void ru_allocated_slices(grpc_exec_ctx *exec_ctx, void *arg, grpc_resource_user_slice_allocator *slice_allocator = arg; if (error == GRPC_ERROR_NONE) { for (size_t i = 0; i < slice_allocator->count; i++) { - gpr_slice_buffer_add_indexed( + grpc_slice_buffer_add_indexed( slice_allocator->dest, ru_slice_create(slice_allocator->resource_user, slice_allocator->length)); } @@ -711,7 +711,7 @@ void grpc_resource_user_slice_allocator_init( void grpc_resource_user_alloc_slices( grpc_exec_ctx *exec_ctx, grpc_resource_user_slice_allocator *slice_allocator, size_t length, - size_t count, gpr_slice_buffer *dest) { + size_t count, grpc_slice_buffer *dest) { slice_allocator->length = length; slice_allocator->count = count; slice_allocator->dest = dest; diff --git a/src/core/lib/iomgr/resource_quota.h b/src/core/lib/iomgr/resource_quota.h index c15cb68310..f644e5bf4d 100644 --- a/src/core/lib/iomgr/resource_quota.h +++ b/src/core/lib/iomgr/resource_quota.h @@ -202,7 +202,7 @@ typedef struct grpc_resource_user_slice_allocator { /* Number of slices to allocate on the current request */ size_t count; /* Destination for slices to allocate on the current request */ - gpr_slice_buffer *dest; + grpc_slice_buffer *dest; /* Parent resource user */ grpc_resource_user *resource_user; } grpc_resource_user_slice_allocator; @@ -218,6 +218,6 @@ void grpc_resource_user_slice_allocator_init( void grpc_resource_user_alloc_slices( grpc_exec_ctx *exec_ctx, grpc_resource_user_slice_allocator *slice_allocator, size_t length, - size_t count, gpr_slice_buffer *dest); + size_t count, grpc_slice_buffer *dest); #endif /* GRPC_CORE_LIB_IOMGR_RESOURCE_QUOTA_H */ diff --git a/src/core/lib/iomgr/tcp_posix.c b/src/core/lib/iomgr/tcp_posix.c index 27b6677545..909237d84d 100644 --- a/src/core/lib/iomgr/tcp_posix.c +++ b/src/core/lib/iomgr/tcp_posix.c @@ -83,10 +83,10 @@ typedef struct { gpr_atm shutdown_count; /* garbage after the last read */ - gpr_slice_buffer last_read_buffer; + grpc_slice_buffer last_read_buffer; - gpr_slice_buffer *incoming_buffer; - gpr_slice_buffer *outgoing_buffer; + grpc_slice_buffer *incoming_buffer; + grpc_slice_buffer *outgoing_buffer; /** slice within outgoing_buffer to write next */ size_t outgoing_slice_idx; /** byte within outgoing_buffer->slices[outgoing_slice_idx] to write next */ @@ -130,7 +130,7 @@ static void tcp_shutdown(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { static void tcp_free(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) { grpc_fd_orphan(exec_ctx, tcp->em_fd, tcp->release_fd_cb, tcp->release_fd, "tcp_unref_orphan"); - gpr_slice_buffer_destroy(&tcp->last_read_buffer); + grpc_slice_buffer_destroy(&tcp->last_read_buffer); grpc_resource_user_destroy(exec_ctx, &tcp->resource_user); gpr_free(tcp->peer_string); gpr_free(tcp); @@ -177,7 +177,7 @@ static void tcp_destroy(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep) { grpc_network_status_unregister_endpoint(ep); grpc_tcp *tcp = (grpc_tcp *)ep; tcp_maybe_shutdown_resource_user(exec_ctx, tcp); - gpr_slice_buffer_reset_and_unref(&tcp->last_read_buffer); + grpc_slice_buffer_reset_and_unref(&tcp->last_read_buffer); TCP_UNREF(exec_ctx, tcp, "destroy"); } @@ -244,19 +244,19 @@ static void tcp_do_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) { /* We've consumed the edge, request a new one */ grpc_fd_notify_on_read(exec_ctx, tcp->em_fd, &tcp->read_closure); } else { - gpr_slice_buffer_reset_and_unref(tcp->incoming_buffer); + grpc_slice_buffer_reset_and_unref(tcp->incoming_buffer); call_read_cb(exec_ctx, tcp, GRPC_OS_ERROR(errno, "recvmsg")); TCP_UNREF(exec_ctx, tcp, "read"); } } else if (read_bytes == 0) { /* 0 read size ==> end of stream */ - gpr_slice_buffer_reset_and_unref(tcp->incoming_buffer); + grpc_slice_buffer_reset_and_unref(tcp->incoming_buffer); call_read_cb(exec_ctx, tcp, GRPC_ERROR_CREATE("Socket closed")); TCP_UNREF(exec_ctx, tcp, "read"); } else { GPR_ASSERT((size_t)read_bytes <= tcp->incoming_buffer->length); if ((size_t)read_bytes < tcp->incoming_buffer->length) { - gpr_slice_buffer_trim_end( + grpc_slice_buffer_trim_end( tcp->incoming_buffer, tcp->incoming_buffer->length - (size_t)read_bytes, &tcp->last_read_buffer); @@ -275,8 +275,8 @@ static void tcp_read_allocation_done(grpc_exec_ctx *exec_ctx, void *tcpp, grpc_error *error) { grpc_tcp *tcp = tcpp; if (error != GRPC_ERROR_NONE) { - gpr_slice_buffer_reset_and_unref(tcp->incoming_buffer); - gpr_slice_buffer_reset_and_unref(&tcp->last_read_buffer); + grpc_slice_buffer_reset_and_unref(tcp->incoming_buffer); + grpc_slice_buffer_reset_and_unref(&tcp->last_read_buffer); call_read_cb(exec_ctx, tcp, GRPC_ERROR_REF(error)); TCP_UNREF(exec_ctx, tcp, "read"); } else { @@ -301,8 +301,8 @@ static void tcp_handle_read(grpc_exec_ctx *exec_ctx, void *arg /* grpc_tcp */, GPR_ASSERT(!tcp->finished_edge); if (error != GRPC_ERROR_NONE) { - gpr_slice_buffer_reset_and_unref(tcp->incoming_buffer); - gpr_slice_buffer_reset_and_unref(&tcp->last_read_buffer); + grpc_slice_buffer_reset_and_unref(tcp->incoming_buffer); + grpc_slice_buffer_reset_and_unref(&tcp->last_read_buffer); call_read_cb(exec_ctx, tcp, GRPC_ERROR_REF(error)); TCP_UNREF(exec_ctx, tcp, "read"); } else { @@ -311,13 +311,13 @@ static void tcp_handle_read(grpc_exec_ctx *exec_ctx, void *arg /* grpc_tcp */, } static void tcp_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - gpr_slice_buffer *incoming_buffer, grpc_closure *cb) { + grpc_slice_buffer *incoming_buffer, grpc_closure *cb) { grpc_tcp *tcp = (grpc_tcp *)ep; GPR_ASSERT(tcp->read_cb == NULL); tcp->read_cb = cb; tcp->incoming_buffer = incoming_buffer; - gpr_slice_buffer_reset_and_unref(incoming_buffer); - gpr_slice_buffer_swap(incoming_buffer, &tcp->last_read_buffer); + grpc_slice_buffer_reset_and_unref(incoming_buffer); + grpc_slice_buffer_swap(incoming_buffer, &tcp->last_read_buffer); TCP_REF(tcp, "read"); if (tcp->finished_edge) { tcp->finished_edge = false; @@ -442,7 +442,7 @@ static void tcp_handle_write(grpc_exec_ctx *exec_ctx, void *arg /* grpc_tcp */, } static void tcp_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - gpr_slice_buffer *buf, grpc_closure *cb) { + grpc_slice_buffer *buf, grpc_closure *cb) { grpc_tcp *tcp = (grpc_tcp *)ep; grpc_error *error = GRPC_ERROR_NONE; @@ -552,7 +552,7 @@ grpc_endpoint *grpc_tcp_create(grpc_fd *em_fd, tcp->read_closure.cb_arg = tcp; tcp->write_closure.cb = tcp_handle_write; tcp->write_closure.cb_arg = tcp; - gpr_slice_buffer_init(&tcp->last_read_buffer); + grpc_slice_buffer_init(&tcp->last_read_buffer); grpc_resource_user_init(&tcp->resource_user, resource_quota, peer_string); grpc_resource_user_slice_allocator_init(&tcp->slice_allocator, &tcp->resource_user, @@ -577,7 +577,7 @@ void grpc_tcp_destroy_and_release_fd(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, tcp->release_fd = fd; tcp->release_fd_cb = done; tcp_maybe_shutdown_resource_user(exec_ctx, tcp); - gpr_slice_buffer_reset_and_unref(&tcp->last_read_buffer); + grpc_slice_buffer_reset_and_unref(&tcp->last_read_buffer); TCP_UNREF(exec_ctx, tcp, "destroy"); } diff --git a/src/core/lib/iomgr/tcp_windows.c b/src/core/lib/iomgr/tcp_windows.c index 448a72671c..6f63f80021 100644 --- a/src/core/lib/iomgr/tcp_windows.c +++ b/src/core/lib/iomgr/tcp_windows.c @@ -105,9 +105,9 @@ typedef struct grpc_tcp { grpc_closure *read_cb; grpc_closure *write_cb; - gpr_slice read_slice; - gpr_slice_buffer *write_slices; - gpr_slice_buffer *read_slices; + grpc_slice read_slice; + grpc_slice_buffer *write_slices; + grpc_slice_buffer *read_slices; /* The IO Completion Port runs from another thread. We need some mechanism to protect ourselves when requesting a shutdown. */ @@ -160,7 +160,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *tcpp, grpc_error *error) { grpc_tcp *tcp = tcpp; grpc_closure *cb = tcp->read_cb; grpc_winsocket *socket = tcp->socket; - gpr_slice sub; + grpc_slice sub; grpc_winsocket_callback_info *info = &socket->read_info; GRPC_ERROR_REF(error); @@ -170,13 +170,13 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *tcpp, grpc_error *error) { char *utf8_message = gpr_format_message(info->wsa_error); error = GRPC_ERROR_CREATE(utf8_message); gpr_free(utf8_message); - gpr_slice_unref(tcp->read_slice); + grpc_slice_unref(tcp->read_slice); } else { if (info->bytes_transfered != 0 && !tcp->shutting_down) { - sub = gpr_slice_sub_no_ref(tcp->read_slice, 0, info->bytes_transfered); - gpr_slice_buffer_add(tcp->read_slices, sub); + sub = grpc_slice_sub_no_ref(tcp->read_slice, 0, info->bytes_transfered); + grpc_slice_buffer_add(tcp->read_slices, sub); } else { - gpr_slice_unref(tcp->read_slice); + grpc_slice_unref(tcp->read_slice); error = GRPC_ERROR_CREATE("End of TCP stream"); } } @@ -188,7 +188,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *tcpp, grpc_error *error) { } static void win_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - gpr_slice_buffer *read_slices, grpc_closure *cb) { + grpc_slice_buffer *read_slices, grpc_closure *cb) { grpc_tcp *tcp = (grpc_tcp *)ep; grpc_winsocket *handle = tcp->socket; grpc_winsocket_callback_info *info = &handle->read_info; @@ -205,9 +205,9 @@ static void win_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, tcp->read_cb = cb; tcp->read_slices = read_slices; - gpr_slice_buffer_reset_and_unref(read_slices); + grpc_slice_buffer_reset_and_unref(read_slices); - tcp->read_slice = gpr_slice_malloc(8192); + tcp->read_slice = grpc_slice_malloc(8192); buffer.len = (ULONG)GPR_SLICE_LENGTH( tcp->read_slice); // we know slice size fits in 32bit. @@ -273,7 +273,7 @@ static void on_write(grpc_exec_ctx *exec_ctx, void *tcpp, grpc_error *error) { /* Initiates a write. */ static void win_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - gpr_slice_buffer *slices, grpc_closure *cb) { + grpc_slice_buffer *slices, grpc_closure *cb) { grpc_tcp *tcp = (grpc_tcp *)ep; grpc_winsocket *socket = tcp->socket; grpc_winsocket_callback_info *info = &socket->write_info; diff --git a/src/core/lib/security/credentials/credentials.h b/src/core/lib/security/credentials/credentials.h index 6fb5b5b15a..85b3bc5350 100644 --- a/src/core/lib/security/credentials/credentials.h +++ b/src/core/lib/security/credentials/credentials.h @@ -141,8 +141,8 @@ grpc_channel_credentials_duplicate_without_call_credentials( /* --- grpc_credentials_md. --- */ typedef struct { - gpr_slice key; - gpr_slice value; + grpc_slice key; + grpc_slice value; } grpc_credentials_md; typedef struct { @@ -157,7 +157,7 @@ grpc_credentials_md_store *grpc_credentials_md_store_create( /* Will ref key and value. */ void grpc_credentials_md_store_add(grpc_credentials_md_store *store, - gpr_slice key, gpr_slice value); + grpc_slice key, grpc_slice value); void grpc_credentials_md_store_add_cstrings(grpc_credentials_md_store *store, const char *key, const char *value); grpc_credentials_md_store *grpc_credentials_md_store_ref( diff --git a/src/core/lib/security/credentials/credentials_metadata.c b/src/core/lib/security/credentials/credentials_metadata.c index 6a352aab3a..e6cb567734 100644 --- a/src/core/lib/security/credentials/credentials_metadata.c +++ b/src/core/lib/security/credentials/credentials_metadata.c @@ -59,11 +59,11 @@ grpc_credentials_md_store *grpc_credentials_md_store_create( } void grpc_credentials_md_store_add(grpc_credentials_md_store *store, - gpr_slice key, gpr_slice value) { + grpc_slice key, grpc_slice value) { if (store == NULL) return; store_ensure_capacity(store); - store->entries[store->num_entries].key = gpr_slice_ref(key); - store->entries[store->num_entries].value = gpr_slice_ref(value); + store->entries[store->num_entries].key = grpc_slice_ref(key); + store->entries[store->num_entries].value = grpc_slice_ref(value); store->num_entries++; } @@ -72,9 +72,9 @@ void grpc_credentials_md_store_add_cstrings(grpc_credentials_md_store *store, const char *value) { if (store == NULL) return; store_ensure_capacity(store); - store->entries[store->num_entries].key = gpr_slice_from_copied_string(key); + store->entries[store->num_entries].key = grpc_slice_from_copied_string(key); store->entries[store->num_entries].value = - gpr_slice_from_copied_string(value); + grpc_slice_from_copied_string(value); store->num_entries++; } @@ -91,8 +91,8 @@ void grpc_credentials_md_store_unref(grpc_credentials_md_store *store) { if (store->entries != NULL) { size_t i; for (i = 0; i < store->num_entries; i++) { - gpr_slice_unref(store->entries[i].key); - gpr_slice_unref(store->entries[i].value); + grpc_slice_unref(store->entries[i].key); + grpc_slice_unref(store->entries[i].value); } gpr_free(store->entries); } diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.c b/src/core/lib/security/credentials/google_default/google_default_credentials.c index cb5ba554b0..b92f29a0d8 100644 --- a/src/core/lib/security/credentials/google_default/google_default_credentials.c +++ b/src/core/lib/security/credentials/google_default/google_default_credentials.c @@ -174,7 +174,7 @@ static grpc_error *create_default_creds_from_path( grpc_auth_json_key key; grpc_auth_refresh_token token; grpc_call_credentials *result = NULL; - gpr_slice creds_data = gpr_empty_slice(); + grpc_slice creds_data = gpr_empty_slice(); grpc_error *error = GRPC_ERROR_NONE; if (creds_path == NULL) { error = GRPC_ERROR_CREATE("creds_path unset"); @@ -224,7 +224,7 @@ static grpc_error *create_default_creds_from_path( end: GPR_ASSERT((result == NULL) + (error == GRPC_ERROR_NONE) == 1); if (creds_path != NULL) gpr_free(creds_path); - gpr_slice_unref(creds_data); + grpc_slice_unref(creds_data); if (json != NULL) grpc_json_destroy(json); *creds = result; return error; diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.c b/src/core/lib/security/credentials/jwt/jwt_verifier.c index 43eb642515..9cb8cd64f6 100644 --- a/src/core/lib/security/credentials/jwt/jwt_verifier.c +++ b/src/core/lib/security/credentials/jwt/jwt_verifier.c @@ -85,7 +85,7 @@ static const EVP_MD *evp_md_from_alg(const char *alg) { } static grpc_json *parse_json_part_from_jwt(const char *str, size_t len, - gpr_slice *buffer) { + grpc_slice *buffer) { grpc_json *json; *buffer = grpc_base64_decode_with_len(str, len, 1); @@ -96,7 +96,7 @@ static grpc_json *parse_json_part_from_jwt(const char *str, size_t len, json = grpc_json_parse_string_with_len((char *)GPR_SLICE_START_PTR(*buffer), GPR_SLICE_LENGTH(*buffer)); if (json == NULL) { - gpr_slice_unref(*buffer); + grpc_slice_unref(*buffer); gpr_log(GPR_ERROR, "JSON parsing error."); } return json; @@ -129,16 +129,16 @@ typedef struct { const char *kid; const char *typ; /* TODO(jboeuf): Add others as needed (jku, jwk, x5u, x5c and so on...). */ - gpr_slice buffer; + grpc_slice buffer; } jose_header; static void jose_header_destroy(jose_header *h) { - gpr_slice_unref(h->buffer); + grpc_slice_unref(h->buffer); gpr_free(h); } /* Takes ownership of json and buffer. */ -static jose_header *jose_header_from_json(grpc_json *json, gpr_slice buffer) { +static jose_header *jose_header_from_json(grpc_json *json, grpc_slice buffer) { grpc_json *cur; jose_header *h = gpr_malloc(sizeof(jose_header)); memset(h, 0, sizeof(jose_header)); @@ -190,12 +190,12 @@ struct grpc_jwt_claims { gpr_timespec nbf; grpc_json *json; - gpr_slice buffer; + grpc_slice buffer; }; void grpc_jwt_claims_destroy(grpc_jwt_claims *claims) { grpc_json_destroy(claims->json); - gpr_slice_unref(claims->buffer); + grpc_slice_unref(claims->buffer); gpr_free(claims); } @@ -240,7 +240,7 @@ gpr_timespec grpc_jwt_claims_not_before(const grpc_jwt_claims *claims) { } /* Takes ownership of json and buffer even in case of failure. */ -grpc_jwt_claims *grpc_jwt_claims_from_json(grpc_json *json, gpr_slice buffer) { +grpc_jwt_claims *grpc_jwt_claims_from_json(grpc_json *json, grpc_slice buffer) { grpc_json *cur; grpc_jwt_claims *claims = gpr_malloc(sizeof(grpc_jwt_claims)); memset(claims, 0, sizeof(grpc_jwt_claims)); @@ -333,8 +333,8 @@ typedef struct { jose_header *header; grpc_jwt_claims *claims; char *audience; - gpr_slice signature; - gpr_slice signed_data; + grpc_slice signature; + grpc_slice signed_data; void *user_data; grpc_jwt_verification_done_cb user_cb; grpc_http_response responses[HTTP_RESPONSE_COUNT]; @@ -343,7 +343,7 @@ typedef struct { /* Takes ownership of the header, claims and signature. */ static verifier_cb_ctx *verifier_cb_ctx_create( grpc_jwt_verifier *verifier, grpc_pollset *pollset, jose_header *header, - grpc_jwt_claims *claims, const char *audience, gpr_slice signature, + grpc_jwt_claims *claims, const char *audience, grpc_slice signature, const char *signed_jwt, size_t signed_jwt_len, void *user_data, grpc_jwt_verification_done_cb cb) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -355,7 +355,7 @@ static verifier_cb_ctx *verifier_cb_ctx_create( ctx->audience = gpr_strdup(audience); ctx->claims = claims; ctx->signature = signature; - ctx->signed_data = gpr_slice_from_copied_buffer(signed_jwt, signed_jwt_len); + ctx->signed_data = grpc_slice_from_copied_buffer(signed_jwt, signed_jwt_len); ctx->user_data = user_data; ctx->user_cb = cb; grpc_exec_ctx_finish(&exec_ctx); @@ -365,8 +365,8 @@ static verifier_cb_ctx *verifier_cb_ctx_create( void verifier_cb_ctx_destroy(verifier_cb_ctx *ctx) { if (ctx->audience != NULL) gpr_free(ctx->audience); if (ctx->claims != NULL) grpc_jwt_claims_destroy(ctx->claims); - gpr_slice_unref(ctx->signature); - gpr_slice_unref(ctx->signed_data); + grpc_slice_unref(ctx->signature); + grpc_slice_unref(ctx->signed_data); jose_header_destroy(ctx->header); for (size_t i = 0; i < HTTP_RESPONSE_COUNT; i++) { grpc_http_response_destroy(&ctx->responses[i]); @@ -449,7 +449,7 @@ end: static BIGNUM *bignum_from_base64(const char *b64) { BIGNUM *result = NULL; - gpr_slice bin; + grpc_slice bin; if (b64 == NULL) return NULL; bin = grpc_base64_decode(b64, 1); @@ -459,7 +459,7 @@ static BIGNUM *bignum_from_base64(const char *b64) { } result = BN_bin2bn(GPR_SLICE_START_PTR(bin), TSI_SIZE_AS_SIZE(GPR_SLICE_LENGTH(bin)), NULL); - gpr_slice_unref(bin); + grpc_slice_unref(bin); return result; } @@ -553,7 +553,7 @@ static EVP_PKEY *find_verification_key(const grpc_json *json, } static int verify_jwt_signature(EVP_PKEY *key, const char *alg, - gpr_slice signature, gpr_slice signed_data) { + grpc_slice signature, grpc_slice signed_data) { EVP_MD_CTX *md_ctx = EVP_MD_CTX_create(); const EVP_MD *md = evp_md_from_alg(alg); int result = 0; @@ -799,9 +799,9 @@ void grpc_jwt_verifier_verify(grpc_exec_ctx *exec_ctx, grpc_json *json; jose_header *header = NULL; grpc_jwt_claims *claims = NULL; - gpr_slice header_buffer; - gpr_slice claims_buffer; - gpr_slice signature; + grpc_slice header_buffer; + grpc_slice claims_buffer; + grpc_slice signature; size_t signed_jwt_len; const char *cur = jwt; diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.h b/src/core/lib/security/credentials/jwt/jwt_verifier.h index b0f6d1c240..e05a9f1824 100644 --- a/src/core/lib/security/credentials/jwt/jwt_verifier.h +++ b/src/core/lib/security/credentials/jwt/jwt_verifier.h @@ -129,7 +129,7 @@ void grpc_jwt_verifier_verify(grpc_exec_ctx *exec_ctx, /* --- TESTING ONLY exposed functions. --- */ -grpc_jwt_claims *grpc_jwt_claims_from_json(grpc_json *json, gpr_slice buffer); +grpc_jwt_claims *grpc_jwt_claims_from_json(grpc_json *json, grpc_slice buffer); grpc_jwt_verifier_status grpc_jwt_claims_check(const grpc_jwt_claims *claims, const char *audience); diff --git a/src/core/lib/security/credentials/plugin/plugin_credentials.c b/src/core/lib/security/credentials/plugin/plugin_credentials.c index 905de3723e..61c10862da 100644 --- a/src/core/lib/security/credentials/plugin/plugin_credentials.c +++ b/src/core/lib/security/credentials/plugin/plugin_credentials.c @@ -93,15 +93,15 @@ static void plugin_md_request_metadata_ready(void *request, } else if (num_md > 0) { md_array = gpr_malloc(num_md * sizeof(grpc_credentials_md)); for (i = 0; i < num_md; i++) { - md_array[i].key = gpr_slice_from_copied_string(md[i].key); + md_array[i].key = grpc_slice_from_copied_string(md[i].key); md_array[i].value = - gpr_slice_from_copied_buffer(md[i].value, md[i].value_length); + grpc_slice_from_copied_buffer(md[i].value, md[i].value_length); } r->cb(&exec_ctx, r->user_data, md_array, num_md, GRPC_CREDENTIALS_OK, NULL); for (i = 0; i < num_md; i++) { - gpr_slice_unref(md_array[i].key); - gpr_slice_unref(md_array[i].value); + grpc_slice_unref(md_array[i].key); + grpc_slice_unref(md_array[i].value); } gpr_free(md_array); } diff --git a/src/core/lib/security/transport/client_auth_filter.c b/src/core/lib/security/transport/client_auth_filter.c index b366d1410f..cd4769ea10 100644 --- a/src/core/lib/security/transport/client_auth_filter.c +++ b/src/core/lib/security/transport/client_auth_filter.c @@ -92,7 +92,7 @@ static void bubble_up_error(grpc_exec_ctx *exec_ctx, grpc_call_element *elem, grpc_status_code status, const char *error_msg) { call_data *calld = elem->call_data; gpr_log(GPR_ERROR, "Client side authentication failure: %s", error_msg); - gpr_slice error_slice = gpr_slice_from_copied_string(error_msg); + grpc_slice error_slice = grpc_slice_from_copied_string(error_msg); grpc_transport_stream_op_add_close(&calld->op, status, &error_slice); grpc_call_next_op(exec_ctx, elem, &calld->op); } @@ -121,8 +121,8 @@ static void on_credentials_metadata(grpc_exec_ctx *exec_ctx, void *user_data, for (i = 0; i < num_md; i++) { grpc_metadata_batch_add_tail( mdb, &calld->md_links[i], - grpc_mdelem_from_slices(gpr_slice_ref(md_elems[i].key), - gpr_slice_ref(md_elems[i].value))); + grpc_mdelem_from_slices(grpc_slice_ref(md_elems[i].key), + grpc_slice_ref(md_elems[i].value))); } grpc_call_next_op(exec_ctx, elem, op); } diff --git a/src/core/lib/security/transport/handshake.c b/src/core/lib/security/transport/handshake.c index fbeec312b6..2d33521d94 100644 --- a/src/core/lib/security/transport/handshake.c +++ b/src/core/lib/security/transport/handshake.c @@ -54,9 +54,9 @@ typedef struct { size_t handshake_buffer_size; grpc_endpoint *wrapped_endpoint; grpc_endpoint *secure_endpoint; - gpr_slice_buffer left_overs; - gpr_slice_buffer incoming; - gpr_slice_buffer outgoing; + grpc_slice_buffer left_overs; + grpc_slice_buffer incoming; + grpc_slice_buffer outgoing; grpc_security_handshake_done_cb cb; void *user_data; grpc_closure on_handshake_data_sent_to_peer; @@ -104,9 +104,9 @@ static void unref_handshake(grpc_security_handshake *h) { if (gpr_unref(&h->refs)) { if (h->handshaker != NULL) tsi_handshaker_destroy(h->handshaker); if (h->handshake_buffer != NULL) gpr_free(h->handshake_buffer); - gpr_slice_buffer_destroy(&h->left_overs); - gpr_slice_buffer_destroy(&h->outgoing); - gpr_slice_buffer_destroy(&h->incoming); + grpc_slice_buffer_destroy(&h->left_overs); + grpc_slice_buffer_destroy(&h->outgoing); + grpc_slice_buffer_destroy(&h->incoming); GRPC_AUTH_CONTEXT_UNREF(h->auth_context, "handshake"); GRPC_SECURITY_CONNECTOR_UNREF(h->connector, "handshake"); gpr_free(h); @@ -190,7 +190,7 @@ static void send_handshake_bytes_to_peer(grpc_exec_ctx *exec_ctx, grpc_security_handshake *h) { size_t offset = 0; tsi_result result = TSI_OK; - gpr_slice to_send; + grpc_slice to_send; do { size_t to_send_size = h->handshake_buffer_size - offset; @@ -212,9 +212,9 @@ static void send_handshake_bytes_to_peer(grpc_exec_ctx *exec_ctx, } to_send = - gpr_slice_from_copied_buffer((const char *)h->handshake_buffer, offset); - gpr_slice_buffer_reset_and_unref(&h->outgoing); - gpr_slice_buffer_add(&h->outgoing, to_send); + grpc_slice_from_copied_buffer((const char *)h->handshake_buffer, offset); + grpc_slice_buffer_reset_and_unref(&h->outgoing); + grpc_slice_buffer_add(&h->outgoing, to_send); /* TODO(klempner,jboeuf): This should probably use the client setup deadline */ grpc_endpoint_write(exec_ctx, h->wrapped_endpoint, &h->outgoing, @@ -277,13 +277,13 @@ static void on_handshake_data_received_from_peer(grpc_exec_ctx *exec_ctx, /* Put the leftovers in our buffer (ownership transfered). */ if (has_left_overs_in_current_slice) { - gpr_slice_buffer_add( + grpc_slice_buffer_add( &h->left_overs, - gpr_slice_split_tail(&h->incoming.slices[i], consumed_slice_size)); - gpr_slice_unref( + grpc_slice_split_tail(&h->incoming.slices[i], consumed_slice_size)); + grpc_slice_unref( h->incoming.slices[i]); /* split_tail above increments refcount. */ } - gpr_slice_buffer_addn( + grpc_slice_buffer_addn( &h->left_overs, &h->incoming.slices[i + 1], num_left_overs - (size_t)has_left_overs_in_current_slice); check_peer(exec_ctx, h); @@ -325,7 +325,7 @@ static void on_timeout(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { void grpc_do_security_handshake( grpc_exec_ctx *exec_ctx, tsi_handshaker *handshaker, grpc_security_connector *connector, bool is_client_side, - grpc_endpoint *nonsecure_endpoint, gpr_slice_buffer *read_buffer, + grpc_endpoint *nonsecure_endpoint, grpc_slice_buffer *read_buffer, gpr_timespec deadline, grpc_security_handshake_done_cb cb, void *user_data) { grpc_security_connector_handshake_list *handshake_node; @@ -344,11 +344,11 @@ void grpc_do_security_handshake( on_handshake_data_sent_to_peer, h); grpc_closure_init(&h->on_handshake_data_received_from_peer, on_handshake_data_received_from_peer, h); - gpr_slice_buffer_init(&h->left_overs); - gpr_slice_buffer_init(&h->outgoing); - gpr_slice_buffer_init(&h->incoming); + grpc_slice_buffer_init(&h->left_overs); + grpc_slice_buffer_init(&h->outgoing); + grpc_slice_buffer_init(&h->incoming); if (read_buffer != NULL) { - gpr_slice_buffer_move_into(read_buffer, &h->incoming); + grpc_slice_buffer_move_into(read_buffer, &h->incoming); gpr_free(read_buffer); } if (!is_client_side) { diff --git a/src/core/lib/security/transport/handshake.h b/src/core/lib/security/transport/handshake.h index 53092f5421..f894540515 100644 --- a/src/core/lib/security/transport/handshake.h +++ b/src/core/lib/security/transport/handshake.h @@ -42,7 +42,7 @@ void grpc_do_security_handshake( grpc_exec_ctx *exec_ctx, tsi_handshaker *handshaker, grpc_security_connector *connector, bool is_client_side, - grpc_endpoint *nonsecure_endpoint, gpr_slice_buffer *read_buffer, + grpc_endpoint *nonsecure_endpoint, grpc_slice_buffer *read_buffer, gpr_timespec deadline, grpc_security_handshake_done_cb cb, void *user_data); void grpc_security_handshake_shutdown(grpc_exec_ctx *exec_ctx, void *handshake); diff --git a/src/core/lib/security/transport/secure_endpoint.c b/src/core/lib/security/transport/secure_endpoint.c index 3924997d31..865a0ec4cf 100644 --- a/src/core/lib/security/transport/secure_endpoint.c +++ b/src/core/lib/security/transport/secure_endpoint.c @@ -54,15 +54,15 @@ typedef struct { grpc_closure *read_cb; grpc_closure *write_cb; grpc_closure on_read; - gpr_slice_buffer *read_buffer; - gpr_slice_buffer source_buffer; + grpc_slice_buffer *read_buffer; + grpc_slice_buffer source_buffer; /* saved handshaker leftover data to unprotect. */ - gpr_slice_buffer leftover_bytes; + grpc_slice_buffer leftover_bytes; /* buffers for read and write */ - gpr_slice read_staging_buffer; + grpc_slice read_staging_buffer; - gpr_slice write_staging_buffer; - gpr_slice_buffer output_buffer; + grpc_slice write_staging_buffer; + grpc_slice_buffer output_buffer; gpr_refcount ref; } secure_endpoint; @@ -73,11 +73,11 @@ static void destroy(grpc_exec_ctx *exec_ctx, secure_endpoint *secure_ep) { secure_endpoint *ep = secure_ep; grpc_endpoint_destroy(exec_ctx, ep->wrapped_ep); tsi_frame_protector_destroy(ep->protector); - gpr_slice_buffer_destroy(&ep->leftover_bytes); - gpr_slice_unref(ep->read_staging_buffer); - gpr_slice_unref(ep->write_staging_buffer); - gpr_slice_buffer_destroy(&ep->output_buffer); - gpr_slice_buffer_destroy(&ep->source_buffer); + grpc_slice_buffer_destroy(&ep->leftover_bytes); + grpc_slice_unref(ep->read_staging_buffer); + grpc_slice_unref(ep->write_staging_buffer); + grpc_slice_buffer_destroy(&ep->output_buffer); + grpc_slice_buffer_destroy(&ep->source_buffer); gpr_mu_destroy(&ep->protector_mu); gpr_free(ep); } @@ -121,8 +121,8 @@ static void secure_endpoint_ref(secure_endpoint *ep) { gpr_ref(&ep->ref); } static void flush_read_staging_buffer(secure_endpoint *ep, uint8_t **cur, uint8_t **end) { - gpr_slice_buffer_add(ep->read_buffer, ep->read_staging_buffer); - ep->read_staging_buffer = gpr_slice_malloc(STAGING_BUFFER_SIZE); + grpc_slice_buffer_add(ep->read_buffer, ep->read_staging_buffer); + ep->read_staging_buffer = grpc_slice_malloc(STAGING_BUFFER_SIZE); *cur = GPR_SLICE_START_PTR(ep->read_staging_buffer); *end = GPR_SLICE_END_PTR(ep->read_staging_buffer); } @@ -153,7 +153,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data, uint8_t *end = GPR_SLICE_END_PTR(ep->read_staging_buffer); if (error != GRPC_ERROR_NONE) { - gpr_slice_buffer_reset_and_unref(ep->read_buffer); + grpc_slice_buffer_reset_and_unref(ep->read_buffer); call_read_cb(exec_ctx, ep, GRPC_ERROR_CREATE_REFERENCING( "Secure read failed", &error, 1)); return; @@ -161,7 +161,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data, /* TODO(yangg) check error, maybe bail out early */ for (i = 0; i < ep->source_buffer.count; i++) { - gpr_slice encrypted = ep->source_buffer.slices[i]; + grpc_slice encrypted = ep->source_buffer.slices[i]; uint8_t *message_bytes = GPR_SLICE_START_PTR(encrypted); size_t message_size = GPR_SLICE_LENGTH(encrypted); @@ -199,19 +199,19 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data, } if (cur != GPR_SLICE_START_PTR(ep->read_staging_buffer)) { - gpr_slice_buffer_add( + grpc_slice_buffer_add( ep->read_buffer, - gpr_slice_split_head( + grpc_slice_split_head( &ep->read_staging_buffer, (size_t)(cur - GPR_SLICE_START_PTR(ep->read_staging_buffer)))); } /* TODO(yangg) experiment with moving this block after read_cb to see if it helps latency */ - gpr_slice_buffer_reset_and_unref(&ep->source_buffer); + grpc_slice_buffer_reset_and_unref(&ep->source_buffer); if (result != TSI_OK) { - gpr_slice_buffer_reset_and_unref(ep->read_buffer); + grpc_slice_buffer_reset_and_unref(ep->read_buffer); call_read_cb(exec_ctx, ep, grpc_set_tsi_error_result( GRPC_ERROR_CREATE("Unwrap failed"), result)); return; @@ -221,15 +221,15 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data, } static void endpoint_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep, - gpr_slice_buffer *slices, grpc_closure *cb) { + grpc_slice_buffer *slices, grpc_closure *cb) { secure_endpoint *ep = (secure_endpoint *)secure_ep; ep->read_cb = cb; ep->read_buffer = slices; - gpr_slice_buffer_reset_and_unref(ep->read_buffer); + grpc_slice_buffer_reset_and_unref(ep->read_buffer); SECURE_ENDPOINT_REF(ep, "read"); if (ep->leftover_bytes.count) { - gpr_slice_buffer_swap(&ep->leftover_bytes, &ep->source_buffer); + grpc_slice_buffer_swap(&ep->leftover_bytes, &ep->source_buffer); GPR_ASSERT(ep->leftover_bytes.count == 0); on_read(exec_ctx, ep, GRPC_ERROR_NONE); return; @@ -241,14 +241,14 @@ static void endpoint_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep, static void flush_write_staging_buffer(secure_endpoint *ep, uint8_t **cur, uint8_t **end) { - gpr_slice_buffer_add(&ep->output_buffer, ep->write_staging_buffer); - ep->write_staging_buffer = gpr_slice_malloc(STAGING_BUFFER_SIZE); + grpc_slice_buffer_add(&ep->output_buffer, ep->write_staging_buffer); + ep->write_staging_buffer = grpc_slice_malloc(STAGING_BUFFER_SIZE); *cur = GPR_SLICE_START_PTR(ep->write_staging_buffer); *end = GPR_SLICE_END_PTR(ep->write_staging_buffer); } static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep, - gpr_slice_buffer *slices, grpc_closure *cb) { + grpc_slice_buffer *slices, grpc_closure *cb) { GPR_TIMER_BEGIN("secure_endpoint.endpoint_write", 0); unsigned i; @@ -257,7 +257,7 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep, uint8_t *cur = GPR_SLICE_START_PTR(ep->write_staging_buffer); uint8_t *end = GPR_SLICE_END_PTR(ep->write_staging_buffer); - gpr_slice_buffer_reset_and_unref(&ep->output_buffer); + grpc_slice_buffer_reset_and_unref(&ep->output_buffer); if (grpc_trace_secure_endpoint) { for (i = 0; i < slices->count; i++) { @@ -269,7 +269,7 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep, } for (i = 0; i < slices->count; i++) { - gpr_slice plain = slices->slices[i]; + grpc_slice plain = slices->slices[i]; uint8_t *message_bytes = GPR_SLICE_START_PTR(plain); size_t message_size = GPR_SLICE_LENGTH(plain); while (message_size > 0) { @@ -311,9 +311,9 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep, } } while (still_pending_size > 0); if (cur != GPR_SLICE_START_PTR(ep->write_staging_buffer)) { - gpr_slice_buffer_add( + grpc_slice_buffer_add( &ep->output_buffer, - gpr_slice_split_head( + grpc_slice_split_head( &ep->write_staging_buffer, (size_t)(cur - GPR_SLICE_START_PTR(ep->write_staging_buffer)))); } @@ -321,7 +321,7 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep, if (result != TSI_OK) { /* TODO(yangg) do different things according to the error type? */ - gpr_slice_buffer_reset_and_unref(&ep->output_buffer); + grpc_slice_buffer_reset_and_unref(&ep->output_buffer); grpc_exec_ctx_sched( exec_ctx, cb, grpc_set_tsi_error_result(GRPC_ERROR_CREATE("Wrap failed"), result), @@ -388,21 +388,21 @@ static const grpc_endpoint_vtable vtable = {endpoint_read, grpc_endpoint *grpc_secure_endpoint_create( struct tsi_frame_protector *protector, grpc_endpoint *transport, - gpr_slice *leftover_slices, size_t leftover_nslices) { + grpc_slice *leftover_slices, size_t leftover_nslices) { size_t i; secure_endpoint *ep = (secure_endpoint *)gpr_malloc(sizeof(secure_endpoint)); ep->base.vtable = &vtable; ep->wrapped_ep = transport; ep->protector = protector; - gpr_slice_buffer_init(&ep->leftover_bytes); + grpc_slice_buffer_init(&ep->leftover_bytes); for (i = 0; i < leftover_nslices; i++) { - gpr_slice_buffer_add(&ep->leftover_bytes, - gpr_slice_ref(leftover_slices[i])); + grpc_slice_buffer_add(&ep->leftover_bytes, + grpc_slice_ref(leftover_slices[i])); } - ep->write_staging_buffer = gpr_slice_malloc(STAGING_BUFFER_SIZE); - ep->read_staging_buffer = gpr_slice_malloc(STAGING_BUFFER_SIZE); - gpr_slice_buffer_init(&ep->output_buffer); - gpr_slice_buffer_init(&ep->source_buffer); + ep->write_staging_buffer = grpc_slice_malloc(STAGING_BUFFER_SIZE); + ep->read_staging_buffer = grpc_slice_malloc(STAGING_BUFFER_SIZE); + grpc_slice_buffer_init(&ep->output_buffer); + grpc_slice_buffer_init(&ep->source_buffer); ep->read_buffer = NULL; grpc_closure_init(&ep->on_read, on_read, ep); gpr_mu_init(&ep->protector_mu); diff --git a/src/core/lib/security/transport/secure_endpoint.h b/src/core/lib/security/transport/secure_endpoint.h index d00075b769..986e5e9f2e 100644 --- a/src/core/lib/security/transport/secure_endpoint.h +++ b/src/core/lib/security/transport/secure_endpoint.h @@ -44,6 +44,6 @@ extern int grpc_trace_secure_endpoint; /* Takes ownership of protector and to_wrap, and refs leftover_slices. */ grpc_endpoint *grpc_secure_endpoint_create( struct tsi_frame_protector *protector, grpc_endpoint *to_wrap, - gpr_slice *leftover_slices, size_t leftover_nslices); + grpc_slice *leftover_slices, size_t leftover_nslices); #endif /* GRPC_CORE_LIB_SECURITY_TRANSPORT_SECURE_ENDPOINT_H */ diff --git a/src/core/lib/security/transport/security_connector.c b/src/core/lib/security/transport/security_connector.c index 0eca46eb52..9de69f2288 100644 --- a/src/core/lib/security/transport/security_connector.c +++ b/src/core/lib/security/transport/security_connector.c @@ -127,7 +127,7 @@ void grpc_server_security_connector_shutdown( void grpc_channel_security_connector_do_handshake( grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc, - grpc_endpoint *nonsecure_endpoint, gpr_slice_buffer *read_buffer, + grpc_endpoint *nonsecure_endpoint, grpc_slice_buffer *read_buffer, gpr_timespec deadline, grpc_security_handshake_done_cb cb, void *user_data) { if (sc == NULL || nonsecure_endpoint == NULL) { @@ -142,7 +142,7 @@ void grpc_channel_security_connector_do_handshake( void grpc_server_security_connector_do_handshake( grpc_exec_ctx *exec_ctx, grpc_server_security_connector *sc, grpc_tcp_server_acceptor *acceptor, grpc_endpoint *nonsecure_endpoint, - gpr_slice_buffer *read_buffer, gpr_timespec deadline, + grpc_slice_buffer *read_buffer, gpr_timespec deadline, grpc_security_handshake_done_cb cb, void *user_data) { if (sc == NULL || nonsecure_endpoint == NULL) { gpr_free(read_buffer); @@ -316,7 +316,7 @@ static void fake_channel_check_call_host(grpc_exec_ctx *exec_ctx, static void fake_channel_do_handshake(grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc, grpc_endpoint *nonsecure_endpoint, - gpr_slice_buffer *read_buffer, + grpc_slice_buffer *read_buffer, gpr_timespec deadline, grpc_security_handshake_done_cb cb, void *user_data) { @@ -328,7 +328,7 @@ static void fake_channel_do_handshake(grpc_exec_ctx *exec_ctx, static void fake_server_do_handshake( grpc_exec_ctx *exec_ctx, grpc_server_security_connector *sc, grpc_tcp_server_acceptor *acceptor, grpc_endpoint *nonsecure_endpoint, - gpr_slice_buffer *read_buffer, gpr_timespec deadline, + grpc_slice_buffer *read_buffer, gpr_timespec deadline, grpc_security_handshake_done_cb cb, void *user_data) { grpc_do_security_handshake(exec_ctx, tsi_create_fake_handshaker(0), &sc->base, false, nonsecure_endpoint, read_buffer, deadline, @@ -422,7 +422,7 @@ static grpc_security_status ssl_create_handshaker( static void ssl_channel_do_handshake(grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc, grpc_endpoint *nonsecure_endpoint, - gpr_slice_buffer *read_buffer, + grpc_slice_buffer *read_buffer, gpr_timespec deadline, grpc_security_handshake_done_cb cb, void *user_data) { @@ -447,7 +447,7 @@ static void ssl_channel_do_handshake(grpc_exec_ctx *exec_ctx, static void ssl_server_do_handshake( grpc_exec_ctx *exec_ctx, grpc_server_security_connector *sc, grpc_tcp_server_acceptor *acceptor, grpc_endpoint *nonsecure_endpoint, - gpr_slice_buffer *read_buffer, gpr_timespec deadline, + grpc_slice_buffer *read_buffer, gpr_timespec deadline, grpc_security_handshake_done_cb cb, void *user_data) { grpc_ssl_server_security_connector *c = (grpc_ssl_server_security_connector *)sc; @@ -642,8 +642,8 @@ static grpc_security_connector_vtable ssl_channel_vtable = { static grpc_security_connector_vtable ssl_server_vtable = { ssl_server_destroy, ssl_server_check_peer}; -static gpr_slice compute_default_pem_root_certs_once(void) { - gpr_slice result = gpr_empty_slice(); +static grpc_slice compute_default_pem_root_certs_once(void) { + grpc_slice result = gpr_empty_slice(); /* First try to load the roots from the environment. */ char *default_root_certs_path = @@ -661,7 +661,7 @@ static gpr_slice compute_default_pem_root_certs_once(void) { ovrd_res = ssl_roots_override_cb(&pem_root_certs); if (ovrd_res == GRPC_SSL_ROOTS_OVERRIDE_OK) { GPR_ASSERT(pem_root_certs != NULL); - result = gpr_slice_new(pem_root_certs, strlen(pem_root_certs), gpr_free); + result = grpc_slice_new(pem_root_certs, strlen(pem_root_certs), gpr_free); } } @@ -674,13 +674,13 @@ static gpr_slice compute_default_pem_root_certs_once(void) { return result; } -static gpr_slice default_pem_root_certs; +static grpc_slice default_pem_root_certs; static void init_default_pem_root_certs(void) { default_pem_root_certs = compute_default_pem_root_certs_once(); } -gpr_slice grpc_get_default_ssl_roots_for_testing(void) { +grpc_slice grpc_get_default_ssl_roots_for_testing(void) { return compute_default_pem_root_certs_once(); } diff --git a/src/core/lib/security/transport/security_connector.h b/src/core/lib/security/transport/security_connector.h index 0b5b44bf1a..dc02692b01 100644 --- a/src/core/lib/security/transport/security_connector.h +++ b/src/core/lib/security/transport/security_connector.h @@ -144,7 +144,7 @@ struct grpc_channel_security_connector { void (*do_handshake)(grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *sc, grpc_endpoint *nonsecure_endpoint, - gpr_slice_buffer *read_buffer, gpr_timespec deadline, + grpc_slice_buffer *read_buffer, gpr_timespec deadline, grpc_security_handshake_done_cb cb, void *user_data); }; @@ -157,7 +157,7 @@ void grpc_channel_security_connector_check_call_host( /* Handshake. */ void grpc_channel_security_connector_do_handshake( grpc_exec_ctx *exec_ctx, grpc_channel_security_connector *connector, - grpc_endpoint *nonsecure_endpoint, gpr_slice_buffer *read_buffer, + grpc_endpoint *nonsecure_endpoint, grpc_slice_buffer *read_buffer, gpr_timespec deadline, grpc_security_handshake_done_cb cb, void *user_data); /* --- server_security_connector object. --- @@ -176,14 +176,14 @@ struct grpc_server_security_connector { grpc_server_security_connector *sc, grpc_tcp_server_acceptor *acceptor, grpc_endpoint *nonsecure_endpoint, - gpr_slice_buffer *read_buffer, gpr_timespec deadline, + grpc_slice_buffer *read_buffer, gpr_timespec deadline, grpc_security_handshake_done_cb cb, void *user_data); }; void grpc_server_security_connector_do_handshake( grpc_exec_ctx *exec_ctx, grpc_server_security_connector *sc, grpc_tcp_server_acceptor *acceptor, grpc_endpoint *nonsecure_endpoint, - gpr_slice_buffer *read_buffer, gpr_timespec deadline, + grpc_slice_buffer *read_buffer, gpr_timespec deadline, grpc_security_handshake_done_cb cb, void *user_data); void grpc_server_security_connector_shutdown( @@ -233,7 +233,7 @@ grpc_security_status grpc_ssl_channel_security_connector_create( size_t grpc_get_default_ssl_roots(const unsigned char **pem_root_certs); /* Exposed for TESTING ONLY!. */ -gpr_slice grpc_get_default_ssl_roots_for_testing(void); +grpc_slice grpc_get_default_ssl_roots_for_testing(void); /* Config for ssl servers. */ typedef struct { diff --git a/src/core/lib/security/transport/server_auth_filter.c b/src/core/lib/security/transport/server_auth_filter.c index b2c6815af8..39973ab036 100644 --- a/src/core/lib/security/transport/server_auth_filter.c +++ b/src/core/lib/security/transport/server_auth_filter.c @@ -134,14 +134,14 @@ static void on_md_processing_done( grpc_metadata_array_destroy(&calld->md); grpc_exec_ctx_sched(&exec_ctx, calld->on_done_recv, GRPC_ERROR_NONE, NULL); } else { - gpr_slice message; + grpc_slice message; grpc_transport_stream_op *close_op = gpr_malloc(sizeof(*close_op)); memset(close_op, 0, sizeof(*close_op)); grpc_metadata_array_destroy(&calld->md); error_details = error_details != NULL ? error_details : "Authentication metadata processing failed."; - message = gpr_slice_from_copied_string(error_details); + message = grpc_slice_from_copied_string(error_details); calld->transport_op->send_initial_metadata = NULL; if (calld->transport_op->send_message != NULL) { grpc_byte_stream_destroy(&exec_ctx, calld->transport_op->send_message); diff --git a/src/core/lib/security/util/b64.c b/src/core/lib/security/util/b64.c index 9da42e4e73..f4f0092c3d 100644 --- a/src/core/lib/security/util/b64.c +++ b/src/core/lib/security/util/b64.c @@ -120,7 +120,7 @@ char *grpc_base64_encode(const void *vdata, size_t data_size, int url_safe, return result; } -gpr_slice grpc_base64_decode(const char *b64, int url_safe) { +grpc_slice grpc_base64_decode(const char *b64, int url_safe) { return grpc_base64_decode_with_len(b64, strlen(b64), url_safe); } @@ -182,9 +182,9 @@ static int decode_group(const unsigned char *codes, size_t num_codes, return 1; } -gpr_slice grpc_base64_decode_with_len(const char *b64, size_t b64_len, +grpc_slice grpc_base64_decode_with_len(const char *b64, size_t b64_len, int url_safe) { - gpr_slice result = gpr_slice_malloc(b64_len); + grpc_slice result = grpc_slice_malloc(b64_len); unsigned char *current = GPR_SLICE_START_PTR(result); size_t result_size = 0; unsigned char codes[4]; @@ -228,6 +228,6 @@ gpr_slice grpc_base64_decode_with_len(const char *b64, size_t b64_len, return result; fail: - gpr_slice_unref(result); + grpc_slice_unref(result); return gpr_empty_slice(); } diff --git a/src/core/lib/security/util/b64.h b/src/core/lib/security/util/b64.h index 6908095287..f1b9bb2f2e 100644 --- a/src/core/lib/security/util/b64.h +++ b/src/core/lib/security/util/b64.h @@ -43,10 +43,10 @@ char *grpc_base64_encode(const void *data, size_t data_size, int url_safe, /* Decodes data according to the base64 specification. Returns an empty slice in case of failure. */ -gpr_slice grpc_base64_decode(const char *b64, int url_safe); +grpc_slice grpc_base64_decode(const char *b64, int url_safe); /* Same as above except that the length is provided by the caller. */ -gpr_slice grpc_base64_decode_with_len(const char *b64, size_t b64_len, +grpc_slice grpc_base64_decode_with_len(const char *b64, size_t b64_len, int url_safe); #endif /* GRPC_CORE_LIB_SECURITY_UTIL_B64_H */ diff --git a/src/core/lib/slice/percent_encoding.c b/src/core/lib/slice/percent_encoding.c new file mode 100644 index 0000000000..ae11e225e7 --- /dev/null +++ b/src/core/lib/slice/percent_encoding.c @@ -0,0 +1,180 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/lib/support/percent_encoding.h" + +#include + +const uint8_t gpr_url_percent_encoding_unreserved_bytes[256 / 8] = { + 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xff, 0x03, 0xfe, 0xff, 0xff, + 0x87, 0xfe, 0xff, 0xff, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; +const uint8_t gpr_compatible_percent_encoding_unreserved_bytes[256 / 8] = { + 0x00, 0x00, 0x00, 0x00, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, + 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; + +static bool is_unreserved_character(uint8_t c, + const uint8_t *unreserved_bytes) { + return ((unreserved_bytes[c / 8] >> (c % 8)) & 1) != 0; +} + +grpc_slice gpr_percent_encode_slice(grpc_slice slice, + const uint8_t *unreserved_bytes) { + static const uint8_t hex[] = "0123456789ABCDEF"; + + // first pass: count the number of bytes needed to output this string + size_t output_length = 0; + const uint8_t *slice_start = GPR_SLICE_START_PTR(slice); + const uint8_t *slice_end = GPR_SLICE_END_PTR(slice); + const uint8_t *p; + bool any_reserved_bytes = false; + for (p = slice_start; p < slice_end; p++) { + bool unres = is_unreserved_character(*p, unreserved_bytes); + output_length += unres ? 1 : 3; + any_reserved_bytes |= !unres; + } + // no unreserved bytes: return the string unmodified + if (!any_reserved_bytes) { + return grpc_slice_ref(slice); + } + // second pass: actually encode + grpc_slice out = grpc_slice_malloc(output_length); + uint8_t *q = GPR_SLICE_START_PTR(out); + for (p = slice_start; p < slice_end; p++) { + if (is_unreserved_character(*p, unreserved_bytes)) { + *q++ = *p; + } else { + *q++ = '%'; + *q++ = hex[*p >> 4]; + *q++ = hex[*p & 15]; + } + } + GPR_ASSERT(q == GPR_SLICE_END_PTR(out)); + return out; +} + +static bool valid_hex(const uint8_t *p, const uint8_t *end) { + if (p >= end) return false; + return (*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f') || + (*p >= 'A' && *p <= 'F'); +} + +static uint8_t dehex(uint8_t c) { + if (c >= '0' && c <= '9') return (uint8_t)(c - '0'); + if (c >= 'A' && c <= 'F') return (uint8_t)(c - 'A' + 10); + if (c >= 'a' && c <= 'f') return (uint8_t)(c - 'a' + 10); + GPR_UNREACHABLE_CODE(return 255); +} + +bool gpr_strict_percent_decode_slice(grpc_slice slice_in, + const uint8_t *unreserved_bytes, + grpc_slice *slice_out) { + const uint8_t *p = GPR_SLICE_START_PTR(slice_in); + const uint8_t *in_end = GPR_SLICE_END_PTR(slice_in); + size_t out_length = 0; + bool any_percent_encoded_stuff = false; + while (p != in_end) { + if (*p == '%') { + if (!valid_hex(++p, in_end)) return false; + if (!valid_hex(++p, in_end)) return false; + p++; + out_length++; + any_percent_encoded_stuff = true; + } else if (is_unreserved_character(*p, unreserved_bytes)) { + p++; + out_length++; + } else { + return false; + } + } + if (!any_percent_encoded_stuff) { + *slice_out = grpc_slice_ref(slice_in); + return true; + } + p = GPR_SLICE_START_PTR(slice_in); + *slice_out = grpc_slice_malloc(out_length); + uint8_t *q = GPR_SLICE_START_PTR(*slice_out); + while (p != in_end) { + if (*p == '%') { + *q++ = (uint8_t)(dehex(p[1]) << 4) | (dehex(p[2])); + p += 3; + } else { + *q++ = *p++; + } + } + GPR_ASSERT(q == GPR_SLICE_END_PTR(*slice_out)); + return true; +} + +grpc_slice gpr_permissive_percent_decode_slice(grpc_slice slice_in) { + const uint8_t *p = GPR_SLICE_START_PTR(slice_in); + const uint8_t *in_end = GPR_SLICE_END_PTR(slice_in); + size_t out_length = 0; + bool any_percent_encoded_stuff = false; + while (p != in_end) { + if (*p == '%') { + if (!valid_hex(p + 1, in_end) || !valid_hex(p + 2, in_end)) { + p++; + out_length++; + } else { + p += 3; + out_length++; + any_percent_encoded_stuff = true; + } + } else { + p++; + out_length++; + } + } + if (!any_percent_encoded_stuff) { + return grpc_slice_ref(slice_in); + } + p = GPR_SLICE_START_PTR(slice_in); + grpc_slice out = grpc_slice_malloc(out_length); + uint8_t *q = GPR_SLICE_START_PTR(out); + while (p != in_end) { + if (*p == '%') { + if (!valid_hex(p + 1, in_end) || !valid_hex(p + 2, in_end)) { + *q++ = *p++; + } else { + *q++ = (uint8_t)(dehex(p[1]) << 4) | (dehex(p[2])); + p += 3; + } + } else { + *q++ = *p++; + } + } + GPR_ASSERT(q == GPR_SLICE_END_PTR(out)); + return out; +} diff --git a/src/core/lib/slice/percent_encoding.h b/src/core/lib/slice/percent_encoding.h new file mode 100644 index 0000000000..a560d74a79 --- /dev/null +++ b/src/core/lib/slice/percent_encoding.h @@ -0,0 +1,78 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_CORE_LIB_SUPPORT_PERCENT_ENCODING_H +#define GRPC_CORE_LIB_SUPPORT_PERCENT_ENCODING_H + +/* Percent encoding and decoding of slices. + Transforms arbitrary strings into safe-for-transmission strings by using + variants of percent encoding (RFC 3986). + Two major variants are supplied: one that strictly matches URL encoding, + and another which applies percent encoding only to non-http2 header + bytes (the 'compatible' variant) */ + +#include + +#include + +/* URL percent encoding spec bitfield (usabel as 'unreserved_bytes' in + gpr_percent_encode_slice, gpr_strict_percent_decode_slice). + Flags [A-Za-z0-9-_.~] as unreserved bytes for the percent encoding routines + */ +extern const uint8_t gpr_url_percent_encoding_unreserved_bytes[256 / 8]; +/* URL percent encoding spec bitfield (usabel as 'unreserved_bytes' in + gpr_percent_encode_slice, gpr_strict_percent_decode_slice). + Flags ascii7 non-control characters excluding '%' as unreserved bytes for the + percent encoding routines */ +extern const uint8_t gpr_compatible_percent_encoding_unreserved_bytes[256 / 8]; + +/* Percent-encode a slice, returning the new slice (this cannot fail): + unreserved_bytes is a bitfield indicating which bytes are considered + unreserved and thus do not need percent encoding */ +grpc_slice gpr_percent_encode_slice(grpc_slice slice, + const uint8_t *unreserved_bytes); +/* Percent-decode a slice, strictly. + If the input is legal (contains no unreserved bytes, and legal % encodings), + returns true and sets *slice_out to the decoded slice. + If the input is not legal, returns false and leaves *slice_out untouched. + unreserved_bytes is a bitfield indicating which bytes are considered + unreserved and thus do not need percent encoding */ +bool gpr_strict_percent_decode_slice(grpc_slice slice_in, + const uint8_t *unreserved_bytes, + grpc_slice *slice_out); +/* Percent-decode a slice, permissively. + If a % triplet can not be decoded, pass it through verbatim. + This cannot fail. */ +grpc_slice gpr_permissive_percent_decode_slice(grpc_slice slice_in); + +#endif /* GRPC_CORE_LIB_SUPPORT_PERCENT_ENCODING_H */ diff --git a/src/core/lib/slice/slice.c b/src/core/lib/slice/slice.c new file mode 100644 index 0000000000..602dd86eca --- /dev/null +++ b/src/core/lib/slice/slice.c @@ -0,0 +1,350 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include + +#include + +grpc_slice gpr_empty_slice(void) { + grpc_slice out; + out.refcount = 0; + out.data.inlined.length = 0; + return out; +} + +grpc_slice grpc_slice_ref(grpc_slice slice) { + if (slice.refcount) { + slice.refcount->ref(slice.refcount); + } + return slice; +} + +void grpc_slice_unref(grpc_slice slice) { + if (slice.refcount) { + slice.refcount->unref(slice.refcount); + } +} + +/* grpc_slice_from_static_string support structure - a refcount that does + nothing */ +static void noop_ref_or_unref(void *unused) {} + +static grpc_slice_refcount noop_refcount = {noop_ref_or_unref, + noop_ref_or_unref}; + +grpc_slice grpc_slice_from_static_string(const char *s) { + grpc_slice slice; + slice.refcount = &noop_refcount; + slice.data.refcounted.bytes = (uint8_t *)s; + slice.data.refcounted.length = strlen(s); + return slice; +} + +/* grpc_slice_new support structures - we create a refcount object extended + with the user provided data pointer & destroy function */ +typedef struct new_slice_refcount { + grpc_slice_refcount rc; + gpr_refcount refs; + void (*user_destroy)(void *); + void *user_data; +} new_slice_refcount; + +static void new_slice_ref(void *p) { + new_slice_refcount *r = p; + gpr_ref(&r->refs); +} + +static void new_slice_unref(void *p) { + new_slice_refcount *r = p; + if (gpr_unref(&r->refs)) { + r->user_destroy(r->user_data); + gpr_free(r); + } +} + +grpc_slice grpc_slice_new_with_user_data(void *p, size_t len, + void (*destroy)(void *), + void *user_data) { + grpc_slice slice; + new_slice_refcount *rc = gpr_malloc(sizeof(new_slice_refcount)); + gpr_ref_init(&rc->refs, 1); + rc->rc.ref = new_slice_ref; + rc->rc.unref = new_slice_unref; + rc->user_destroy = destroy; + rc->user_data = user_data; + + slice.refcount = &rc->rc; + slice.data.refcounted.bytes = p; + slice.data.refcounted.length = len; + return slice; +} + +grpc_slice grpc_slice_new(void *p, size_t len, void (*destroy)(void *)) { + /* Pass "p" to *destroy when the slice is no longer needed. */ + return grpc_slice_new_with_user_data(p, len, destroy, p); +} + +/* grpc_slice_new_with_len support structures - we create a refcount object + extended with the user provided data pointer & destroy function */ +typedef struct new_with_len_slice_refcount { + grpc_slice_refcount rc; + gpr_refcount refs; + void *user_data; + size_t user_length; + void (*user_destroy)(void *, size_t); +} new_with_len_slice_refcount; + +static void new_with_len_ref(void *p) { + new_with_len_slice_refcount *r = p; + gpr_ref(&r->refs); +} + +static void new_with_len_unref(void *p) { + new_with_len_slice_refcount *r = p; + if (gpr_unref(&r->refs)) { + r->user_destroy(r->user_data, r->user_length); + gpr_free(r); + } +} + +grpc_slice grpc_slice_new_with_len(void *p, size_t len, + void (*destroy)(void *, size_t)) { + grpc_slice slice; + new_with_len_slice_refcount *rc = + gpr_malloc(sizeof(new_with_len_slice_refcount)); + gpr_ref_init(&rc->refs, 1); + rc->rc.ref = new_with_len_ref; + rc->rc.unref = new_with_len_unref; + rc->user_destroy = destroy; + rc->user_data = p; + rc->user_length = len; + + slice.refcount = &rc->rc; + slice.data.refcounted.bytes = p; + slice.data.refcounted.length = len; + return slice; +} + +grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t length) { + grpc_slice slice = grpc_slice_malloc(length); + memcpy(GPR_SLICE_START_PTR(slice), source, length); + return slice; +} + +grpc_slice grpc_slice_from_copied_string(const char *source) { + return grpc_slice_from_copied_buffer(source, strlen(source)); +} + +typedef struct { + grpc_slice_refcount base; + gpr_refcount refs; +} malloc_refcount; + +static void malloc_ref(void *p) { + malloc_refcount *r = p; + gpr_ref(&r->refs); +} + +static void malloc_unref(void *p) { + malloc_refcount *r = p; + if (gpr_unref(&r->refs)) { + gpr_free(r); + } +} + +grpc_slice grpc_slice_malloc(size_t length) { + grpc_slice slice; + + if (length > sizeof(slice.data.inlined.bytes)) { + /* Memory layout used by the slice created here: + + +-----------+----------------------------------------------------------+ + | refcount | bytes | + +-----------+----------------------------------------------------------+ + + refcount is a malloc_refcount + bytes is an array of bytes of the requested length + Both parts are placed in the same allocation returned from gpr_malloc */ + malloc_refcount *rc = gpr_malloc(sizeof(malloc_refcount) + length); + + /* Initial refcount on rc is 1 - and it's up to the caller to release + this reference. */ + gpr_ref_init(&rc->refs, 1); + + rc->base.ref = malloc_ref; + rc->base.unref = malloc_unref; + + /* Build up the slice to be returned. */ + /* The slices refcount points back to the allocated block. */ + slice.refcount = &rc->base; + /* The data bytes are placed immediately after the refcount struct */ + slice.data.refcounted.bytes = (uint8_t *)(rc + 1); + /* And the length of the block is set to the requested length */ + slice.data.refcounted.length = length; + } else { + /* small slice: just inline the data */ + slice.refcount = NULL; + slice.data.inlined.length = (uint8_t)length; + } + return slice; +} + +grpc_slice grpc_slice_sub_no_ref(grpc_slice source, size_t begin, size_t end) { + grpc_slice subset; + + GPR_ASSERT(end >= begin); + + if (source.refcount) { + /* Enforce preconditions */ + GPR_ASSERT(source.data.refcounted.length >= end); + + /* Build the result */ + subset.refcount = source.refcount; + /* Point into the source array */ + subset.data.refcounted.bytes = source.data.refcounted.bytes + begin; + subset.data.refcounted.length = end - begin; + } else { + /* Enforce preconditions */ + GPR_ASSERT(source.data.inlined.length >= end); + subset.refcount = NULL; + subset.data.inlined.length = (uint8_t)(end - begin); + memcpy(subset.data.inlined.bytes, source.data.inlined.bytes + begin, + end - begin); + } + return subset; +} + +grpc_slice grpc_slice_sub(grpc_slice source, size_t begin, size_t end) { + grpc_slice subset; + + if (end - begin <= sizeof(subset.data.inlined.bytes)) { + subset.refcount = NULL; + subset.data.inlined.length = (uint8_t)(end - begin); + memcpy(subset.data.inlined.bytes, GPR_SLICE_START_PTR(source) + begin, + end - begin); + } else { + subset = grpc_slice_sub_no_ref(source, begin, end); + /* Bump the refcount */ + subset.refcount->ref(subset.refcount); + } + return subset; +} + +grpc_slice grpc_slice_split_tail(grpc_slice *source, size_t split) { + grpc_slice tail; + + if (source->refcount == NULL) { + /* inlined data, copy it out */ + GPR_ASSERT(source->data.inlined.length >= split); + tail.refcount = NULL; + tail.data.inlined.length = (uint8_t)(source->data.inlined.length - split); + memcpy(tail.data.inlined.bytes, source->data.inlined.bytes + split, + tail.data.inlined.length); + source->data.inlined.length = (uint8_t)split; + } else { + size_t tail_length = source->data.refcounted.length - split; + GPR_ASSERT(source->data.refcounted.length >= split); + if (tail_length < sizeof(tail.data.inlined.bytes)) { + /* Copy out the bytes - it'll be cheaper than refcounting */ + tail.refcount = NULL; + tail.data.inlined.length = (uint8_t)tail_length; + memcpy(tail.data.inlined.bytes, source->data.refcounted.bytes + split, + tail_length); + } else { + /* Build the result */ + tail.refcount = source->refcount; + /* Bump the refcount */ + tail.refcount->ref(tail.refcount); + /* Point into the source array */ + tail.data.refcounted.bytes = source->data.refcounted.bytes + split; + tail.data.refcounted.length = tail_length; + } + source->data.refcounted.length = split; + } + + return tail; +} + +grpc_slice grpc_slice_split_head(grpc_slice *source, size_t split) { + grpc_slice head; + + if (source->refcount == NULL) { + GPR_ASSERT(source->data.inlined.length >= split); + + head.refcount = NULL; + head.data.inlined.length = (uint8_t)split; + memcpy(head.data.inlined.bytes, source->data.inlined.bytes, split); + source->data.inlined.length = + (uint8_t)(source->data.inlined.length - split); + memmove(source->data.inlined.bytes, source->data.inlined.bytes + split, + source->data.inlined.length); + } else if (split < sizeof(head.data.inlined.bytes)) { + GPR_ASSERT(source->data.refcounted.length >= split); + + head.refcount = NULL; + head.data.inlined.length = (uint8_t)split; + memcpy(head.data.inlined.bytes, source->data.refcounted.bytes, split); + source->data.refcounted.bytes += split; + source->data.refcounted.length -= split; + } else { + GPR_ASSERT(source->data.refcounted.length >= split); + + /* Build the result */ + head.refcount = source->refcount; + /* Bump the refcount */ + head.refcount->ref(head.refcount); + /* Point into the source array */ + head.data.refcounted.bytes = source->data.refcounted.bytes; + head.data.refcounted.length = split; + source->data.refcounted.bytes += split; + source->data.refcounted.length -= split; + } + + return head; +} + +int grpc_slice_cmp(grpc_slice a, grpc_slice b) { + int d = (int)(GPR_SLICE_LENGTH(a) - GPR_SLICE_LENGTH(b)); + if (d != 0) return d; + return memcmp(GPR_SLICE_START_PTR(a), GPR_SLICE_START_PTR(b), + GPR_SLICE_LENGTH(a)); +} + +int grpc_slice_str_cmp(grpc_slice a, const char *b) { + size_t b_length = strlen(b); + int d = (int)(GPR_SLICE_LENGTH(a) - b_length); + if (d != 0) return d; + return memcmp(GPR_SLICE_START_PTR(a), b, b_length); +} diff --git a/src/core/lib/slice/slice_buffer.c b/src/core/lib/slice/slice_buffer.c new file mode 100644 index 0000000000..c92797233d --- /dev/null +++ b/src/core/lib/slice/slice_buffer.c @@ -0,0 +1,282 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include + +#include + +#include +#include +#include + +/* grow a buffer; requires GRPC_SLICE_BUFFER_INLINE_ELEMENTS > 1 */ +#define GROW(x) (3 * (x) / 2) + +static void maybe_embiggen(grpc_slice_buffer *sb) { + if (sb->count == sb->capacity) { + sb->capacity = GROW(sb->capacity); + GPR_ASSERT(sb->capacity > sb->count); + if (sb->slices == sb->inlined) { + sb->slices = gpr_malloc(sb->capacity * sizeof(grpc_slice)); + memcpy(sb->slices, sb->inlined, sb->count * sizeof(grpc_slice)); + } else { + sb->slices = gpr_realloc(sb->slices, sb->capacity * sizeof(grpc_slice)); + } + } +} + +void grpc_slice_buffer_init(grpc_slice_buffer *sb) { + sb->count = 0; + sb->length = 0; + sb->capacity = GRPC_SLICE_BUFFER_INLINE_ELEMENTS; + sb->slices = sb->inlined; +} + +void grpc_slice_buffer_destroy(grpc_slice_buffer *sb) { + grpc_slice_buffer_reset_and_unref(sb); + if (sb->slices != sb->inlined) { + gpr_free(sb->slices); + } +} + +uint8_t *grpc_slice_buffer_tiny_add(grpc_slice_buffer *sb, size_t n) { + grpc_slice *back; + uint8_t *out; + + sb->length += n; + + if (sb->count == 0) goto add_new; + back = &sb->slices[sb->count - 1]; + if (back->refcount) goto add_new; + if ((back->data.inlined.length + n) > sizeof(back->data.inlined.bytes)) + goto add_new; + out = back->data.inlined.bytes + back->data.inlined.length; + back->data.inlined.length = (uint8_t)(back->data.inlined.length + n); + return out; + +add_new: + maybe_embiggen(sb); + back = &sb->slices[sb->count]; + sb->count++; + back->refcount = NULL; + back->data.inlined.length = (uint8_t)n; + return back->data.inlined.bytes; +} + +size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer *sb, grpc_slice s) { + size_t out = sb->count; + maybe_embiggen(sb); + sb->slices[out] = s; + sb->length += GPR_SLICE_LENGTH(s); + sb->count = out + 1; + return out; +} + +void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice s) { + size_t n = sb->count; + /* if both the last slice in the slice buffer and the slice being added + are inlined (that is, that they carry their data inside the slice data + structure), and the back slice is not full, then concatenate directly + into the back slice, preventing many small slices being passed into + writes */ + if (!s.refcount && n) { + grpc_slice *back = &sb->slices[n - 1]; + if (!back->refcount && back->data.inlined.length < GPR_SLICE_INLINED_SIZE) { + if (s.data.inlined.length + back->data.inlined.length <= + GPR_SLICE_INLINED_SIZE) { + memcpy(back->data.inlined.bytes + back->data.inlined.length, + s.data.inlined.bytes, s.data.inlined.length); + back->data.inlined.length = + (uint8_t)(back->data.inlined.length + s.data.inlined.length); + } else { + size_t cp1 = GPR_SLICE_INLINED_SIZE - back->data.inlined.length; + memcpy(back->data.inlined.bytes + back->data.inlined.length, + s.data.inlined.bytes, cp1); + back->data.inlined.length = GPR_SLICE_INLINED_SIZE; + maybe_embiggen(sb); + back = &sb->slices[n]; + sb->count = n + 1; + back->refcount = NULL; + back->data.inlined.length = (uint8_t)(s.data.inlined.length - cp1); + memcpy(back->data.inlined.bytes, s.data.inlined.bytes + cp1, + s.data.inlined.length - cp1); + } + sb->length += s.data.inlined.length; + return; /* early out */ + } + } + grpc_slice_buffer_add_indexed(sb, s); +} + +void grpc_slice_buffer_addn(grpc_slice_buffer *sb, grpc_slice *s, size_t n) { + size_t i; + for (i = 0; i < n; i++) { + grpc_slice_buffer_add(sb, s[i]); + } +} + +void grpc_slice_buffer_pop(grpc_slice_buffer *sb) { + if (sb->count != 0) { + size_t count = --sb->count; + sb->length -= GPR_SLICE_LENGTH(sb->slices[count]); + } +} + +void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer *sb) { + size_t i; + + for (i = 0; i < sb->count; i++) { + grpc_slice_unref(sb->slices[i]); + } + + sb->count = 0; + sb->length = 0; +} + +void grpc_slice_buffer_swap(grpc_slice_buffer *a, grpc_slice_buffer *b) { + GPR_SWAP(size_t, a->count, b->count); + GPR_SWAP(size_t, a->capacity, b->capacity); + GPR_SWAP(size_t, a->length, b->length); + + if (a->slices == a->inlined) { + if (b->slices == b->inlined) { + /* swap contents of inlined buffer */ + grpc_slice temp[GRPC_SLICE_BUFFER_INLINE_ELEMENTS]; + memcpy(temp, a->slices, b->count * sizeof(grpc_slice)); + memcpy(a->slices, b->slices, a->count * sizeof(grpc_slice)); + memcpy(b->slices, temp, b->count * sizeof(grpc_slice)); + } else { + /* a is inlined, b is not - copy a inlined into b, fix pointers */ + a->slices = b->slices; + b->slices = b->inlined; + memcpy(b->slices, a->inlined, b->count * sizeof(grpc_slice)); + } + } else if (b->slices == b->inlined) { + /* b is inlined, a is not - copy b inlined int a, fix pointers */ + b->slices = a->slices; + a->slices = a->inlined; + memcpy(a->slices, b->inlined, a->count * sizeof(grpc_slice)); + } else { + /* no inlining: easy swap */ + GPR_SWAP(grpc_slice *, a->slices, b->slices); + } +} + +void grpc_slice_buffer_move_into(grpc_slice_buffer *src, grpc_slice_buffer *dst) { + /* anything to move? */ + if (src->count == 0) { + return; + } + /* anything in dst? */ + if (dst->count == 0) { + grpc_slice_buffer_swap(src, dst); + return; + } + /* both buffers have data - copy, and reset src */ + grpc_slice_buffer_addn(dst, src->slices, src->count); + src->count = 0; + src->length = 0; +} + +void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n, + grpc_slice_buffer *dst) { + size_t src_idx; + size_t output_len = dst->length + n; + size_t new_input_len = src->length - n; + GPR_ASSERT(src->length >= n); + if (src->length == n) { + grpc_slice_buffer_move_into(src, dst); + return; + } + src_idx = 0; + while (src_idx < src->capacity) { + grpc_slice slice = src->slices[src_idx]; + size_t slice_len = GPR_SLICE_LENGTH(slice); + if (n > slice_len) { + grpc_slice_buffer_add(dst, slice); + n -= slice_len; + src_idx++; + } else if (n == slice_len) { + grpc_slice_buffer_add(dst, slice); + src_idx++; + break; + } else { /* n < slice_len */ + src->slices[src_idx] = grpc_slice_split_tail(&slice, n); + GPR_ASSERT(GPR_SLICE_LENGTH(slice) == n); + GPR_ASSERT(GPR_SLICE_LENGTH(src->slices[src_idx]) == slice_len - n); + grpc_slice_buffer_add(dst, slice); + break; + } + } + GPR_ASSERT(dst->length == output_len); + memmove(src->slices, src->slices + src_idx, + sizeof(grpc_slice) * (src->count - src_idx)); + src->count -= src_idx; + src->length = new_input_len; + GPR_ASSERT(src->count > 0); +} + +void grpc_slice_buffer_trim_end(grpc_slice_buffer *sb, size_t n, + grpc_slice_buffer *garbage) { + GPR_ASSERT(n <= sb->length); + sb->length -= n; + for (;;) { + size_t idx = sb->count - 1; + grpc_slice slice = sb->slices[idx]; + size_t slice_len = GPR_SLICE_LENGTH(slice); + if (slice_len > n) { + sb->slices[idx] = grpc_slice_split_head(&slice, slice_len - n); + grpc_slice_buffer_add_indexed(garbage, slice); + return; + } else if (slice_len == n) { + grpc_slice_buffer_add_indexed(garbage, slice); + sb->count = idx; + return; + } else { + grpc_slice_buffer_add_indexed(garbage, slice); + n -= slice_len; + sb->count = idx; + } + } +} + +grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer *sb) { + grpc_slice slice; + GPR_ASSERT(sb->count > 0); + slice = sb->slices[0]; + memmove(&sb->slices[0], &sb->slices[1], (sb->count - 1) * sizeof(grpc_slice)); + sb->count--; + sb->length -= GPR_SLICE_LENGTH(slice); + return slice; +} diff --git a/src/core/lib/slice/slice_string_helpers.c b/src/core/lib/slice/slice_string_helpers.c new file mode 100644 index 0000000000..cc8b80d3b8 --- /dev/null +++ b/src/core/lib/slice/slice_string_helpers.c @@ -0,0 +1,81 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +char *gpr_dump_slice(grpc_slice s, uint32_t flags) { + return gpr_dump((const char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s), + flags); +} + +/** Finds the initial (\a begin) and final (\a end) offsets of the next + * substring from \a str + \a read_offset until the next \a sep or the end of \a + * str. + * + * Returns 1 and updates \a begin and \a end. Returns 0 otherwise. */ +static int slice_find_separator_offset(const grpc_slice str, const char *sep, + const size_t read_offset, size_t *begin, + size_t *end) { + size_t i; + const uint8_t *str_ptr = GPR_SLICE_START_PTR(str) + read_offset; + const size_t str_len = GPR_SLICE_LENGTH(str) - read_offset; + const size_t sep_len = strlen(sep); + if (str_len < sep_len) { + return 0; + } + + for (i = 0; i <= str_len - sep_len; i++) { + if (memcmp(str_ptr + i, sep, sep_len) == 0) { + *begin = read_offset; + *end = read_offset + i; + return 1; + } + } + return 0; +} + +void grpc_slice_split(grpc_slice str, const char *sep, grpc_slice_buffer *dst) { + const size_t sep_len = strlen(sep); + size_t begin, end; + + GPR_ASSERT(sep_len > 0); + + if (slice_find_separator_offset(str, sep, 0, &begin, &end) != 0) { + do { + grpc_slice_buffer_add_indexed(dst, grpc_slice_sub(str, begin, end)); + } while (slice_find_separator_offset(str, sep, end + sep_len, &begin, + &end) != 0); + grpc_slice_buffer_add_indexed( + dst, grpc_slice_sub(str, end + sep_len, GPR_SLICE_LENGTH(str))); + } else { /* no sep found, add whole input */ + grpc_slice_buffer_add_indexed(dst, grpc_slice_ref(str)); + } +} diff --git a/src/core/lib/slice/slice_string_helpers.h b/src/core/lib/slice/slice_string_helpers.h new file mode 100644 index 0000000000..d144a70889 --- /dev/null +++ b/src/core/lib/slice/slice_string_helpers.h @@ -0,0 +1,58 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#ifndef GRPC_CORE_LIB_SUPPORT_SLICE_STRING_H +#define GRPC_CORE_LIB_SUPPORT_SLICE_STRING_H + +#include + +#include +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/* Calls gpr_dump on a slice. */ +char *gpr_dump_slice(grpc_slice slice, uint32_t flags); + +/** Split \a str by the separator \a sep. Results are stored in \a dst, which + * should be a properly initialized instance. */ +void grpc_slice_split(grpc_slice str, const char *sep, grpc_slice_buffer *dst); + +#ifdef __cplusplus +} +#endif + +#endif /* GRPC_CORE_LIB_SUPPORT_STRING_H */ diff --git a/src/core/lib/support/percent_encoding.c b/src/core/lib/support/percent_encoding.c deleted file mode 100644 index 3c19f264f9..0000000000 --- a/src/core/lib/support/percent_encoding.c +++ /dev/null @@ -1,180 +0,0 @@ -/* - * - * Copyright 2016, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "src/core/lib/support/percent_encoding.h" - -#include - -const uint8_t gpr_url_percent_encoding_unreserved_bytes[256 / 8] = { - 0x00, 0x00, 0x00, 0x00, 0x00, 0x60, 0xff, 0x03, 0xfe, 0xff, 0xff, - 0x87, 0xfe, 0xff, 0xff, 0x47, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; -const uint8_t gpr_compatible_percent_encoding_unreserved_bytes[256 / 8] = { - 0x00, 0x00, 0x00, 0x00, 0xdf, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, - 0xff, 0xff, 0xff, 0xff, 0x7f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}; - -static bool is_unreserved_character(uint8_t c, - const uint8_t *unreserved_bytes) { - return ((unreserved_bytes[c / 8] >> (c % 8)) & 1) != 0; -} - -gpr_slice gpr_percent_encode_slice(gpr_slice slice, - const uint8_t *unreserved_bytes) { - static const uint8_t hex[] = "0123456789ABCDEF"; - - // first pass: count the number of bytes needed to output this string - size_t output_length = 0; - const uint8_t *slice_start = GPR_SLICE_START_PTR(slice); - const uint8_t *slice_end = GPR_SLICE_END_PTR(slice); - const uint8_t *p; - bool any_reserved_bytes = false; - for (p = slice_start; p < slice_end; p++) { - bool unres = is_unreserved_character(*p, unreserved_bytes); - output_length += unres ? 1 : 3; - any_reserved_bytes |= !unres; - } - // no unreserved bytes: return the string unmodified - if (!any_reserved_bytes) { - return gpr_slice_ref(slice); - } - // second pass: actually encode - gpr_slice out = gpr_slice_malloc(output_length); - uint8_t *q = GPR_SLICE_START_PTR(out); - for (p = slice_start; p < slice_end; p++) { - if (is_unreserved_character(*p, unreserved_bytes)) { - *q++ = *p; - } else { - *q++ = '%'; - *q++ = hex[*p >> 4]; - *q++ = hex[*p & 15]; - } - } - GPR_ASSERT(q == GPR_SLICE_END_PTR(out)); - return out; -} - -static bool valid_hex(const uint8_t *p, const uint8_t *end) { - if (p >= end) return false; - return (*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f') || - (*p >= 'A' && *p <= 'F'); -} - -static uint8_t dehex(uint8_t c) { - if (c >= '0' && c <= '9') return (uint8_t)(c - '0'); - if (c >= 'A' && c <= 'F') return (uint8_t)(c - 'A' + 10); - if (c >= 'a' && c <= 'f') return (uint8_t)(c - 'a' + 10); - GPR_UNREACHABLE_CODE(return 255); -} - -bool gpr_strict_percent_decode_slice(gpr_slice slice_in, - const uint8_t *unreserved_bytes, - gpr_slice *slice_out) { - const uint8_t *p = GPR_SLICE_START_PTR(slice_in); - const uint8_t *in_end = GPR_SLICE_END_PTR(slice_in); - size_t out_length = 0; - bool any_percent_encoded_stuff = false; - while (p != in_end) { - if (*p == '%') { - if (!valid_hex(++p, in_end)) return false; - if (!valid_hex(++p, in_end)) return false; - p++; - out_length++; - any_percent_encoded_stuff = true; - } else if (is_unreserved_character(*p, unreserved_bytes)) { - p++; - out_length++; - } else { - return false; - } - } - if (!any_percent_encoded_stuff) { - *slice_out = gpr_slice_ref(slice_in); - return true; - } - p = GPR_SLICE_START_PTR(slice_in); - *slice_out = gpr_slice_malloc(out_length); - uint8_t *q = GPR_SLICE_START_PTR(*slice_out); - while (p != in_end) { - if (*p == '%') { - *q++ = (uint8_t)(dehex(p[1]) << 4) | (dehex(p[2])); - p += 3; - } else { - *q++ = *p++; - } - } - GPR_ASSERT(q == GPR_SLICE_END_PTR(*slice_out)); - return true; -} - -gpr_slice gpr_permissive_percent_decode_slice(gpr_slice slice_in) { - const uint8_t *p = GPR_SLICE_START_PTR(slice_in); - const uint8_t *in_end = GPR_SLICE_END_PTR(slice_in); - size_t out_length = 0; - bool any_percent_encoded_stuff = false; - while (p != in_end) { - if (*p == '%') { - if (!valid_hex(p + 1, in_end) || !valid_hex(p + 2, in_end)) { - p++; - out_length++; - } else { - p += 3; - out_length++; - any_percent_encoded_stuff = true; - } - } else { - p++; - out_length++; - } - } - if (!any_percent_encoded_stuff) { - return gpr_slice_ref(slice_in); - } - p = GPR_SLICE_START_PTR(slice_in); - gpr_slice out = gpr_slice_malloc(out_length); - uint8_t *q = GPR_SLICE_START_PTR(out); - while (p != in_end) { - if (*p == '%') { - if (!valid_hex(p + 1, in_end) || !valid_hex(p + 2, in_end)) { - *q++ = *p++; - } else { - *q++ = (uint8_t)(dehex(p[1]) << 4) | (dehex(p[2])); - p += 3; - } - } else { - *q++ = *p++; - } - } - GPR_ASSERT(q == GPR_SLICE_END_PTR(out)); - return out; -} diff --git a/src/core/lib/support/percent_encoding.h b/src/core/lib/support/percent_encoding.h deleted file mode 100644 index 000bf14ede..0000000000 --- a/src/core/lib/support/percent_encoding.h +++ /dev/null @@ -1,78 +0,0 @@ -/* - * - * Copyright 2016, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#ifndef GRPC_CORE_LIB_SUPPORT_PERCENT_ENCODING_H -#define GRPC_CORE_LIB_SUPPORT_PERCENT_ENCODING_H - -/* Percent encoding and decoding of slices. - Transforms arbitrary strings into safe-for-transmission strings by using - variants of percent encoding (RFC 3986). - Two major variants are supplied: one that strictly matches URL encoding, - and another which applies percent encoding only to non-http2 header - bytes (the 'compatible' variant) */ - -#include - -#include - -/* URL percent encoding spec bitfield (usabel as 'unreserved_bytes' in - gpr_percent_encode_slice, gpr_strict_percent_decode_slice). - Flags [A-Za-z0-9-_.~] as unreserved bytes for the percent encoding routines - */ -extern const uint8_t gpr_url_percent_encoding_unreserved_bytes[256 / 8]; -/* URL percent encoding spec bitfield (usabel as 'unreserved_bytes' in - gpr_percent_encode_slice, gpr_strict_percent_decode_slice). - Flags ascii7 non-control characters excluding '%' as unreserved bytes for the - percent encoding routines */ -extern const uint8_t gpr_compatible_percent_encoding_unreserved_bytes[256 / 8]; - -/* Percent-encode a slice, returning the new slice (this cannot fail): - unreserved_bytes is a bitfield indicating which bytes are considered - unreserved and thus do not need percent encoding */ -gpr_slice gpr_percent_encode_slice(gpr_slice slice, - const uint8_t *unreserved_bytes); -/* Percent-decode a slice, strictly. - If the input is legal (contains no unreserved bytes, and legal % encodings), - returns true and sets *slice_out to the decoded slice. - If the input is not legal, returns false and leaves *slice_out untouched. - unreserved_bytes is a bitfield indicating which bytes are considered - unreserved and thus do not need percent encoding */ -bool gpr_strict_percent_decode_slice(gpr_slice slice_in, - const uint8_t *unreserved_bytes, - gpr_slice *slice_out); -/* Percent-decode a slice, permissively. - If a % triplet can not be decoded, pass it through verbatim. - This cannot fail. */ -gpr_slice gpr_permissive_percent_decode_slice(gpr_slice slice_in); - -#endif /* GRPC_CORE_LIB_SUPPORT_PERCENT_ENCODING_H */ diff --git a/src/core/lib/support/slice.c b/src/core/lib/support/slice.c deleted file mode 100644 index 8a2c0a9086..0000000000 --- a/src/core/lib/support/slice.c +++ /dev/null @@ -1,350 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -#include -#include - -#include - -gpr_slice gpr_empty_slice(void) { - gpr_slice out; - out.refcount = 0; - out.data.inlined.length = 0; - return out; -} - -gpr_slice gpr_slice_ref(gpr_slice slice) { - if (slice.refcount) { - slice.refcount->ref(slice.refcount); - } - return slice; -} - -void gpr_slice_unref(gpr_slice slice) { - if (slice.refcount) { - slice.refcount->unref(slice.refcount); - } -} - -/* gpr_slice_from_static_string support structure - a refcount that does - nothing */ -static void noop_ref_or_unref(void *unused) {} - -static gpr_slice_refcount noop_refcount = {noop_ref_or_unref, - noop_ref_or_unref}; - -gpr_slice gpr_slice_from_static_string(const char *s) { - gpr_slice slice; - slice.refcount = &noop_refcount; - slice.data.refcounted.bytes = (uint8_t *)s; - slice.data.refcounted.length = strlen(s); - return slice; -} - -/* gpr_slice_new support structures - we create a refcount object extended - with the user provided data pointer & destroy function */ -typedef struct new_slice_refcount { - gpr_slice_refcount rc; - gpr_refcount refs; - void (*user_destroy)(void *); - void *user_data; -} new_slice_refcount; - -static void new_slice_ref(void *p) { - new_slice_refcount *r = p; - gpr_ref(&r->refs); -} - -static void new_slice_unref(void *p) { - new_slice_refcount *r = p; - if (gpr_unref(&r->refs)) { - r->user_destroy(r->user_data); - gpr_free(r); - } -} - -gpr_slice gpr_slice_new_with_user_data(void *p, size_t len, - void (*destroy)(void *), - void *user_data) { - gpr_slice slice; - new_slice_refcount *rc = gpr_malloc(sizeof(new_slice_refcount)); - gpr_ref_init(&rc->refs, 1); - rc->rc.ref = new_slice_ref; - rc->rc.unref = new_slice_unref; - rc->user_destroy = destroy; - rc->user_data = user_data; - - slice.refcount = &rc->rc; - slice.data.refcounted.bytes = p; - slice.data.refcounted.length = len; - return slice; -} - -gpr_slice gpr_slice_new(void *p, size_t len, void (*destroy)(void *)) { - /* Pass "p" to *destroy when the slice is no longer needed. */ - return gpr_slice_new_with_user_data(p, len, destroy, p); -} - -/* gpr_slice_new_with_len support structures - we create a refcount object - extended with the user provided data pointer & destroy function */ -typedef struct new_with_len_slice_refcount { - gpr_slice_refcount rc; - gpr_refcount refs; - void *user_data; - size_t user_length; - void (*user_destroy)(void *, size_t); -} new_with_len_slice_refcount; - -static void new_with_len_ref(void *p) { - new_with_len_slice_refcount *r = p; - gpr_ref(&r->refs); -} - -static void new_with_len_unref(void *p) { - new_with_len_slice_refcount *r = p; - if (gpr_unref(&r->refs)) { - r->user_destroy(r->user_data, r->user_length); - gpr_free(r); - } -} - -gpr_slice gpr_slice_new_with_len(void *p, size_t len, - void (*destroy)(void *, size_t)) { - gpr_slice slice; - new_with_len_slice_refcount *rc = - gpr_malloc(sizeof(new_with_len_slice_refcount)); - gpr_ref_init(&rc->refs, 1); - rc->rc.ref = new_with_len_ref; - rc->rc.unref = new_with_len_unref; - rc->user_destroy = destroy; - rc->user_data = p; - rc->user_length = len; - - slice.refcount = &rc->rc; - slice.data.refcounted.bytes = p; - slice.data.refcounted.length = len; - return slice; -} - -gpr_slice gpr_slice_from_copied_buffer(const char *source, size_t length) { - gpr_slice slice = gpr_slice_malloc(length); - memcpy(GPR_SLICE_START_PTR(slice), source, length); - return slice; -} - -gpr_slice gpr_slice_from_copied_string(const char *source) { - return gpr_slice_from_copied_buffer(source, strlen(source)); -} - -typedef struct { - gpr_slice_refcount base; - gpr_refcount refs; -} malloc_refcount; - -static void malloc_ref(void *p) { - malloc_refcount *r = p; - gpr_ref(&r->refs); -} - -static void malloc_unref(void *p) { - malloc_refcount *r = p; - if (gpr_unref(&r->refs)) { - gpr_free(r); - } -} - -gpr_slice gpr_slice_malloc(size_t length) { - gpr_slice slice; - - if (length > sizeof(slice.data.inlined.bytes)) { - /* Memory layout used by the slice created here: - - +-----------+----------------------------------------------------------+ - | refcount | bytes | - +-----------+----------------------------------------------------------+ - - refcount is a malloc_refcount - bytes is an array of bytes of the requested length - Both parts are placed in the same allocation returned from gpr_malloc */ - malloc_refcount *rc = gpr_malloc(sizeof(malloc_refcount) + length); - - /* Initial refcount on rc is 1 - and it's up to the caller to release - this reference. */ - gpr_ref_init(&rc->refs, 1); - - rc->base.ref = malloc_ref; - rc->base.unref = malloc_unref; - - /* Build up the slice to be returned. */ - /* The slices refcount points back to the allocated block. */ - slice.refcount = &rc->base; - /* The data bytes are placed immediately after the refcount struct */ - slice.data.refcounted.bytes = (uint8_t *)(rc + 1); - /* And the length of the block is set to the requested length */ - slice.data.refcounted.length = length; - } else { - /* small slice: just inline the data */ - slice.refcount = NULL; - slice.data.inlined.length = (uint8_t)length; - } - return slice; -} - -gpr_slice gpr_slice_sub_no_ref(gpr_slice source, size_t begin, size_t end) { - gpr_slice subset; - - GPR_ASSERT(end >= begin); - - if (source.refcount) { - /* Enforce preconditions */ - GPR_ASSERT(source.data.refcounted.length >= end); - - /* Build the result */ - subset.refcount = source.refcount; - /* Point into the source array */ - subset.data.refcounted.bytes = source.data.refcounted.bytes + begin; - subset.data.refcounted.length = end - begin; - } else { - /* Enforce preconditions */ - GPR_ASSERT(source.data.inlined.length >= end); - subset.refcount = NULL; - subset.data.inlined.length = (uint8_t)(end - begin); - memcpy(subset.data.inlined.bytes, source.data.inlined.bytes + begin, - end - begin); - } - return subset; -} - -gpr_slice gpr_slice_sub(gpr_slice source, size_t begin, size_t end) { - gpr_slice subset; - - if (end - begin <= sizeof(subset.data.inlined.bytes)) { - subset.refcount = NULL; - subset.data.inlined.length = (uint8_t)(end - begin); - memcpy(subset.data.inlined.bytes, GPR_SLICE_START_PTR(source) + begin, - end - begin); - } else { - subset = gpr_slice_sub_no_ref(source, begin, end); - /* Bump the refcount */ - subset.refcount->ref(subset.refcount); - } - return subset; -} - -gpr_slice gpr_slice_split_tail(gpr_slice *source, size_t split) { - gpr_slice tail; - - if (source->refcount == NULL) { - /* inlined data, copy it out */ - GPR_ASSERT(source->data.inlined.length >= split); - tail.refcount = NULL; - tail.data.inlined.length = (uint8_t)(source->data.inlined.length - split); - memcpy(tail.data.inlined.bytes, source->data.inlined.bytes + split, - tail.data.inlined.length); - source->data.inlined.length = (uint8_t)split; - } else { - size_t tail_length = source->data.refcounted.length - split; - GPR_ASSERT(source->data.refcounted.length >= split); - if (tail_length < sizeof(tail.data.inlined.bytes)) { - /* Copy out the bytes - it'll be cheaper than refcounting */ - tail.refcount = NULL; - tail.data.inlined.length = (uint8_t)tail_length; - memcpy(tail.data.inlined.bytes, source->data.refcounted.bytes + split, - tail_length); - } else { - /* Build the result */ - tail.refcount = source->refcount; - /* Bump the refcount */ - tail.refcount->ref(tail.refcount); - /* Point into the source array */ - tail.data.refcounted.bytes = source->data.refcounted.bytes + split; - tail.data.refcounted.length = tail_length; - } - source->data.refcounted.length = split; - } - - return tail; -} - -gpr_slice gpr_slice_split_head(gpr_slice *source, size_t split) { - gpr_slice head; - - if (source->refcount == NULL) { - GPR_ASSERT(source->data.inlined.length >= split); - - head.refcount = NULL; - head.data.inlined.length = (uint8_t)split; - memcpy(head.data.inlined.bytes, source->data.inlined.bytes, split); - source->data.inlined.length = - (uint8_t)(source->data.inlined.length - split); - memmove(source->data.inlined.bytes, source->data.inlined.bytes + split, - source->data.inlined.length); - } else if (split < sizeof(head.data.inlined.bytes)) { - GPR_ASSERT(source->data.refcounted.length >= split); - - head.refcount = NULL; - head.data.inlined.length = (uint8_t)split; - memcpy(head.data.inlined.bytes, source->data.refcounted.bytes, split); - source->data.refcounted.bytes += split; - source->data.refcounted.length -= split; - } else { - GPR_ASSERT(source->data.refcounted.length >= split); - - /* Build the result */ - head.refcount = source->refcount; - /* Bump the refcount */ - head.refcount->ref(head.refcount); - /* Point into the source array */ - head.data.refcounted.bytes = source->data.refcounted.bytes; - head.data.refcounted.length = split; - source->data.refcounted.bytes += split; - source->data.refcounted.length -= split; - } - - return head; -} - -int gpr_slice_cmp(gpr_slice a, gpr_slice b) { - int d = (int)(GPR_SLICE_LENGTH(a) - GPR_SLICE_LENGTH(b)); - if (d != 0) return d; - return memcmp(GPR_SLICE_START_PTR(a), GPR_SLICE_START_PTR(b), - GPR_SLICE_LENGTH(a)); -} - -int gpr_slice_str_cmp(gpr_slice a, const char *b) { - size_t b_length = strlen(b); - int d = (int)(GPR_SLICE_LENGTH(a) - b_length); - if (d != 0) return d; - return memcmp(GPR_SLICE_START_PTR(a), b, b_length); -} diff --git a/src/core/lib/support/slice_buffer.c b/src/core/lib/support/slice_buffer.c deleted file mode 100644 index 66f111d767..0000000000 --- a/src/core/lib/support/slice_buffer.c +++ /dev/null @@ -1,282 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -#include - -#include - -#include -#include -#include - -/* grow a buffer; requires GRPC_SLICE_BUFFER_INLINE_ELEMENTS > 1 */ -#define GROW(x) (3 * (x) / 2) - -static void maybe_embiggen(gpr_slice_buffer *sb) { - if (sb->count == sb->capacity) { - sb->capacity = GROW(sb->capacity); - GPR_ASSERT(sb->capacity > sb->count); - if (sb->slices == sb->inlined) { - sb->slices = gpr_malloc(sb->capacity * sizeof(gpr_slice)); - memcpy(sb->slices, sb->inlined, sb->count * sizeof(gpr_slice)); - } else { - sb->slices = gpr_realloc(sb->slices, sb->capacity * sizeof(gpr_slice)); - } - } -} - -void gpr_slice_buffer_init(gpr_slice_buffer *sb) { - sb->count = 0; - sb->length = 0; - sb->capacity = GRPC_SLICE_BUFFER_INLINE_ELEMENTS; - sb->slices = sb->inlined; -} - -void gpr_slice_buffer_destroy(gpr_slice_buffer *sb) { - gpr_slice_buffer_reset_and_unref(sb); - if (sb->slices != sb->inlined) { - gpr_free(sb->slices); - } -} - -uint8_t *gpr_slice_buffer_tiny_add(gpr_slice_buffer *sb, size_t n) { - gpr_slice *back; - uint8_t *out; - - sb->length += n; - - if (sb->count == 0) goto add_new; - back = &sb->slices[sb->count - 1]; - if (back->refcount) goto add_new; - if ((back->data.inlined.length + n) > sizeof(back->data.inlined.bytes)) - goto add_new; - out = back->data.inlined.bytes + back->data.inlined.length; - back->data.inlined.length = (uint8_t)(back->data.inlined.length + n); - return out; - -add_new: - maybe_embiggen(sb); - back = &sb->slices[sb->count]; - sb->count++; - back->refcount = NULL; - back->data.inlined.length = (uint8_t)n; - return back->data.inlined.bytes; -} - -size_t gpr_slice_buffer_add_indexed(gpr_slice_buffer *sb, gpr_slice s) { - size_t out = sb->count; - maybe_embiggen(sb); - sb->slices[out] = s; - sb->length += GPR_SLICE_LENGTH(s); - sb->count = out + 1; - return out; -} - -void gpr_slice_buffer_add(gpr_slice_buffer *sb, gpr_slice s) { - size_t n = sb->count; - /* if both the last slice in the slice buffer and the slice being added - are inlined (that is, that they carry their data inside the slice data - structure), and the back slice is not full, then concatenate directly - into the back slice, preventing many small slices being passed into - writes */ - if (!s.refcount && n) { - gpr_slice *back = &sb->slices[n - 1]; - if (!back->refcount && back->data.inlined.length < GPR_SLICE_INLINED_SIZE) { - if (s.data.inlined.length + back->data.inlined.length <= - GPR_SLICE_INLINED_SIZE) { - memcpy(back->data.inlined.bytes + back->data.inlined.length, - s.data.inlined.bytes, s.data.inlined.length); - back->data.inlined.length = - (uint8_t)(back->data.inlined.length + s.data.inlined.length); - } else { - size_t cp1 = GPR_SLICE_INLINED_SIZE - back->data.inlined.length; - memcpy(back->data.inlined.bytes + back->data.inlined.length, - s.data.inlined.bytes, cp1); - back->data.inlined.length = GPR_SLICE_INLINED_SIZE; - maybe_embiggen(sb); - back = &sb->slices[n]; - sb->count = n + 1; - back->refcount = NULL; - back->data.inlined.length = (uint8_t)(s.data.inlined.length - cp1); - memcpy(back->data.inlined.bytes, s.data.inlined.bytes + cp1, - s.data.inlined.length - cp1); - } - sb->length += s.data.inlined.length; - return; /* early out */ - } - } - gpr_slice_buffer_add_indexed(sb, s); -} - -void gpr_slice_buffer_addn(gpr_slice_buffer *sb, gpr_slice *s, size_t n) { - size_t i; - for (i = 0; i < n; i++) { - gpr_slice_buffer_add(sb, s[i]); - } -} - -void gpr_slice_buffer_pop(gpr_slice_buffer *sb) { - if (sb->count != 0) { - size_t count = --sb->count; - sb->length -= GPR_SLICE_LENGTH(sb->slices[count]); - } -} - -void gpr_slice_buffer_reset_and_unref(gpr_slice_buffer *sb) { - size_t i; - - for (i = 0; i < sb->count; i++) { - gpr_slice_unref(sb->slices[i]); - } - - sb->count = 0; - sb->length = 0; -} - -void gpr_slice_buffer_swap(gpr_slice_buffer *a, gpr_slice_buffer *b) { - GPR_SWAP(size_t, a->count, b->count); - GPR_SWAP(size_t, a->capacity, b->capacity); - GPR_SWAP(size_t, a->length, b->length); - - if (a->slices == a->inlined) { - if (b->slices == b->inlined) { - /* swap contents of inlined buffer */ - gpr_slice temp[GRPC_SLICE_BUFFER_INLINE_ELEMENTS]; - memcpy(temp, a->slices, b->count * sizeof(gpr_slice)); - memcpy(a->slices, b->slices, a->count * sizeof(gpr_slice)); - memcpy(b->slices, temp, b->count * sizeof(gpr_slice)); - } else { - /* a is inlined, b is not - copy a inlined into b, fix pointers */ - a->slices = b->slices; - b->slices = b->inlined; - memcpy(b->slices, a->inlined, b->count * sizeof(gpr_slice)); - } - } else if (b->slices == b->inlined) { - /* b is inlined, a is not - copy b inlined int a, fix pointers */ - b->slices = a->slices; - a->slices = a->inlined; - memcpy(a->slices, b->inlined, a->count * sizeof(gpr_slice)); - } else { - /* no inlining: easy swap */ - GPR_SWAP(gpr_slice *, a->slices, b->slices); - } -} - -void gpr_slice_buffer_move_into(gpr_slice_buffer *src, gpr_slice_buffer *dst) { - /* anything to move? */ - if (src->count == 0) { - return; - } - /* anything in dst? */ - if (dst->count == 0) { - gpr_slice_buffer_swap(src, dst); - return; - } - /* both buffers have data - copy, and reset src */ - gpr_slice_buffer_addn(dst, src->slices, src->count); - src->count = 0; - src->length = 0; -} - -void gpr_slice_buffer_move_first(gpr_slice_buffer *src, size_t n, - gpr_slice_buffer *dst) { - size_t src_idx; - size_t output_len = dst->length + n; - size_t new_input_len = src->length - n; - GPR_ASSERT(src->length >= n); - if (src->length == n) { - gpr_slice_buffer_move_into(src, dst); - return; - } - src_idx = 0; - while (src_idx < src->capacity) { - gpr_slice slice = src->slices[src_idx]; - size_t slice_len = GPR_SLICE_LENGTH(slice); - if (n > slice_len) { - gpr_slice_buffer_add(dst, slice); - n -= slice_len; - src_idx++; - } else if (n == slice_len) { - gpr_slice_buffer_add(dst, slice); - src_idx++; - break; - } else { /* n < slice_len */ - src->slices[src_idx] = gpr_slice_split_tail(&slice, n); - GPR_ASSERT(GPR_SLICE_LENGTH(slice) == n); - GPR_ASSERT(GPR_SLICE_LENGTH(src->slices[src_idx]) == slice_len - n); - gpr_slice_buffer_add(dst, slice); - break; - } - } - GPR_ASSERT(dst->length == output_len); - memmove(src->slices, src->slices + src_idx, - sizeof(gpr_slice) * (src->count - src_idx)); - src->count -= src_idx; - src->length = new_input_len; - GPR_ASSERT(src->count > 0); -} - -void gpr_slice_buffer_trim_end(gpr_slice_buffer *sb, size_t n, - gpr_slice_buffer *garbage) { - GPR_ASSERT(n <= sb->length); - sb->length -= n; - for (;;) { - size_t idx = sb->count - 1; - gpr_slice slice = sb->slices[idx]; - size_t slice_len = GPR_SLICE_LENGTH(slice); - if (slice_len > n) { - sb->slices[idx] = gpr_slice_split_head(&slice, slice_len - n); - gpr_slice_buffer_add_indexed(garbage, slice); - return; - } else if (slice_len == n) { - gpr_slice_buffer_add_indexed(garbage, slice); - sb->count = idx; - return; - } else { - gpr_slice_buffer_add_indexed(garbage, slice); - n -= slice_len; - sb->count = idx; - } - } -} - -gpr_slice gpr_slice_buffer_take_first(gpr_slice_buffer *sb) { - gpr_slice slice; - GPR_ASSERT(sb->count > 0); - slice = sb->slices[0]; - memmove(&sb->slices[0], &sb->slices[1], (sb->count - 1) * sizeof(gpr_slice)); - sb->count--; - sb->length -= GPR_SLICE_LENGTH(slice); - return slice; -} diff --git a/src/core/lib/support/string.c b/src/core/lib/support/string.c index d17fb9da4b..dc243bf0bf 100644 --- a/src/core/lib/support/string.c +++ b/src/core/lib/support/string.c @@ -120,11 +120,6 @@ char *gpr_dump(const char *buf, size_t len, uint32_t flags) { return out.data; } -char *gpr_dump_slice(gpr_slice s, uint32_t flags) { - return gpr_dump((const char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s), - flags); -} - int gpr_parse_bytes_to_uint32(const char *buf, size_t len, uint32_t *result) { uint32_t out = 0; uint32_t new; @@ -239,50 +234,6 @@ char *gpr_strjoin_sep(const char **strs, size_t nstrs, const char *sep, return out; } -/** Finds the initial (\a begin) and final (\a end) offsets of the next - * substring from \a str + \a read_offset until the next \a sep or the end of \a - * str. - * - * Returns 1 and updates \a begin and \a end. Returns 0 otherwise. */ -static int slice_find_separator_offset(const gpr_slice str, const char *sep, - const size_t read_offset, size_t *begin, - size_t *end) { - size_t i; - const uint8_t *str_ptr = GPR_SLICE_START_PTR(str) + read_offset; - const size_t str_len = GPR_SLICE_LENGTH(str) - read_offset; - const size_t sep_len = strlen(sep); - if (str_len < sep_len) { - return 0; - } - - for (i = 0; i <= str_len - sep_len; i++) { - if (memcmp(str_ptr + i, sep, sep_len) == 0) { - *begin = read_offset; - *end = read_offset + i; - return 1; - } - } - return 0; -} - -void gpr_slice_split(gpr_slice str, const char *sep, gpr_slice_buffer *dst) { - const size_t sep_len = strlen(sep); - size_t begin, end; - - GPR_ASSERT(sep_len > 0); - - if (slice_find_separator_offset(str, sep, 0, &begin, &end) != 0) { - do { - gpr_slice_buffer_add_indexed(dst, gpr_slice_sub(str, begin, end)); - } while (slice_find_separator_offset(str, sep, end + sep_len, &begin, - &end) != 0); - gpr_slice_buffer_add_indexed( - dst, gpr_slice_sub(str, end + sep_len, GPR_SLICE_LENGTH(str))); - } else { /* no sep found, add whole input */ - gpr_slice_buffer_add_indexed(dst, gpr_slice_ref(str)); - } -} - void gpr_strvec_init(gpr_strvec *sv) { memset(sv, 0, sizeof(*sv)); } void gpr_strvec_destroy(gpr_strvec *sv) { diff --git a/src/core/lib/support/string.h b/src/core/lib/support/string.h index 9a94e9471c..2cd908aad6 100644 --- a/src/core/lib/support/string.h +++ b/src/core/lib/support/string.h @@ -54,9 +54,6 @@ extern "C" { Result should be freed with gpr_free() */ char *gpr_dump(const char *buf, size_t len, uint32_t flags); -/* Calls gpr_dump on a slice. */ -char *gpr_dump_slice(gpr_slice slice, uint32_t flags); - /* Parses an array of bytes into an integer (base 10). Returns 1 on success, 0 on failure. */ int gpr_parse_bytes_to_uint32(const char *data, size_t length, @@ -98,10 +95,6 @@ char *gpr_strjoin(const char **strs, size_t nstrs, size_t *total_length); char *gpr_strjoin_sep(const char **strs, size_t nstrs, const char *sep, size_t *total_length); -/** Split \a str by the separator \a sep. Results are stored in \a dst, which - * should be a properly initialized instance. */ -void gpr_slice_split(gpr_slice str, const char *sep, gpr_slice_buffer *dst); - /* A vector of strings... for building up a final string one piece at a time */ typedef struct { char **strs; diff --git a/src/core/lib/surface/byte_buffer.c b/src/core/lib/surface/byte_buffer.c index 054a6e6c58..5ae7e3264b 100644 --- a/src/core/lib/surface/byte_buffer.c +++ b/src/core/lib/surface/byte_buffer.c @@ -35,22 +35,22 @@ #include #include -grpc_byte_buffer *grpc_raw_byte_buffer_create(gpr_slice *slices, +grpc_byte_buffer *grpc_raw_byte_buffer_create(grpc_slice *slices, size_t nslices) { return grpc_raw_compressed_byte_buffer_create(slices, nslices, GRPC_COMPRESS_NONE); } grpc_byte_buffer *grpc_raw_compressed_byte_buffer_create( - gpr_slice *slices, size_t nslices, grpc_compression_algorithm compression) { + grpc_slice *slices, size_t nslices, grpc_compression_algorithm compression) { size_t i; grpc_byte_buffer *bb = gpr_malloc(sizeof(grpc_byte_buffer)); bb->type = GRPC_BB_RAW; bb->data.raw.compression = compression; - gpr_slice_buffer_init(&bb->data.raw.slice_buffer); + grpc_slice_buffer_init(&bb->data.raw.slice_buffer); for (i = 0; i < nslices; i++) { - gpr_slice_ref(slices[i]); - gpr_slice_buffer_add(&bb->data.raw.slice_buffer, slices[i]); + grpc_slice_ref(slices[i]); + grpc_slice_buffer_add(&bb->data.raw.slice_buffer, slices[i]); } return bb; } @@ -58,13 +58,13 @@ grpc_byte_buffer *grpc_raw_compressed_byte_buffer_create( grpc_byte_buffer *grpc_raw_byte_buffer_from_reader( grpc_byte_buffer_reader *reader) { grpc_byte_buffer *bb = gpr_malloc(sizeof(grpc_byte_buffer)); - gpr_slice slice; + grpc_slice slice; bb->type = GRPC_BB_RAW; bb->data.raw.compression = GRPC_COMPRESS_NONE; - gpr_slice_buffer_init(&bb->data.raw.slice_buffer); + grpc_slice_buffer_init(&bb->data.raw.slice_buffer); while (grpc_byte_buffer_reader_next(reader, &slice)) { - gpr_slice_buffer_add(&bb->data.raw.slice_buffer, slice); + grpc_slice_buffer_add(&bb->data.raw.slice_buffer, slice); } return bb; } @@ -83,7 +83,7 @@ void grpc_byte_buffer_destroy(grpc_byte_buffer *bb) { if (!bb) return; switch (bb->type) { case GRPC_BB_RAW: - gpr_slice_buffer_destroy(&bb->data.raw.slice_buffer); + grpc_slice_buffer_destroy(&bb->data.raw.slice_buffer); break; } gpr_free(bb); diff --git a/src/core/lib/surface/byte_buffer_reader.c b/src/core/lib/surface/byte_buffer_reader.c index 310bacb2c9..9455709b4b 100644 --- a/src/core/lib/surface/byte_buffer_reader.c +++ b/src/core/lib/surface/byte_buffer_reader.c @@ -56,11 +56,11 @@ static int is_compressed(grpc_byte_buffer *buffer) { int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader *reader, grpc_byte_buffer *buffer) { - gpr_slice_buffer decompressed_slices_buffer; + grpc_slice_buffer decompressed_slices_buffer; reader->buffer_in = buffer; switch (reader->buffer_in->type) { case GRPC_BB_RAW: - gpr_slice_buffer_init(&decompressed_slices_buffer); + grpc_slice_buffer_init(&decompressed_slices_buffer); if (is_compressed(reader->buffer_in)) { if (grpc_msg_decompress(reader->buffer_in->data.raw.compression, &reader->buffer_in->data.raw.slice_buffer, @@ -76,7 +76,7 @@ int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader *reader, grpc_raw_byte_buffer_create(decompressed_slices_buffer.slices, decompressed_slices_buffer.count); } - gpr_slice_buffer_destroy(&decompressed_slices_buffer); + grpc_slice_buffer_destroy(&decompressed_slices_buffer); } else { /* not compressed, use the input buffer as output */ reader->buffer_out = reader->buffer_in; } @@ -98,13 +98,13 @@ void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader) { } int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader, - gpr_slice *slice) { + grpc_slice *slice) { switch (reader->buffer_in->type) { case GRPC_BB_RAW: { - gpr_slice_buffer *slice_buffer; + grpc_slice_buffer *slice_buffer; slice_buffer = &reader->buffer_out->data.raw.slice_buffer; if (reader->current.index < slice_buffer->count) { - *slice = gpr_slice_ref(slice_buffer->slices[reader->current.index]); + *slice = grpc_slice_ref(slice_buffer->slices[reader->current.index]); reader->current.index += 1; return 1; } @@ -114,18 +114,18 @@ int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader, return 0; } -gpr_slice grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader *reader) { - gpr_slice in_slice; +grpc_slice grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader *reader) { + grpc_slice in_slice; size_t bytes_read = 0; const size_t input_size = grpc_byte_buffer_length(reader->buffer_out); - gpr_slice out_slice = gpr_slice_malloc(input_size); + grpc_slice out_slice = grpc_slice_malloc(input_size); uint8_t *const outbuf = GPR_SLICE_START_PTR(out_slice); /* just an alias */ while (grpc_byte_buffer_reader_next(reader, &in_slice) != 0) { const size_t slice_length = GPR_SLICE_LENGTH(in_slice); memcpy(&(outbuf[bytes_read]), GPR_SLICE_START_PTR(in_slice), slice_length); bytes_read += slice_length; - gpr_slice_unref(in_slice); + grpc_slice_unref(in_slice); GPR_ASSERT(bytes_read <= input_size); } return out_slice; diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c index ee94f274f8..06dc5f5942 100644 --- a/src/core/lib/surface/call.c +++ b/src/core/lib/surface/call.c @@ -183,7 +183,7 @@ struct grpc_call { grpc_slice_buffer_stream sending_stream; grpc_byte_stream *receiving_stream; grpc_byte_buffer **receiving_buffer; - gpr_slice receiving_slice; + grpc_slice receiving_slice; grpc_closure receiving_slice_ready; grpc_closure receiving_stream_ready; grpc_closure receiving_initial_metadata_ready; @@ -492,8 +492,8 @@ static void destroy_encodings_accepted_by_peer(void *p) { return; } static void set_encodings_accepted_by_peer(grpc_call *call, grpc_mdelem *mdel) { size_t i; grpc_compression_algorithm algorithm; - gpr_slice_buffer accept_encoding_parts; - gpr_slice accept_encoding_slice; + grpc_slice_buffer accept_encoding_parts; + grpc_slice accept_encoding_slice; void *accepted_user_data; accepted_user_data = @@ -505,15 +505,15 @@ static void set_encodings_accepted_by_peer(grpc_call *call, grpc_mdelem *mdel) { } accept_encoding_slice = mdel->value->slice; - gpr_slice_buffer_init(&accept_encoding_parts); - gpr_slice_split(accept_encoding_slice, ",", &accept_encoding_parts); + grpc_slice_buffer_init(&accept_encoding_parts); + grpc_slice_split(accept_encoding_slice, ",", &accept_encoding_parts); /* No need to zero call->encodings_accepted_by_peer: grpc_call_create already * zeroes the whole grpc_call */ /* Always support no compression */ GPR_BITSET(&call->encodings_accepted_by_peer, GRPC_COMPRESS_NONE); for (i = 0; i < accept_encoding_parts.count; i++) { - const gpr_slice *accept_encoding_entry_slice = + const grpc_slice *accept_encoding_entry_slice = &accept_encoding_parts.slices[i]; if (grpc_compression_algorithm_parse( (const char *)GPR_SLICE_START_PTR(*accept_encoding_entry_slice), @@ -529,7 +529,7 @@ static void set_encodings_accepted_by_peer(grpc_call *call, grpc_mdelem *mdel) { } } - gpr_slice_buffer_destroy(&accept_encoding_parts); + grpc_slice_buffer_destroy(&accept_encoding_parts); grpc_mdelem_set_user_data( mdel, destroy_encodings_accepted_by_peer, @@ -550,7 +550,7 @@ static void get_final_details(grpc_call *call, char **out_details, for (i = 0; i < STATUS_SOURCE_COUNT; i++) { if (call->status[i].is_set) { if (call->status[i].details) { - gpr_slice details = call->status[i].details->slice; + grpc_slice details = call->status[i].details->slice; size_t len = GPR_SLICE_LENGTH(details); if (len + 1 > *out_details_capacity) { *out_details_capacity = @@ -1084,7 +1084,7 @@ static void continue_receiving_slices(grpc_exec_ctx *exec_ctx, if (grpc_byte_stream_next(exec_ctx, call->receiving_stream, &call->receiving_slice, remaining, &call->receiving_slice_ready)) { - gpr_slice_buffer_add(&(*call->receiving_buffer)->data.raw.slice_buffer, + grpc_slice_buffer_add(&(*call->receiving_buffer)->data.raw.slice_buffer, call->receiving_slice); } else { return; @@ -1098,7 +1098,7 @@ static void receiving_slice_ready(grpc_exec_ctx *exec_ctx, void *bctlp, grpc_call *call = bctl->call; if (error == GRPC_ERROR_NONE) { - gpr_slice_buffer_add(&(*call->receiving_buffer)->data.raw.slice_buffer, + grpc_slice_buffer_add(&(*call->receiving_buffer)->data.raw.slice_buffer, call->receiving_slice); continue_receiving_slices(exec_ctx, bctl); } else { diff --git a/src/core/lib/surface/server.c b/src/core/lib/surface/server.c index be16162e7f..2045e59e53 100644 --- a/src/core/lib/surface/server.c +++ b/src/core/lib/surface/server.c @@ -264,13 +264,13 @@ static void channel_broadcaster_init(grpc_server *s, channel_broadcaster *cb) { struct shutdown_cleanup_args { grpc_closure closure; - gpr_slice slice; + grpc_slice slice; }; static void shutdown_cleanup(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { struct shutdown_cleanup_args *a = arg; - gpr_slice_unref(a->slice); + grpc_slice_unref(a->slice); gpr_free(a); } @@ -283,7 +283,7 @@ static void send_shutdown(grpc_exec_ctx *exec_ctx, grpc_channel *channel, op->send_goaway = send_goaway; op->set_accept_stream = true; - sc->slice = gpr_slice_from_copied_string("Server shutdown"); + sc->slice = grpc_slice_from_copied_string("Server shutdown"); op->goaway_message = &sc->slice; op->goaway_status = GRPC_STATUS_OK; op->disconnect_with_error = send_disconnect; @@ -459,7 +459,7 @@ static void destroy_channel(grpc_exec_ctx *exec_ctx, channel_data *chand, } static void cpstr(char **dest, size_t *capacity, grpc_mdstr *value) { - gpr_slice slice = value->slice; + grpc_slice slice = value->slice; size_t len = GPR_SLICE_LENGTH(slice); if (len + 1 > *capacity) { diff --git a/src/core/lib/transport/byte_stream.c b/src/core/lib/transport/byte_stream.c index 2f6c75cb6a..2f1d7b7c60 100644 --- a/src/core/lib/transport/byte_stream.c +++ b/src/core/lib/transport/byte_stream.c @@ -38,7 +38,7 @@ #include int grpc_byte_stream_next(grpc_exec_ctx *exec_ctx, - grpc_byte_stream *byte_stream, gpr_slice *slice, + grpc_byte_stream *byte_stream, grpc_slice *slice, size_t max_size_hint, grpc_closure *on_complete) { return byte_stream->next(exec_ctx, byte_stream, slice, max_size_hint, on_complete); @@ -53,11 +53,11 @@ void grpc_byte_stream_destroy(grpc_exec_ctx *exec_ctx, static int slice_buffer_stream_next(grpc_exec_ctx *exec_ctx, grpc_byte_stream *byte_stream, - gpr_slice *slice, size_t max_size_hint, + grpc_slice *slice, size_t max_size_hint, grpc_closure *on_complete) { grpc_slice_buffer_stream *stream = (grpc_slice_buffer_stream *)byte_stream; GPR_ASSERT(stream->cursor < stream->backing_buffer->count); - *slice = gpr_slice_ref(stream->backing_buffer->slices[stream->cursor]); + *slice = grpc_slice_ref(stream->backing_buffer->slices[stream->cursor]); stream->cursor++; return 1; } @@ -66,7 +66,7 @@ static void slice_buffer_stream_destroy(grpc_exec_ctx *exec_ctx, grpc_byte_stream *byte_stream) {} void grpc_slice_buffer_stream_init(grpc_slice_buffer_stream *stream, - gpr_slice_buffer *slice_buffer, + grpc_slice_buffer *slice_buffer, uint32_t flags) { GPR_ASSERT(slice_buffer->length <= UINT32_MAX); stream->base.length = (uint32_t)slice_buffer->length; diff --git a/src/core/lib/transport/byte_stream.h b/src/core/lib/transport/byte_stream.h index e64dce6283..8139782701 100644 --- a/src/core/lib/transport/byte_stream.h +++ b/src/core/lib/transport/byte_stream.h @@ -50,7 +50,7 @@ struct grpc_byte_stream { uint32_t length; uint32_t flags; int (*next)(grpc_exec_ctx *exec_ctx, grpc_byte_stream *byte_stream, - gpr_slice *slice, size_t max_size_hint, + grpc_slice *slice, size_t max_size_hint, grpc_closure *on_complete); void (*destroy)(grpc_exec_ctx *exec_ctx, grpc_byte_stream *byte_stream); }; @@ -65,7 +65,7 @@ struct grpc_byte_stream { * once a slice is returned into *slice, it is owned by the caller. */ int grpc_byte_stream_next(grpc_exec_ctx *exec_ctx, - grpc_byte_stream *byte_stream, gpr_slice *slice, + grpc_byte_stream *byte_stream, grpc_slice *slice, size_t max_size_hint, grpc_closure *on_complete); void grpc_byte_stream_destroy(grpc_exec_ctx *exec_ctx, @@ -74,12 +74,12 @@ void grpc_byte_stream_destroy(grpc_exec_ctx *exec_ctx, /* grpc_byte_stream that wraps a slice buffer */ typedef struct grpc_slice_buffer_stream { grpc_byte_stream base; - gpr_slice_buffer *backing_buffer; + grpc_slice_buffer *backing_buffer; size_t cursor; } grpc_slice_buffer_stream; void grpc_slice_buffer_stream_init(grpc_slice_buffer_stream *stream, - gpr_slice_buffer *slice_buffer, + grpc_slice_buffer *slice_buffer, uint32_t flags); #endif /* GRPC_CORE_LIB_TRANSPORT_BYTE_STREAM_H */ diff --git a/src/core/lib/transport/metadata.c b/src/core/lib/transport/metadata.c index 4b40c275ad..b8364c4cb7 100644 --- a/src/core/lib/transport/metadata.c +++ b/src/core/lib/transport/metadata.c @@ -51,7 +51,7 @@ #include "src/core/lib/support/string.h" #include "src/core/lib/transport/static_metadata.h" -gpr_slice (*grpc_chttp2_base64_encode_and_huffman_compress)(gpr_slice input); +grpc_slice (*grpc_chttp2_base64_encode_and_huffman_compress)(grpc_slice input); /* There are two kinds of mdelem and mdstr instances. * Static instances are declared in static_metadata.{h,c} and @@ -85,16 +85,16 @@ typedef void (*destroy_user_data_func)(void *user_data); /* Shadow structure for grpc_mdstr for non-static values */ typedef struct internal_string { /* must be byte compatible with grpc_mdstr */ - gpr_slice slice; + grpc_slice slice; uint32_t hash; /* private only data */ gpr_atm refcnt; uint8_t has_base64_and_huffman_encoded; - gpr_slice_refcount refcount; + grpc_slice_refcount refcount; - gpr_slice base64_and_huffman; + grpc_slice base64_and_huffman; gpr_atm size_in_decoder_table; @@ -174,7 +174,7 @@ void grpc_mdctx_global_init(void) { grpc_mdstr *elem = &grpc_static_mdstr_table[i]; const char *str = grpc_static_metadata_strings[i]; uint32_t hash = gpr_murmur_hash3(str, strlen(str), g_hash_seed); - *(gpr_slice *)&elem->slice = gpr_slice_from_static_string(str); + *(grpc_slice *)&elem->slice = grpc_slice_from_static_string(str); *(uint32_t *)&elem->hash = hash; for (j = 0;; j++) { size_t idx = (hash + j) % GPR_ARRAY_SIZE(g_static_strtab); @@ -321,7 +321,7 @@ static void internal_destroy_string(strtab_shard *shard, internal_string *is) { internal_string *cur; GPR_TIMER_BEGIN("internal_destroy_string", 0); if (is->has_base64_and_huffman_encoded) { - gpr_slice_unref(is->base64_and_huffman); + grpc_slice_unref(is->base64_and_huffman); } for (prev_next = &shard->strs[TABLE_IDX(is->hash, LOG2_STRTAB_SHARD_COUNT, shard->capacity)], @@ -350,10 +350,10 @@ grpc_mdstr *grpc_mdstr_from_string(const char *str) { return grpc_mdstr_from_buffer((const uint8_t *)str, strlen(str)); } -grpc_mdstr *grpc_mdstr_from_slice(gpr_slice slice) { +grpc_mdstr *grpc_mdstr_from_slice(grpc_slice slice) { grpc_mdstr *result = grpc_mdstr_from_buffer(GPR_SLICE_START_PTR(slice), GPR_SLICE_LENGTH(slice)); - gpr_slice_unref(slice); + grpc_slice_unref(slice); return result; } @@ -589,7 +589,7 @@ grpc_mdelem *grpc_mdelem_from_strings(const char *key, const char *value) { grpc_mdstr_from_string(value)); } -grpc_mdelem *grpc_mdelem_from_slices(gpr_slice key, gpr_slice value) { +grpc_mdelem *grpc_mdelem_from_slices(grpc_slice key, grpc_slice value) { return grpc_mdelem_from_metadata_strings(grpc_mdstr_from_slice(key), grpc_mdstr_from_slice(value)); } @@ -737,9 +737,9 @@ void grpc_mdelem_set_user_data(grpc_mdelem *md, void (*destroy_func)(void *), gpr_mu_unlock(&im->mu_user_data); } -gpr_slice grpc_mdstr_as_base64_encoded_and_huffman_compressed(grpc_mdstr *gs) { +grpc_slice grpc_mdstr_as_base64_encoded_and_huffman_compressed(grpc_mdstr *gs) { internal_string *s = (internal_string *)gs; - gpr_slice slice; + grpc_slice slice; strtab_shard *shard = &g_strtab_shard[SHARD_IDX(s->hash, LOG2_STRTAB_SHARD_COUNT)]; gpr_mu_lock(&shard->mu); diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index 71eff0acf2..5875ffb323 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -77,7 +77,7 @@ typedef struct grpc_mdelem grpc_mdelem; /* if changing this, make identical changes in internal_string in metadata.c */ struct grpc_mdstr { - const gpr_slice slice; + const grpc_slice slice; const uint32_t hash; /* there is a private part to this in metadata.c */ }; @@ -96,12 +96,12 @@ void grpc_test_only_set_metadata_hash_seed(uint32_t seed); clients may have handy */ grpc_mdstr *grpc_mdstr_from_string(const char *str); /* Unrefs the slice. */ -grpc_mdstr *grpc_mdstr_from_slice(gpr_slice slice); +grpc_mdstr *grpc_mdstr_from_slice(grpc_slice slice); grpc_mdstr *grpc_mdstr_from_buffer(const uint8_t *str, size_t length); /* Returns a borrowed slice from the mdstr with its contents base64 encoded and huffman compressed */ -gpr_slice grpc_mdstr_as_base64_encoded_and_huffman_compressed(grpc_mdstr *str); +grpc_slice grpc_mdstr_as_base64_encoded_and_huffman_compressed(grpc_mdstr *str); /* Constructors for grpc_mdelem instances; take a variety of data types that clients may have handy */ @@ -109,7 +109,7 @@ grpc_mdelem *grpc_mdelem_from_metadata_strings(grpc_mdstr *key, grpc_mdstr *value); grpc_mdelem *grpc_mdelem_from_strings(const char *key, const char *value); /* Unrefs the slices. */ -grpc_mdelem *grpc_mdelem_from_slices(gpr_slice key, gpr_slice value); +grpc_mdelem *grpc_mdelem_from_slices(grpc_slice key, grpc_slice value); grpc_mdelem *grpc_mdelem_from_string_and_buffer(const char *key, const uint8_t *value, size_t value_length); @@ -165,8 +165,8 @@ void grpc_mdctx_global_init(void); void grpc_mdctx_global_shutdown(void); /* Implementation provided by chttp2_transport */ -extern gpr_slice (*grpc_chttp2_base64_encode_and_huffman_compress)( - gpr_slice input); +extern grpc_slice (*grpc_chttp2_base64_encode_and_huffman_compress)( + grpc_slice input); #ifdef __cplusplus } diff --git a/src/core/lib/transport/transport.c b/src/core/lib/transport/transport.c index 75aec7a5b4..3ca85b12e9 100644 --- a/src/core/lib/transport/transport.c +++ b/src/core/lib/transport/transport.c @@ -207,11 +207,11 @@ void grpc_transport_stream_op_add_cancellation(grpc_transport_stream_op *op, void grpc_transport_stream_op_add_cancellation_with_message( grpc_transport_stream_op *op, grpc_status_code status, - gpr_slice *optional_message) { + grpc_slice *optional_message) { GPR_ASSERT(status != GRPC_STATUS_OK); if (op->cancel_error != GRPC_ERROR_NONE) { if (optional_message) { - gpr_slice_unref(*optional_message); + grpc_slice_unref(*optional_message); } return; } @@ -221,7 +221,7 @@ void grpc_transport_stream_op_add_cancellation_with_message( error = grpc_error_set_str(GRPC_ERROR_CREATE(msg), GRPC_ERROR_STR_GRPC_MESSAGE, msg); gpr_free(msg); - gpr_slice_unref(*optional_message); + grpc_slice_unref(*optional_message); } else { error = GRPC_ERROR_CREATE("Call cancelled"); } @@ -231,12 +231,12 @@ void grpc_transport_stream_op_add_cancellation_with_message( void grpc_transport_stream_op_add_close(grpc_transport_stream_op *op, grpc_status_code status, - gpr_slice *optional_message) { + grpc_slice *optional_message) { GPR_ASSERT(status != GRPC_STATUS_OK); if (op->cancel_error != GRPC_ERROR_NONE || op->close_error != GRPC_ERROR_NONE) { if (optional_message) { - gpr_slice_unref(*optional_message); + grpc_slice_unref(*optional_message); } return; } @@ -246,7 +246,7 @@ void grpc_transport_stream_op_add_close(grpc_transport_stream_op *op, error = grpc_error_set_str(GRPC_ERROR_CREATE(msg), GRPC_ERROR_STR_GRPC_MESSAGE, msg); gpr_free(msg); - gpr_slice_unref(*optional_message); + grpc_slice_unref(*optional_message); } else { error = GRPC_ERROR_CREATE("Call force closed"); } diff --git a/src/core/lib/transport/transport.h b/src/core/lib/transport/transport.h index 50253ebad1..8916b28b72 100644 --- a/src/core/lib/transport/transport.h +++ b/src/core/lib/transport/transport.h @@ -181,7 +181,7 @@ typedef struct grpc_transport_op { bool send_goaway; /** what should the goaway contain? */ grpc_status_code goaway_status; - gpr_slice *goaway_message; + grpc_slice *goaway_message; /** set the callback for accepting new streams; this is a permanent callback, unlike the other one-shot closures. If true, the callback is set to set_accept_stream_fn, with its @@ -249,11 +249,11 @@ void grpc_transport_stream_op_add_cancellation(grpc_transport_stream_op *op, void grpc_transport_stream_op_add_cancellation_with_message( grpc_transport_stream_op *op, grpc_status_code status, - gpr_slice *optional_message); + grpc_slice *optional_message); void grpc_transport_stream_op_add_close(grpc_transport_stream_op *op, grpc_status_code status, - gpr_slice *optional_message); + grpc_slice *optional_message); char *grpc_transport_stream_op_string(grpc_transport_stream_op *op); char *grpc_transport_op_string(grpc_transport_op *op); @@ -283,7 +283,7 @@ void grpc_transport_ping(grpc_transport *transport, grpc_closure *cb); /* Advise peer of pending connection termination. */ void grpc_transport_goaway(grpc_transport *transport, grpc_status_code status, - gpr_slice debug_data); + grpc_slice debug_data); /* Close a transport. Aborts all open streams. */ void grpc_transport_close(grpc_transport *transport); diff --git a/src/cpp/common/core_codegen.cc b/src/cpp/common/core_codegen.cc index ce02202976..ad874bb369 100644 --- a/src/cpp/common/core_codegen.cc +++ b/src/cpp/common/core_codegen.cc @@ -102,31 +102,31 @@ void CoreCodegen::grpc_byte_buffer_reader_destroy( } int CoreCodegen::grpc_byte_buffer_reader_next(grpc_byte_buffer_reader* reader, - gpr_slice* slice) { + grpc_slice* slice) { return ::grpc_byte_buffer_reader_next(reader, slice); } -grpc_byte_buffer* CoreCodegen::grpc_raw_byte_buffer_create(gpr_slice* slice, +grpc_byte_buffer* CoreCodegen::grpc_raw_byte_buffer_create(grpc_slice* slice, size_t nslices) { return ::grpc_raw_byte_buffer_create(slice, nslices); } -gpr_slice CoreCodegen::gpr_slice_malloc(size_t length) { - return ::gpr_slice_malloc(length); +grpc_slice CoreCodegen::grpc_slice_malloc(size_t length) { + return ::grpc_slice_malloc(length); } -void CoreCodegen::gpr_slice_unref(gpr_slice slice) { ::gpr_slice_unref(slice); } +void CoreCodegen::grpc_slice_unref(grpc_slice slice) { ::grpc_slice_unref(slice); } -gpr_slice CoreCodegen::gpr_slice_split_tail(gpr_slice* s, size_t split) { - return ::gpr_slice_split_tail(s, split); +grpc_slice CoreCodegen::grpc_slice_split_tail(grpc_slice* s, size_t split) { + return ::grpc_slice_split_tail(s, split); } -void CoreCodegen::gpr_slice_buffer_add(gpr_slice_buffer* sb, gpr_slice slice) { - ::gpr_slice_buffer_add(sb, slice); +void CoreCodegen::grpc_slice_buffer_add(grpc_slice_buffer* sb, grpc_slice slice) { + ::grpc_slice_buffer_add(sb, slice); } -void CoreCodegen::gpr_slice_buffer_pop(gpr_slice_buffer* sb) { - ::gpr_slice_buffer_pop(sb); +void CoreCodegen::grpc_slice_buffer_pop(grpc_slice_buffer* sb) { + ::grpc_slice_buffer_pop(sb); } void CoreCodegen::grpc_metadata_array_init(grpc_metadata_array* array) { diff --git a/src/cpp/util/byte_buffer_cc.cc b/src/cpp/util/byte_buffer_cc.cc index 91ed66b766..cbe0aad26c 100644 --- a/src/cpp/util/byte_buffer_cc.cc +++ b/src/cpp/util/byte_buffer_cc.cc @@ -38,18 +38,18 @@ namespace grpc { ByteBuffer::ByteBuffer(const Slice* slices, size_t nslices) { // The following assertions check that the representation of a grpc::Slice is - // identical to that of a gpr_slice: it has a gpr_slice field, and nothing + // identical to that of a grpc_slice: it has a grpc_slice field, and nothing // else. - static_assert(std::is_same::value, - "Slice must have same representation as gpr_slice"); - static_assert(sizeof(Slice) == sizeof(gpr_slice), - "Slice must have same representation as gpr_slice"); + static_assert(std::is_same::value, + "Slice must have same representation as grpc_slice"); + static_assert(sizeof(Slice) == sizeof(grpc_slice), + "Slice must have same representation as grpc_slice"); // The const_cast is legal if grpc_raw_byte_buffer_create() does no more // than its advertised side effect of increasing the reference count of the // slices it processes, and such an increase does not affect the semantics // seen by the caller of this constructor. buffer_ = grpc_raw_byte_buffer_create( - reinterpret_cast(const_cast(slices)), nslices); + reinterpret_cast(const_cast(slices)), nslices); } ByteBuffer::~ByteBuffer() { @@ -75,7 +75,7 @@ Status ByteBuffer::Dump(std::vector* slices) const { return Status(StatusCode::INTERNAL, "Couldn't initialize byte buffer reader"); } - gpr_slice s; + grpc_slice s; while (grpc_byte_buffer_reader_next(&reader, &s)) { slices->push_back(Slice(s, Slice::STEAL_REF)); } diff --git a/src/cpp/util/slice_cc.cc b/src/cpp/util/slice_cc.cc index 7e88423b6c..c05f1cf124 100644 --- a/src/cpp/util/slice_cc.cc +++ b/src/cpp/util/slice_cc.cc @@ -37,12 +37,12 @@ namespace grpc { Slice::Slice() : slice_(gpr_empty_slice()) {} -Slice::~Slice() { gpr_slice_unref(slice_); } +Slice::~Slice() { grpc_slice_unref(slice_); } -Slice::Slice(gpr_slice slice, AddRef) : slice_(gpr_slice_ref(slice)) {} +Slice::Slice(grpc_slice slice, AddRef) : slice_(grpc_slice_ref(slice)) {} -Slice::Slice(gpr_slice slice, StealRef) : slice_(slice) {} +Slice::Slice(grpc_slice slice, StealRef) : slice_(slice) {} -Slice::Slice(const Slice& other) : slice_(gpr_slice_ref(other.slice_)) {} +Slice::Slice(const Slice& other) : slice_(grpc_slice_ref(other.slice_)) {} } // namespace grpc diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index 9a5d7869d3..0f725f5e23 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -59,9 +59,9 @@ #endif grpc_byte_buffer *string_to_byte_buffer(const char *buffer, size_t len) { - gpr_slice slice = gpr_slice_from_copied_buffer(buffer, len); + grpc_slice slice = grpc_slice_from_copied_buffer(buffer, len); grpc_byte_buffer *bb = grpc_raw_byte_buffer_create(&slice, 1); - gpr_slice_unref(slice); + grpc_slice_unref(slice); return bb; } @@ -282,7 +282,7 @@ GPR_EXPORT intptr_t GPR_CALLTYPE grpcsharp_batch_context_recv_message_length( GPR_EXPORT void GPR_CALLTYPE grpcsharp_batch_context_recv_message_to_buffer( const grpcsharp_batch_context *ctx, char *buffer, size_t buffer_len) { grpc_byte_buffer_reader reader; - gpr_slice slice; + grpc_slice slice; size_t offset = 0; GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, ctx->recv_message)); @@ -293,7 +293,7 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_batch_context_recv_message_to_buffer( memcpy(buffer + offset, GPR_SLICE_START_PTR(slice), GPR_SLICE_LENGTH(slice)); offset += len; - gpr_slice_unref(slice); + grpc_slice_unref(slice); } grpc_byte_buffer_reader_destroy(&reader); diff --git a/src/node/ext/byte_buffer.cc b/src/node/ext/byte_buffer.cc index a3f678f32c..76aa611a5d 100644 --- a/src/node/ext/byte_buffer.cc +++ b/src/node/ext/byte_buffer.cc @@ -56,10 +56,10 @@ grpc_byte_buffer *BufferToByteBuffer(Local buffer) { Nan::HandleScope scope; int length = ::node::Buffer::Length(buffer); char *data = ::node::Buffer::Data(buffer); - gpr_slice slice = gpr_slice_malloc(length); + grpc_slice slice = grpc_slice_malloc(length); memcpy(GPR_SLICE_START_PTR(slice), data, length); grpc_byte_buffer *byte_buffer(grpc_raw_byte_buffer_create(&slice, 1)); - gpr_slice_unref(slice); + grpc_slice_unref(slice); return byte_buffer; } @@ -77,11 +77,11 @@ Local ByteBufferToBuffer(grpc_byte_buffer *buffer) { Nan::ThrowError("Error initializing byte buffer reader."); return scope.Escape(Nan::Undefined()); } - gpr_slice slice = grpc_byte_buffer_reader_readall(&reader); + grpc_slice slice = grpc_byte_buffer_reader_readall(&reader); size_t length = GPR_SLICE_LENGTH(slice); char *result = new char[length]; memcpy(result, GPR_SLICE_START_PTR(slice), length); - gpr_slice_unref(slice); + grpc_slice_unref(slice); return scope.Escape(MakeFastBuffer( Nan::NewBuffer(result, length, delete_buffer, NULL).ToLocalChecked())); } diff --git a/src/objective-c/GRPCClient/private/NSData+GRPC.m b/src/objective-c/GRPCClient/private/NSData+GRPC.m index 98337799e9..45d23d8651 100644 --- a/src/objective-c/GRPCClient/private/NSData+GRPC.m +++ b/src/objective-c/GRPCClient/private/NSData+GRPC.m @@ -53,22 +53,22 @@ static void MallocAndCopyByteBufferToCharArray(grpc_byte_buffer *buffer, } // The slice contains uncompressed data even if compressed data was received // because the reader takes care of automatically decompressing it - gpr_slice slice = grpc_byte_buffer_reader_readall(&reader); + grpc_slice slice = grpc_byte_buffer_reader_readall(&reader); size_t uncompressed_length = GPR_SLICE_LENGTH(slice); char *result = malloc(uncompressed_length); if (result) { memcpy(result, GPR_SLICE_START_PTR(slice), uncompressed_length); } - gpr_slice_unref(slice); + grpc_slice_unref(slice); *array = result; *length = uncompressed_length; } static grpc_byte_buffer *CopyCharArrayToNewByteBuffer(const char *array, size_t length) { - gpr_slice slice = gpr_slice_from_copied_buffer(array, length); + grpc_slice slice = grpc_slice_from_copied_buffer(array, length); grpc_byte_buffer *buffer = grpc_raw_byte_buffer_create(&slice, 1); - gpr_slice_unref(slice); + grpc_slice_unref(slice); return buffer; } @@ -97,9 +97,9 @@ static grpc_byte_buffer *CopyCharArrayToNewByteBuffer(const char *array, // appending of byte arrays by not using internally a single contiguous memory // block for representation. // The following implementation is thus not optimal, sometimes requiring two - // copies (one by self.bytes and another by gpr_slice_from_copied_buffer). + // copies (one by self.bytes and another by grpc_slice_from_copied_buffer). // If it turns out to be an issue, we can use enumerateByteRangesUsingblock: - // to create an array of gpr_slice objects to pass to + // to create an array of grpc_slice objects to pass to // grpc_raw_byte_buffer_create. // That would make it do exactly one copy, always. return CopyCharArrayToNewByteBuffer((const char *)self.bytes, diff --git a/src/php/ext/grpc/byte_buffer.c b/src/php/ext/grpc/byte_buffer.c index 3be1429f13..56fd11d09b 100644 --- a/src/php/ext/grpc/byte_buffer.c +++ b/src/php/ext/grpc/byte_buffer.c @@ -50,9 +50,9 @@ #include grpc_byte_buffer *string_to_byte_buffer(char *string, size_t length) { - gpr_slice slice = gpr_slice_from_copied_buffer(string, length); + grpc_slice slice = grpc_slice_from_copied_buffer(string, length); grpc_byte_buffer *buffer = grpc_raw_byte_buffer_create(&slice, 1); - gpr_slice_unref(slice); + grpc_slice_unref(slice); return buffer; } @@ -66,11 +66,11 @@ void byte_buffer_to_string(grpc_byte_buffer *buffer, char **out_string, return; } - gpr_slice slice = grpc_byte_buffer_reader_readall(&reader); + grpc_slice slice = grpc_byte_buffer_reader_readall(&reader); size_t length = GPR_SLICE_LENGTH(slice); char *string = ecalloc(length + 1, sizeof(char)); memcpy(string, GPR_SLICE_START_PTR(slice), length); - gpr_slice_unref(slice); + grpc_slice_unref(slice); *out_string = string; *out_length = length; diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index 9560fad137..ba26284b2c 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -53,23 +53,23 @@ cdef extern from "grpc/byte_buffer_reader.h": cdef extern from "grpc/grpc.h": - ctypedef struct gpr_slice: - # don't worry about writing out the members of gpr_slice; we never access + ctypedef struct grpc_slice: + # don't worry about writing out the members of grpc_slice; we never access # them directly. pass - gpr_slice gpr_slice_ref(gpr_slice s) nogil - void gpr_slice_unref(gpr_slice s) nogil - gpr_slice gpr_slice_new(void *p, size_t len, void (*destroy)(void *)) nogil - gpr_slice gpr_slice_new_with_len( + grpc_slice grpc_slice_ref(grpc_slice s) nogil + void grpc_slice_unref(grpc_slice s) nogil + grpc_slice grpc_slice_new(void *p, size_t len, void (*destroy)(void *)) nogil + grpc_slice grpc_slice_new_with_len( void *p, size_t len, void (*destroy)(void *, size_t)) nogil - gpr_slice gpr_slice_malloc(size_t length) nogil - gpr_slice gpr_slice_from_copied_string(const char *source) nogil - gpr_slice gpr_slice_from_copied_buffer(const char *source, size_t len) nogil + grpc_slice grpc_slice_malloc(size_t length) nogil + grpc_slice grpc_slice_from_copied_string(const char *source) nogil + grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len) nogil # Declare functions for function-like macros (because Cython)... - void *gpr_slice_start_ptr "GPR_SLICE_START_PTR" (gpr_slice s) nogil - size_t gpr_slice_length "GPR_SLICE_LENGTH" (gpr_slice s) nogil + void *grpc_slice_start_ptr "GPR_SLICE_START_PTR" (grpc_slice s) nogil + size_t grpc_slice_length "GPR_SLICE_LENGTH" (grpc_slice s) nogil ctypedef enum gpr_clock_type: GPR_CLOCK_MONOTONIC @@ -101,7 +101,7 @@ cdef extern from "grpc/grpc.h": # We don't care about the internals. pass - grpc_byte_buffer *grpc_raw_byte_buffer_create(gpr_slice *slices, + grpc_byte_buffer *grpc_raw_byte_buffer_create(grpc_slice *slices, size_t nslices) nogil size_t grpc_byte_buffer_length(grpc_byte_buffer *bb) nogil void grpc_byte_buffer_destroy(grpc_byte_buffer *byte_buffer) nogil @@ -109,7 +109,7 @@ cdef extern from "grpc/grpc.h": int grpc_byte_buffer_reader_init(grpc_byte_buffer_reader *reader, grpc_byte_buffer *buffer) nogil int grpc_byte_buffer_reader_next(grpc_byte_buffer_reader *reader, - gpr_slice *slice) nogil + grpc_slice *slice) nogil void grpc_byte_buffer_reader_destroy(grpc_byte_buffer_reader *reader) nogil ctypedef enum grpc_status_code: diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi index 8a4eef4d2e..cadfce6ee6 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/records.pyx.pxi @@ -242,19 +242,19 @@ cdef class ByteBuffer: return cdef char *c_data = data - cdef gpr_slice data_slice + cdef grpc_slice data_slice cdef size_t data_length = len(data) with nogil: - data_slice = gpr_slice_from_copied_buffer(c_data, data_length) + data_slice = grpc_slice_from_copied_buffer(c_data, data_length) with nogil: self.c_byte_buffer = grpc_raw_byte_buffer_create( &data_slice, 1) with nogil: - gpr_slice_unref(data_slice) + grpc_slice_unref(data_slice) def bytes(self): cdef grpc_byte_buffer_reader reader - cdef gpr_slice data_slice + cdef grpc_slice data_slice cdef size_t data_slice_length cdef void *data_slice_pointer cdef bint reader_status @@ -267,11 +267,11 @@ cdef class ByteBuffer: result = bytearray() with nogil: while grpc_byte_buffer_reader_next(&reader, &data_slice): - data_slice_pointer = gpr_slice_start_ptr(data_slice) - data_slice_length = gpr_slice_length(data_slice) + data_slice_pointer = grpc_slice_start_ptr(data_slice) + data_slice_length = grpc_slice_length(data_slice) with gil: result += (data_slice_pointer)[:data_slice_length] - gpr_slice_unref(data_slice) + grpc_slice_unref(data_slice) with nogil: grpc_byte_buffer_reader_destroy(&reader) return bytes(result) diff --git a/src/ruby/ext/grpc/rb_byte_buffer.c b/src/ruby/ext/grpc/rb_byte_buffer.c index 61b7c30315..511abe3fbe 100644 --- a/src/ruby/ext/grpc/rb_byte_buffer.c +++ b/src/ruby/ext/grpc/rb_byte_buffer.c @@ -42,16 +42,16 @@ #include "rb_grpc.h" grpc_byte_buffer* grpc_rb_s_to_byte_buffer(char *string, size_t length) { - gpr_slice slice = gpr_slice_from_copied_buffer(string, length); + grpc_slice slice = grpc_slice_from_copied_buffer(string, length); grpc_byte_buffer *buffer = grpc_raw_byte_buffer_create(&slice, 1); - gpr_slice_unref(slice); + grpc_slice_unref(slice); return buffer; } VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer *buffer) { VALUE rb_string; grpc_byte_buffer_reader reader; - gpr_slice next; + grpc_slice next; if (buffer == NULL) { return Qnil; } @@ -63,7 +63,7 @@ VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer *buffer) { while (grpc_byte_buffer_reader_next(&reader, &next) != 0) { rb_str_cat(rb_string, (const char *) GPR_SLICE_START_PTR(next), GPR_SLICE_LENGTH(next)); - gpr_slice_unref(next); + grpc_slice_unref(next); } return rb_string; } diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.c b/src/ruby/ext/grpc/rb_grpc_imports.generated.c index fd73cc7970..dd156f0867 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.c +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.c @@ -221,35 +221,35 @@ gpr_set_log_verbosity_type gpr_set_log_verbosity_import; gpr_log_verbosity_init_type gpr_log_verbosity_init_import; gpr_set_log_function_type gpr_set_log_function_import; gpr_format_message_type gpr_format_message_import; -gpr_slice_ref_type gpr_slice_ref_import; -gpr_slice_unref_type gpr_slice_unref_import; -gpr_slice_new_type gpr_slice_new_import; -gpr_slice_new_with_user_data_type gpr_slice_new_with_user_data_import; -gpr_slice_new_with_len_type gpr_slice_new_with_len_import; -gpr_slice_malloc_type gpr_slice_malloc_import; -gpr_slice_from_copied_string_type gpr_slice_from_copied_string_import; -gpr_slice_from_copied_buffer_type gpr_slice_from_copied_buffer_import; -gpr_slice_from_static_string_type gpr_slice_from_static_string_import; -gpr_slice_sub_type gpr_slice_sub_import; -gpr_slice_sub_no_ref_type gpr_slice_sub_no_ref_import; -gpr_slice_split_tail_type gpr_slice_split_tail_import; -gpr_slice_split_head_type gpr_slice_split_head_import; +grpc_slice_ref_type grpc_slice_ref_import; +grpc_slice_unref_type grpc_slice_unref_import; +grpc_slice_new_type grpc_slice_new_import; +grpc_slice_new_with_user_data_type grpc_slice_new_with_user_data_import; +grpc_slice_new_with_len_type grpc_slice_new_with_len_import; +grpc_slice_malloc_type grpc_slice_malloc_import; +grpc_slice_from_copied_string_type grpc_slice_from_copied_string_import; +grpc_slice_from_copied_buffer_type grpc_slice_from_copied_buffer_import; +grpc_slice_from_static_string_type grpc_slice_from_static_string_import; +grpc_slice_sub_type grpc_slice_sub_import; +grpc_slice_sub_no_ref_type grpc_slice_sub_no_ref_import; +grpc_slice_split_tail_type grpc_slice_split_tail_import; +grpc_slice_split_head_type grpc_slice_split_head_import; gpr_empty_slice_type gpr_empty_slice_import; -gpr_slice_cmp_type gpr_slice_cmp_import; -gpr_slice_str_cmp_type gpr_slice_str_cmp_import; -gpr_slice_buffer_init_type gpr_slice_buffer_init_import; -gpr_slice_buffer_destroy_type gpr_slice_buffer_destroy_import; -gpr_slice_buffer_add_type gpr_slice_buffer_add_import; -gpr_slice_buffer_add_indexed_type gpr_slice_buffer_add_indexed_import; -gpr_slice_buffer_addn_type gpr_slice_buffer_addn_import; -gpr_slice_buffer_tiny_add_type gpr_slice_buffer_tiny_add_import; -gpr_slice_buffer_pop_type gpr_slice_buffer_pop_import; -gpr_slice_buffer_reset_and_unref_type gpr_slice_buffer_reset_and_unref_import; -gpr_slice_buffer_swap_type gpr_slice_buffer_swap_import; -gpr_slice_buffer_move_into_type gpr_slice_buffer_move_into_import; -gpr_slice_buffer_trim_end_type gpr_slice_buffer_trim_end_import; -gpr_slice_buffer_move_first_type gpr_slice_buffer_move_first_import; -gpr_slice_buffer_take_first_type gpr_slice_buffer_take_first_import; +grpc_slice_cmp_type grpc_slice_cmp_import; +grpc_slice_str_cmp_type grpc_slice_str_cmp_import; +grpc_slice_buffer_init_type grpc_slice_buffer_init_import; +grpc_slice_buffer_destroy_type grpc_slice_buffer_destroy_import; +grpc_slice_buffer_add_type grpc_slice_buffer_add_import; +grpc_slice_buffer_add_indexed_type grpc_slice_buffer_add_indexed_import; +grpc_slice_buffer_addn_type grpc_slice_buffer_addn_import; +grpc_slice_buffer_tiny_add_type grpc_slice_buffer_tiny_add_import; +grpc_slice_buffer_pop_type grpc_slice_buffer_pop_import; +grpc_slice_buffer_reset_and_unref_type grpc_slice_buffer_reset_and_unref_import; +grpc_slice_buffer_swap_type grpc_slice_buffer_swap_import; +grpc_slice_buffer_move_into_type grpc_slice_buffer_move_into_import; +grpc_slice_buffer_trim_end_type grpc_slice_buffer_trim_end_import; +grpc_slice_buffer_move_first_type grpc_slice_buffer_move_first_import; +grpc_slice_buffer_take_first_type grpc_slice_buffer_take_first_import; gpr_strdup_type gpr_strdup_import; gpr_asprintf_type gpr_asprintf_import; gpr_subprocess_binary_extension_type gpr_subprocess_binary_extension_import; @@ -495,35 +495,35 @@ void grpc_rb_load_imports(HMODULE library) { gpr_log_verbosity_init_import = (gpr_log_verbosity_init_type) GetProcAddress(library, "gpr_log_verbosity_init"); gpr_set_log_function_import = (gpr_set_log_function_type) GetProcAddress(library, "gpr_set_log_function"); gpr_format_message_import = (gpr_format_message_type) GetProcAddress(library, "gpr_format_message"); - gpr_slice_ref_import = (gpr_slice_ref_type) GetProcAddress(library, "gpr_slice_ref"); - gpr_slice_unref_import = (gpr_slice_unref_type) GetProcAddress(library, "gpr_slice_unref"); - gpr_slice_new_import = (gpr_slice_new_type) GetProcAddress(library, "gpr_slice_new"); - gpr_slice_new_with_user_data_import = (gpr_slice_new_with_user_data_type) GetProcAddress(library, "gpr_slice_new_with_user_data"); - gpr_slice_new_with_len_import = (gpr_slice_new_with_len_type) GetProcAddress(library, "gpr_slice_new_with_len"); - gpr_slice_malloc_import = (gpr_slice_malloc_type) GetProcAddress(library, "gpr_slice_malloc"); - gpr_slice_from_copied_string_import = (gpr_slice_from_copied_string_type) GetProcAddress(library, "gpr_slice_from_copied_string"); - gpr_slice_from_copied_buffer_import = (gpr_slice_from_copied_buffer_type) GetProcAddress(library, "gpr_slice_from_copied_buffer"); - gpr_slice_from_static_string_import = (gpr_slice_from_static_string_type) GetProcAddress(library, "gpr_slice_from_static_string"); - gpr_slice_sub_import = (gpr_slice_sub_type) GetProcAddress(library, "gpr_slice_sub"); - gpr_slice_sub_no_ref_import = (gpr_slice_sub_no_ref_type) GetProcAddress(library, "gpr_slice_sub_no_ref"); - gpr_slice_split_tail_import = (gpr_slice_split_tail_type) GetProcAddress(library, "gpr_slice_split_tail"); - gpr_slice_split_head_import = (gpr_slice_split_head_type) GetProcAddress(library, "gpr_slice_split_head"); + grpc_slice_ref_import = (grpc_slice_ref_type) GetProcAddress(library, "grpc_slice_ref"); + grpc_slice_unref_import = (grpc_slice_unref_type) GetProcAddress(library, "grpc_slice_unref"); + grpc_slice_new_import = (grpc_slice_new_type) GetProcAddress(library, "grpc_slice_new"); + grpc_slice_new_with_user_data_import = (grpc_slice_new_with_user_data_type) GetProcAddress(library, "grpc_slice_new_with_user_data"); + grpc_slice_new_with_len_import = (grpc_slice_new_with_len_type) GetProcAddress(library, "grpc_slice_new_with_len"); + grpc_slice_malloc_import = (grpc_slice_malloc_type) GetProcAddress(library, "grpc_slice_malloc"); + grpc_slice_from_copied_string_import = (grpc_slice_from_copied_string_type) GetProcAddress(library, "grpc_slice_from_copied_string"); + grpc_slice_from_copied_buffer_import = (grpc_slice_from_copied_buffer_type) GetProcAddress(library, "grpc_slice_from_copied_buffer"); + grpc_slice_from_static_string_import = (grpc_slice_from_static_string_type) GetProcAddress(library, "grpc_slice_from_static_string"); + grpc_slice_sub_import = (grpc_slice_sub_type) GetProcAddress(library, "grpc_slice_sub"); + grpc_slice_sub_no_ref_import = (grpc_slice_sub_no_ref_type) GetProcAddress(library, "grpc_slice_sub_no_ref"); + grpc_slice_split_tail_import = (grpc_slice_split_tail_type) GetProcAddress(library, "grpc_slice_split_tail"); + grpc_slice_split_head_import = (grpc_slice_split_head_type) GetProcAddress(library, "grpc_slice_split_head"); gpr_empty_slice_import = (gpr_empty_slice_type) GetProcAddress(library, "gpr_empty_slice"); - gpr_slice_cmp_import = (gpr_slice_cmp_type) GetProcAddress(library, "gpr_slice_cmp"); - gpr_slice_str_cmp_import = (gpr_slice_str_cmp_type) GetProcAddress(library, "gpr_slice_str_cmp"); - gpr_slice_buffer_init_import = (gpr_slice_buffer_init_type) GetProcAddress(library, "gpr_slice_buffer_init"); - gpr_slice_buffer_destroy_import = (gpr_slice_buffer_destroy_type) GetProcAddress(library, "gpr_slice_buffer_destroy"); - gpr_slice_buffer_add_import = (gpr_slice_buffer_add_type) GetProcAddress(library, "gpr_slice_buffer_add"); - gpr_slice_buffer_add_indexed_import = (gpr_slice_buffer_add_indexed_type) GetProcAddress(library, "gpr_slice_buffer_add_indexed"); - gpr_slice_buffer_addn_import = (gpr_slice_buffer_addn_type) GetProcAddress(library, "gpr_slice_buffer_addn"); - gpr_slice_buffer_tiny_add_import = (gpr_slice_buffer_tiny_add_type) GetProcAddress(library, "gpr_slice_buffer_tiny_add"); - gpr_slice_buffer_pop_import = (gpr_slice_buffer_pop_type) GetProcAddress(library, "gpr_slice_buffer_pop"); - gpr_slice_buffer_reset_and_unref_import = (gpr_slice_buffer_reset_and_unref_type) GetProcAddress(library, "gpr_slice_buffer_reset_and_unref"); - gpr_slice_buffer_swap_import = (gpr_slice_buffer_swap_type) GetProcAddress(library, "gpr_slice_buffer_swap"); - gpr_slice_buffer_move_into_import = (gpr_slice_buffer_move_into_type) GetProcAddress(library, "gpr_slice_buffer_move_into"); - gpr_slice_buffer_trim_end_import = (gpr_slice_buffer_trim_end_type) GetProcAddress(library, "gpr_slice_buffer_trim_end"); - gpr_slice_buffer_move_first_import = (gpr_slice_buffer_move_first_type) GetProcAddress(library, "gpr_slice_buffer_move_first"); - gpr_slice_buffer_take_first_import = (gpr_slice_buffer_take_first_type) GetProcAddress(library, "gpr_slice_buffer_take_first"); + grpc_slice_cmp_import = (grpc_slice_cmp_type) GetProcAddress(library, "grpc_slice_cmp"); + grpc_slice_str_cmp_import = (grpc_slice_str_cmp_type) GetProcAddress(library, "grpc_slice_str_cmp"); + grpc_slice_buffer_init_import = (grpc_slice_buffer_init_type) GetProcAddress(library, "grpc_slice_buffer_init"); + grpc_slice_buffer_destroy_import = (grpc_slice_buffer_destroy_type) GetProcAddress(library, "grpc_slice_buffer_destroy"); + grpc_slice_buffer_add_import = (grpc_slice_buffer_add_type) GetProcAddress(library, "grpc_slice_buffer_add"); + grpc_slice_buffer_add_indexed_import = (grpc_slice_buffer_add_indexed_type) GetProcAddress(library, "grpc_slice_buffer_add_indexed"); + grpc_slice_buffer_addn_import = (grpc_slice_buffer_addn_type) GetProcAddress(library, "grpc_slice_buffer_addn"); + grpc_slice_buffer_tiny_add_import = (grpc_slice_buffer_tiny_add_type) GetProcAddress(library, "grpc_slice_buffer_tiny_add"); + grpc_slice_buffer_pop_import = (grpc_slice_buffer_pop_type) GetProcAddress(library, "grpc_slice_buffer_pop"); + grpc_slice_buffer_reset_and_unref_import = (grpc_slice_buffer_reset_and_unref_type) GetProcAddress(library, "grpc_slice_buffer_reset_and_unref"); + grpc_slice_buffer_swap_import = (grpc_slice_buffer_swap_type) GetProcAddress(library, "grpc_slice_buffer_swap"); + grpc_slice_buffer_move_into_import = (grpc_slice_buffer_move_into_type) GetProcAddress(library, "grpc_slice_buffer_move_into"); + grpc_slice_buffer_trim_end_import = (grpc_slice_buffer_trim_end_type) GetProcAddress(library, "grpc_slice_buffer_trim_end"); + grpc_slice_buffer_move_first_import = (grpc_slice_buffer_move_first_type) GetProcAddress(library, "grpc_slice_buffer_move_first"); + grpc_slice_buffer_take_first_import = (grpc_slice_buffer_take_first_type) GetProcAddress(library, "grpc_slice_buffer_take_first"); gpr_strdup_import = (gpr_strdup_type) GetProcAddress(library, "gpr_strdup"); gpr_asprintf_import = (gpr_asprintf_type) GetProcAddress(library, "gpr_asprintf"); gpr_subprocess_binary_extension_import = (gpr_subprocess_binary_extension_type) GetProcAddress(library, "gpr_subprocess_binary_extension"); diff --git a/src/ruby/ext/grpc/rb_grpc_imports.generated.h b/src/ruby/ext/grpc/rb_grpc_imports.generated.h index c2244150f2..30962a1c79 100644 --- a/src/ruby/ext/grpc/rb_grpc_imports.generated.h +++ b/src/ruby/ext/grpc/rb_grpc_imports.generated.h @@ -62,10 +62,10 @@ #include #include -typedef grpc_byte_buffer *(*grpc_raw_byte_buffer_create_type)(gpr_slice *slices, size_t nslices); +typedef grpc_byte_buffer *(*grpc_raw_byte_buffer_create_type)(grpc_slice *slices, size_t nslices); extern grpc_raw_byte_buffer_create_type grpc_raw_byte_buffer_create_import; #define grpc_raw_byte_buffer_create grpc_raw_byte_buffer_create_import -typedef grpc_byte_buffer *(*grpc_raw_compressed_byte_buffer_create_type)(gpr_slice *slices, size_t nslices, grpc_compression_algorithm compression); +typedef grpc_byte_buffer *(*grpc_raw_compressed_byte_buffer_create_type)(grpc_slice *slices, size_t nslices, grpc_compression_algorithm compression); extern grpc_raw_compressed_byte_buffer_create_type grpc_raw_compressed_byte_buffer_create_import; #define grpc_raw_compressed_byte_buffer_create grpc_raw_compressed_byte_buffer_create_import typedef grpc_byte_buffer *(*grpc_byte_buffer_copy_type)(grpc_byte_buffer *bb); @@ -83,10 +83,10 @@ extern grpc_byte_buffer_reader_init_type grpc_byte_buffer_reader_init_import; typedef void(*grpc_byte_buffer_reader_destroy_type)(grpc_byte_buffer_reader *reader); extern grpc_byte_buffer_reader_destroy_type grpc_byte_buffer_reader_destroy_import; #define grpc_byte_buffer_reader_destroy grpc_byte_buffer_reader_destroy_import -typedef int(*grpc_byte_buffer_reader_next_type)(grpc_byte_buffer_reader *reader, gpr_slice *slice); +typedef int(*grpc_byte_buffer_reader_next_type)(grpc_byte_buffer_reader *reader, grpc_slice *slice); extern grpc_byte_buffer_reader_next_type grpc_byte_buffer_reader_next_import; #define grpc_byte_buffer_reader_next grpc_byte_buffer_reader_next_import -typedef gpr_slice(*grpc_byte_buffer_reader_readall_type)(grpc_byte_buffer_reader *reader); +typedef grpc_slice(*grpc_byte_buffer_reader_readall_type)(grpc_byte_buffer_reader *reader); extern grpc_byte_buffer_reader_readall_type grpc_byte_buffer_reader_readall_import; #define grpc_byte_buffer_reader_readall grpc_byte_buffer_reader_readall_import typedef grpc_byte_buffer *(*grpc_raw_byte_buffer_from_reader_type)(grpc_byte_buffer_reader *reader); @@ -614,93 +614,93 @@ extern gpr_set_log_function_type gpr_set_log_function_import; typedef char *(*gpr_format_message_type)(int messageid); extern gpr_format_message_type gpr_format_message_import; #define gpr_format_message gpr_format_message_import -typedef gpr_slice(*gpr_slice_ref_type)(gpr_slice s); -extern gpr_slice_ref_type gpr_slice_ref_import; -#define gpr_slice_ref gpr_slice_ref_import -typedef void(*gpr_slice_unref_type)(gpr_slice s); -extern gpr_slice_unref_type gpr_slice_unref_import; -#define gpr_slice_unref gpr_slice_unref_import -typedef gpr_slice(*gpr_slice_new_type)(void *p, size_t len, void (*destroy)(void *)); -extern gpr_slice_new_type gpr_slice_new_import; -#define gpr_slice_new gpr_slice_new_import -typedef gpr_slice(*gpr_slice_new_with_user_data_type)(void *p, size_t len, void (*destroy)(void *), void *user_data); -extern gpr_slice_new_with_user_data_type gpr_slice_new_with_user_data_import; -#define gpr_slice_new_with_user_data gpr_slice_new_with_user_data_import -typedef gpr_slice(*gpr_slice_new_with_len_type)(void *p, size_t len, void (*destroy)(void *, size_t)); -extern gpr_slice_new_with_len_type gpr_slice_new_with_len_import; -#define gpr_slice_new_with_len gpr_slice_new_with_len_import -typedef gpr_slice(*gpr_slice_malloc_type)(size_t length); -extern gpr_slice_malloc_type gpr_slice_malloc_import; -#define gpr_slice_malloc gpr_slice_malloc_import -typedef gpr_slice(*gpr_slice_from_copied_string_type)(const char *source); -extern gpr_slice_from_copied_string_type gpr_slice_from_copied_string_import; -#define gpr_slice_from_copied_string gpr_slice_from_copied_string_import -typedef gpr_slice(*gpr_slice_from_copied_buffer_type)(const char *source, size_t len); -extern gpr_slice_from_copied_buffer_type gpr_slice_from_copied_buffer_import; -#define gpr_slice_from_copied_buffer gpr_slice_from_copied_buffer_import -typedef gpr_slice(*gpr_slice_from_static_string_type)(const char *source); -extern gpr_slice_from_static_string_type gpr_slice_from_static_string_import; -#define gpr_slice_from_static_string gpr_slice_from_static_string_import -typedef gpr_slice(*gpr_slice_sub_type)(gpr_slice s, size_t begin, size_t end); -extern gpr_slice_sub_type gpr_slice_sub_import; -#define gpr_slice_sub gpr_slice_sub_import -typedef gpr_slice(*gpr_slice_sub_no_ref_type)(gpr_slice s, size_t begin, size_t end); -extern gpr_slice_sub_no_ref_type gpr_slice_sub_no_ref_import; -#define gpr_slice_sub_no_ref gpr_slice_sub_no_ref_import -typedef gpr_slice(*gpr_slice_split_tail_type)(gpr_slice *s, size_t split); -extern gpr_slice_split_tail_type gpr_slice_split_tail_import; -#define gpr_slice_split_tail gpr_slice_split_tail_import -typedef gpr_slice(*gpr_slice_split_head_type)(gpr_slice *s, size_t split); -extern gpr_slice_split_head_type gpr_slice_split_head_import; -#define gpr_slice_split_head gpr_slice_split_head_import -typedef gpr_slice(*gpr_empty_slice_type)(void); +typedef grpc_slice(*grpc_slice_ref_type)(grpc_slice s); +extern grpc_slice_ref_type grpc_slice_ref_import; +#define grpc_slice_ref grpc_slice_ref_import +typedef void(*grpc_slice_unref_type)(grpc_slice s); +extern grpc_slice_unref_type grpc_slice_unref_import; +#define grpc_slice_unref grpc_slice_unref_import +typedef grpc_slice(*grpc_slice_new_type)(void *p, size_t len, void (*destroy)(void *)); +extern grpc_slice_new_type grpc_slice_new_import; +#define grpc_slice_new grpc_slice_new_import +typedef grpc_slice(*grpc_slice_new_with_user_data_type)(void *p, size_t len, void (*destroy)(void *), void *user_data); +extern grpc_slice_new_with_user_data_type grpc_slice_new_with_user_data_import; +#define grpc_slice_new_with_user_data grpc_slice_new_with_user_data_import +typedef grpc_slice(*grpc_slice_new_with_len_type)(void *p, size_t len, void (*destroy)(void *, size_t)); +extern grpc_slice_new_with_len_type grpc_slice_new_with_len_import; +#define grpc_slice_new_with_len grpc_slice_new_with_len_import +typedef grpc_slice(*grpc_slice_malloc_type)(size_t length); +extern grpc_slice_malloc_type grpc_slice_malloc_import; +#define grpc_slice_malloc grpc_slice_malloc_import +typedef grpc_slice(*grpc_slice_from_copied_string_type)(const char *source); +extern grpc_slice_from_copied_string_type grpc_slice_from_copied_string_import; +#define grpc_slice_from_copied_string grpc_slice_from_copied_string_import +typedef grpc_slice(*grpc_slice_from_copied_buffer_type)(const char *source, size_t len); +extern grpc_slice_from_copied_buffer_type grpc_slice_from_copied_buffer_import; +#define grpc_slice_from_copied_buffer grpc_slice_from_copied_buffer_import +typedef grpc_slice(*grpc_slice_from_static_string_type)(const char *source); +extern grpc_slice_from_static_string_type grpc_slice_from_static_string_import; +#define grpc_slice_from_static_string grpc_slice_from_static_string_import +typedef grpc_slice(*grpc_slice_sub_type)(grpc_slice s, size_t begin, size_t end); +extern grpc_slice_sub_type grpc_slice_sub_import; +#define grpc_slice_sub grpc_slice_sub_import +typedef grpc_slice(*grpc_slice_sub_no_ref_type)(grpc_slice s, size_t begin, size_t end); +extern grpc_slice_sub_no_ref_type grpc_slice_sub_no_ref_import; +#define grpc_slice_sub_no_ref grpc_slice_sub_no_ref_import +typedef grpc_slice(*grpc_slice_split_tail_type)(grpc_slice *s, size_t split); +extern grpc_slice_split_tail_type grpc_slice_split_tail_import; +#define grpc_slice_split_tail grpc_slice_split_tail_import +typedef grpc_slice(*grpc_slice_split_head_type)(grpc_slice *s, size_t split); +extern grpc_slice_split_head_type grpc_slice_split_head_import; +#define grpc_slice_split_head grpc_slice_split_head_import +typedef grpc_slice(*gpr_empty_slice_type)(void); extern gpr_empty_slice_type gpr_empty_slice_import; #define gpr_empty_slice gpr_empty_slice_import -typedef int(*gpr_slice_cmp_type)(gpr_slice a, gpr_slice b); -extern gpr_slice_cmp_type gpr_slice_cmp_import; -#define gpr_slice_cmp gpr_slice_cmp_import -typedef int(*gpr_slice_str_cmp_type)(gpr_slice a, const char *b); -extern gpr_slice_str_cmp_type gpr_slice_str_cmp_import; -#define gpr_slice_str_cmp gpr_slice_str_cmp_import -typedef void(*gpr_slice_buffer_init_type)(gpr_slice_buffer *sb); -extern gpr_slice_buffer_init_type gpr_slice_buffer_init_import; -#define gpr_slice_buffer_init gpr_slice_buffer_init_import -typedef void(*gpr_slice_buffer_destroy_type)(gpr_slice_buffer *sb); -extern gpr_slice_buffer_destroy_type gpr_slice_buffer_destroy_import; -#define gpr_slice_buffer_destroy gpr_slice_buffer_destroy_import -typedef void(*gpr_slice_buffer_add_type)(gpr_slice_buffer *sb, gpr_slice slice); -extern gpr_slice_buffer_add_type gpr_slice_buffer_add_import; -#define gpr_slice_buffer_add gpr_slice_buffer_add_import -typedef size_t(*gpr_slice_buffer_add_indexed_type)(gpr_slice_buffer *sb, gpr_slice slice); -extern gpr_slice_buffer_add_indexed_type gpr_slice_buffer_add_indexed_import; -#define gpr_slice_buffer_add_indexed gpr_slice_buffer_add_indexed_import -typedef void(*gpr_slice_buffer_addn_type)(gpr_slice_buffer *sb, gpr_slice *slices, size_t n); -extern gpr_slice_buffer_addn_type gpr_slice_buffer_addn_import; -#define gpr_slice_buffer_addn gpr_slice_buffer_addn_import -typedef uint8_t *(*gpr_slice_buffer_tiny_add_type)(gpr_slice_buffer *sb, size_t len); -extern gpr_slice_buffer_tiny_add_type gpr_slice_buffer_tiny_add_import; -#define gpr_slice_buffer_tiny_add gpr_slice_buffer_tiny_add_import -typedef void(*gpr_slice_buffer_pop_type)(gpr_slice_buffer *sb); -extern gpr_slice_buffer_pop_type gpr_slice_buffer_pop_import; -#define gpr_slice_buffer_pop gpr_slice_buffer_pop_import -typedef void(*gpr_slice_buffer_reset_and_unref_type)(gpr_slice_buffer *sb); -extern gpr_slice_buffer_reset_and_unref_type gpr_slice_buffer_reset_and_unref_import; -#define gpr_slice_buffer_reset_and_unref gpr_slice_buffer_reset_and_unref_import -typedef void(*gpr_slice_buffer_swap_type)(gpr_slice_buffer *a, gpr_slice_buffer *b); -extern gpr_slice_buffer_swap_type gpr_slice_buffer_swap_import; -#define gpr_slice_buffer_swap gpr_slice_buffer_swap_import -typedef void(*gpr_slice_buffer_move_into_type)(gpr_slice_buffer *src, gpr_slice_buffer *dst); -extern gpr_slice_buffer_move_into_type gpr_slice_buffer_move_into_import; -#define gpr_slice_buffer_move_into gpr_slice_buffer_move_into_import -typedef void(*gpr_slice_buffer_trim_end_type)(gpr_slice_buffer *src, size_t n, gpr_slice_buffer *garbage); -extern gpr_slice_buffer_trim_end_type gpr_slice_buffer_trim_end_import; -#define gpr_slice_buffer_trim_end gpr_slice_buffer_trim_end_import -typedef void(*gpr_slice_buffer_move_first_type)(gpr_slice_buffer *src, size_t n, gpr_slice_buffer *dst); -extern gpr_slice_buffer_move_first_type gpr_slice_buffer_move_first_import; -#define gpr_slice_buffer_move_first gpr_slice_buffer_move_first_import -typedef gpr_slice(*gpr_slice_buffer_take_first_type)(gpr_slice_buffer *src); -extern gpr_slice_buffer_take_first_type gpr_slice_buffer_take_first_import; -#define gpr_slice_buffer_take_first gpr_slice_buffer_take_first_import +typedef int(*grpc_slice_cmp_type)(grpc_slice a, grpc_slice b); +extern grpc_slice_cmp_type grpc_slice_cmp_import; +#define grpc_slice_cmp grpc_slice_cmp_import +typedef int(*grpc_slice_str_cmp_type)(grpc_slice a, const char *b); +extern grpc_slice_str_cmp_type grpc_slice_str_cmp_import; +#define grpc_slice_str_cmp grpc_slice_str_cmp_import +typedef void(*grpc_slice_buffer_init_type)(grpc_slice_buffer *sb); +extern grpc_slice_buffer_init_type grpc_slice_buffer_init_import; +#define grpc_slice_buffer_init grpc_slice_buffer_init_import +typedef void(*grpc_slice_buffer_destroy_type)(grpc_slice_buffer *sb); +extern grpc_slice_buffer_destroy_type grpc_slice_buffer_destroy_import; +#define grpc_slice_buffer_destroy grpc_slice_buffer_destroy_import +typedef void(*grpc_slice_buffer_add_type)(grpc_slice_buffer *sb, grpc_slice slice); +extern grpc_slice_buffer_add_type grpc_slice_buffer_add_import; +#define grpc_slice_buffer_add grpc_slice_buffer_add_import +typedef size_t(*grpc_slice_buffer_add_indexed_type)(grpc_slice_buffer *sb, grpc_slice slice); +extern grpc_slice_buffer_add_indexed_type grpc_slice_buffer_add_indexed_import; +#define grpc_slice_buffer_add_indexed grpc_slice_buffer_add_indexed_import +typedef void(*grpc_slice_buffer_addn_type)(grpc_slice_buffer *sb, grpc_slice *slices, size_t n); +extern grpc_slice_buffer_addn_type grpc_slice_buffer_addn_import; +#define grpc_slice_buffer_addn grpc_slice_buffer_addn_import +typedef uint8_t *(*grpc_slice_buffer_tiny_add_type)(grpc_slice_buffer *sb, size_t len); +extern grpc_slice_buffer_tiny_add_type grpc_slice_buffer_tiny_add_import; +#define grpc_slice_buffer_tiny_add grpc_slice_buffer_tiny_add_import +typedef void(*grpc_slice_buffer_pop_type)(grpc_slice_buffer *sb); +extern grpc_slice_buffer_pop_type grpc_slice_buffer_pop_import; +#define grpc_slice_buffer_pop grpc_slice_buffer_pop_import +typedef void(*grpc_slice_buffer_reset_and_unref_type)(grpc_slice_buffer *sb); +extern grpc_slice_buffer_reset_and_unref_type grpc_slice_buffer_reset_and_unref_import; +#define grpc_slice_buffer_reset_and_unref grpc_slice_buffer_reset_and_unref_import +typedef void(*grpc_slice_buffer_swap_type)(grpc_slice_buffer *a, grpc_slice_buffer *b); +extern grpc_slice_buffer_swap_type grpc_slice_buffer_swap_import; +#define grpc_slice_buffer_swap grpc_slice_buffer_swap_import +typedef void(*grpc_slice_buffer_move_into_type)(grpc_slice_buffer *src, grpc_slice_buffer *dst); +extern grpc_slice_buffer_move_into_type grpc_slice_buffer_move_into_import; +#define grpc_slice_buffer_move_into grpc_slice_buffer_move_into_import +typedef void(*grpc_slice_buffer_trim_end_type)(grpc_slice_buffer *src, size_t n, grpc_slice_buffer *garbage); +extern grpc_slice_buffer_trim_end_type grpc_slice_buffer_trim_end_import; +#define grpc_slice_buffer_trim_end grpc_slice_buffer_trim_end_import +typedef void(*grpc_slice_buffer_move_first_type)(grpc_slice_buffer *src, size_t n, grpc_slice_buffer *dst); +extern grpc_slice_buffer_move_first_type grpc_slice_buffer_move_first_import; +#define grpc_slice_buffer_move_first grpc_slice_buffer_move_first_import +typedef grpc_slice(*grpc_slice_buffer_take_first_type)(grpc_slice_buffer *src); +extern grpc_slice_buffer_take_first_type grpc_slice_buffer_take_first_import; +#define grpc_slice_buffer_take_first grpc_slice_buffer_take_first_import typedef char *(*gpr_strdup_type)(const char *src); extern gpr_strdup_type gpr_strdup_import; #define gpr_strdup gpr_strdup_import diff --git a/test/core/bad_client/bad_client.c b/test/core/bad_client/bad_client.c index a9638500b7..07fcd995d7 100644 --- a/test/core/bad_client/bad_client.c +++ b/test/core/bad_client/bad_client.c @@ -77,7 +77,7 @@ static void server_setup_transport(void *ts, grpc_transport *transport) { typedef struct { grpc_bad_client_client_stream_validator validator; - gpr_slice_buffer incoming; + grpc_slice_buffer incoming; gpr_event read_done; } read_args; @@ -96,9 +96,9 @@ void grpc_run_bad_client_test( gpr_thd_id id; char *hex; grpc_transport *transport; - gpr_slice slice = - gpr_slice_from_copied_buffer(client_payload, client_payload_length); - gpr_slice_buffer outgoing; + grpc_slice slice = + grpc_slice_from_copied_buffer(client_payload, client_payload_length); + grpc_slice_buffer outgoing; grpc_closure done_write_closure; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -146,8 +146,8 @@ void grpc_run_bad_client_test( /* Start validator */ gpr_thd_new(&id, thd_func, &a, NULL); - gpr_slice_buffer_init(&outgoing); - gpr_slice_buffer_add(&outgoing, slice); + grpc_slice_buffer_init(&outgoing); + grpc_slice_buffer_add(&outgoing, slice); grpc_closure_init(&done_write_closure, done_write, &a); /* Write data */ @@ -172,7 +172,7 @@ void grpc_run_bad_client_test( if (client_validator != NULL) { read_args args; args.validator = client_validator; - gpr_slice_buffer_init(&args.incoming); + grpc_slice_buffer_init(&args.incoming); gpr_event_init(&args.read_done); grpc_closure read_done_closure; grpc_closure_init(&read_done_closure, read_done, &args); @@ -181,7 +181,7 @@ void grpc_run_bad_client_test( grpc_exec_ctx_finish(&exec_ctx); GPR_ASSERT( gpr_event_wait(&args.read_done, GRPC_TIMEOUT_SECONDS_TO_DEADLINE(5))); - gpr_slice_buffer_destroy(&args.incoming); + grpc_slice_buffer_destroy(&args.incoming); } // Shutdown. grpc_endpoint_shutdown(&exec_ctx, sfd.client); @@ -194,7 +194,7 @@ void grpc_run_bad_client_test( .type == GRPC_OP_COMPLETE); grpc_server_destroy(a.server); grpc_completion_queue_destroy(a.cq); - gpr_slice_buffer_destroy(&outgoing); + grpc_slice_buffer_destroy(&outgoing); grpc_exec_ctx_finish(&exec_ctx); grpc_shutdown(); diff --git a/test/core/bad_client/bad_client.h b/test/core/bad_client/bad_client.h index c8b2a4122f..bbca418ef3 100644 --- a/test/core/bad_client/bad_client.h +++ b/test/core/bad_client/bad_client.h @@ -45,7 +45,7 @@ typedef void (*grpc_bad_client_server_side_validator)(grpc_server *server, void *registered_method); typedef void (*grpc_bad_client_client_stream_validator)( - gpr_slice_buffer *incoming); + grpc_slice_buffer *incoming); #define GRPC_BAD_CLIENT_DISCONNECT 1 diff --git a/test/core/bad_client/tests/large_metadata.c b/test/core/bad_client/tests/large_metadata.c index b9c8093ef9..124035c070 100644 --- a/test/core/bad_client/tests/large_metadata.c +++ b/test/core/bad_client/tests/large_metadata.c @@ -183,15 +183,15 @@ static void server_verifier_sends_too_much_metadata(grpc_server *server, cq_verifier_destroy(cqv); } -static void client_validator(gpr_slice_buffer *incoming) { +static void client_validator(grpc_slice_buffer *incoming) { // Get last frame from incoming slice buffer. - gpr_slice_buffer last_frame_buffer; - gpr_slice_buffer_init(&last_frame_buffer); - gpr_slice_buffer_trim_end(incoming, 13, &last_frame_buffer); + grpc_slice_buffer last_frame_buffer; + grpc_slice_buffer_init(&last_frame_buffer); + grpc_slice_buffer_trim_end(incoming, 13, &last_frame_buffer); GPR_ASSERT(last_frame_buffer.count == 1); - gpr_slice last_frame = last_frame_buffer.slices[0]; + grpc_slice last_frame = last_frame_buffer.slices[0]; // Construct expected frame. - gpr_slice expected = gpr_slice_malloc(13); + grpc_slice expected = grpc_slice_malloc(13); uint8_t *p = GPR_SLICE_START_PTR(expected); // Length. *p++ = 0; @@ -212,8 +212,8 @@ static void client_validator(gpr_slice_buffer *incoming) { *p++ = 0; *p++ = 11; // Compare actual and expected. - GPR_ASSERT(gpr_slice_cmp(last_frame, expected) == 0); - gpr_slice_buffer_destroy(&last_frame_buffer); + GPR_ASSERT(grpc_slice_cmp(last_frame, expected) == 0); + grpc_slice_buffer_destroy(&last_frame_buffer); } int main(int argc, char **argv) { diff --git a/test/core/bad_ssl/servers/cert.c b/test/core/bad_ssl/servers/cert.c index 91dd9de81b..52922f5d6b 100644 --- a/test/core/bad_ssl/servers/cert.c +++ b/test/core/bad_ssl/servers/cert.c @@ -51,7 +51,7 @@ int main(int argc, char **argv) { grpc_ssl_pem_key_cert_pair pem_key_cert_pair; grpc_server_credentials *ssl_creds; grpc_server *server; - gpr_slice cert_slice, key_slice; + grpc_slice cert_slice, key_slice; grpc_init(); @@ -70,8 +70,8 @@ int main(int argc, char **argv) { GPR_ASSERT(grpc_server_add_secure_http2_port(server, addr, ssl_creds)); grpc_server_credentials_release(ssl_creds); - gpr_slice_unref(cert_slice); - gpr_slice_unref(key_slice); + grpc_slice_unref(cert_slice); + grpc_slice_unref(key_slice); bad_ssl_run(server); grpc_shutdown(); diff --git a/test/core/client_channel/set_initial_connect_string_test.c b/test/core/client_channel/set_initial_connect_string_test.c index b7bd67567c..350f2884d7 100644 --- a/test/core/client_channel/set_initial_connect_string_test.c +++ b/test/core/client_channel/set_initial_connect_string_test.c @@ -54,8 +54,8 @@ struct rpc_state { grpc_channel *channel; grpc_call *call; grpc_op op; - gpr_slice_buffer incoming_buffer; - gpr_slice_buffer temp_incoming_buffer; + grpc_slice_buffer incoming_buffer; + grpc_slice_buffer temp_incoming_buffer; grpc_endpoint *tcp; gpr_atm done_atm; }; @@ -67,7 +67,7 @@ static grpc_closure on_read; static void handle_read(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { GPR_ASSERT(error == GRPC_ERROR_NONE); - gpr_slice_buffer_move_into(&state.temp_incoming_buffer, + grpc_slice_buffer_move_into(&state.temp_incoming_buffer, &state.incoming_buffer); gpr_log(GPR_DEBUG, "got %" PRIuPTR " bytes, magic is %" PRIuPTR " bytes", state.incoming_buffer.length, strlen(magic_connect_string)); @@ -86,25 +86,25 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, grpc_tcp_server_acceptor *acceptor) { test_tcp_server *server = arg; grpc_closure_init(&on_read, handle_read, NULL); - gpr_slice_buffer_init(&state.incoming_buffer); - gpr_slice_buffer_init(&state.temp_incoming_buffer); + grpc_slice_buffer_init(&state.incoming_buffer); + grpc_slice_buffer_init(&state.temp_incoming_buffer); state.tcp = tcp; grpc_endpoint_add_to_pollset(exec_ctx, tcp, server->pollset); grpc_endpoint_read(exec_ctx, tcp, &state.temp_incoming_buffer, &on_read); } static void set_magic_initial_string(struct sockaddr **addr, size_t *addr_len, - gpr_slice *connect_string) { + grpc_slice *connect_string) { GPR_ASSERT(addr); GPR_ASSERT(addr_len); - *connect_string = gpr_slice_from_copied_string(magic_connect_string); + *connect_string = grpc_slice_from_copied_string(magic_connect_string); } static void reset_addr_and_set_magic_string(struct sockaddr **addr, size_t *addr_len, - gpr_slice *connect_string) { + grpc_slice *connect_string) { struct sockaddr_in target; - *connect_string = gpr_slice_from_copied_string(magic_connect_string); + *connect_string = grpc_slice_from_copied_string(magic_connect_string); gpr_free(*addr); target.sin_family = AF_INET; target.sin_addr.s_addr = htonl(INADDR_LOOPBACK); @@ -148,8 +148,8 @@ static void start_rpc(int use_creds, int target_port) { static void cleanup_rpc(void) { grpc_event ev; - gpr_slice_buffer_destroy(&state.incoming_buffer); - gpr_slice_buffer_destroy(&state.temp_incoming_buffer); + grpc_slice_buffer_destroy(&state.incoming_buffer); + grpc_slice_buffer_destroy(&state.temp_incoming_buffer); grpc_channel_credentials_unref(state.creds); grpc_call_destroy(state.call); grpc_completion_queue_shutdown(state.cq); @@ -194,7 +194,7 @@ static void poll_server_until_read_done(test_tcp_server *server, gpr_thd_new(&id, actually_poll_server, pa, NULL); } -static void match_initial_magic_string(gpr_slice_buffer *buffer) { +static void match_initial_magic_string(grpc_slice_buffer *buffer) { size_t i, j, cmp_length; size_t magic_length = strlen(magic_connect_string); GPR_ASSERT(buffer->length >= magic_length); diff --git a/test/core/compression/message_compress_test.c b/test/core/compression/message_compress_test.c index 47ecf72e08..c6963df85d 100644 --- a/test/core/compression/message_compress_test.c +++ b/test/core/compression/message_compress_test.c @@ -52,16 +52,16 @@ typedef enum { MAYBE_COMPRESSES } compressability; -static void assert_passthrough(gpr_slice value, +static void assert_passthrough(grpc_slice value, grpc_compression_algorithm algorithm, grpc_slice_split_mode uncompressed_split_mode, grpc_slice_split_mode compressed_split_mode, compressability compress_result_check) { - gpr_slice_buffer input; - gpr_slice_buffer compressed_raw; - gpr_slice_buffer compressed; - gpr_slice_buffer output; - gpr_slice final; + grpc_slice_buffer input; + grpc_slice_buffer compressed_raw; + grpc_slice_buffer compressed; + grpc_slice_buffer output; + grpc_slice final; int was_compressed; char *algorithm_name; @@ -75,10 +75,10 @@ static void assert_passthrough(gpr_slice value, algorithm_name, grpc_slice_split_mode_name(uncompressed_split_mode), grpc_slice_split_mode_name(compressed_split_mode)); - gpr_slice_buffer_init(&input); - gpr_slice_buffer_init(&compressed_raw); - gpr_slice_buffer_init(&compressed); - gpr_slice_buffer_init(&output); + grpc_slice_buffer_init(&input); + grpc_slice_buffer_init(&compressed_raw); + grpc_slice_buffer_init(&compressed); + grpc_slice_buffer_init(&output); grpc_split_slices_to_buffer(uncompressed_split_mode, &value, 1, &input); @@ -103,17 +103,17 @@ static void assert_passthrough(gpr_slice value, was_compressed ? algorithm : GRPC_COMPRESS_NONE, &compressed, &output)); final = grpc_slice_merge(output.slices, output.count); - GPR_ASSERT(0 == gpr_slice_cmp(value, final)); + GPR_ASSERT(0 == grpc_slice_cmp(value, final)); - gpr_slice_buffer_destroy(&input); - gpr_slice_buffer_destroy(&compressed); - gpr_slice_buffer_destroy(&compressed_raw); - gpr_slice_buffer_destroy(&output); - gpr_slice_unref(final); + grpc_slice_buffer_destroy(&input); + grpc_slice_buffer_destroy(&compressed); + grpc_slice_buffer_destroy(&compressed_raw); + grpc_slice_buffer_destroy(&output); + grpc_slice_unref(final); } -static gpr_slice repeated(char c, size_t length) { - gpr_slice out = gpr_slice_malloc(length); +static grpc_slice repeated(char c, size_t length) { + grpc_slice out = grpc_slice_malloc(length); memset(GPR_SLICE_START_PTR(out), c, length); return out; } @@ -134,10 +134,10 @@ static compressability get_compressability( return MAYBE_COMPRESSES; } -static gpr_slice create_test_value(test_value id) { +static grpc_slice create_test_value(test_value id) { switch (id) { case ONE_A: - return gpr_slice_from_copied_string("a"); + return grpc_slice_from_copied_string("a"); case ONE_KB_A: return repeated('a', 1024); case ONE_MB_A: @@ -146,17 +146,17 @@ static gpr_slice create_test_value(test_value id) { abort(); break; } - return gpr_slice_from_copied_string("bad value"); + return grpc_slice_from_copied_string("bad value"); } static void test_tiny_data_compress(void) { - gpr_slice_buffer input; - gpr_slice_buffer output; + grpc_slice_buffer input; + grpc_slice_buffer output; grpc_compression_algorithm i; - gpr_slice_buffer_init(&input); - gpr_slice_buffer_init(&output); - gpr_slice_buffer_add(&input, create_test_value(ONE_A)); + grpc_slice_buffer_init(&input); + grpc_slice_buffer_init(&output); + grpc_slice_buffer_add(&input, create_test_value(ONE_A)); for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) { if (i == GRPC_COMPRESS_NONE) continue; @@ -164,21 +164,21 @@ static void test_tiny_data_compress(void) { GPR_ASSERT(1 == output.count); } - gpr_slice_buffer_destroy(&input); - gpr_slice_buffer_destroy(&output); + grpc_slice_buffer_destroy(&input); + grpc_slice_buffer_destroy(&output); } static void test_bad_decompression_data_crc(void) { - gpr_slice_buffer input; - gpr_slice_buffer corrupted; - gpr_slice_buffer output; + grpc_slice_buffer input; + grpc_slice_buffer corrupted; + grpc_slice_buffer output; size_t idx; const uint32_t bad = 0xdeadbeef; - gpr_slice_buffer_init(&input); - gpr_slice_buffer_init(&corrupted); - gpr_slice_buffer_init(&output); - gpr_slice_buffer_add(&input, create_test_value(ONE_MB_A)); + grpc_slice_buffer_init(&input); + grpc_slice_buffer_init(&corrupted); + grpc_slice_buffer_init(&output); + grpc_slice_buffer_add(&input, create_test_value(ONE_MB_A)); /* compress it */ grpc_msg_compress(GRPC_COMPRESS_GZIP, &input, &corrupted); @@ -191,54 +191,54 @@ static void test_bad_decompression_data_crc(void) { /* try (and fail) to decompress the corrupted compresed buffer */ GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_GZIP, &corrupted, &output)); - gpr_slice_buffer_destroy(&input); - gpr_slice_buffer_destroy(&corrupted); - gpr_slice_buffer_destroy(&output); + grpc_slice_buffer_destroy(&input); + grpc_slice_buffer_destroy(&corrupted); + grpc_slice_buffer_destroy(&output); } static void test_bad_decompression_data_trailing_garbage(void) { - gpr_slice_buffer input; - gpr_slice_buffer output; + grpc_slice_buffer input; + grpc_slice_buffer output; - gpr_slice_buffer_init(&input); - gpr_slice_buffer_init(&output); + grpc_slice_buffer_init(&input); + grpc_slice_buffer_init(&output); /* append 0x99 to the end of an otherwise valid stream */ - gpr_slice_buffer_add( - &input, gpr_slice_from_copied_buffer( + grpc_slice_buffer_add( + &input, grpc_slice_from_copied_buffer( "\x78\xda\x63\x60\x60\x60\x00\x00\x00\x04\x00\x01\x99", 13)); /* try (and fail) to decompress the invalid compresed buffer */ GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_DEFLATE, &input, &output)); - gpr_slice_buffer_destroy(&input); - gpr_slice_buffer_destroy(&output); + grpc_slice_buffer_destroy(&input); + grpc_slice_buffer_destroy(&output); } static void test_bad_decompression_data_stream(void) { - gpr_slice_buffer input; - gpr_slice_buffer output; + grpc_slice_buffer input; + grpc_slice_buffer output; - gpr_slice_buffer_init(&input); - gpr_slice_buffer_init(&output); - gpr_slice_buffer_add(&input, - gpr_slice_from_copied_buffer("\x78\xda\xff\xff", 4)); + grpc_slice_buffer_init(&input); + grpc_slice_buffer_init(&output); + grpc_slice_buffer_add(&input, + grpc_slice_from_copied_buffer("\x78\xda\xff\xff", 4)); /* try (and fail) to decompress the invalid compresed buffer */ GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_DEFLATE, &input, &output)); - gpr_slice_buffer_destroy(&input); - gpr_slice_buffer_destroy(&output); + grpc_slice_buffer_destroy(&input); + grpc_slice_buffer_destroy(&output); } static void test_bad_compression_algorithm(void) { - gpr_slice_buffer input; - gpr_slice_buffer output; + grpc_slice_buffer input; + grpc_slice_buffer output; int was_compressed; - 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")); + grpc_slice_buffer_init(&input); + grpc_slice_buffer_init(&output); + grpc_slice_buffer_add(&input, + grpc_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); @@ -247,19 +247,19 @@ static void test_bad_compression_algorithm(void) { grpc_msg_compress(GRPC_COMPRESS_ALGORITHMS_COUNT + 123, &input, &output); GPR_ASSERT(0 == was_compressed); - gpr_slice_buffer_destroy(&input); - gpr_slice_buffer_destroy(&output); + grpc_slice_buffer_destroy(&input); + grpc_slice_buffer_destroy(&output); } static void test_bad_decompression_algorithm(void) { - gpr_slice_buffer input; - gpr_slice_buffer output; + grpc_slice_buffer input; + grpc_slice_buffer output; int was_decompressed; - gpr_slice_buffer_init(&input); - gpr_slice_buffer_init(&output); - gpr_slice_buffer_add(&input, - gpr_slice_from_copied_string( + grpc_slice_buffer_init(&input); + grpc_slice_buffer_init(&output); + grpc_slice_buffer_add(&input, + grpc_slice_from_copied_string( "I'm not really compressed but it doesn't matter")); was_decompressed = grpc_msg_decompress(GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output); @@ -269,8 +269,8 @@ static void test_bad_decompression_algorithm(void) { &input, &output); GPR_ASSERT(0 == was_decompressed); - gpr_slice_buffer_destroy(&input); - gpr_slice_buffer_destroy(&output); + grpc_slice_buffer_destroy(&input); + grpc_slice_buffer_destroy(&output); } int main(int argc, char **argv) { @@ -288,9 +288,9 @@ int main(int argc, char **argv) { for (j = 0; j < GPR_ARRAY_SIZE(uncompressed_split_modes); j++) { for (k = 0; k < GPR_ARRAY_SIZE(compressed_split_modes); k++) { for (m = 0; m < TEST_VALUE_COUNT; m++) { - gpr_slice slice = create_test_value(m); + grpc_slice slice = create_test_value(m); assert_passthrough(slice, i, j, k, get_compressability(m, i)); - gpr_slice_unref(slice); + grpc_slice_unref(slice); } } } diff --git a/test/core/end2end/bad_server_response_test.c b/test/core/end2end/bad_server_response_test.c index 5ed0eb64d2..cb2030a7d7 100644 --- a/test/core/end2end/bad_server_response_test.c +++ b/test/core/end2end/bad_server_response_test.c @@ -82,8 +82,8 @@ struct rpc_state { grpc_channel *channel; grpc_call *call; size_t incoming_data_length; - gpr_slice_buffer temp_incoming_buffer; - gpr_slice_buffer outgoing_buffer; + grpc_slice_buffer temp_incoming_buffer; + grpc_slice_buffer outgoing_buffer; grpc_endpoint *tcp; gpr_atm done_atm; bool write_done; @@ -105,11 +105,11 @@ static void done_write(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { } static void handle_write(grpc_exec_ctx *exec_ctx) { - gpr_slice slice = gpr_slice_from_copied_buffer(state.response_payload, + grpc_slice slice = grpc_slice_from_copied_buffer(state.response_payload, state.response_payload_length); - gpr_slice_buffer_reset_and_unref(&state.outgoing_buffer); - gpr_slice_buffer_add(&state.outgoing_buffer, slice); + grpc_slice_buffer_reset_and_unref(&state.outgoing_buffer); + grpc_slice_buffer_add(&state.outgoing_buffer, slice); grpc_endpoint_write(exec_ctx, state.tcp, &state.outgoing_buffer, &on_write); } @@ -141,8 +141,8 @@ static void on_connect(grpc_exec_ctx *exec_ctx, void *arg, grpc_endpoint *tcp, test_tcp_server *server = arg; grpc_closure_init(&on_read, handle_read, NULL); grpc_closure_init(&on_write, done_write, NULL); - gpr_slice_buffer_init(&state.temp_incoming_buffer); - gpr_slice_buffer_init(&state.outgoing_buffer); + grpc_slice_buffer_init(&state.temp_incoming_buffer); + grpc_slice_buffer_init(&state.outgoing_buffer); state.tcp = tcp; state.incoming_data_length = 0; grpc_endpoint_add_to_pollset(exec_ctx, tcp, server->pollset); @@ -221,8 +221,8 @@ static void start_rpc(int target_port, grpc_status_code expected_status, static void cleanup_rpc(void) { grpc_event ev; - gpr_slice_buffer_destroy(&state.temp_incoming_buffer); - gpr_slice_buffer_destroy(&state.outgoing_buffer); + grpc_slice_buffer_destroy(&state.temp_incoming_buffer); + grpc_slice_buffer_destroy(&state.outgoing_buffer); grpc_call_destroy(state.call); grpc_completion_queue_shutdown(state.cq); do { diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c index 3e7e3f22a2..3b9aa24368 100644 --- a/test/core/end2end/cq_verifier.c +++ b/test/core/end2end/cq_verifier.c @@ -105,17 +105,17 @@ int contains_metadata(grpc_metadata_array *array, const char *key, return has_metadata(array->metadata, array->count, key, value); } -static gpr_slice merge_slices(gpr_slice *slices, size_t nslices) { +static grpc_slice merge_slices(grpc_slice *slices, size_t nslices) { size_t i; size_t len = 0; uint8_t *cursor; - gpr_slice out; + grpc_slice out; for (i = 0; i < nslices; i++) { len += GPR_SLICE_LENGTH(slices[i]); } - out = gpr_slice_malloc(len); + out = grpc_slice_malloc(len); cursor = GPR_SLICE_START_PTR(out); for (i = 0; i < nslices; i++) { @@ -126,8 +126,8 @@ static gpr_slice merge_slices(gpr_slice *slices, size_t nslices) { return out; } -int raw_byte_buffer_eq_slice(grpc_byte_buffer *rbb, gpr_slice b) { - gpr_slice a; +int raw_byte_buffer_eq_slice(grpc_byte_buffer *rbb, grpc_slice b) { + grpc_slice a; int ok; if (!rbb) return 0; @@ -137,12 +137,12 @@ int raw_byte_buffer_eq_slice(grpc_byte_buffer *rbb, gpr_slice b) { ok = GPR_SLICE_LENGTH(a) == GPR_SLICE_LENGTH(b) && 0 == memcmp(GPR_SLICE_START_PTR(a), GPR_SLICE_START_PTR(b), GPR_SLICE_LENGTH(a)); - gpr_slice_unref(a); - gpr_slice_unref(b); + grpc_slice_unref(a); + grpc_slice_unref(b); return ok; } -int byte_buffer_eq_slice(grpc_byte_buffer *bb, gpr_slice b) { +int byte_buffer_eq_slice(grpc_byte_buffer *bb, grpc_slice b) { grpc_byte_buffer_reader reader; grpc_byte_buffer *rbb; int res; @@ -165,7 +165,7 @@ int byte_buffer_eq_string(grpc_byte_buffer *bb, const char *str) { GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, bb) && "Couldn't init byte buffer reader"); rbb = grpc_raw_byte_buffer_from_reader(&reader); - res = raw_byte_buffer_eq_slice(rbb, gpr_slice_from_copied_string(str)); + res = raw_byte_buffer_eq_slice(rbb, grpc_slice_from_copied_string(str)); grpc_byte_buffer_reader_destroy(&reader); grpc_byte_buffer_destroy(rbb); diff --git a/test/core/end2end/cq_verifier.h b/test/core/end2end/cq_verifier.h index 47464fa319..b754de9bbe 100644 --- a/test/core/end2end/cq_verifier.h +++ b/test/core/end2end/cq_verifier.h @@ -67,7 +67,7 @@ void cq_expect_completion(cq_verifier *v, const char *file, int line, void *tag, #define CQ_EXPECT_COMPLETION(v, tag, success) \ cq_expect_completion(v, __FILE__, __LINE__, tag, success) -int byte_buffer_eq_slice(grpc_byte_buffer *bb, gpr_slice b); +int byte_buffer_eq_slice(grpc_byte_buffer *bb, grpc_slice b); int byte_buffer_eq_string(grpc_byte_buffer *byte_buffer, const char *string); int contains_metadata(grpc_metadata_array *array, const char *key, const char *value); diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c index cb07ca535b..5860257607 100644 --- a/test/core/end2end/dualstack_socket_test.c +++ b/test/core/end2end/dualstack_socket_test.c @@ -120,14 +120,14 @@ void test_connect(const char *server_host, const char *client_host, int port, if (client_host[0] == 'i') { /* for ipv4:/ipv6: addresses, concatenate the port to each of the parts */ size_t i; - gpr_slice uri_slice; - gpr_slice_buffer uri_parts; + grpc_slice uri_slice; + grpc_slice_buffer uri_parts; char **hosts_with_port; uri_slice = - gpr_slice_new((char *)client_host, strlen(client_host), do_nothing); - gpr_slice_buffer_init(&uri_parts); - gpr_slice_split(uri_slice, ",", &uri_parts); + grpc_slice_new((char *)client_host, strlen(client_host), do_nothing); + grpc_slice_buffer_init(&uri_parts); + grpc_slice_split(uri_slice, ",", &uri_parts); 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); @@ -140,8 +140,8 @@ void test_connect(const char *server_host, const char *client_host, int port, gpr_free(hosts_with_port[i]); } gpr_free(hosts_with_port); - gpr_slice_buffer_destroy(&uri_parts); - gpr_slice_unref(uri_slice); + grpc_slice_buffer_destroy(&uri_parts); + grpc_slice_unref(uri_slice); } else { gpr_join_host_port(&client_hostport, client_host, port); } diff --git a/test/core/end2end/fake_resolver.c b/test/core/end2end/fake_resolver.c index 5669ce51e8..4687e52313 100644 --- a/test/core/end2end/fake_resolver.c +++ b/test/core/end2end/fake_resolver.c @@ -163,11 +163,11 @@ static grpc_resolver* fake_resolver_create(grpc_resolver_factory* factory, const bool lb_enabled = lb_enabled_qpart != NULL && strcmp("0", lb_enabled_qpart) != 0; // Construct addresses. - gpr_slice path_slice = - gpr_slice_new(args->uri->path, strlen(args->uri->path), do_nothing); - gpr_slice_buffer path_parts; - gpr_slice_buffer_init(&path_parts); - gpr_slice_split(path_slice, ",", &path_parts); + grpc_slice path_slice = + grpc_slice_new(args->uri->path, strlen(args->uri->path), do_nothing); + grpc_slice_buffer path_parts; + grpc_slice_buffer_init(&path_parts); + grpc_slice_split(path_slice, ",", &path_parts); grpc_lb_addresses* addresses = grpc_lb_addresses_create(path_parts.count); bool errors_found = false; for (size_t i = 0; i < addresses->num_addresses; i++) { @@ -184,8 +184,8 @@ static grpc_resolver* fake_resolver_create(grpc_resolver_factory* factory, addresses->addresses[i].is_balancer = lb_enabled; if (errors_found) break; } - gpr_slice_buffer_destroy(&path_parts); - gpr_slice_unref(path_slice); + grpc_slice_buffer_destroy(&path_parts); + grpc_slice_unref(path_slice); if (errors_found) { grpc_lb_addresses_destroy(addresses, NULL /* user_data_destroy */); return NULL; diff --git a/test/core/end2end/fixtures/http_proxy.c b/test/core/end2end/fixtures/http_proxy.c index bc24cb33cf..88c77a5168 100644 --- a/test/core/end2end/fixtures/http_proxy.c +++ b/test/core/end2end/fixtures/http_proxy.c @@ -89,12 +89,12 @@ typedef struct proxy_connection { grpc_closure on_server_read_done; grpc_closure on_server_write_done; - gpr_slice_buffer client_read_buffer; - gpr_slice_buffer client_deferred_write_buffer; - gpr_slice_buffer client_write_buffer; - gpr_slice_buffer server_read_buffer; - gpr_slice_buffer server_deferred_write_buffer; - gpr_slice_buffer server_write_buffer; + grpc_slice_buffer client_read_buffer; + grpc_slice_buffer client_deferred_write_buffer; + grpc_slice_buffer client_write_buffer; + grpc_slice_buffer server_read_buffer; + grpc_slice_buffer server_deferred_write_buffer; + grpc_slice_buffer server_write_buffer; grpc_http_parser http_parser; grpc_http_request http_request; @@ -108,12 +108,12 @@ static void proxy_connection_unref(grpc_exec_ctx* exec_ctx, if (conn->server_endpoint != NULL) grpc_endpoint_destroy(exec_ctx, conn->server_endpoint); grpc_pollset_set_destroy(conn->pollset_set); - gpr_slice_buffer_destroy(&conn->client_read_buffer); - gpr_slice_buffer_destroy(&conn->client_deferred_write_buffer); - gpr_slice_buffer_destroy(&conn->client_write_buffer); - gpr_slice_buffer_destroy(&conn->server_read_buffer); - gpr_slice_buffer_destroy(&conn->server_deferred_write_buffer); - gpr_slice_buffer_destroy(&conn->server_write_buffer); + grpc_slice_buffer_destroy(&conn->client_read_buffer); + grpc_slice_buffer_destroy(&conn->client_deferred_write_buffer); + grpc_slice_buffer_destroy(&conn->client_write_buffer); + grpc_slice_buffer_destroy(&conn->server_read_buffer); + grpc_slice_buffer_destroy(&conn->server_deferred_write_buffer); + grpc_slice_buffer_destroy(&conn->server_write_buffer); grpc_http_parser_destroy(&conn->http_parser); grpc_http_request_destroy(&conn->http_request); gpr_free(conn); @@ -144,11 +144,11 @@ static void on_client_write_done(grpc_exec_ctx* exec_ctx, void* arg, return; } // Clear write buffer (the data we just wrote). - gpr_slice_buffer_reset_and_unref(&conn->client_write_buffer); + grpc_slice_buffer_reset_and_unref(&conn->client_write_buffer); // If more data was read from the server since we started this write, // write that data now. if (conn->client_deferred_write_buffer.length > 0) { - gpr_slice_buffer_move_into(&conn->client_deferred_write_buffer, + grpc_slice_buffer_move_into(&conn->client_deferred_write_buffer, &conn->client_write_buffer); grpc_endpoint_write(exec_ctx, conn->client_endpoint, &conn->client_write_buffer, @@ -169,11 +169,11 @@ static void on_server_write_done(grpc_exec_ctx* exec_ctx, void* arg, return; } // Clear write buffer (the data we just wrote). - gpr_slice_buffer_reset_and_unref(&conn->server_write_buffer); + grpc_slice_buffer_reset_and_unref(&conn->server_write_buffer); // If more data was read from the client since we started this write, // write that data now. if (conn->server_deferred_write_buffer.length > 0) { - gpr_slice_buffer_move_into(&conn->server_deferred_write_buffer, + grpc_slice_buffer_move_into(&conn->server_deferred_write_buffer, &conn->server_write_buffer); grpc_endpoint_write(exec_ctx, conn->server_endpoint, &conn->server_write_buffer, @@ -201,10 +201,10 @@ static void on_client_read_done(grpc_exec_ctx* exec_ctx, void* arg, // // Otherwise, move the read data into the write buffer and write it. if (conn->server_write_buffer.length > 0) { - gpr_slice_buffer_move_into(&conn->client_read_buffer, + grpc_slice_buffer_move_into(&conn->client_read_buffer, &conn->server_deferred_write_buffer); } else { - gpr_slice_buffer_move_into(&conn->client_read_buffer, + grpc_slice_buffer_move_into(&conn->client_read_buffer, &conn->server_write_buffer); gpr_ref(&conn->refcount); grpc_endpoint_write(exec_ctx, conn->server_endpoint, @@ -233,10 +233,10 @@ static void on_server_read_done(grpc_exec_ctx* exec_ctx, void* arg, // // Otherwise, move the read data into the write buffer and write it. if (conn->client_write_buffer.length > 0) { - gpr_slice_buffer_move_into(&conn->server_read_buffer, + grpc_slice_buffer_move_into(&conn->server_read_buffer, &conn->client_deferred_write_buffer); } else { - gpr_slice_buffer_move_into(&conn->server_read_buffer, + grpc_slice_buffer_move_into(&conn->server_read_buffer, &conn->client_write_buffer); gpr_ref(&conn->refcount); grpc_endpoint_write(exec_ctx, conn->client_endpoint, @@ -258,7 +258,7 @@ static void on_write_response_done(grpc_exec_ctx* exec_ctx, void* arg, return; } // Clear write buffer. - gpr_slice_buffer_reset_and_unref(&conn->client_write_buffer); + grpc_slice_buffer_reset_and_unref(&conn->client_write_buffer); // Start reading from both client and server. One of the read // requests inherits our ref to conn, but we need to take a new ref // for the other one. @@ -287,9 +287,9 @@ static void on_server_connect_done(grpc_exec_ctx* exec_ctx, void* arg, // We've established a connection, so send back a 200 response code to // the client. // The write callback inherits our reference to conn. - gpr_slice slice = - gpr_slice_from_copied_string("HTTP/1.0 200 connected\r\n\r\n"); - gpr_slice_buffer_add(&conn->client_write_buffer, slice); + grpc_slice slice = + grpc_slice_from_copied_string("HTTP/1.0 200 connected\r\n\r\n"); + grpc_slice_buffer_add(&conn->client_write_buffer, slice); grpc_endpoint_write(exec_ctx, conn->client_endpoint, &conn->client_write_buffer, &conn->on_write_response_done); @@ -322,7 +322,7 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg, } } } - gpr_slice_buffer_reset_and_unref(&conn->client_read_buffer); + grpc_slice_buffer_reset_and_unref(&conn->client_read_buffer); // If we're not done reading the request, read more data. if (conn->http_parser.state != GRPC_HTTP_BODY) { grpc_endpoint_read(exec_ctx, conn->client_endpoint, @@ -383,12 +383,12 @@ static void on_accept(grpc_exec_ctx* exec_ctx, void* arg, grpc_closure_init(&conn->on_client_write_done, on_client_write_done, conn); grpc_closure_init(&conn->on_server_read_done, on_server_read_done, conn); grpc_closure_init(&conn->on_server_write_done, on_server_write_done, conn); - gpr_slice_buffer_init(&conn->client_read_buffer); - gpr_slice_buffer_init(&conn->client_deferred_write_buffer); - gpr_slice_buffer_init(&conn->client_write_buffer); - gpr_slice_buffer_init(&conn->server_read_buffer); - gpr_slice_buffer_init(&conn->server_deferred_write_buffer); - gpr_slice_buffer_init(&conn->server_write_buffer); + grpc_slice_buffer_init(&conn->client_read_buffer); + grpc_slice_buffer_init(&conn->client_deferred_write_buffer); + grpc_slice_buffer_init(&conn->client_write_buffer); + grpc_slice_buffer_init(&conn->server_read_buffer); + grpc_slice_buffer_init(&conn->server_deferred_write_buffer); + grpc_slice_buffer_init(&conn->server_write_buffer); grpc_http_parser_init(&conn->http_parser, GRPC_HTTP_REQUEST, &conn->http_request); grpc_endpoint_read(exec_ctx, conn->client_endpoint, &conn->client_read_buffer, diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index 945cc960e9..210a863f48 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -137,10 +137,10 @@ static uint32_t read_uint32(input_stream *inp) { } static grpc_byte_buffer *read_message(input_stream *inp) { - gpr_slice slice = gpr_slice_malloc(read_uint22(inp)); + grpc_slice slice = grpc_slice_malloc(read_uint22(inp)); memset(GPR_SLICE_START_PTR(slice), 0, GPR_SLICE_LENGTH(slice)); grpc_byte_buffer *out = grpc_raw_byte_buffer_create(&slice, 1); - gpr_slice_unref(slice); + grpc_slice_unref(slice); return out; } diff --git a/test/core/end2end/fuzzers/client_fuzzer.c b/test/core/end2end/fuzzers/client_fuzzer.c index d104fe55e5..c5260cd287 100644 --- a/test/core/end2end/fuzzers/client_fuzzer.c +++ b/test/core/end2end/fuzzers/client_fuzzer.c @@ -44,7 +44,7 @@ bool squelch = true; bool leak_check = true; -static void discard_write(gpr_slice slice) {} +static void discard_write(grpc_slice slice) {} static void *tag(int n) { return (void *)(uintptr_t)n; } @@ -121,7 +121,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_mock_endpoint_put_read( &exec_ctx, mock_endpoint, - gpr_slice_from_copied_buffer((const char *)data, size)); + grpc_slice_from_copied_buffer((const char *)data, size)); grpc_event ev; while (1) { diff --git a/test/core/end2end/fuzzers/server_fuzzer.c b/test/core/end2end/fuzzers/server_fuzzer.c index ae4c8e658d..164022ec79 100644 --- a/test/core/end2end/fuzzers/server_fuzzer.c +++ b/test/core/end2end/fuzzers/server_fuzzer.c @@ -41,7 +41,7 @@ bool squelch = true; bool leak_check = true; -static void discard_write(gpr_slice slice) {} +static void discard_write(grpc_slice slice) {} static void *tag(int n) { return (void *)(uintptr_t)n; } static int detag(void *p) { return (int)(uintptr_t)p; } @@ -63,7 +63,7 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_resource_quota_internal_unref(&exec_ctx, resource_quota); grpc_mock_endpoint_put_read( &exec_ctx, mock_endpoint, - gpr_slice_from_copied_buffer((const char *)data, size)); + grpc_slice_from_copied_buffer((const char *)data, size)); grpc_server *server = grpc_server_create(NULL, NULL); grpc_completion_queue *cq = grpc_completion_queue_create(NULL); diff --git a/test/core/end2end/invalid_call_argument_test.c b/test/core/end2end/invalid_call_argument_test.c index 2b9904a244..6cc7d28489 100644 --- a/test/core/end2end/invalid_call_argument_test.c +++ b/test/core/end2end/invalid_call_argument_test.c @@ -251,7 +251,7 @@ static void test_send_messages_at_the_same_time() { gpr_log(GPR_INFO, "test_send_messages_at_the_same_time"); grpc_op *op; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); prepare_test(1); diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.c index 73b0f17c24..317ca3110b 100644 --- a/test/core/end2end/tests/binary_metadata.c +++ b/test/core/end2end/tests/binary_metadata.c @@ -100,8 +100,8 @@ static void test_request_response_with_metadata_and_payload( grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); - gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_byte_buffer *response_payload = diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index 99c5d94e39..8f8b7d5119 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -135,8 +135,8 @@ static void request_response_with_payload_and_call_creds( override_mode mode) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); - gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_byte_buffer *response_payload = @@ -389,7 +389,7 @@ static void test_request_with_server_rejecting_client_creds( char *details = NULL; size_t details_capacity = 0; grpc_byte_buffer *response_payload_recv = NULL; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_call_credentials *creds; diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index 9f49815527..4bf55c8725 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -118,8 +118,8 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, size_t details_capacity = 0; grpc_byte_buffer *request_payload_recv = NULL; grpc_byte_buffer *response_payload_recv = NULL; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); - gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_byte_buffer *response_payload = diff --git a/test/core/end2end/tests/cancel_after_client_done.c b/test/core/end2end/tests/cancel_after_client_done.c index f61a404b2d..afb17b0719 100644 --- a/test/core/end2end/tests/cancel_after_client_done.c +++ b/test/core/end2end/tests/cancel_after_client_done.c @@ -117,8 +117,8 @@ static void test_cancel_after_accept_and_writes_closed( size_t details_capacity = 0; grpc_byte_buffer *request_payload_recv = NULL; grpc_byte_buffer *response_payload_recv = NULL; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); - gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_byte_buffer *response_payload = diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index c31582bf2e..fe0e0d689c 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -116,7 +116,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, char *details = NULL; size_t details_capacity = 0; grpc_byte_buffer *response_payload_recv = NULL; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c index 5dcd44e7b4..3a0b83c4d2 100644 --- a/test/core/end2end/tests/cancel_before_invoke.c +++ b/test/core/end2end/tests/cancel_before_invoke.c @@ -114,7 +114,7 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, char *details = NULL; size_t details_capacity = 0; grpc_byte_buffer *response_payload_recv = NULL; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index f598a3812b..92788dd8fa 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -110,7 +110,7 @@ static void request_for_disabled_algorithm( grpc_status_code expected_error, grpc_metadata *client_metadata) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice; + grpc_slice request_payload_slice; grpc_byte_buffer *request_payload; gpr_timespec deadline = five_seconds_time(); grpc_channel_args *client_args; @@ -133,7 +133,7 @@ static void request_for_disabled_algorithm( memset(str, 'x', 1023); str[1023] = '\0'; - request_payload_slice = gpr_slice_from_copied_string(str); + request_payload_slice = grpc_slice_from_copied_string(str); request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); client_args = grpc_channel_args_set_compression_algorithm( @@ -255,7 +255,7 @@ static void request_for_disabled_algorithm( cq_verifier_destroy(cqv); - gpr_slice_unref(request_payload_slice); + grpc_slice_unref(request_payload_slice); grpc_byte_buffer_destroy(request_payload); grpc_byte_buffer_destroy(request_payload_recv); @@ -277,7 +277,7 @@ static void request_with_payload_template( grpc_compression_level server_compression_level) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice; + grpc_slice request_payload_slice; grpc_byte_buffer *request_payload; gpr_timespec deadline = five_seconds_time(); grpc_channel_args *client_args; @@ -307,8 +307,8 @@ static void request_with_payload_template( memset(response_str, 'y', 1023); response_str[1023] = '\0'; - request_payload_slice = gpr_slice_from_copied_string(request_str); - gpr_slice response_payload_slice = gpr_slice_from_copied_string(response_str); + request_payload_slice = grpc_slice_from_copied_string(request_str); + grpc_slice response_payload_slice = grpc_slice_from_copied_string(response_str); client_args = grpc_channel_args_set_compression_algorithm( NULL, default_client_channel_compression_algorithm); @@ -458,8 +458,8 @@ static void request_with_payload_template( grpc_byte_buffer_destroy(response_payload_recv); } - gpr_slice_unref(request_payload_slice); - gpr_slice_unref(response_payload_slice); + grpc_slice_unref(request_payload_slice); + grpc_slice_unref(response_payload_slice); memset(ops, 0, sizeof(ops)); op = ops; diff --git a/test/core/end2end/tests/filter_call_init_fails.c b/test/core/end2end/tests/filter_call_init_fails.c index 0e5692f4c9..36f98694b6 100644 --- a/test/core/end2end/tests/filter_call_init_fails.c +++ b/test/core/end2end/tests/filter_call_init_fails.c @@ -108,7 +108,7 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test_request(grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); diff --git a/test/core/end2end/tests/filter_causes_close.c b/test/core/end2end/tests/filter_causes_close.c index d5eddc7330..66449558c7 100644 --- a/test/core/end2end/tests/filter_causes_close.c +++ b/test/core/end2end/tests/filter_causes_close.c @@ -104,7 +104,7 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test_request(grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); @@ -207,8 +207,8 @@ static void recv_im_ready(grpc_exec_ctx *exec_ctx, void *arg, call_data *calld = elem->call_data; if (error == GRPC_ERROR_NONE) { // close the stream with an error. - gpr_slice message = - gpr_slice_from_copied_string("Failure that's not preventable."); + grpc_slice message = + grpc_slice_from_copied_string("Failure that's not preventable."); grpc_transport_stream_op *op = grpc_make_transport_stream_op(NULL); grpc_transport_stream_op_add_close(op, GRPC_STATUS_PERMISSION_DENIED, &message); diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index 3820504e11..0a4d87c2fb 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -94,8 +94,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static gpr_slice large_slice(void) { - gpr_slice slice = gpr_slice_malloc(1000000); +static grpc_slice large_slice(void) { + grpc_slice slice = grpc_slice_malloc(1000000); memset(GPR_SLICE_START_PTR(slice), 'x', GPR_SLICE_LENGTH(slice)); return slice; } @@ -120,8 +120,8 @@ static void test_invoke_large_request(grpc_end2end_test_config config, begin_test(config, name, &channel_args, &channel_args); gpr_free(name); - gpr_slice request_payload_slice = large_slice(); - gpr_slice response_payload_slice = large_slice(); + grpc_slice request_payload_slice = large_slice(); + grpc_slice response_payload_slice = large_slice(); grpc_call *c; grpc_call *s; grpc_byte_buffer *request_payload = @@ -262,8 +262,8 @@ static void test_invoke_large_request(grpc_end2end_test_config config, grpc_byte_buffer_destroy(response_payload); grpc_byte_buffer_destroy(request_payload_recv); grpc_byte_buffer_destroy(response_payload_recv); - gpr_slice_unref(request_payload_slice); - gpr_slice_unref(response_payload_slice); + grpc_slice_unref(request_payload_slice); + grpc_slice_unref(response_payload_slice); end_test(&f); config.tear_down_data(&f); diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c index 6107836b12..29dcafb985 100644 --- a/test/core/end2end/tests/large_metadata.c +++ b/test/core/end2end/tests/large_metadata.c @@ -99,7 +99,7 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test_request_with_large_metadata(grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); diff --git a/test/core/end2end/tests/load_reporting_hook.c b/test/core/end2end/tests/load_reporting_hook.c index 0915730a02..1dba200c02 100644 --- a/test/core/end2end/tests/load_reporting_hook.c +++ b/test/core/end2end/tests/load_reporting_hook.c @@ -127,8 +127,8 @@ static void request_response_with_payload(grpc_end2end_test_fixture f, const char *response_msg, grpc_metadata *initial_lr_metadata, grpc_metadata *trailing_lr_metadata) { - gpr_slice request_payload_slice = gpr_slice_from_static_string(request_msg); - gpr_slice response_payload_slice = gpr_slice_from_static_string(response_msg); + grpc_slice request_payload_slice = grpc_slice_from_static_string(request_msg); + grpc_slice response_payload_slice = grpc_slice_from_static_string(response_msg); grpc_call *c; grpc_call *s; grpc_byte_buffer *request_payload = diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index 449a581d23..cdf52f9838 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -116,7 +116,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, cq_verifier *cqv; grpc_op ops[6]; grpc_op *op; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_byte_buffer *recv_payload = NULL; @@ -277,8 +277,8 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, cq_verifier *cqv; grpc_op ops[6]; grpc_op *op; - gpr_slice response_payload_slice = - gpr_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = + grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *response_payload = grpc_raw_byte_buffer_create(&response_payload_slice, 1); grpc_byte_buffer *recv_payload = NULL; diff --git a/test/core/end2end/tests/network_status_change.c b/test/core/end2end/tests/network_status_change.c index fa711bb0b6..e9528ff105 100644 --- a/test/core/end2end/tests/network_status_change.c +++ b/test/core/end2end/tests/network_status_change.c @@ -102,7 +102,7 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test_invoke_network_status_change(grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c index 8353ea32fd..5a19950726 100644 --- a/test/core/end2end/tests/payload.c +++ b/test/core/end2end/tests/payload.c @@ -95,8 +95,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -/* Creates and returns a gpr_slice containing random alphanumeric characters. */ -static gpr_slice generate_random_slice() { +/* Creates and returns a grpc_slice containing random alphanumeric characters. */ +static grpc_slice generate_random_slice() { size_t i; static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890"; char *output; @@ -106,7 +106,7 @@ static gpr_slice generate_random_slice() { output[i] = chars[rand() % (int)(sizeof(chars) - 1)]; } output[output_size - 1] = '\0'; - gpr_slice out = gpr_slice_from_copied_string(output); + grpc_slice out = grpc_slice_from_copied_string(output); gpr_free(output); return out; } @@ -115,8 +115,8 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) { /* Create large request and response bodies. These are big enough to require * multiple round trips to deliver to the peer, and their exact contents of * will be verified on completion. */ - gpr_slice request_payload_slice = generate_random_slice(); - gpr_slice response_payload_slice = generate_random_slice(); + grpc_slice request_payload_slice = generate_random_slice(); + grpc_slice response_payload_slice = generate_random_slice(); grpc_call *c; grpc_call *s; diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index 30ea80043b..3398a9cff7 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -120,8 +120,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, grpc_byte_buffer *response_payload; grpc_byte_buffer *response_payload_recv; int i; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); - gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", deadline, @@ -228,8 +228,8 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, grpc_byte_buffer_destroy(response_payload_recv); } - gpr_slice_unref(request_payload_slice); - gpr_slice_unref(response_payload_slice); + grpc_slice_unref(request_payload_slice); + grpc_slice_unref(response_payload_slice); memset(ops, 0, sizeof(ops)); op = ops; diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c index 69ad69af66..a37fc645b4 100644 --- a/test/core/end2end/tests/request_with_flags.c +++ b/test/core/end2end/tests/request_with_flags.c @@ -100,7 +100,7 @@ static void test_invoke_request_with_flags( grpc_end2end_test_config config, uint32_t *flags_for_op, grpc_call_error call_start_batch_expected_result) { grpc_call *c; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index 56ff83cdb4..3e2bbb3b0e 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -99,7 +99,7 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test_invoke_request_with_payload(grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); diff --git a/test/core/end2end/tests/resource_quota_server.c b/test/core/end2end/tests/resource_quota_server.c index 6170444373..280bad5749 100644 --- a/test/core/end2end/tests/resource_quota_server.c +++ b/test/core/end2end/tests/resource_quota_server.c @@ -95,8 +95,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -/* Creates and returns a gpr_slice containing random alphanumeric characters. */ -static gpr_slice generate_random_slice() { +/* Creates and returns a grpc_slice containing random alphanumeric characters. */ +static grpc_slice generate_random_slice() { size_t i; static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890"; char output[1024 * 1024]; @@ -104,7 +104,7 @@ static gpr_slice generate_random_slice() { output[i] = chars[rand() % (int)(sizeof(chars) - 1)]; } output[GPR_ARRAY_SIZE(output) - 1] = '\0'; - return gpr_slice_from_copied_string(output); + return grpc_slice_from_copied_string(output); } void resource_quota_server(grpc_end2end_test_config config) { @@ -131,7 +131,7 @@ void resource_quota_server(grpc_end2end_test_config config) { /* Create large request and response bodies. These are big enough to require * multiple round trips to deliver to the peer, and their exact contents of * will be verified on completion. */ - gpr_slice request_payload_slice = generate_random_slice(); + grpc_slice request_payload_slice = generate_random_slice(); grpc_call *client_calls[NUM_CALLS]; grpc_call *server_calls[NUM_CALLS]; @@ -349,7 +349,7 @@ void resource_quota_server(grpc_end2end_test_config config) { GPR_ASSERT(cancelled_calls_on_server >= 0.9 * cancelled_calls_on_client); grpc_byte_buffer_destroy(request_payload); - gpr_slice_unref(request_payload_slice); + grpc_slice_unref(request_payload_slice); grpc_resource_quota_unref(resource_quota); end_test(&f); diff --git a/test/core/end2end/tests/simple_cacheable_request.c b/test/core/end2end/tests/simple_cacheable_request.c index 29ba41bd8b..40dd3983e1 100644 --- a/test/core/end2end/tests/simple_cacheable_request.c +++ b/test/core/end2end/tests/simple_cacheable_request.c @@ -102,8 +102,8 @@ static void test_cacheable_request_response_with_metadata_and_payload( grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); - gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_byte_buffer *response_payload = diff --git a/test/core/end2end/tests/simple_metadata.c b/test/core/end2end/tests/simple_metadata.c index 304af9c3fa..1ac9dc8210 100644 --- a/test/core/end2end/tests/simple_metadata.c +++ b/test/core/end2end/tests/simple_metadata.c @@ -100,8 +100,8 @@ static void test_request_response_with_metadata_and_payload( grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); - gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_byte_buffer *response_payload = diff --git a/test/core/end2end/tests/streaming_error_response.c b/test/core/end2end/tests/streaming_error_response.c index fe63c6f7bb..efd41c508c 100644 --- a/test/core/end2end/tests/streaming_error_response.c +++ b/test/core/end2end/tests/streaming_error_response.c @@ -101,10 +101,10 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test(grpc_end2end_test_config config, bool request_status_early) { grpc_call *c; grpc_call *s; - gpr_slice response_payload1_slice = gpr_slice_from_copied_string("hello"); + grpc_slice response_payload1_slice = grpc_slice_from_copied_string("hello"); grpc_byte_buffer *response_payload1 = grpc_raw_byte_buffer_create(&response_payload1_slice, 1); - gpr_slice response_payload2_slice = gpr_slice_from_copied_string("world"); + grpc_slice response_payload2_slice = grpc_slice_from_copied_string("world"); grpc_byte_buffer *response_payload2 = grpc_raw_byte_buffer_create(&response_payload2_slice, 1); gpr_timespec deadline = five_seconds_time(); diff --git a/test/core/end2end/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.c index e6bfc7c9f1..0bbf0879cc 100644 --- a/test/core/end2end/tests/trailing_metadata.c +++ b/test/core/end2end/tests/trailing_metadata.c @@ -100,8 +100,8 @@ static void test_request_response_with_metadata_and_payload( grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); - gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_byte_buffer *response_payload = diff --git a/test/core/fling/client.c b/test/core/fling/client.c index bcc195a92f..e717b7f7fe 100644 --- a/test/core/fling/client.c +++ b/test/core/fling/client.c @@ -155,7 +155,7 @@ static const scenario scenarios[] = { }; int main(int argc, char **argv) { - gpr_slice slice = gpr_slice_from_copied_string("x"); + grpc_slice slice = grpc_slice_from_copied_string("x"); double start, stop; unsigned i; @@ -241,7 +241,7 @@ int main(int argc, char **argv) { } while (event.type != GRPC_QUEUE_SHUTDOWN); grpc_completion_queue_destroy(cq); grpc_byte_buffer_destroy(the_buffer); - gpr_slice_unref(slice); + grpc_slice_unref(slice); gpr_log(GPR_INFO, "latency (50/95/99/99.9): %f/%f/%f/%f", gpr_histogram_percentile(histogram, 50), diff --git a/test/core/http/format_request_test.c b/test/core/http/format_request_test.c index 0d21e1200b..bd31e5e8ab 100644 --- a/test/core/http/format_request_test.c +++ b/test/core/http/format_request_test.c @@ -41,7 +41,7 @@ static void test_format_get_request(void) { grpc_http_header hdr = {"x-yz", "abc"}; grpc_httpcli_request req; - gpr_slice slice; + grpc_slice slice; memset(&req, 0, sizeof(req)); req.host = "example.com"; @@ -51,7 +51,7 @@ static void test_format_get_request(void) { slice = grpc_httpcli_format_get_request(&req); - GPR_ASSERT(0 == gpr_slice_str_cmp(slice, + GPR_ASSERT(0 == grpc_slice_str_cmp(slice, "GET /index.html HTTP/1.0\r\n" "Host: example.com\r\n" "Connection: close\r\n" @@ -60,13 +60,13 @@ static void test_format_get_request(void) { "x-yz: abc\r\n" "\r\n")); - gpr_slice_unref(slice); + grpc_slice_unref(slice); } static void test_format_post_request(void) { grpc_http_header hdr = {"x-yz", "abc"}; grpc_httpcli_request req; - gpr_slice slice; + grpc_slice slice; char body_bytes[] = "fake body"; size_t body_len = 9; @@ -78,7 +78,7 @@ static void test_format_post_request(void) { slice = grpc_httpcli_format_post_request(&req, body_bytes, body_len); - GPR_ASSERT(0 == gpr_slice_str_cmp(slice, + GPR_ASSERT(0 == grpc_slice_str_cmp(slice, "POST /index.html HTTP/1.0\r\n" "Host: example.com\r\n" "Connection: close\r\n" @@ -90,13 +90,13 @@ static void test_format_post_request(void) { "\r\n" "fake body")); - gpr_slice_unref(slice); + grpc_slice_unref(slice); } static void test_format_post_request_no_body(void) { grpc_http_header hdr = {"x-yz", "abc"}; grpc_httpcli_request req; - gpr_slice slice; + grpc_slice slice; memset(&req, 0, sizeof(req)); req.host = "example.com"; @@ -106,7 +106,7 @@ static void test_format_post_request_no_body(void) { slice = grpc_httpcli_format_post_request(&req, NULL, 0); - GPR_ASSERT(0 == gpr_slice_str_cmp(slice, + GPR_ASSERT(0 == grpc_slice_str_cmp(slice, "POST /index.html HTTP/1.0\r\n" "Host: example.com\r\n" "Connection: close\r\n" @@ -115,13 +115,13 @@ static void test_format_post_request_no_body(void) { "x-yz: abc\r\n" "\r\n")); - gpr_slice_unref(slice); + grpc_slice_unref(slice); } static void test_format_post_request_content_type_override(void) { grpc_http_header hdrs[2]; grpc_httpcli_request req; - gpr_slice slice; + grpc_slice slice; char body_bytes[] = "fake%20body"; size_t body_len = 11; @@ -137,7 +137,7 @@ static void test_format_post_request_content_type_override(void) { slice = grpc_httpcli_format_post_request(&req, body_bytes, body_len); - GPR_ASSERT(0 == gpr_slice_str_cmp( + GPR_ASSERT(0 == grpc_slice_str_cmp( slice, "POST /index.html HTTP/1.0\r\n" "Host: example.com\r\n" @@ -149,7 +149,7 @@ static void test_format_post_request_content_type_override(void) { "\r\n" "fake%20body")); - gpr_slice_unref(slice); + grpc_slice_unref(slice); } int main(int argc, char **argv) { diff --git a/test/core/http/parser_test.c b/test/core/http/parser_test.c index 2fc354d9ee..4f1445d3f1 100644 --- a/test/core/http/parser_test.c +++ b/test/core/http/parser_test.c @@ -48,23 +48,23 @@ static void test_request_succeeds(grpc_slice_split_mode split_mode, grpc_http_version expect_version, char *expect_path, char *expect_body, ...) { grpc_http_parser parser; - gpr_slice input_slice = gpr_slice_from_copied_string(request_text); + grpc_slice input_slice = grpc_slice_from_copied_string(request_text); size_t num_slices; size_t i; - gpr_slice *slices; + grpc_slice *slices; va_list args; grpc_http_request request; memset(&request, 0, sizeof(request)); grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices); - gpr_slice_unref(input_slice); + grpc_slice_unref(input_slice); grpc_http_parser_init(&parser, GRPC_HTTP_REQUEST, &request); for (i = 0; i < num_slices; i++) { GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i], NULL) == GRPC_ERROR_NONE); - gpr_slice_unref(slices[i]); + grpc_slice_unref(slices[i]); } GPR_ASSERT(grpc_http_parser_eof(&parser) == GRPC_ERROR_NONE); @@ -105,23 +105,23 @@ static void test_request_succeeds(grpc_slice_split_mode split_mode, static void test_succeeds(grpc_slice_split_mode split_mode, char *response_text, int expect_status, char *expect_body, ...) { grpc_http_parser parser; - gpr_slice input_slice = gpr_slice_from_copied_string(response_text); + grpc_slice input_slice = grpc_slice_from_copied_string(response_text); size_t num_slices; size_t i; - gpr_slice *slices; + grpc_slice *slices; va_list args; grpc_http_response response; memset(&response, 0, sizeof(response)); grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices); - gpr_slice_unref(input_slice); + grpc_slice_unref(input_slice); grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response); for (i = 0; i < num_slices; i++) { GPR_ASSERT(grpc_http_parser_parse(&parser, slices[i], NULL) == GRPC_ERROR_NONE); - gpr_slice_unref(slices[i]); + grpc_slice_unref(slices[i]); } GPR_ASSERT(grpc_http_parser_eof(&parser) == GRPC_ERROR_NONE); @@ -158,16 +158,16 @@ static void test_succeeds(grpc_slice_split_mode split_mode, char *response_text, static void test_fails(grpc_slice_split_mode split_mode, char *response_text) { grpc_http_parser parser; - gpr_slice input_slice = gpr_slice_from_copied_string(response_text); + grpc_slice input_slice = grpc_slice_from_copied_string(response_text); size_t num_slices; size_t i; - gpr_slice *slices; + grpc_slice *slices; grpc_error *error = GRPC_ERROR_NONE; grpc_http_response response; memset(&response, 0, sizeof(response)); grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices); - gpr_slice_unref(input_slice); + grpc_slice_unref(input_slice); grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response); @@ -175,7 +175,7 @@ static void test_fails(grpc_slice_split_mode split_mode, char *response_text) { if (GRPC_ERROR_NONE == error) { error = grpc_http_parser_parse(&parser, slices[i], NULL); } - gpr_slice_unref(slices[i]); + grpc_slice_unref(slices[i]); } if (GRPC_ERROR_NONE == error) { error = grpc_http_parser_eof(&parser); @@ -191,16 +191,16 @@ static void test_fails(grpc_slice_split_mode split_mode, char *response_text) { static void test_request_fails(grpc_slice_split_mode split_mode, char *request_text) { grpc_http_parser parser; - gpr_slice input_slice = gpr_slice_from_copied_string(request_text); + grpc_slice input_slice = grpc_slice_from_copied_string(request_text); size_t num_slices; size_t i; - gpr_slice *slices; + grpc_slice *slices; grpc_error *error = GRPC_ERROR_NONE; grpc_http_request request; memset(&request, 0, sizeof(request)); grpc_split_slices(split_mode, &input_slice, 1, &slices, &num_slices); - gpr_slice_unref(input_slice); + grpc_slice_unref(input_slice); grpc_http_parser_init(&parser, GRPC_HTTP_REQUEST, &request); @@ -208,7 +208,7 @@ static void test_request_fails(grpc_slice_split_mode split_mode, if (error == GRPC_ERROR_NONE) { error = grpc_http_parser_parse(&parser, slices[i], NULL); } - gpr_slice_unref(slices[i]); + grpc_slice_unref(slices[i]); } if (error == GRPC_ERROR_NONE) { error = grpc_http_parser_eof(&parser); diff --git a/test/core/http/request_fuzzer.c b/test/core/http/request_fuzzer.c index bb6cb92c0c..98e2c9680d 100644 --- a/test/core/http/request_fuzzer.c +++ b/test/core/http/request_fuzzer.c @@ -47,10 +47,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_http_request request; memset(&request, 0, sizeof(request)); grpc_http_parser_init(&parser, GRPC_HTTP_REQUEST, &request); - gpr_slice slice = gpr_slice_from_copied_buffer((const char *)data, size); + grpc_slice slice = grpc_slice_from_copied_buffer((const char *)data, size); GRPC_ERROR_UNREF(grpc_http_parser_parse(&parser, slice, NULL)); GRPC_ERROR_UNREF(grpc_http_parser_eof(&parser)); - gpr_slice_unref(slice); + grpc_slice_unref(slice); grpc_http_parser_destroy(&parser); grpc_http_request_destroy(&request); return 0; diff --git a/test/core/http/response_fuzzer.c b/test/core/http/response_fuzzer.c index 4393840484..fff04117b2 100644 --- a/test/core/http/response_fuzzer.c +++ b/test/core/http/response_fuzzer.c @@ -46,10 +46,10 @@ int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { grpc_http_response response; memset(&response, 0, sizeof(response)); grpc_http_parser_init(&parser, GRPC_HTTP_RESPONSE, &response); - gpr_slice slice = gpr_slice_from_copied_buffer((const char *)data, size); + grpc_slice slice = grpc_slice_from_copied_buffer((const char *)data, size); GRPC_ERROR_UNREF(grpc_http_parser_parse(&parser, slice, NULL)); GRPC_ERROR_UNREF(grpc_http_parser_eof(&parser)); - gpr_slice_unref(slice); + grpc_slice_unref(slice); grpc_http_parser_destroy(&parser); grpc_http_response_destroy(&response); return 0; diff --git a/test/core/internal_api_canaries/transport.c b/test/core/internal_api_canaries/transport.c index 0617865412..2989f59535 100644 --- a/test/core/internal_api_canaries/transport.c +++ b/test/core/internal_api_canaries/transport.c @@ -69,7 +69,7 @@ static void test_code(void) { grpc_transport_perform_op(&transport, NULL, NULL); grpc_transport_ping(&transport, NULL); grpc_transport_goaway(&transport, GRPC_STATUS_UNAVAILABLE, - gpr_slice_malloc(0)); + grpc_slice_malloc(0)); grpc_transport_close(&transport); grpc_transport_destroy(&transport, NULL); GPR_ASSERT("xyz" == grpc_transport_get_peer(&transport, NULL)); diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c index b79c22e42a..775c0a3e6b 100644 --- a/test/core/iomgr/endpoint_tests.c +++ b/test/core/iomgr/endpoint_tests.c @@ -62,7 +62,7 @@ static gpr_mu *g_mu; static grpc_pollset *g_pollset; -size_t count_slices(gpr_slice *slices, size_t nslices, int *current_data) { +size_t count_slices(grpc_slice *slices, size_t nslices, int *current_data) { size_t num_bytes = 0; size_t i; size_t j; @@ -87,10 +87,10 @@ static grpc_endpoint_test_fixture begin_test(grpc_endpoint_test_config config, static void end_test(grpc_endpoint_test_config config) { config.clean_up(); } -static gpr_slice *allocate_blocks(size_t num_bytes, size_t slice_size, +static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size, size_t *num_blocks, uint8_t *current_data) { size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1 : 0); - gpr_slice *slices = gpr_malloc(sizeof(gpr_slice) * nslices); + grpc_slice *slices = gpr_malloc(sizeof(grpc_slice) * nslices); size_t num_bytes_left = num_bytes; size_t i; size_t j; @@ -98,7 +98,7 @@ static gpr_slice *allocate_blocks(size_t num_bytes, size_t slice_size, *num_blocks = nslices; for (i = 0; i < nslices; ++i) { - slices[i] = gpr_slice_malloc(slice_size > num_bytes_left ? num_bytes_left + slices[i] = grpc_slice_malloc(slice_size > num_bytes_left ? num_bytes_left : slice_size); num_bytes_left -= GPR_SLICE_LENGTH(slices[i]); buf = GPR_SLICE_START_PTR(slices[i]); @@ -122,8 +122,8 @@ struct read_and_write_test_state { uint8_t current_write_data; int read_done; int write_done; - gpr_slice_buffer incoming; - gpr_slice_buffer outgoing; + grpc_slice_buffer incoming; + grpc_slice_buffer outgoing; grpc_closure done_read; grpc_closure done_write; }; @@ -149,7 +149,7 @@ static void read_and_write_test_read_handler(grpc_exec_ctx *exec_ctx, static void read_and_write_test_write_handler(grpc_exec_ctx *exec_ctx, void *data, grpc_error *error) { struct read_and_write_test_state *state = data; - gpr_slice *slices = NULL; + grpc_slice *slices = NULL; size_t nslices; if (error == GRPC_ERROR_NONE) { @@ -161,8 +161,8 @@ static void read_and_write_test_write_handler(grpc_exec_ctx *exec_ctx, if (state->current_write_size != 0) { slices = allocate_blocks(state->current_write_size, 8192, &nslices, &state->current_write_data); - gpr_slice_buffer_reset_and_unref(&state->outgoing); - gpr_slice_buffer_addn(&state->outgoing, slices, nslices); + grpc_slice_buffer_reset_and_unref(&state->outgoing); + grpc_slice_buffer_addn(&state->outgoing, slices, nslices); grpc_endpoint_write(exec_ctx, state->write_ep, &state->outgoing, &state->done_write); gpr_free(slices); @@ -214,8 +214,8 @@ static void read_and_write_test(grpc_endpoint_test_config config, grpc_closure_init(&state.done_read, read_and_write_test_read_handler, &state); grpc_closure_init(&state.done_write, read_and_write_test_write_handler, &state); - gpr_slice_buffer_init(&state.outgoing); - gpr_slice_buffer_init(&state.incoming); + grpc_slice_buffer_init(&state.outgoing); + grpc_slice_buffer_init(&state.incoming); /* Get started by pretending an initial write completed */ /* NOTE: Sets up initial conditions so we can have the same write handler @@ -249,8 +249,8 @@ static void read_and_write_test(grpc_endpoint_test_config config, grpc_exec_ctx_flush(&exec_ctx); end_test(config); - gpr_slice_buffer_destroy(&state.outgoing); - gpr_slice_buffer_destroy(&state.incoming); + grpc_slice_buffer_destroy(&state.outgoing); + grpc_slice_buffer_destroy(&state.incoming); grpc_endpoint_destroy(&exec_ctx, state.read_ep); grpc_endpoint_destroy(&exec_ctx, state.write_ep); grpc_exec_ctx_finish(&exec_ctx); @@ -284,8 +284,8 @@ static void multiple_shutdown_test(grpc_endpoint_test_config config) { begin_test(config, "multiple_shutdown_test", 128); int fail_count = 0; - gpr_slice_buffer slice_buffer; - gpr_slice_buffer_init(&slice_buffer); + grpc_slice_buffer slice_buffer; + grpc_slice_buffer_init(&slice_buffer); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_endpoint_add_to_pollset(&exec_ctx, f.client_ep, g_pollset); @@ -297,14 +297,14 @@ static void multiple_shutdown_test(grpc_endpoint_test_config config) { grpc_endpoint_read(&exec_ctx, f.client_ep, &slice_buffer, grpc_closure_create(inc_on_failure, &fail_count)); wait_for_fail_count(&exec_ctx, &fail_count, 2); - gpr_slice_buffer_add(&slice_buffer, gpr_slice_from_copied_string("a")); + grpc_slice_buffer_add(&slice_buffer, grpc_slice_from_copied_string("a")); grpc_endpoint_write(&exec_ctx, f.client_ep, &slice_buffer, grpc_closure_create(inc_on_failure, &fail_count)); wait_for_fail_count(&exec_ctx, &fail_count, 3); grpc_endpoint_shutdown(&exec_ctx, f.client_ep); wait_for_fail_count(&exec_ctx, &fail_count, 3); - gpr_slice_buffer_destroy(&slice_buffer); + grpc_slice_buffer_destroy(&slice_buffer); grpc_endpoint_destroy(&exec_ctx, f.client_ep); grpc_endpoint_destroy(&exec_ctx, f.server_ep); diff --git a/test/core/iomgr/load_file_test.c b/test/core/iomgr/load_file_test.c index f70295a81c..c7387fe7a4 100644 --- a/test/core/iomgr/load_file_test.c +++ b/test/core/iomgr/load_file_test.c @@ -49,8 +49,8 @@ static const char prefix[] = "file_test"; static void test_load_empty_file(void) { FILE *tmp = NULL; - gpr_slice slice; - gpr_slice slice_with_null_term; + grpc_slice slice; + grpc_slice slice_with_null_term; grpc_error *error; char *tmp_name; @@ -72,13 +72,13 @@ static void test_load_empty_file(void) { remove(tmp_name); gpr_free(tmp_name); - gpr_slice_unref(slice); - gpr_slice_unref(slice_with_null_term); + grpc_slice_unref(slice); + grpc_slice_unref(slice_with_null_term); } static void test_load_failure(void) { FILE *tmp = NULL; - gpr_slice slice; + grpc_slice slice; grpc_error *error; char *tmp_name; @@ -95,13 +95,13 @@ static void test_load_failure(void) { GRPC_ERROR_UNREF(error); GPR_ASSERT(GPR_SLICE_LENGTH(slice) == 0); gpr_free(tmp_name); - gpr_slice_unref(slice); + grpc_slice_unref(slice); } static void test_load_small_file(void) { FILE *tmp = NULL; - gpr_slice slice; - gpr_slice slice_with_null_term; + grpc_slice slice; + grpc_slice slice_with_null_term; grpc_error *error; char *tmp_name; const char *blah = "blah"; @@ -127,13 +127,13 @@ static void test_load_small_file(void) { remove(tmp_name); gpr_free(tmp_name); - gpr_slice_unref(slice); - gpr_slice_unref(slice_with_null_term); + grpc_slice_unref(slice); + grpc_slice_unref(slice_with_null_term); } static void test_load_big_file(void) { FILE *tmp = NULL; - gpr_slice slice; + grpc_slice slice; grpc_error *error; char *tmp_name; static const size_t buffer_size = 124631; @@ -161,7 +161,7 @@ static void test_load_big_file(void) { remove(tmp_name); gpr_free(tmp_name); - gpr_slice_unref(slice); + grpc_slice_unref(slice); gpr_free(buffer); } diff --git a/test/core/iomgr/resource_quota_test.c b/test/core/iomgr/resource_quota_test.c index 5e2f9f8359..85c6ce6e70 100644 --- a/test/core/iomgr/resource_quota_test.c +++ b/test/core/iomgr/resource_quota_test.c @@ -657,8 +657,8 @@ static void test_one_slice(void) { grpc_resource_user_slice_allocator_init(&alloc, &usr, inc_int_cb, &num_allocs); - gpr_slice_buffer buffer; - gpr_slice_buffer_init(&buffer); + grpc_slice_buffer buffer; + grpc_slice_buffer_init(&buffer); { const int start_allocs = num_allocs; @@ -668,7 +668,7 @@ static void test_one_slice(void) { GPR_ASSERT(num_allocs == start_allocs + 1); } - gpr_slice_buffer_destroy(&buffer); + grpc_slice_buffer_destroy(&buffer); destroy_user(&usr); grpc_resource_quota_unref(q); } @@ -688,8 +688,8 @@ static void test_one_slice_deleted_late(void) { grpc_resource_user_slice_allocator_init(&alloc, &usr, inc_int_cb, &num_allocs); - gpr_slice_buffer buffer; - gpr_slice_buffer_init(&buffer); + grpc_slice_buffer buffer; + grpc_slice_buffer_init(&buffer); { const int start_allocs = num_allocs; @@ -708,7 +708,7 @@ static void test_one_slice_deleted_late(void) { } grpc_resource_quota_unref(q); - gpr_slice_buffer_destroy(&buffer); + grpc_slice_buffer_destroy(&buffer); GPR_ASSERT(done); { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c index 3f2e19ffd8..a259390d5e 100644 --- a/test/core/iomgr/tcp_posix_test.c +++ b/test/core/iomgr/tcp_posix_test.c @@ -119,11 +119,11 @@ struct read_socket_state { grpc_endpoint *ep; size_t read_bytes; size_t target_read_bytes; - gpr_slice_buffer incoming; + grpc_slice_buffer incoming; grpc_closure read_cb; }; -static size_t count_slices(gpr_slice *slices, size_t nslices, +static size_t count_slices(grpc_slice *slices, size_t nslices, int *current_data) { size_t num_bytes = 0; unsigned i, j; @@ -188,7 +188,7 @@ static void read_test(size_t num_bytes, size_t slice_size) { state.ep = ep; state.read_bytes = 0; state.target_read_bytes = written_bytes; - gpr_slice_buffer_init(&state.incoming); + grpc_slice_buffer_init(&state.incoming); grpc_closure_init(&state.read_cb, read_cb, &state); grpc_endpoint_read(&exec_ctx, ep, &state.incoming, &state.read_cb); @@ -207,7 +207,7 @@ static void read_test(size_t num_bytes, size_t slice_size) { GPR_ASSERT(state.read_bytes == state.target_read_bytes); gpr_mu_unlock(g_mu); - gpr_slice_buffer_destroy(&state.incoming); + grpc_slice_buffer_destroy(&state.incoming); grpc_endpoint_destroy(&exec_ctx, ep); grpc_exec_ctx_finish(&exec_ctx); } @@ -239,7 +239,7 @@ static void large_read_test(size_t slice_size) { state.ep = ep; state.read_bytes = 0; state.target_read_bytes = (size_t)written_bytes; - gpr_slice_buffer_init(&state.incoming); + grpc_slice_buffer_init(&state.incoming); grpc_closure_init(&state.read_cb, read_cb, &state); grpc_endpoint_read(&exec_ctx, ep, &state.incoming, &state.read_cb); @@ -258,7 +258,7 @@ static void large_read_test(size_t slice_size) { GPR_ASSERT(state.read_bytes == state.target_read_bytes); gpr_mu_unlock(g_mu); - gpr_slice_buffer_destroy(&state.incoming); + grpc_slice_buffer_destroy(&state.incoming); grpc_endpoint_destroy(&exec_ctx, ep); grpc_exec_ctx_finish(&exec_ctx); } @@ -268,17 +268,17 @@ struct write_socket_state { int write_done; }; -static gpr_slice *allocate_blocks(size_t num_bytes, size_t slice_size, +static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size, size_t *num_blocks, uint8_t *current_data) { size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1u : 0u); - gpr_slice *slices = gpr_malloc(sizeof(gpr_slice) * nslices); + grpc_slice *slices = gpr_malloc(sizeof(grpc_slice) * nslices); size_t num_bytes_left = num_bytes; unsigned i, j; unsigned char *buf; *num_blocks = nslices; for (i = 0; i < nslices; ++i) { - slices[i] = gpr_slice_malloc(slice_size > num_bytes_left ? num_bytes_left + slices[i] = grpc_slice_malloc(slice_size > num_bytes_left ? num_bytes_left : slice_size); num_bytes_left -= GPR_SLICE_LENGTH(slices[i]); buf = GPR_SLICE_START_PTR(slices[i]); @@ -352,9 +352,9 @@ static void write_test(size_t num_bytes, size_t slice_size) { grpc_endpoint *ep; struct write_socket_state state; size_t num_blocks; - gpr_slice *slices; + grpc_slice *slices; uint8_t current_data = 0; - gpr_slice_buffer outgoing; + grpc_slice_buffer outgoing; grpc_closure write_done_closure; gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -377,8 +377,8 @@ static void write_test(size_t num_bytes, size_t slice_size) { slices = allocate_blocks(num_bytes, slice_size, &num_blocks, ¤t_data); - gpr_slice_buffer_init(&outgoing); - gpr_slice_buffer_addn(&outgoing, slices, num_blocks); + grpc_slice_buffer_init(&outgoing); + grpc_slice_buffer_addn(&outgoing, slices, num_blocks); grpc_closure_init(&write_done_closure, write_done, &state); grpc_endpoint_write(&exec_ctx, ep, &outgoing, &write_done_closure); @@ -399,7 +399,7 @@ static void write_test(size_t num_bytes, size_t slice_size) { } gpr_mu_unlock(g_mu); - gpr_slice_buffer_destroy(&outgoing); + grpc_slice_buffer_destroy(&outgoing); grpc_endpoint_destroy(&exec_ctx, ep); gpr_free(slices); grpc_exec_ctx_finish(&exec_ctx); @@ -446,7 +446,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { state.ep = ep; state.read_bytes = 0; state.target_read_bytes = written_bytes; - gpr_slice_buffer_init(&state.incoming); + grpc_slice_buffer_init(&state.incoming); grpc_closure_init(&state.read_cb, read_cb, &state); grpc_endpoint_read(&exec_ctx, ep, &state.incoming, &state.read_cb); @@ -467,7 +467,7 @@ static void release_fd_test(size_t num_bytes, size_t slice_size) { GPR_ASSERT(state.read_bytes == state.target_read_bytes); gpr_mu_unlock(g_mu); - gpr_slice_buffer_destroy(&state.incoming); + grpc_slice_buffer_destroy(&state.incoming); grpc_tcp_destroy_and_release_fd(&exec_ctx, ep, &fd, &fd_released_cb); grpc_exec_ctx_flush(&exec_ctx); gpr_mu_lock(g_mu); diff --git a/test/core/nanopb/fuzzer_response.c b/test/core/nanopb/fuzzer_response.c index a82f20df83..202c120c67 100644 --- a/test/core/nanopb/fuzzer_response.c +++ b/test/core/nanopb/fuzzer_response.c @@ -45,11 +45,11 @@ static void dont_log(gpr_log_func_args *args) {} int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if (squelch) gpr_set_log_function(dont_log); - gpr_slice slice = gpr_slice_from_copied_buffer((const char *)data, size); + grpc_slice slice = grpc_slice_from_copied_buffer((const char *)data, size); grpc_grpclb_initial_response *response; if ((response = grpc_grpclb_initial_response_parse(slice))) { grpc_grpclb_initial_response_destroy(response); } - gpr_slice_unref(slice); + grpc_slice_unref(slice); return 0; } diff --git a/test/core/nanopb/fuzzer_serverlist.c b/test/core/nanopb/fuzzer_serverlist.c index 9700bf1cda..b225ae0d51 100644 --- a/test/core/nanopb/fuzzer_serverlist.c +++ b/test/core/nanopb/fuzzer_serverlist.c @@ -45,11 +45,11 @@ static void dont_log(gpr_log_func_args *args) {} int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { if (squelch) gpr_set_log_function(dont_log); - gpr_slice slice = gpr_slice_from_copied_buffer((const char *)data, size); + grpc_slice slice = grpc_slice_from_copied_buffer((const char *)data, size); grpc_grpclb_serverlist *serverlist; if ((serverlist = grpc_grpclb_response_parse_serverlist(slice))) { grpc_grpclb_destroy_serverlist(serverlist); } - gpr_slice_unref(slice); + grpc_slice_unref(slice); return 0; } diff --git a/test/core/security/b64_test.c b/test/core/security/b64_test.c index b26bd026fd..f88be392a2 100644 --- a/test/core/security/b64_test.c +++ b/test/core/security/b64_test.c @@ -57,12 +57,12 @@ static void test_simple_encode_decode_b64(int url_safe, int multiline) { const char *hello = "hello"; char *hello_b64 = grpc_base64_encode(hello, strlen(hello), url_safe, multiline); - gpr_slice hello_slice = grpc_base64_decode(hello_b64, url_safe); + grpc_slice hello_slice = grpc_base64_decode(hello_b64, url_safe); GPR_ASSERT(GPR_SLICE_LENGTH(hello_slice) == strlen(hello)); GPR_ASSERT(strncmp((const char *)GPR_SLICE_START_PTR(hello_slice), hello, GPR_SLICE_LENGTH(hello_slice)) == 0); - gpr_slice_unref(hello_slice); + grpc_slice_unref(hello_slice); gpr_free(hello_b64); } @@ -70,7 +70,7 @@ static void test_full_range_encode_decode_b64(int url_safe, int multiline) { unsigned char orig[256]; size_t i; char *b64; - gpr_slice orig_decoded; + grpc_slice orig_decoded; for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i; /* Try all the different paddings. */ @@ -80,7 +80,7 @@ static void test_full_range_encode_decode_b64(int url_safe, int multiline) { GPR_ASSERT(GPR_SLICE_LENGTH(orig_decoded) == (sizeof(orig) - i)); GPR_ASSERT(buffers_are_equal(orig, GPR_SLICE_START_PTR(orig_decoded), sizeof(orig) - i)); - gpr_slice_unref(orig_decoded); + grpc_slice_unref(orig_decoded); gpr_free(b64); } } @@ -121,7 +121,7 @@ static void test_url_safe_unsafe_mismtach_failure(void) { unsigned char orig[256]; size_t i; char *b64; - gpr_slice orig_decoded; + grpc_slice orig_decoded; int url_safe = 1; for (i = 0; i < sizeof(orig); i++) orig[i] = (uint8_t)i; @@ -129,13 +129,13 @@ static void test_url_safe_unsafe_mismtach_failure(void) { orig_decoded = grpc_base64_decode(b64, !url_safe); GPR_ASSERT(GPR_SLICE_IS_EMPTY(orig_decoded)); gpr_free(b64); - gpr_slice_unref(orig_decoded); + grpc_slice_unref(orig_decoded); b64 = grpc_base64_encode(orig, sizeof(orig), !url_safe, 0); orig_decoded = grpc_base64_decode(b64, url_safe); GPR_ASSERT(GPR_SLICE_IS_EMPTY(orig_decoded)); gpr_free(b64); - gpr_slice_unref(orig_decoded); + grpc_slice_unref(orig_decoded); } static void test_rfc4648_test_vectors(void) { @@ -171,37 +171,37 @@ static void test_rfc4648_test_vectors(void) { } static void test_unpadded_decode(void) { - gpr_slice decoded; + grpc_slice decoded; decoded = grpc_base64_decode("Zm9vYmFy", 0); GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(gpr_slice_str_cmp(decoded, "foobar") == 0); - gpr_slice_unref(decoded); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "foobar") == 0); + grpc_slice_unref(decoded); decoded = grpc_base64_decode("Zm9vYmE", 0); GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(gpr_slice_str_cmp(decoded, "fooba") == 0); - gpr_slice_unref(decoded); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "fooba") == 0); + grpc_slice_unref(decoded); decoded = grpc_base64_decode("Zm9vYg", 0); GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(gpr_slice_str_cmp(decoded, "foob") == 0); - gpr_slice_unref(decoded); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "foob") == 0); + grpc_slice_unref(decoded); decoded = grpc_base64_decode("Zm9v", 0); GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(gpr_slice_str_cmp(decoded, "foo") == 0); - gpr_slice_unref(decoded); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "foo") == 0); + grpc_slice_unref(decoded); decoded = grpc_base64_decode("Zm8", 0); GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(gpr_slice_str_cmp(decoded, "fo") == 0); - gpr_slice_unref(decoded); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "fo") == 0); + grpc_slice_unref(decoded); decoded = grpc_base64_decode("Zg", 0); GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); - GPR_ASSERT(gpr_slice_str_cmp(decoded, "f") == 0); - gpr_slice_unref(decoded); + GPR_ASSERT(grpc_slice_str_cmp(decoded, "f") == 0); + grpc_slice_unref(decoded); decoded = grpc_base64_decode("", 0); GPR_ASSERT(GPR_SLICE_IS_EMPTY(decoded)); diff --git a/test/core/security/create_jwt.c b/test/core/security/create_jwt.c index 1bd135f175..8b78dc5da5 100644 --- a/test/core/security/create_jwt.c +++ b/test/core/security/create_jwt.c @@ -46,12 +46,12 @@ void create_jwt(const char *json_key_file_path, const char *service_url, const char *scope) { grpc_auth_json_key key; char *jwt; - gpr_slice json_key_data; + grpc_slice json_key_data; GPR_ASSERT(GRPC_LOG_IF_ERROR( "load_file", grpc_load_file(json_key_file_path, 1, &json_key_data))); key = grpc_auth_json_key_create_from_string( (const char *)GPR_SLICE_START_PTR(json_key_data)); - gpr_slice_unref(json_key_data); + grpc_slice_unref(json_key_data); if (!grpc_auth_json_key_is_valid(&key)) { fprintf(stderr, "Could not parse json key.\n"); exit(1); diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.c index 2f8ffe4da6..d8bde4f2c2 100644 --- a/test/core/security/credentials_test.c +++ b/test/core/security/credentials_test.c @@ -187,14 +187,14 @@ static void test_add_to_empty_md_store(void) { grpc_credentials_md_store *store = grpc_credentials_md_store_create(0); const char *key_str = "hello"; const char *value_str = "there blah blah blah blah blah blah blah"; - gpr_slice key = gpr_slice_from_copied_string(key_str); - gpr_slice value = gpr_slice_from_copied_string(value_str); + grpc_slice key = grpc_slice_from_copied_string(key_str); + grpc_slice value = grpc_slice_from_copied_string(value_str); grpc_credentials_md_store_add(store, key, value); GPR_ASSERT(store->num_entries == 1); - GPR_ASSERT(gpr_slice_cmp(key, store->entries[0].key) == 0); - GPR_ASSERT(gpr_slice_cmp(value, store->entries[0].value) == 0); - gpr_slice_unref(key); - gpr_slice_unref(value); + GPR_ASSERT(grpc_slice_cmp(key, store->entries[0].key) == 0); + GPR_ASSERT(grpc_slice_cmp(value, store->entries[0].value) == 0); + grpc_slice_unref(key); + grpc_slice_unref(value); grpc_credentials_md_store_unref(store); } @@ -204,8 +204,8 @@ static void test_add_cstrings_to_empty_md_store(void) { const char *value_str = "there blah blah blah blah blah blah blah"; grpc_credentials_md_store_add_cstrings(store, key_str, value_str); GPR_ASSERT(store->num_entries == 1); - GPR_ASSERT(gpr_slice_str_cmp(store->entries[0].key, key_str) == 0); - GPR_ASSERT(gpr_slice_str_cmp(store->entries[0].value, value_str) == 0); + GPR_ASSERT(grpc_slice_str_cmp(store->entries[0].key, key_str) == 0); + GPR_ASSERT(grpc_slice_str_cmp(store->entries[0].value, value_str) == 0); grpc_credentials_md_store_unref(store); } @@ -227,8 +227,8 @@ static void test_add_abunch_to_md_store(void) { grpc_credentials_md_store_add_cstrings(store, key_str, value_str); } for (i = 0; i < num_entries; i++) { - GPR_ASSERT(gpr_slice_str_cmp(store->entries[i].key, key_str) == 0); - GPR_ASSERT(gpr_slice_str_cmp(store->entries[i].value, value_str) == 0); + GPR_ASSERT(grpc_slice_str_cmp(store->entries[i].key, key_str) == 0); + GPR_ASSERT(grpc_slice_str_cmp(store->entries[i].value, value_str) == 0); } grpc_credentials_md_store_unref(store); } @@ -243,8 +243,8 @@ static void test_oauth2_token_fetcher_creds_parsing_ok(void) { GPR_ASSERT(token_lifetime.tv_sec == 3599); GPR_ASSERT(token_lifetime.tv_nsec == 0); GPR_ASSERT(token_md->num_entries == 1); - GPR_ASSERT(gpr_slice_str_cmp(token_md->entries[0].key, "authorization") == 0); - GPR_ASSERT(gpr_slice_str_cmp(token_md->entries[0].value, + GPR_ASSERT(grpc_slice_str_cmp(token_md->entries[0].key, "authorization") == 0); + GPR_ASSERT(grpc_slice_str_cmp(token_md->entries[0].value, "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_") == 0); grpc_credentials_md_store_unref(token_md); @@ -333,8 +333,8 @@ static void check_metadata(expected_md *expected, grpc_credentials_md *md_elems, for (i = 0; i < num_md; i++) { size_t j; for (j = 0; j < num_md; j++) { - if (0 == gpr_slice_str_cmp(md_elems[j].key, expected[i].key)) { - GPR_ASSERT(gpr_slice_str_cmp(md_elems[j].value, expected[i].value) == + if (0 == grpc_slice_str_cmp(md_elems[j].key, expected[i].key)) { + GPR_ASSERT(grpc_slice_str_cmp(md_elems[j].value, expected[i].value) == 0); break; } @@ -528,8 +528,8 @@ static void on_oauth2_creds_get_metadata_success( GPR_ASSERT(status == GRPC_CREDENTIALS_OK); GPR_ASSERT(error_details == NULL); GPR_ASSERT(num_md == 1); - GPR_ASSERT(gpr_slice_str_cmp(md_elems[0].key, "authorization") == 0); - GPR_ASSERT(gpr_slice_str_cmp(md_elems[0].value, + GPR_ASSERT(grpc_slice_str_cmp(md_elems[0].key, "authorization") == 0); + GPR_ASSERT(grpc_slice_str_cmp(md_elems[0].value, "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_") == 0); GPR_ASSERT(user_data != NULL); @@ -781,8 +781,8 @@ static void on_jwt_creds_get_metadata_success( GPR_ASSERT(status == GRPC_CREDENTIALS_OK); GPR_ASSERT(error_details == NULL); GPR_ASSERT(num_md == 1); - GPR_ASSERT(gpr_slice_str_cmp(md_elems[0].key, "authorization") == 0); - GPR_ASSERT(gpr_slice_str_cmp(md_elems[0].value, expected_md_value) == 0); + GPR_ASSERT(grpc_slice_str_cmp(md_elems[0].key, "authorization") == 0); + GPR_ASSERT(grpc_slice_str_cmp(md_elems[0].value, expected_md_value) == 0); GPR_ASSERT(user_data != NULL); GPR_ASSERT(strcmp((const char *)user_data, test_user_data) == 0); gpr_free(expected_md_value); @@ -1057,8 +1057,8 @@ static void on_plugin_metadata_received_success( GPR_ASSERT(md_elems != NULL); GPR_ASSERT(num_md == GPR_ARRAY_SIZE(plugin_md)); for (i = 0; i < num_md; i++) { - GPR_ASSERT(gpr_slice_str_cmp(md_elems[i].key, plugin_md[i].key) == 0); - GPR_ASSERT(gpr_slice_str_cmp(md_elems[i].value, plugin_md[i].value) == 0); + GPR_ASSERT(grpc_slice_str_cmp(md_elems[i].key, plugin_md[i].key) == 0); + GPR_ASSERT(grpc_slice_str_cmp(md_elems[i].value, plugin_md[i].value) == 0); } } diff --git a/test/core/security/fetch_oauth2.c b/test/core/security/fetch_oauth2.c index 292f59a7c1..aa3db9f398 100644 --- a/test/core/security/fetch_oauth2.c +++ b/test/core/security/fetch_oauth2.c @@ -48,7 +48,7 @@ static grpc_call_credentials *create_refresh_token_creds( const char *json_refresh_token_file_path) { - gpr_slice refresh_token; + grpc_slice refresh_token; GPR_ASSERT(GRPC_LOG_IF_ERROR( "load_file", grpc_load_file(json_refresh_token_file_path, 1, &refresh_token))); diff --git a/test/core/security/json_token_test.c b/test/core/security/json_token_test.c index 405fe56c46..162997662e 100644 --- a/test/core/security/json_token_test.c +++ b/test/core/security/json_token_test.c @@ -223,7 +223,7 @@ static grpc_json *parse_json_part_from_jwt(const char *str, size_t len, char *b64; char *decoded; grpc_json *json; - gpr_slice slice; + grpc_slice slice; b64 = gpr_malloc(len + 1); strncpy(b64, str, len); b64[len] = '\0'; @@ -236,7 +236,7 @@ static grpc_json *parse_json_part_from_jwt(const char *str, size_t len, json = grpc_json_parse_string(decoded); gpr_free(b64); *scratchpad = decoded; - gpr_slice_unref(slice); + grpc_slice_unref(slice); return json; } @@ -341,7 +341,7 @@ static void check_jwt_signature(const char *b64_signature, RSA *rsa_key, EVP_MD_CTX *md_ctx = EVP_MD_CTX_create(); EVP_PKEY *key = EVP_PKEY_new(); - gpr_slice sig = grpc_base64_decode(b64_signature, 1); + grpc_slice sig = grpc_base64_decode(b64_signature, 1); GPR_ASSERT(!GPR_SLICE_IS_EMPTY(sig)); GPR_ASSERT(GPR_SLICE_LENGTH(sig) == 128); @@ -355,7 +355,7 @@ static void check_jwt_signature(const char *b64_signature, RSA *rsa_key, GPR_ASSERT(EVP_DigestVerifyFinal(md_ctx, GPR_SLICE_START_PTR(sig), GPR_SLICE_LENGTH(sig)) == 1); - gpr_slice_unref(sig); + grpc_slice_unref(sig); if (key != NULL) EVP_PKEY_free(key); if (md_ctx != NULL) EVP_MD_CTX_destroy(md_ctx); } diff --git a/test/core/security/jwt_verifier_test.c b/test/core/security/jwt_verifier_test.c index 36b331a777..ce2ee04c99 100644 --- a/test/core/security/jwt_verifier_test.c +++ b/test/core/security/jwt_verifier_test.c @@ -181,7 +181,7 @@ typedef struct { static void test_claims_success(void) { grpc_jwt_claims *claims; - gpr_slice s = gpr_slice_from_copied_string(claims_without_time_constraint); + grpc_slice s = grpc_slice_from_copied_string(claims_without_time_constraint); grpc_json *json = grpc_json_parse_string_with_len( (char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s)); GPR_ASSERT(json != NULL); @@ -199,7 +199,7 @@ static void test_claims_success(void) { static void test_expired_claims_failure(void) { grpc_jwt_claims *claims; - gpr_slice s = gpr_slice_from_copied_string(expired_claims); + grpc_slice s = grpc_slice_from_copied_string(expired_claims); grpc_json *json = grpc_json_parse_string_with_len( (char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s)); gpr_timespec exp_iat = {100, 0, GPR_CLOCK_REALTIME}; @@ -223,7 +223,7 @@ static void test_expired_claims_failure(void) { } static void test_invalid_claims_failure(void) { - gpr_slice s = gpr_slice_from_copied_string(invalid_claims); + grpc_slice s = grpc_slice_from_copied_string(invalid_claims); grpc_json *json = grpc_json_parse_string_with_len( (char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s)); GPR_ASSERT(grpc_jwt_claims_from_json(json, s) == NULL); @@ -231,7 +231,7 @@ static void test_invalid_claims_failure(void) { static void test_bad_audience_claims_failure(void) { grpc_jwt_claims *claims; - gpr_slice s = gpr_slice_from_copied_string(claims_without_time_constraint); + grpc_slice s = grpc_slice_from_copied_string(claims_without_time_constraint); grpc_json *json = grpc_json_parse_string_with_len( (char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s)); GPR_ASSERT(json != NULL); @@ -478,7 +478,7 @@ static void test_jwt_verifier_bad_json_key(void) { } static void corrupt_jwt_sig(char *jwt) { - gpr_slice sig; + grpc_slice sig; char *bad_b64_sig; uint8_t *sig_bytes; char *last_dot = strrchr(jwt, '.'); @@ -491,7 +491,7 @@ static void corrupt_jwt_sig(char *jwt) { grpc_base64_encode(GPR_SLICE_START_PTR(sig), GPR_SLICE_LENGTH(sig), 1, 0); memcpy(last_dot + 1, bad_b64_sig, strlen(bad_b64_sig)); gpr_free(bad_b64_sig); - gpr_slice_unref(sig); + grpc_slice_unref(sig); } static void on_verification_bad_signature(void *user_data, diff --git a/test/core/security/oauth2_utils.c b/test/core/security/oauth2_utils.c index 9b97c38fcb..3b774fecb6 100644 --- a/test/core/security/oauth2_utils.c +++ b/test/core/security/oauth2_utils.c @@ -57,7 +57,7 @@ static void on_oauth2_response(grpc_exec_ctx *exec_ctx, void *user_data, const char *error_details) { oauth2_request *request = user_data; char *token = NULL; - gpr_slice token_slice; + grpc_slice token_slice; if (status == GRPC_CREDENTIALS_ERROR) { gpr_log(GPR_ERROR, "Fetching token failed."); } else { diff --git a/test/core/security/secure_endpoint_test.c b/test/core/security/secure_endpoint_test.c index 2262fde98d..e12ca48c2f 100644 --- a/test/core/security/secure_endpoint_test.c +++ b/test/core/security/secure_endpoint_test.c @@ -49,7 +49,7 @@ static gpr_mu *g_mu; static grpc_pollset *g_pollset; static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair( - size_t slice_size, gpr_slice *leftover_slices, size_t leftover_nslices) { + size_t slice_size, grpc_slice *leftover_slices, size_t leftover_nslices) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; tsi_frame_protector *fake_read_protector = tsi_create_fake_protector(NULL); tsi_frame_protector *fake_write_protector = tsi_create_fake_protector(NULL); @@ -74,9 +74,9 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair( size_t buffer_size = total_buffer_size; uint8_t *encrypted_buffer = gpr_malloc(buffer_size); uint8_t *cur = encrypted_buffer; - gpr_slice encrypted_leftover; + grpc_slice encrypted_leftover; for (i = 0; i < leftover_nslices; i++) { - gpr_slice plain = leftover_slices[i]; + grpc_slice plain = leftover_slices[i]; uint8_t *message_bytes = GPR_SLICE_START_PTR(plain); size_t message_size = GPR_SLICE_LENGTH(plain); while (message_size > 0) { @@ -92,7 +92,7 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair( GPR_ASSERT(buffer_size >= protected_buffer_size_to_send); buffer_size -= protected_buffer_size_to_send; } - gpr_slice_unref(plain); + grpc_slice_unref(plain); } do { size_t protected_buffer_size_to_send = buffer_size; @@ -104,11 +104,11 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair( GPR_ASSERT(buffer_size >= protected_buffer_size_to_send); buffer_size -= protected_buffer_size_to_send; } while (still_pending_size > 0); - encrypted_leftover = gpr_slice_from_copied_buffer( + encrypted_leftover = grpc_slice_from_copied_buffer( (const char *)encrypted_buffer, total_buffer_size - buffer_size); f.client_ep = grpc_secure_endpoint_create(fake_read_protector, tcp.client, &encrypted_leftover, 1); - gpr_slice_unref(encrypted_leftover); + grpc_slice_unref(encrypted_leftover); gpr_free(encrypted_buffer); } @@ -125,8 +125,8 @@ secure_endpoint_create_fixture_tcp_socketpair_noleftover(size_t slice_size) { static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair_leftover(size_t slice_size) { - gpr_slice s = - gpr_slice_from_copied_string("hello world 12345678900987654321"); + grpc_slice s = + grpc_slice_from_copied_string("hello world 12345678900987654321"); grpc_endpoint_test_fixture f; f = secure_endpoint_create_fixture_tcp_socketpair(slice_size, &s, 1); @@ -149,29 +149,29 @@ static void inc_call_ctr(grpc_exec_ctx *exec_ctx, void *arg, static void test_leftover(grpc_endpoint_test_config config, size_t slice_size) { grpc_endpoint_test_fixture f = config.create_fixture(slice_size); - gpr_slice_buffer incoming; - gpr_slice s = - gpr_slice_from_copied_string("hello world 12345678900987654321"); + grpc_slice_buffer incoming; + grpc_slice s = + grpc_slice_from_copied_string("hello world 12345678900987654321"); grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; int n = 0; grpc_closure done_closure; gpr_log(GPR_INFO, "Start test left over"); - gpr_slice_buffer_init(&incoming); + grpc_slice_buffer_init(&incoming); grpc_closure_init(&done_closure, inc_call_ctr, &n); grpc_endpoint_read(&exec_ctx, f.client_ep, &incoming, &done_closure); grpc_exec_ctx_finish(&exec_ctx); GPR_ASSERT(n == 1); GPR_ASSERT(incoming.count == 1); - GPR_ASSERT(0 == gpr_slice_cmp(s, incoming.slices[0])); + GPR_ASSERT(0 == grpc_slice_cmp(s, incoming.slices[0])); grpc_endpoint_shutdown(&exec_ctx, f.client_ep); grpc_endpoint_shutdown(&exec_ctx, f.server_ep); grpc_endpoint_destroy(&exec_ctx, f.client_ep); grpc_endpoint_destroy(&exec_ctx, f.server_ep); grpc_exec_ctx_finish(&exec_ctx); - gpr_slice_unref(s); - gpr_slice_buffer_destroy(&incoming); + grpc_slice_unref(s); + grpc_slice_buffer_destroy(&incoming); clean_up(); } diff --git a/test/core/security/security_connector_test.c b/test/core/security/security_connector_test.c index 6106bec9d3..4692db1853 100644 --- a/test/core/security/security_connector_test.c +++ b/test/core/security/security_connector_test.c @@ -368,9 +368,9 @@ static void test_default_ssl_roots(void) { value. */ gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, ""); grpc_set_ssl_roots_override_callback(override_roots_success); - gpr_slice roots = grpc_get_default_ssl_roots_for_testing(); + grpc_slice roots = grpc_get_default_ssl_roots_for_testing(); char *roots_contents = gpr_dump_slice(roots, GPR_DUMP_ASCII); - gpr_slice_unref(roots); + grpc_slice_unref(roots); GPR_ASSERT(strcmp(roots_contents, roots_for_override_api) == 0); gpr_free(roots_contents); @@ -379,7 +379,7 @@ static void test_default_ssl_roots(void) { gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, roots_env_var_file_path); roots = grpc_get_default_ssl_roots_for_testing(); roots_contents = gpr_dump_slice(roots, GPR_DUMP_ASCII); - gpr_slice_unref(roots); + grpc_slice_unref(roots); GPR_ASSERT(strcmp(roots_contents, roots_for_env_var) == 0); gpr_free(roots_contents); @@ -388,7 +388,7 @@ static void test_default_ssl_roots(void) { gpr_setenv(GRPC_DEFAULT_SSL_ROOTS_FILE_PATH_ENV_VAR, ""); roots = grpc_get_default_ssl_roots_for_testing(); roots_contents = gpr_dump_slice(roots, GPR_DUMP_ASCII); - gpr_slice_unref(roots); + grpc_slice_unref(roots); GPR_ASSERT(strcmp(roots_contents, roots_for_override_api) == 0); gpr_free(roots_contents); diff --git a/test/core/slice/percent_decode_corpus/04cb8ccc553f9b2f5e52c421aff6d1c954d3dae6 b/test/core/slice/percent_decode_corpus/04cb8ccc553f9b2f5e52c421aff6d1c954d3dae6 new file mode 100644 index 0000000000..a0c7605580 --- /dev/null +++ b/test/core/slice/percent_decode_corpus/04cb8ccc553f9b2f5e52c421aff6d1c954d3dae6 @@ -0,0 +1 @@ +:Ê%cE'yzŠ \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/0dd8f3a63745b3a2d39791559b5c1b311447b537 b/test/core/slice/percent_decode_corpus/0dd8f3a63745b3a2d39791559b5c1b311447b537 new file mode 100644 index 0000000000..8b36124b3f --- /dev/null +++ b/test/core/slice/percent_decode_corpus/0dd8f3a63745b3a2d39791559b5c1b311447b537 @@ -0,0 +1 @@ +x;x_%C88 \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/17eeaca784409adbe43365c32ac87915d736bba3 b/test/core/slice/percent_decode_corpus/17eeaca784409adbe43365c32ac87915d736bba3 new file mode 100644 index 0000000000..ea02afac49 --- /dev/null +++ b/test/core/slice/percent_decode_corpus/17eeaca784409adbe43365c32ac87915d736bba3 @@ -0,0 +1,2 @@ +xxyyz%øyzŠ[zxy'z + diff --git a/test/core/slice/percent_decode_corpus/2040c1ff65f52a7ae668c2c8f324de5dacc9d695 b/test/core/slice/percent_decode_corpus/2040c1ff65f52a7ae668c2c8f324de5dacc9d695 new file mode 100644 index 0000000000..9e9b466b2f --- /dev/null +++ b/test/core/slice/percent_decode_corpus/2040c1ff65f52a7ae668c2c8f324de5dacc9d695 @@ -0,0 +1 @@ +xx;x_%;:Ê%C)x_%C88c8E'yzŠ8 \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/26b0d1da23027ae54db96e125e4a9e98842d77fb b/test/core/slice/percent_decode_corpus/26b0d1da23027ae54db96e125e4a9e98842d77fb new file mode 100644 index 0000000000..88c739ecaa --- /dev/null +++ b/test/core/slice/percent_decode_corpus/26b0d1da23027ae54db96e125e4a9e98842d77fb @@ -0,0 +1 @@ +))'x;x_%C88xy(Pyz) \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/2a089c0db45acdb4c6ed8e7ff81ca7235792c0b9 b/test/core/slice/percent_decode_corpus/2a089c0db45acdb4c6ed8e7ff81ca7235792c0b9 new file mode 100644 index 0000000000..5e6f546ff5 --- /dev/null +++ b/test/core/slice/percent_decode_corpus/2a089c0db45acdb4c6ed8e7ff81ca7235792c0b9 @@ -0,0 +1 @@ +_x;x)x;x_x;x_%88%8888: \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/35b7b3bc3a740d5c3abca0d75b53f0e1e1ee998a b/test/core/slice/percent_decode_corpus/35b7b3bc3a740d5c3abca0d75b53f0e1e1ee998a new file mode 100644 index 0000000000..71d688b694 --- /dev/null +++ b/test/core/slice/percent_decode_corpus/35b7b3bc3a740d5c3abca0d75b53f0e1e1ee998a @@ -0,0 +1 @@ +x8 \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/36367ba1adba47a1cbc3a88707fde8cc7abdc248 b/test/core/slice/percent_decode_corpus/36367ba1adba47a1cbc3a88707fde8cc7abdc248 new file mode 100644 index 0000000000..5a89a07ba7 --- /dev/null +++ b/test/core/slice/percent_decode_corpus/36367ba1adba47a1cbc3a88707fde8cc7abdc248 @@ -0,0 +1 @@ +x);x(_%88x;x_%88 \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/39c2ba51548a0beaf0d6d1164531f1447dc311b5 b/test/core/slice/percent_decode_corpus/39c2ba51548a0beaf0d6d1164531f1447dc311b5 new file mode 100644 index 0000000000..cfa2be994f --- /dev/null +++ b/test/core/slice/percent_decode_corpus/39c2ba51548a0beaf0d6d1164531f1447dc311b5 @@ -0,0 +1 @@ +)x;x_x;x_%88%88: \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/56d08fea787c041395c6697ce26cfbc0decbe688 b/test/core/slice/percent_decode_corpus/56d08fea787c041395c6697ce26cfbc0decbe688 new file mode 100644 index 0000000000..c1ddf65acd --- /dev/null +++ b/test/core/slice/percent_decode_corpus/56d08fea787c041395c6697ce26cfbc0decbe688 @@ -0,0 +1 @@ +%cyzŠ \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/678d981fdabb9f0d6640235cf1719dd1e1e66ae9 b/test/core/slice/percent_decode_corpus/678d981fdabb9f0d6640235cf1719dd1e1e66ae9 new file mode 100644 index 0000000000..dc427d1e12 --- /dev/null +++ b/test/core/slice/percent_decode_corpus/678d981fdabb9f0d6640235cf1719dd1e1e66ae9 @@ -0,0 +1 @@ +%øyzŠ \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/68751961609ec010565de0aa87521dcbf0722c5d b/test/core/slice/percent_decode_corpus/68751961609ec010565de0aa87521dcbf0722c5d new file mode 100644 index 0000000000..154449d0ef --- /dev/null +++ b/test/core/slice/percent_decode_corpus/68751961609ec010565de0aa87521dcbf0722c5d @@ -0,0 +1 @@ +Ê:%Ec \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/7875c06c6f03c9aa2f8e9c59f8d8957c8a32e759 b/test/core/slice/percent_decode_corpus/7875c06c6f03c9aa2f8e9c59f8d8957c8a32e759 new file mode 100644 index 0000000000..841ced83c3 --- /dev/null +++ b/test/core/slice/percent_decode_corpus/7875c06c6f03c9aa2f8e9c59f8d8957c8a32e759 @@ -0,0 +1,2 @@ +xxyyz!úyzŠ[zxy'zyz +Š diff --git a/test/core/slice/percent_decode_corpus/7b302090e090a5829b6d1dd7be30bd4e36a7e60f b/test/core/slice/percent_decode_corpus/7b302090e090a5829b6d1dd7be30bd4e36a7e60f new file mode 100644 index 0000000000..6790bc2798 --- /dev/null +++ b/test/core/slice/percent_decode_corpus/7b302090e090a5829b6d1dd7be30bd4e36a7e60f @@ -0,0 +1 @@ +x;:Ê%)x_%C8cE'yzŠ8 \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/875e1022169c9e4c541a9ad894e69e989df22ba1 b/test/core/slice/percent_decode_corpus/875e1022169c9e4c541a9ad894e69e989df22ba1 new file mode 100644 index 0000000000..1625d0a1ae --- /dev/null +++ b/test/core/slice/percent_decode_corpus/875e1022169c9e4c541a9ad894e69e989df22ba1 @@ -0,0 +1 @@ +x;x_%88 \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/8c1051ce066f5a26de9a9d133180621d0da957b4 b/test/core/slice/percent_decode_corpus/8c1051ce066f5a26de9a9d133180621d0da957b4 new file mode 100644 index 0000000000..125c330b3e --- /dev/null +++ b/test/core/slice/percent_decode_corpus/8c1051ce066f5a26de9a9d133180621d0da957b4 @@ -0,0 +1 @@ +)))'x;x_%C88)'x;x_%C89xyyzxyyz) \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/8e084e628ab83a18ac7ca7cb3506525263655c63 b/test/core/slice/percent_decode_corpus/8e084e628ab83a18ac7ca7cb3506525263655c63 new file mode 100644 index 0000000000..6e6f08cb07 --- /dev/null +++ b/test/core/slice/percent_decode_corpus/8e084e628ab83a18ac7ca7cb3506525263655c63 @@ -0,0 +1 @@ +))'x;x_%C88xyyz) \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/9d316c4675f40ddccaf8f1cc7aea94170b1e4223 b/test/core/slice/percent_decode_corpus/9d316c4675f40ddccaf8f1cc7aea94170b1e4223 new file mode 100644 index 0000000000..ab4a1c7657 --- /dev/null +++ b/test/core/slice/percent_decode_corpus/9d316c4675f40ddccaf8f1cc7aea94170b1e4223 @@ -0,0 +1 @@ +x%8 \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/ad1c7c11d18a7d116e2c2ef4d4c5afb1270836ae b/test/core/slice/percent_decode_corpus/ad1c7c11d18a7d116e2c2ef4d4c5afb1270836ae new file mode 100644 index 0000000000..4ac1945a84 --- /dev/null +++ b/test/core/slice/percent_decode_corpus/ad1c7c11d18a7d116e2c2ef4d4c5afb1270836ae @@ -0,0 +1 @@ +x);x(_%88x;x_xxyyz \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/b471f94aa4facf502e622e4a248f1ba4063ae681 b/test/core/slice/percent_decode_corpus/b471f94aa4facf502e622e4a248f1ba4063ae681 new file mode 100644 index 0000000000..5c673ae28a --- /dev/null +++ b/test/core/slice/percent_decode_corpus/b471f94aa4facf502e622e4a248f1ba4063ae681 @@ -0,0 +1 @@ +Ê%ccyzyzŠ \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/bf52ece030f16136d46e0dc97f58d60a0d8a1f0b b/test/core/slice/percent_decode_corpus/bf52ece030f16136d46e0dc97f58d60a0d8a1f0b new file mode 100644 index 0000000000..e478275ed4 --- /dev/null +++ b/test/core/slice/percent_decode_corpus/bf52ece030f16136d46e0dc97f58d60a0d8a1f0b @@ -0,0 +1,2 @@ +)'xyyz!úyzŠ[zxÊ%ccyzyzy'z*zŠ +Š diff --git a/test/core/slice/percent_decode_corpus/d5b2a7177339ba2b7ce2f60e5f4459bef1e72758 b/test/core/slice/percent_decode_corpus/d5b2a7177339ba2b7ce2f60e5f4459bef1e72758 new file mode 100644 index 0000000000..c73cbfe8af --- /dev/null +++ b/test/core/slice/percent_decode_corpus/d5b2a7177339ba2b7ce2f60e5f4459bef1e72758 @@ -0,0 +1,2 @@ +)'xyyz)úyzŠ[zxÊ%cCyzyzy'z*zŠ +Š diff --git a/test/core/slice/percent_decode_corpus/de867b64c54a7ed773dc611fc5cd2f17c5433113 b/test/core/slice/percent_decode_corpus/de867b64c54a7ed773dc611fc5cd2f17c5433113 new file mode 100644 index 0000000000..f9f7246e9c --- /dev/null +++ b/test/core/slice/percent_decode_corpus/de867b64c54a7ed773dc611fc5cd2f17c5433113 @@ -0,0 +1,2 @@ +xxyyz%%øyzŠ[zxy'zyz +Š diff --git a/test/core/slice/percent_decode_corpus/e3948dbe004950591630dd5c52f4e0fcbd5e388a b/test/core/slice/percent_decode_corpus/e3948dbe004950591630dd5c52f4e0fcbd5e388a new file mode 100644 index 0000000000..83ac46d833 --- /dev/null +++ b/test/core/slice/percent_decode_corpus/e3948dbe004950591630dd5c52f4e0fcbd5e388a @@ -0,0 +1 @@ +Ê:%Dx;:Ê%)x_%C8cc \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/e7064f0b80f61dbc65915311032d27baa569ae2a b/test/core/slice/percent_decode_corpus/e7064f0b80f61dbc65915311032d27baa569ae2a new file mode 100644 index 0000000000..e8a0f87653 --- /dev/null +++ b/test/core/slice/percent_decode_corpus/e7064f0b80f61dbc65915311032d27baa569ae2a @@ -0,0 +1 @@ +) \ No newline at end of file diff --git a/test/core/slice/percent_decode_corpus/xyz b/test/core/slice/percent_decode_corpus/xyz new file mode 100644 index 0000000000..cd470e6190 --- /dev/null +++ b/test/core/slice/percent_decode_corpus/xyz @@ -0,0 +1 @@ +xyz diff --git a/test/core/slice/percent_decode_fuzzer.c b/test/core/slice/percent_decode_fuzzer.c new file mode 100644 index 0000000000..69d74816a7 --- /dev/null +++ b/test/core/slice/percent_decode_fuzzer.c @@ -0,0 +1,66 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include + +#include +#include + +#include "src/core/lib/support/percent_encoding.h" +#include "test/core/util/memory_counters.h" + +bool squelch = true; +bool leak_check = true; + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + struct grpc_memory_counters counters; + grpc_memory_counters_init(); + grpc_slice input = grpc_slice_from_copied_buffer((const char *)data, size); + grpc_slice output; + if (gpr_strict_percent_decode_slice( + input, gpr_url_percent_encoding_unreserved_bytes, &output)) { + grpc_slice_unref(output); + } + if (gpr_strict_percent_decode_slice( + input, gpr_compatible_percent_encoding_unreserved_bytes, &output)) { + grpc_slice_unref(output); + } + grpc_slice_unref(gpr_permissive_percent_decode_slice(input)); + grpc_slice_unref(input); + counters = grpc_memory_counters_snapshot(); + grpc_memory_counters_destroy(); + GPR_ASSERT(counters.total_size_relative == 0); + return 0; +} diff --git a/test/core/slice/percent_encode_corpus/0d3ee7fa54e6c66103965fd4409b044ba7db6c3f b/test/core/slice/percent_encode_corpus/0d3ee7fa54e6c66103965fd4409b044ba7db6c3f new file mode 100644 index 0000000000..d09c4a039c --- /dev/null +++ b/test/core/slice/percent_encode_corpus/0d3ee7fa54e6c66103965fd4409b044ba7db6c3f @@ -0,0 +1,3 @@ +_x;7y +xyz')S)xy-zý +Æ* \ No newline at end of file diff --git a/test/core/slice/percent_encode_corpus/2e7ccf75e27b9501e3b28cf1c50ed0c45ab7c226 b/test/core/slice/percent_encode_corpus/2e7ccf75e27b9501e3b28cf1c50ed0c45ab7c226 new file mode 100644 index 0000000000..4d0c38d0e2 --- /dev/null +++ b/test/core/slice/percent_encode_corpus/2e7ccf75e27b9501e3b28cf1c50ed0c45ab7c226 @@ -0,0 +1 @@ +xyx \ No newline at end of file diff --git a/test/core/slice/percent_encode_corpus/55bb859f3942c462b03b7cbcf22ab4a0ac9705cf b/test/core/slice/percent_encode_corpus/55bb859f3942c462b03b7cbcf22ab4a0ac9705cf new file mode 100644 index 0000000000..fc6e93342a --- /dev/null +++ b/test/core/slice/percent_encode_corpus/55bb859f3942c462b03b7cbcf22ab4a0ac9705cf @@ -0,0 +1 @@ +.yx.yxxxyzxyyzxy \ No newline at end of file diff --git a/test/core/slice/percent_encode_corpus/56070cecd54c845b6d4334953b17b712eb000d93 b/test/core/slice/percent_encode_corpus/56070cecd54c845b6d4334953b17b712eb000d93 new file mode 100644 index 0000000000..6823c73f76 --- /dev/null +++ b/test/core/slice/percent_encode_corpus/56070cecd54c845b6d4334953b17b712eb000d93 @@ -0,0 +1 @@ +xyrxyxyzxxyzxyzxyxyy \ No newline at end of file diff --git a/test/core/slice/percent_encode_corpus/61f50e891bf7ff5eb7a7af206f1e25d77f8756e7 b/test/core/slice/percent_encode_corpus/61f50e891bf7ff5eb7a7af206f1e25d77f8756e7 new file mode 100644 index 0000000000..a65cbb4d5b --- /dev/null +++ b/test/core/slice/percent_encode_corpus/61f50e891bf7ff5eb7a7af206f1e25d77f8756e7 @@ -0,0 +1,3 @@ +xy +xyz +)S-Æþ \ No newline at end of file diff --git a/test/core/slice/percent_encode_corpus/6e0c60cefc704c7940e475a87dd9ae423061cb5a b/test/core/slice/percent_encode_corpus/6e0c60cefc704c7940e475a87dd9ae423061cb5a new file mode 100644 index 0000000000..8d031d7e2d --- /dev/null +++ b/test/core/slice/percent_encode_corpus/6e0c60cefc704c7940e475a87dd9ae423061cb5a @@ -0,0 +1,3 @@ +xy +xyz +)S)Æ* \ No newline at end of file diff --git a/test/core/slice/percent_encode_corpus/7271ebcc6d22a0f186f7bc3c1973a7ed1bec8d8e b/test/core/slice/percent_encode_corpus/7271ebcc6d22a0f186f7bc3c1973a7ed1bec8d8e new file mode 100644 index 0000000000..4d82ca3953 --- /dev/null +++ b/test/core/slice/percent_encode_corpus/7271ebcc6d22a0f186f7bc3c1973a7ed1bec8d8e @@ -0,0 +1,4 @@ +x;7y +xyz +)S)xyz +Æ* \ No newline at end of file diff --git a/test/core/slice/percent_encode_corpus/74c83ece3e2920a67593a9be9c82468f16cbb969 b/test/core/slice/percent_encode_corpus/74c83ece3e2920a67593a9be9c82468f16cbb969 new file mode 100644 index 0000000000..bb7f4ae07e --- /dev/null +++ b/test/core/slice/percent_encode_corpus/74c83ece3e2920a67593a9be9c82468f16cbb969 @@ -0,0 +1 @@ +xyzxy \ No newline at end of file diff --git a/test/core/slice/percent_encode_corpus/98e004fd2a9f141a7a019720820080e12d637c06 b/test/core/slice/percent_encode_corpus/98e004fd2a9f141a7a019720820080e12d637c06 new file mode 100644 index 0000000000..50879d0f37 --- /dev/null +++ b/test/core/slice/percent_encode_corpus/98e004fd2a9f141a7a019720820080e12d637c06 @@ -0,0 +1,3 @@ +xy +xz +)Sxy-Æzx_yþ \ No newline at end of file diff --git a/test/core/slice/percent_encode_corpus/ba2c1e98227aa21ea3bb2ca4d0e504119717da8b b/test/core/slice/percent_encode_corpus/ba2c1e98227aa21ea3bb2ca4d0e504119717da8b new file mode 100644 index 0000000000..dc1ab9bfc2 --- /dev/null +++ b/test/core/slice/percent_encode_corpus/ba2c1e98227aa21ea3bb2ca4d0e504119717da8b @@ -0,0 +1,3 @@ +_x;7y +xyz')S)xyz +Æ* \ No newline at end of file diff --git a/test/core/slice/percent_encode_corpus/c16b9fd45370d4afb5d3ebd307a6e263c25ffd45 b/test/core/slice/percent_encode_corpus/c16b9fd45370d4afb5d3ebd307a6e263c25ffd45 new file mode 100644 index 0000000000..3476e0b70b --- /dev/null +++ b/test/core/slice/percent_encode_corpus/c16b9fd45370d4afb5d3ebd307a6e263c25ffd45 @@ -0,0 +1,2 @@ +xyz +)S \ No newline at end of file diff --git a/test/core/slice/percent_encode_corpus/d58c3cd4eab9b6d2343abfa1c25c90a383fe0ec3 b/test/core/slice/percent_encode_corpus/d58c3cd4eab9b6d2343abfa1c25c90a383fe0ec3 new file mode 100644 index 0000000000..822d50abf8 --- /dev/null +++ b/test/core/slice/percent_encode_corpus/d58c3cd4eab9b6d2343abfa1c25c90a383fe0ec3 @@ -0,0 +1 @@ +.yx \ No newline at end of file diff --git a/test/core/slice/percent_encode_corpus/e2619218ede30d2b7b8ecd601a9f0ae754b728b4 b/test/core/slice/percent_encode_corpus/e2619218ede30d2b7b8ecd601a9f0ae754b728b4 new file mode 100644 index 0000000000..101639c93d --- /dev/null +++ b/test/core/slice/percent_encode_corpus/e2619218ede30d2b7b8ecd601a9f0ae754b728b4 @@ -0,0 +1,4 @@ +x;y +xyz +)S)xyz +Æ* \ No newline at end of file diff --git a/test/core/slice/percent_encode_corpus/f93b3653e453f0e3eea3198001be6ce46e64bd21 b/test/core/slice/percent_encode_corpus/f93b3653e453f0e3eea3198001be6ce46e64bd21 new file mode 100644 index 0000000000..6e07ab342f --- /dev/null +++ b/test/core/slice/percent_encode_corpus/f93b3653e453f0e3eea3198001be6ce46e64bd21 @@ -0,0 +1,5 @@ +x;y +xøyz +)S)xyz +Æ.y~ +)S \ No newline at end of file diff --git a/test/core/slice/percent_encode_corpus/fd41d029c7682ad3d1c40a9fd017a4c85b673a54 b/test/core/slice/percent_encode_corpus/fd41d029c7682ad3d1c40a9fd017a4c85b673a54 new file mode 100644 index 0000000000..13d7fab596 --- /dev/null +++ b/test/core/slice/percent_encode_corpus/fd41d029c7682ad3d1c40a9fd017a4c85b673a54 @@ -0,0 +1,3 @@ +xy +xyz +)S)S \ No newline at end of file diff --git a/test/core/slice/percent_encode_corpus/xyz b/test/core/slice/percent_encode_corpus/xyz new file mode 100644 index 0000000000..cd470e6190 --- /dev/null +++ b/test/core/slice/percent_encode_corpus/xyz @@ -0,0 +1 @@ +xyz diff --git a/test/core/slice/percent_encode_fuzzer.c b/test/core/slice/percent_encode_fuzzer.c new file mode 100644 index 0000000000..99599bf16e --- /dev/null +++ b/test/core/slice/percent_encode_fuzzer.c @@ -0,0 +1,73 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include + +#include +#include + +#include "src/core/lib/support/percent_encoding.h" +#include "test/core/util/memory_counters.h" + +bool squelch = true; +bool leak_check = true; + +static void test(const uint8_t *data, size_t size, const uint8_t *dict) { + struct grpc_memory_counters counters; + grpc_memory_counters_init(); + grpc_slice input = grpc_slice_from_copied_buffer((const char *)data, size); + grpc_slice output = gpr_percent_encode_slice(input, dict); + grpc_slice decoded_output; + // encoder must always produce decodable output + GPR_ASSERT(gpr_strict_percent_decode_slice(output, dict, &decoded_output)); + grpc_slice permissive_decoded_output = + gpr_permissive_percent_decode_slice(output); + // and decoded output must always match the input + GPR_ASSERT(grpc_slice_cmp(input, decoded_output) == 0); + GPR_ASSERT(grpc_slice_cmp(input, permissive_decoded_output) == 0); + grpc_slice_unref(input); + grpc_slice_unref(output); + grpc_slice_unref(decoded_output); + grpc_slice_unref(permissive_decoded_output); + counters = grpc_memory_counters_snapshot(); + grpc_memory_counters_destroy(); + GPR_ASSERT(counters.total_size_relative == 0); +} + +int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { + test(data, size, gpr_url_percent_encoding_unreserved_bytes); + test(data, size, gpr_compatible_percent_encoding_unreserved_bytes); + return 0; +} diff --git a/test/core/slice/percent_encoding_test.c b/test/core/slice/percent_encoding_test.c new file mode 100644 index 0000000000..e9ba8f5ec4 --- /dev/null +++ b/test/core/slice/percent_encoding_test.c @@ -0,0 +1,157 @@ +/* + * + * Copyright 2016, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/lib/support/percent_encoding.h" + +#include +#include + +#include "src/core/lib/support/string.h" +#include "test/core/util/test_config.h" + +#define TEST_VECTOR(raw, encoded, dict) \ + test_vector(raw, sizeof(raw) - 1, encoded, sizeof(encoded) - 1, dict) + +#define TEST_NONCONFORMANT_VECTOR(encoded, permissive_unencoded, dict) \ + test_nonconformant_vector(encoded, sizeof(encoded) - 1, \ + permissive_unencoded, \ + sizeof(permissive_unencoded) - 1, dict) + +static void test_vector(const char *raw, size_t raw_length, const char *encoded, + size_t encoded_length, const uint8_t *dict) { + char *raw_msg = gpr_dump(raw, raw_length, GPR_DUMP_HEX | GPR_DUMP_ASCII); + char *encoded_msg = + gpr_dump(encoded, encoded_length, GPR_DUMP_HEX | GPR_DUMP_ASCII); + gpr_log(GPR_DEBUG, "Trial:\nraw = %s\nencoded = %s", raw_msg, encoded_msg); + gpr_free(raw_msg); + gpr_free(encoded_msg); + + grpc_slice raw_slice = grpc_slice_from_copied_buffer(raw, raw_length); + grpc_slice encoded_slice = + grpc_slice_from_copied_buffer(encoded, encoded_length); + grpc_slice raw2encoded_slice = gpr_percent_encode_slice(raw_slice, dict); + grpc_slice encoded2raw_slice; + GPR_ASSERT( + gpr_strict_percent_decode_slice(encoded_slice, dict, &encoded2raw_slice)); + grpc_slice encoded2raw_permissive_slice = + gpr_permissive_percent_decode_slice(encoded_slice); + + char *raw2encoded_msg = + gpr_dump_slice(raw2encoded_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); + char *encoded2raw_msg = + gpr_dump_slice(encoded2raw_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); + char *encoded2raw_permissive_msg = gpr_dump_slice( + encoded2raw_permissive_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); + gpr_log(GPR_DEBUG, + "Result:\nraw2encoded = %s\nencoded2raw = %s\nencoded2raw_permissive " + "= %s", + raw2encoded_msg, encoded2raw_msg, encoded2raw_permissive_msg); + gpr_free(raw2encoded_msg); + gpr_free(encoded2raw_msg); + gpr_free(encoded2raw_permissive_msg); + + GPR_ASSERT(0 == grpc_slice_cmp(raw_slice, encoded2raw_slice)); + GPR_ASSERT(0 == grpc_slice_cmp(raw_slice, encoded2raw_permissive_slice)); + GPR_ASSERT(0 == grpc_slice_cmp(encoded_slice, raw2encoded_slice)); + + grpc_slice_unref(encoded2raw_slice); + grpc_slice_unref(encoded2raw_permissive_slice); + grpc_slice_unref(raw2encoded_slice); + grpc_slice_unref(raw_slice); + grpc_slice_unref(encoded_slice); +} + +static void test_nonconformant_vector(const char *encoded, + size_t encoded_length, + const char *permissive_unencoded, + size_t permissive_unencoded_length, + const uint8_t *dict) { + char *permissive_unencoded_msg = + gpr_dump(permissive_unencoded, permissive_unencoded_length, + GPR_DUMP_HEX | GPR_DUMP_ASCII); + char *encoded_msg = + gpr_dump(encoded, encoded_length, GPR_DUMP_HEX | GPR_DUMP_ASCII); + gpr_log(GPR_DEBUG, "Trial:\nraw = %s\nencoded = %s", permissive_unencoded_msg, + encoded_msg); + gpr_free(permissive_unencoded_msg); + gpr_free(encoded_msg); + + grpc_slice permissive_unencoded_slice = grpc_slice_from_copied_buffer( + permissive_unencoded, permissive_unencoded_length); + grpc_slice encoded_slice = + grpc_slice_from_copied_buffer(encoded, encoded_length); + grpc_slice encoded2raw_slice; + GPR_ASSERT(!gpr_strict_percent_decode_slice(encoded_slice, dict, + &encoded2raw_slice)); + grpc_slice encoded2raw_permissive_slice = + gpr_permissive_percent_decode_slice(encoded_slice); + + char *encoded2raw_permissive_msg = gpr_dump_slice( + encoded2raw_permissive_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); + gpr_log(GPR_DEBUG, "Result:\nencoded2raw_permissive = %s", + encoded2raw_permissive_msg); + gpr_free(encoded2raw_permissive_msg); + + GPR_ASSERT(0 == grpc_slice_cmp(permissive_unencoded_slice, + encoded2raw_permissive_slice)); + + grpc_slice_unref(permissive_unencoded_slice); + grpc_slice_unref(encoded2raw_permissive_slice); + grpc_slice_unref(encoded_slice); +} + +int main(int argc, char **argv) { + grpc_test_init(argc, argv); + TEST_VECTOR( + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~", + "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~", + gpr_url_percent_encoding_unreserved_bytes); + TEST_VECTOR("\x00", "%00", gpr_url_percent_encoding_unreserved_bytes); + TEST_VECTOR("\x01", "%01", gpr_url_percent_encoding_unreserved_bytes); + TEST_VECTOR("a b", "a%20b", gpr_url_percent_encoding_unreserved_bytes); + TEST_VECTOR(" b", "%20b", gpr_url_percent_encoding_unreserved_bytes); + TEST_VECTOR("a b", "a b", gpr_compatible_percent_encoding_unreserved_bytes); + TEST_VECTOR(" b", " b", gpr_compatible_percent_encoding_unreserved_bytes); + TEST_VECTOR("\x0f", "%0F", gpr_url_percent_encoding_unreserved_bytes); + TEST_VECTOR("\xff", "%FF", gpr_url_percent_encoding_unreserved_bytes); + TEST_VECTOR("\xee", "%EE", gpr_url_percent_encoding_unreserved_bytes); + TEST_NONCONFORMANT_VECTOR("%", "%", + gpr_url_percent_encoding_unreserved_bytes); + TEST_NONCONFORMANT_VECTOR("%A", "%A", + gpr_url_percent_encoding_unreserved_bytes); + TEST_NONCONFORMANT_VECTOR("%AG", "%AG", + gpr_url_percent_encoding_unreserved_bytes); + TEST_NONCONFORMANT_VECTOR("\0", "\0", + gpr_url_percent_encoding_unreserved_bytes); + return 0; +} diff --git a/test/core/slice/slice_buffer_test.c b/test/core/slice/slice_buffer_test.c new file mode 100644 index 0000000000..9c55a5c473 --- /dev/null +++ b/test/core/slice/slice_buffer_test.c @@ -0,0 +1,129 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include +#include +#include "test/core/util/test_config.h" + +void test_slice_buffer_add() { + grpc_slice_buffer buf; + grpc_slice aaa = grpc_slice_from_copied_string("aaa"); + grpc_slice bb = grpc_slice_from_copied_string("bb"); + size_t i; + + grpc_slice_buffer_init(&buf); + for (i = 0; i < 10; i++) { + grpc_slice_ref(aaa); + grpc_slice_ref(bb); + grpc_slice_buffer_add(&buf, aaa); + grpc_slice_buffer_add(&buf, bb); + } + GPR_ASSERT(buf.count > 0); + GPR_ASSERT(buf.length == 50); + grpc_slice_buffer_reset_and_unref(&buf); + GPR_ASSERT(buf.count == 0); + GPR_ASSERT(buf.length == 0); + for (i = 0; i < 10; i++) { + grpc_slice_ref(aaa); + grpc_slice_ref(bb); + grpc_slice_buffer_add(&buf, aaa); + grpc_slice_buffer_add(&buf, bb); + } + GPR_ASSERT(buf.count > 0); + GPR_ASSERT(buf.length == 50); + for (i = 0; i < 10; i++) { + grpc_slice_buffer_pop(&buf); + grpc_slice_unref(aaa); + grpc_slice_unref(bb); + } + GPR_ASSERT(buf.count == 0); + GPR_ASSERT(buf.length == 0); + grpc_slice_buffer_destroy(&buf); +} + +void test_slice_buffer_move_first() { + grpc_slice slices[3]; + grpc_slice_buffer src; + grpc_slice_buffer dst; + int idx = 0; + size_t src_len = 0; + size_t dst_len = 0; + + slices[0] = grpc_slice_from_copied_string("aaa"); + slices[1] = grpc_slice_from_copied_string("bbbb"); + slices[2] = grpc_slice_from_copied_string("ccc"); + + grpc_slice_buffer_init(&src); + grpc_slice_buffer_init(&dst); + for (idx = 0; idx < 3; idx++) { + grpc_slice_ref(slices[idx]); + /* For this test, it is important that we add each slice at a new + slice index */ + grpc_slice_buffer_add_indexed(&src, slices[idx]); + grpc_slice_buffer_add_indexed(&dst, slices[idx]); + } + + /* Case 1: Move more than the first slice's length from src to dst */ + src_len = src.length; + dst_len = dst.length; + grpc_slice_buffer_move_first(&src, 4, &dst); + src_len -= 4; + dst_len += 4; + GPR_ASSERT(src.length == src_len); + GPR_ASSERT(dst.length == dst_len); + + /* src now has two slices ["bbb"] and ["ccc"] */ + /* Case 2: Move the first slice from src to dst */ + grpc_slice_buffer_move_first(&src, 3, &dst); + src_len -= 3; + dst_len += 3; + GPR_ASSERT(src.length == src_len); + GPR_ASSERT(dst.length == dst_len); + + /* src now has one slice ["ccc"] */ + /* Case 3: Move less than the first slice's length from src to dst*/ + grpc_slice_buffer_move_first(&src, 2, &dst); + src_len -= 2; + dst_len += 2; + GPR_ASSERT(src.length == src.length); + GPR_ASSERT(dst.length == dst.length); +} + +int main(int argc, char **argv) { + grpc_test_init(argc, argv); + + test_slice_buffer_add(); + test_slice_buffer_move_first(); + + return 0; +} diff --git a/test/core/slice/slice_string_helpers_test.c b/test/core/slice/slice_string_helpers_test.c new file mode 100644 index 0000000000..d3dbb1e7f9 --- /dev/null +++ b/test/core/slice/slice_string_helpers_test.c @@ -0,0 +1,148 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include "src/core/lib/support/string.h" + +#include +#include +#include +#include + +#include +#include +#include +#include +#include "test/core/util/test_config.h" + +#define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x) + +static void expect_slice_dump(grpc_slice slice, uint32_t flags, + const char *result) { + char *got = gpr_dump_slice(slice, flags); + GPR_ASSERT(0 == strcmp(got, result)); + gpr_free(got); + grpc_slice_unref(slice); +} + +static void test_dump_slice(void) { + static const char *text = "HELLO WORLD!"; + static const char *long_text = + "It was a bright cold day in April, and the clocks were striking " + "thirteen. Winston Smith, his chin nuzzled into his breast in an effort " + "to escape the vile wind, slipped quickly through the glass doors of " + "Victory Mansions, though not quickly enough to prevent a swirl of " + "gritty dust from entering along with him."; + + LOG_TEST_NAME("test_dump_slice"); + + expect_slice_dump(grpc_slice_from_copied_string(text), GPR_DUMP_ASCII, text); + expect_slice_dump(grpc_slice_from_copied_string(long_text), GPR_DUMP_ASCII, + long_text); + expect_slice_dump(grpc_slice_from_copied_buffer("\x01", 1), GPR_DUMP_HEX, + "01"); + expect_slice_dump(grpc_slice_from_copied_buffer("\x01", 1), + GPR_DUMP_HEX | GPR_DUMP_ASCII, "01 '.'"); +} + +static void test_strsplit(void) { + grpc_slice_buffer *parts; + grpc_slice str; + + LOG_TEST_NAME("test_strsplit"); + + parts = gpr_malloc(sizeof(grpc_slice_buffer)); + grpc_slice_buffer_init(parts); + + str = grpc_slice_from_copied_string("one, two, three, four"); + grpc_slice_split(str, ", ", parts); + GPR_ASSERT(4 == parts->count); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "one")); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], "two")); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[2], "three")); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[3], "four")); + grpc_slice_buffer_reset_and_unref(parts); + grpc_slice_unref(str); + + /* separator not present in string */ + str = grpc_slice_from_copied_string("one two three four"); + grpc_slice_split(str, ", ", parts); + GPR_ASSERT(1 == parts->count); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "one two three four")); + grpc_slice_buffer_reset_and_unref(parts); + grpc_slice_unref(str); + + /* separator at the end */ + str = grpc_slice_from_copied_string("foo,"); + grpc_slice_split(str, ",", parts); + GPR_ASSERT(2 == parts->count); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "foo")); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], "")); + grpc_slice_buffer_reset_and_unref(parts); + grpc_slice_unref(str); + + /* separator at the beginning */ + str = grpc_slice_from_copied_string(",foo"); + grpc_slice_split(str, ",", parts); + GPR_ASSERT(2 == parts->count); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "")); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], "foo")); + grpc_slice_buffer_reset_and_unref(parts); + grpc_slice_unref(str); + + /* standalone separator */ + str = grpc_slice_from_copied_string(","); + grpc_slice_split(str, ",", parts); + GPR_ASSERT(2 == parts->count); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "")); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[1], "")); + grpc_slice_buffer_reset_and_unref(parts); + grpc_slice_unref(str); + + /* empty input */ + str = grpc_slice_from_copied_string(""); + grpc_slice_split(str, ", ", parts); + GPR_ASSERT(1 == parts->count); + GPR_ASSERT(0 == grpc_slice_str_cmp(parts->slices[0], "")); + grpc_slice_buffer_reset_and_unref(parts); + grpc_slice_unref(str); + + grpc_slice_buffer_destroy(parts); + gpr_free(parts); +} + +int main(int argc, char **argv) { + grpc_test_init(argc, argv); + test_dump_slice(); + test_strsplit(); + return 0; +} diff --git a/test/core/slice/slice_test.c b/test/core/slice/slice_test.c new file mode 100644 index 0000000000..c263fe27d6 --- /dev/null +++ b/test/core/slice/slice_test.c @@ -0,0 +1,265 @@ +/* + * + * Copyright 2015, Google Inc. + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above + * copyright notice, this list of conditions and the following disclaimer + * in the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Google Inc. nor the names of its + * contributors may be used to endorse or promote products derived from + * this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + */ + +#include + +#include + +#include +#include +#include "test/core/util/test_config.h" + +#define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x); + +static void test_slice_malloc_returns_something_sensible(void) { + /* Calls grpc_slice_create for various lengths and verifies the internals for + consistency. */ + size_t length; + size_t i; + grpc_slice slice; + + LOG_TEST_NAME("test_slice_malloc_returns_something_sensible"); + + for (length = 0; length <= 1024; length++) { + slice = grpc_slice_malloc(length); + /* If there is a length, slice.data must be non-NULL. If length is zero + we don't care. */ + if (length) { + GPR_ASSERT(GPR_SLICE_START_PTR(slice)); + } + /* Returned slice length must be what was requested. */ + GPR_ASSERT(GPR_SLICE_LENGTH(slice) == length); + /* If the slice has a refcount, it must be destroyable. */ + if (slice.refcount) { + GPR_ASSERT(slice.refcount->ref != NULL); + GPR_ASSERT(slice.refcount->unref != NULL); + } + /* We must be able to write to every byte of the data */ + for (i = 0; i < length; i++) { + GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; + } + /* And finally we must succeed in destroying the slice */ + grpc_slice_unref(slice); + } +} + +static void do_nothing(void *ignored) {} + +static void test_slice_new_returns_something_sensible(void) { + uint8_t x; + + grpc_slice slice = grpc_slice_new(&x, 1, do_nothing); + GPR_ASSERT(slice.refcount); + GPR_ASSERT(slice.data.refcounted.bytes == &x); + GPR_ASSERT(slice.data.refcounted.length == 1); + grpc_slice_unref(slice); +} + +/* destroy function that sets a mark to indicate it was called. */ +static void set_mark(void *p) { *((int *)p) = 1; } + +static void test_slice_new_with_user_data(void) { + int marker = 0; + uint8_t buf[2]; + grpc_slice slice; + + buf[0] = 0; + buf[1] = 1; + slice = grpc_slice_new_with_user_data(buf, 2, set_mark, &marker); + GPR_ASSERT(marker == 0); + GPR_ASSERT(GPR_SLICE_LENGTH(slice) == 2); + GPR_ASSERT(GPR_SLICE_START_PTR(slice)[0] == 0); + GPR_ASSERT(GPR_SLICE_START_PTR(slice)[1] == 1); + + /* unref should cause destroy function to run. */ + grpc_slice_unref(slice); + GPR_ASSERT(marker == 1); +} + +static int do_nothing_with_len_1_calls = 0; + +static void do_nothing_with_len_1(void *ignored, size_t len) { + GPR_ASSERT(len == 1); + do_nothing_with_len_1_calls++; +} + +static void test_slice_new_with_len_returns_something_sensible(void) { + uint8_t x; + int num_refs = 5; /* To test adding/removing an arbitrary number of refs */ + int i; + + grpc_slice slice = grpc_slice_new_with_len(&x, 1, do_nothing_with_len_1); + GPR_ASSERT(slice.refcount); /* ref count is initialized to 1 at this point */ + GPR_ASSERT(slice.data.refcounted.bytes == &x); + GPR_ASSERT(slice.data.refcounted.length == 1); + GPR_ASSERT(do_nothing_with_len_1_calls == 0); + + /* Add an arbitrary number of refs to the slice and remoe the refs. This is to + make sure that that the destroy callback (i.e do_nothing_with_len_1()) is + not called until the last unref operation */ + for (i = 0; i < num_refs; i++) { + grpc_slice_ref(slice); + } + for (i = 0; i < num_refs; i++) { + grpc_slice_unref(slice); + } + GPR_ASSERT(do_nothing_with_len_1_calls == 0); /* Shouldn't be called yet */ + + /* last unref */ + grpc_slice_unref(slice); + GPR_ASSERT(do_nothing_with_len_1_calls == 1); +} + +static void test_slice_sub_works(unsigned length) { + grpc_slice slice; + grpc_slice sub; + unsigned i, j, k; + + LOG_TEST_NAME("test_slice_sub_works"); + gpr_log(GPR_INFO, "length=%d", length); + + /* Create a slice in which each byte is equal to the distance from it to the + beginning of the slice. */ + slice = grpc_slice_malloc(length); + for (i = 0; i < length; i++) { + GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; + } + + /* Ensure that for all subsets length is correct and that we start on the + correct byte. Additionally check that no copies were made. */ + for (i = 0; i < length; i++) { + for (j = i; j < length; j++) { + sub = grpc_slice_sub(slice, i, j); + GPR_ASSERT(GPR_SLICE_LENGTH(sub) == j - i); + for (k = 0; k < j - i; k++) { + GPR_ASSERT(GPR_SLICE_START_PTR(sub)[k] == (uint8_t)(i + k)); + } + grpc_slice_unref(sub); + } + } + grpc_slice_unref(slice); +} + +static void check_head_tail(grpc_slice slice, grpc_slice head, grpc_slice tail) { + GPR_ASSERT(GPR_SLICE_LENGTH(slice) == + GPR_SLICE_LENGTH(head) + GPR_SLICE_LENGTH(tail)); + GPR_ASSERT(0 == memcmp(GPR_SLICE_START_PTR(slice), GPR_SLICE_START_PTR(head), + GPR_SLICE_LENGTH(head))); + GPR_ASSERT(0 == memcmp(GPR_SLICE_START_PTR(slice) + GPR_SLICE_LENGTH(head), + GPR_SLICE_START_PTR(tail), GPR_SLICE_LENGTH(tail))); +} + +static void test_slice_split_head_works(size_t length) { + grpc_slice slice; + grpc_slice head, tail; + size_t i; + + LOG_TEST_NAME("test_slice_split_head_works"); + gpr_log(GPR_INFO, "length=%" PRIuPTR, length); + + /* Create a slice in which each byte is equal to the distance from it to the + beginning of the slice. */ + slice = grpc_slice_malloc(length); + for (i = 0; i < length; i++) { + GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; + } + + /* Ensure that for all subsets length is correct and that we start on the + correct byte. Additionally check that no copies were made. */ + for (i = 0; i < length; i++) { + tail = grpc_slice_ref(slice); + head = grpc_slice_split_head(&tail, i); + check_head_tail(slice, head, tail); + grpc_slice_unref(tail); + grpc_slice_unref(head); + } + + grpc_slice_unref(slice); +} + +static void test_slice_split_tail_works(size_t length) { + grpc_slice slice; + grpc_slice head, tail; + size_t i; + + LOG_TEST_NAME("test_slice_split_tail_works"); + gpr_log(GPR_INFO, "length=%" PRIuPTR, length); + + /* Create a slice in which each byte is equal to the distance from it to the + beginning of the slice. */ + slice = grpc_slice_malloc(length); + for (i = 0; i < length; i++) { + GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; + } + + /* Ensure that for all subsets length is correct and that we start on the + correct byte. Additionally check that no copies were made. */ + for (i = 0; i < length; i++) { + head = grpc_slice_ref(slice); + tail = grpc_slice_split_tail(&head, i); + check_head_tail(slice, head, tail); + grpc_slice_unref(tail); + grpc_slice_unref(head); + } + + grpc_slice_unref(slice); +} + +static void test_slice_from_copied_string_works(void) { + static const char *text = "HELLO WORLD!"; + grpc_slice slice; + + LOG_TEST_NAME("test_slice_from_copied_string_works"); + + slice = grpc_slice_from_copied_string(text); + GPR_ASSERT(strlen(text) == GPR_SLICE_LENGTH(slice)); + GPR_ASSERT(0 == + memcmp(text, GPR_SLICE_START_PTR(slice), GPR_SLICE_LENGTH(slice))); + grpc_slice_unref(slice); +} + +int main(int argc, char **argv) { + unsigned length; + grpc_test_init(argc, argv); + test_slice_malloc_returns_something_sensible(); + test_slice_new_returns_something_sensible(); + test_slice_new_with_user_data(); + test_slice_new_with_len_returns_something_sensible(); + for (length = 0; length < 128; length++) { + test_slice_sub_works(length); + test_slice_split_head_works(length); + test_slice_split_tail_works(length); + } + test_slice_from_copied_string_works(); + return 0; +} diff --git a/test/core/support/percent_decode_corpus/04cb8ccc553f9b2f5e52c421aff6d1c954d3dae6 b/test/core/support/percent_decode_corpus/04cb8ccc553f9b2f5e52c421aff6d1c954d3dae6 deleted file mode 100644 index a0c7605580..0000000000 --- a/test/core/support/percent_decode_corpus/04cb8ccc553f9b2f5e52c421aff6d1c954d3dae6 +++ /dev/null @@ -1 +0,0 @@ -:Ê%cE'yzŠ \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/0dd8f3a63745b3a2d39791559b5c1b311447b537 b/test/core/support/percent_decode_corpus/0dd8f3a63745b3a2d39791559b5c1b311447b537 deleted file mode 100644 index 8b36124b3f..0000000000 --- a/test/core/support/percent_decode_corpus/0dd8f3a63745b3a2d39791559b5c1b311447b537 +++ /dev/null @@ -1 +0,0 @@ -x;x_%C88 \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/17eeaca784409adbe43365c32ac87915d736bba3 b/test/core/support/percent_decode_corpus/17eeaca784409adbe43365c32ac87915d736bba3 deleted file mode 100644 index ea02afac49..0000000000 --- a/test/core/support/percent_decode_corpus/17eeaca784409adbe43365c32ac87915d736bba3 +++ /dev/null @@ -1,2 +0,0 @@ -xxyyz%øyzŠ[zxy'z - diff --git a/test/core/support/percent_decode_corpus/2040c1ff65f52a7ae668c2c8f324de5dacc9d695 b/test/core/support/percent_decode_corpus/2040c1ff65f52a7ae668c2c8f324de5dacc9d695 deleted file mode 100644 index 9e9b466b2f..0000000000 --- a/test/core/support/percent_decode_corpus/2040c1ff65f52a7ae668c2c8f324de5dacc9d695 +++ /dev/null @@ -1 +0,0 @@ -xx;x_%;:Ê%C)x_%C88c8E'yzŠ8 \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/26b0d1da23027ae54db96e125e4a9e98842d77fb b/test/core/support/percent_decode_corpus/26b0d1da23027ae54db96e125e4a9e98842d77fb deleted file mode 100644 index 88c739ecaa..0000000000 --- a/test/core/support/percent_decode_corpus/26b0d1da23027ae54db96e125e4a9e98842d77fb +++ /dev/null @@ -1 +0,0 @@ -))'x;x_%C88xy(Pyz) \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/2a089c0db45acdb4c6ed8e7ff81ca7235792c0b9 b/test/core/support/percent_decode_corpus/2a089c0db45acdb4c6ed8e7ff81ca7235792c0b9 deleted file mode 100644 index 5e6f546ff5..0000000000 --- a/test/core/support/percent_decode_corpus/2a089c0db45acdb4c6ed8e7ff81ca7235792c0b9 +++ /dev/null @@ -1 +0,0 @@ -_x;x)x;x_x;x_%88%8888: \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/35b7b3bc3a740d5c3abca0d75b53f0e1e1ee998a b/test/core/support/percent_decode_corpus/35b7b3bc3a740d5c3abca0d75b53f0e1e1ee998a deleted file mode 100644 index 71d688b694..0000000000 --- a/test/core/support/percent_decode_corpus/35b7b3bc3a740d5c3abca0d75b53f0e1e1ee998a +++ /dev/null @@ -1 +0,0 @@ -x8 \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/36367ba1adba47a1cbc3a88707fde8cc7abdc248 b/test/core/support/percent_decode_corpus/36367ba1adba47a1cbc3a88707fde8cc7abdc248 deleted file mode 100644 index 5a89a07ba7..0000000000 --- a/test/core/support/percent_decode_corpus/36367ba1adba47a1cbc3a88707fde8cc7abdc248 +++ /dev/null @@ -1 +0,0 @@ -x);x(_%88x;x_%88 \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/39c2ba51548a0beaf0d6d1164531f1447dc311b5 b/test/core/support/percent_decode_corpus/39c2ba51548a0beaf0d6d1164531f1447dc311b5 deleted file mode 100644 index cfa2be994f..0000000000 --- a/test/core/support/percent_decode_corpus/39c2ba51548a0beaf0d6d1164531f1447dc311b5 +++ /dev/null @@ -1 +0,0 @@ -)x;x_x;x_%88%88: \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/56d08fea787c041395c6697ce26cfbc0decbe688 b/test/core/support/percent_decode_corpus/56d08fea787c041395c6697ce26cfbc0decbe688 deleted file mode 100644 index c1ddf65acd..0000000000 --- a/test/core/support/percent_decode_corpus/56d08fea787c041395c6697ce26cfbc0decbe688 +++ /dev/null @@ -1 +0,0 @@ -%cyzŠ \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/678d981fdabb9f0d6640235cf1719dd1e1e66ae9 b/test/core/support/percent_decode_corpus/678d981fdabb9f0d6640235cf1719dd1e1e66ae9 deleted file mode 100644 index dc427d1e12..0000000000 --- a/test/core/support/percent_decode_corpus/678d981fdabb9f0d6640235cf1719dd1e1e66ae9 +++ /dev/null @@ -1 +0,0 @@ -%øyzŠ \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/68751961609ec010565de0aa87521dcbf0722c5d b/test/core/support/percent_decode_corpus/68751961609ec010565de0aa87521dcbf0722c5d deleted file mode 100644 index 154449d0ef..0000000000 --- a/test/core/support/percent_decode_corpus/68751961609ec010565de0aa87521dcbf0722c5d +++ /dev/null @@ -1 +0,0 @@ -Ê:%Ec \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/7875c06c6f03c9aa2f8e9c59f8d8957c8a32e759 b/test/core/support/percent_decode_corpus/7875c06c6f03c9aa2f8e9c59f8d8957c8a32e759 deleted file mode 100644 index 841ced83c3..0000000000 --- a/test/core/support/percent_decode_corpus/7875c06c6f03c9aa2f8e9c59f8d8957c8a32e759 +++ /dev/null @@ -1,2 +0,0 @@ -xxyyz!úyzŠ[zxy'zyz -Š diff --git a/test/core/support/percent_decode_corpus/7b302090e090a5829b6d1dd7be30bd4e36a7e60f b/test/core/support/percent_decode_corpus/7b302090e090a5829b6d1dd7be30bd4e36a7e60f deleted file mode 100644 index 6790bc2798..0000000000 --- a/test/core/support/percent_decode_corpus/7b302090e090a5829b6d1dd7be30bd4e36a7e60f +++ /dev/null @@ -1 +0,0 @@ -x;:Ê%)x_%C8cE'yzŠ8 \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/875e1022169c9e4c541a9ad894e69e989df22ba1 b/test/core/support/percent_decode_corpus/875e1022169c9e4c541a9ad894e69e989df22ba1 deleted file mode 100644 index 1625d0a1ae..0000000000 --- a/test/core/support/percent_decode_corpus/875e1022169c9e4c541a9ad894e69e989df22ba1 +++ /dev/null @@ -1 +0,0 @@ -x;x_%88 \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/8c1051ce066f5a26de9a9d133180621d0da957b4 b/test/core/support/percent_decode_corpus/8c1051ce066f5a26de9a9d133180621d0da957b4 deleted file mode 100644 index 125c330b3e..0000000000 --- a/test/core/support/percent_decode_corpus/8c1051ce066f5a26de9a9d133180621d0da957b4 +++ /dev/null @@ -1 +0,0 @@ -)))'x;x_%C88)'x;x_%C89xyyzxyyz) \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/8e084e628ab83a18ac7ca7cb3506525263655c63 b/test/core/support/percent_decode_corpus/8e084e628ab83a18ac7ca7cb3506525263655c63 deleted file mode 100644 index 6e6f08cb07..0000000000 --- a/test/core/support/percent_decode_corpus/8e084e628ab83a18ac7ca7cb3506525263655c63 +++ /dev/null @@ -1 +0,0 @@ -))'x;x_%C88xyyz) \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/9d316c4675f40ddccaf8f1cc7aea94170b1e4223 b/test/core/support/percent_decode_corpus/9d316c4675f40ddccaf8f1cc7aea94170b1e4223 deleted file mode 100644 index ab4a1c7657..0000000000 --- a/test/core/support/percent_decode_corpus/9d316c4675f40ddccaf8f1cc7aea94170b1e4223 +++ /dev/null @@ -1 +0,0 @@ -x%8 \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/ad1c7c11d18a7d116e2c2ef4d4c5afb1270836ae b/test/core/support/percent_decode_corpus/ad1c7c11d18a7d116e2c2ef4d4c5afb1270836ae deleted file mode 100644 index 4ac1945a84..0000000000 --- a/test/core/support/percent_decode_corpus/ad1c7c11d18a7d116e2c2ef4d4c5afb1270836ae +++ /dev/null @@ -1 +0,0 @@ -x);x(_%88x;x_xxyyz \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/b471f94aa4facf502e622e4a248f1ba4063ae681 b/test/core/support/percent_decode_corpus/b471f94aa4facf502e622e4a248f1ba4063ae681 deleted file mode 100644 index 5c673ae28a..0000000000 --- a/test/core/support/percent_decode_corpus/b471f94aa4facf502e622e4a248f1ba4063ae681 +++ /dev/null @@ -1 +0,0 @@ -Ê%ccyzyzŠ \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/bf52ece030f16136d46e0dc97f58d60a0d8a1f0b b/test/core/support/percent_decode_corpus/bf52ece030f16136d46e0dc97f58d60a0d8a1f0b deleted file mode 100644 index e478275ed4..0000000000 --- a/test/core/support/percent_decode_corpus/bf52ece030f16136d46e0dc97f58d60a0d8a1f0b +++ /dev/null @@ -1,2 +0,0 @@ -)'xyyz!úyzŠ[zxÊ%ccyzyzy'z*zŠ -Š diff --git a/test/core/support/percent_decode_corpus/d5b2a7177339ba2b7ce2f60e5f4459bef1e72758 b/test/core/support/percent_decode_corpus/d5b2a7177339ba2b7ce2f60e5f4459bef1e72758 deleted file mode 100644 index c73cbfe8af..0000000000 --- a/test/core/support/percent_decode_corpus/d5b2a7177339ba2b7ce2f60e5f4459bef1e72758 +++ /dev/null @@ -1,2 +0,0 @@ -)'xyyz)úyzŠ[zxÊ%cCyzyzy'z*zŠ -Š diff --git a/test/core/support/percent_decode_corpus/de867b64c54a7ed773dc611fc5cd2f17c5433113 b/test/core/support/percent_decode_corpus/de867b64c54a7ed773dc611fc5cd2f17c5433113 deleted file mode 100644 index f9f7246e9c..0000000000 --- a/test/core/support/percent_decode_corpus/de867b64c54a7ed773dc611fc5cd2f17c5433113 +++ /dev/null @@ -1,2 +0,0 @@ -xxyyz%%øyzŠ[zxy'zyz -Š diff --git a/test/core/support/percent_decode_corpus/e3948dbe004950591630dd5c52f4e0fcbd5e388a b/test/core/support/percent_decode_corpus/e3948dbe004950591630dd5c52f4e0fcbd5e388a deleted file mode 100644 index 83ac46d833..0000000000 --- a/test/core/support/percent_decode_corpus/e3948dbe004950591630dd5c52f4e0fcbd5e388a +++ /dev/null @@ -1 +0,0 @@ -Ê:%Dx;:Ê%)x_%C8cc \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/e7064f0b80f61dbc65915311032d27baa569ae2a b/test/core/support/percent_decode_corpus/e7064f0b80f61dbc65915311032d27baa569ae2a deleted file mode 100644 index e8a0f87653..0000000000 --- a/test/core/support/percent_decode_corpus/e7064f0b80f61dbc65915311032d27baa569ae2a +++ /dev/null @@ -1 +0,0 @@ -) \ No newline at end of file diff --git a/test/core/support/percent_decode_corpus/xyz b/test/core/support/percent_decode_corpus/xyz deleted file mode 100644 index cd470e6190..0000000000 --- a/test/core/support/percent_decode_corpus/xyz +++ /dev/null @@ -1 +0,0 @@ -xyz diff --git a/test/core/support/percent_decode_fuzzer.c b/test/core/support/percent_decode_fuzzer.c deleted file mode 100644 index 3e02980e05..0000000000 --- a/test/core/support/percent_decode_fuzzer.c +++ /dev/null @@ -1,66 +0,0 @@ -/* - * - * Copyright 2016, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -#include -#include - -#include -#include - -#include "src/core/lib/support/percent_encoding.h" -#include "test/core/util/memory_counters.h" - -bool squelch = true; -bool leak_check = true; - -int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - struct grpc_memory_counters counters; - grpc_memory_counters_init(); - gpr_slice input = gpr_slice_from_copied_buffer((const char *)data, size); - gpr_slice output; - if (gpr_strict_percent_decode_slice( - input, gpr_url_percent_encoding_unreserved_bytes, &output)) { - gpr_slice_unref(output); - } - if (gpr_strict_percent_decode_slice( - input, gpr_compatible_percent_encoding_unreserved_bytes, &output)) { - gpr_slice_unref(output); - } - gpr_slice_unref(gpr_permissive_percent_decode_slice(input)); - gpr_slice_unref(input); - counters = grpc_memory_counters_snapshot(); - grpc_memory_counters_destroy(); - GPR_ASSERT(counters.total_size_relative == 0); - return 0; -} diff --git a/test/core/support/percent_encode_corpus/0d3ee7fa54e6c66103965fd4409b044ba7db6c3f b/test/core/support/percent_encode_corpus/0d3ee7fa54e6c66103965fd4409b044ba7db6c3f deleted file mode 100644 index d09c4a039c..0000000000 --- a/test/core/support/percent_encode_corpus/0d3ee7fa54e6c66103965fd4409b044ba7db6c3f +++ /dev/null @@ -1,3 +0,0 @@ -_x;7y -xyz')S)xy-zý -Æ* \ No newline at end of file diff --git a/test/core/support/percent_encode_corpus/2e7ccf75e27b9501e3b28cf1c50ed0c45ab7c226 b/test/core/support/percent_encode_corpus/2e7ccf75e27b9501e3b28cf1c50ed0c45ab7c226 deleted file mode 100644 index 4d0c38d0e2..0000000000 --- a/test/core/support/percent_encode_corpus/2e7ccf75e27b9501e3b28cf1c50ed0c45ab7c226 +++ /dev/null @@ -1 +0,0 @@ -xyx \ No newline at end of file diff --git a/test/core/support/percent_encode_corpus/55bb859f3942c462b03b7cbcf22ab4a0ac9705cf b/test/core/support/percent_encode_corpus/55bb859f3942c462b03b7cbcf22ab4a0ac9705cf deleted file mode 100644 index fc6e93342a..0000000000 --- a/test/core/support/percent_encode_corpus/55bb859f3942c462b03b7cbcf22ab4a0ac9705cf +++ /dev/null @@ -1 +0,0 @@ -.yx.yxxxyzxyyzxy \ No newline at end of file diff --git a/test/core/support/percent_encode_corpus/56070cecd54c845b6d4334953b17b712eb000d93 b/test/core/support/percent_encode_corpus/56070cecd54c845b6d4334953b17b712eb000d93 deleted file mode 100644 index 6823c73f76..0000000000 --- a/test/core/support/percent_encode_corpus/56070cecd54c845b6d4334953b17b712eb000d93 +++ /dev/null @@ -1 +0,0 @@ -xyrxyxyzxxyzxyzxyxyy \ No newline at end of file diff --git a/test/core/support/percent_encode_corpus/61f50e891bf7ff5eb7a7af206f1e25d77f8756e7 b/test/core/support/percent_encode_corpus/61f50e891bf7ff5eb7a7af206f1e25d77f8756e7 deleted file mode 100644 index a65cbb4d5b..0000000000 --- a/test/core/support/percent_encode_corpus/61f50e891bf7ff5eb7a7af206f1e25d77f8756e7 +++ /dev/null @@ -1,3 +0,0 @@ -xy -xyz -)S-Æþ \ No newline at end of file diff --git a/test/core/support/percent_encode_corpus/6e0c60cefc704c7940e475a87dd9ae423061cb5a b/test/core/support/percent_encode_corpus/6e0c60cefc704c7940e475a87dd9ae423061cb5a deleted file mode 100644 index 8d031d7e2d..0000000000 --- a/test/core/support/percent_encode_corpus/6e0c60cefc704c7940e475a87dd9ae423061cb5a +++ /dev/null @@ -1,3 +0,0 @@ -xy -xyz -)S)Æ* \ No newline at end of file diff --git a/test/core/support/percent_encode_corpus/7271ebcc6d22a0f186f7bc3c1973a7ed1bec8d8e b/test/core/support/percent_encode_corpus/7271ebcc6d22a0f186f7bc3c1973a7ed1bec8d8e deleted file mode 100644 index 4d82ca3953..0000000000 --- a/test/core/support/percent_encode_corpus/7271ebcc6d22a0f186f7bc3c1973a7ed1bec8d8e +++ /dev/null @@ -1,4 +0,0 @@ -x;7y -xyz -)S)xyz -Æ* \ No newline at end of file diff --git a/test/core/support/percent_encode_corpus/74c83ece3e2920a67593a9be9c82468f16cbb969 b/test/core/support/percent_encode_corpus/74c83ece3e2920a67593a9be9c82468f16cbb969 deleted file mode 100644 index bb7f4ae07e..0000000000 --- a/test/core/support/percent_encode_corpus/74c83ece3e2920a67593a9be9c82468f16cbb969 +++ /dev/null @@ -1 +0,0 @@ -xyzxy \ No newline at end of file diff --git a/test/core/support/percent_encode_corpus/98e004fd2a9f141a7a019720820080e12d637c06 b/test/core/support/percent_encode_corpus/98e004fd2a9f141a7a019720820080e12d637c06 deleted file mode 100644 index 50879d0f37..0000000000 --- a/test/core/support/percent_encode_corpus/98e004fd2a9f141a7a019720820080e12d637c06 +++ /dev/null @@ -1,3 +0,0 @@ -xy -xz -)Sxy-Æzx_yþ \ No newline at end of file diff --git a/test/core/support/percent_encode_corpus/ba2c1e98227aa21ea3bb2ca4d0e504119717da8b b/test/core/support/percent_encode_corpus/ba2c1e98227aa21ea3bb2ca4d0e504119717da8b deleted file mode 100644 index dc1ab9bfc2..0000000000 --- a/test/core/support/percent_encode_corpus/ba2c1e98227aa21ea3bb2ca4d0e504119717da8b +++ /dev/null @@ -1,3 +0,0 @@ -_x;7y -xyz')S)xyz -Æ* \ No newline at end of file diff --git a/test/core/support/percent_encode_corpus/c16b9fd45370d4afb5d3ebd307a6e263c25ffd45 b/test/core/support/percent_encode_corpus/c16b9fd45370d4afb5d3ebd307a6e263c25ffd45 deleted file mode 100644 index 3476e0b70b..0000000000 --- a/test/core/support/percent_encode_corpus/c16b9fd45370d4afb5d3ebd307a6e263c25ffd45 +++ /dev/null @@ -1,2 +0,0 @@ -xyz -)S \ No newline at end of file diff --git a/test/core/support/percent_encode_corpus/d58c3cd4eab9b6d2343abfa1c25c90a383fe0ec3 b/test/core/support/percent_encode_corpus/d58c3cd4eab9b6d2343abfa1c25c90a383fe0ec3 deleted file mode 100644 index 822d50abf8..0000000000 --- a/test/core/support/percent_encode_corpus/d58c3cd4eab9b6d2343abfa1c25c90a383fe0ec3 +++ /dev/null @@ -1 +0,0 @@ -.yx \ No newline at end of file diff --git a/test/core/support/percent_encode_corpus/e2619218ede30d2b7b8ecd601a9f0ae754b728b4 b/test/core/support/percent_encode_corpus/e2619218ede30d2b7b8ecd601a9f0ae754b728b4 deleted file mode 100644 index 101639c93d..0000000000 --- a/test/core/support/percent_encode_corpus/e2619218ede30d2b7b8ecd601a9f0ae754b728b4 +++ /dev/null @@ -1,4 +0,0 @@ -x;y -xyz -)S)xyz -Æ* \ No newline at end of file diff --git a/test/core/support/percent_encode_corpus/f93b3653e453f0e3eea3198001be6ce46e64bd21 b/test/core/support/percent_encode_corpus/f93b3653e453f0e3eea3198001be6ce46e64bd21 deleted file mode 100644 index 6e07ab342f..0000000000 --- a/test/core/support/percent_encode_corpus/f93b3653e453f0e3eea3198001be6ce46e64bd21 +++ /dev/null @@ -1,5 +0,0 @@ -x;y -xøyz -)S)xyz -Æ.y~ -)S \ No newline at end of file diff --git a/test/core/support/percent_encode_corpus/fd41d029c7682ad3d1c40a9fd017a4c85b673a54 b/test/core/support/percent_encode_corpus/fd41d029c7682ad3d1c40a9fd017a4c85b673a54 deleted file mode 100644 index 13d7fab596..0000000000 --- a/test/core/support/percent_encode_corpus/fd41d029c7682ad3d1c40a9fd017a4c85b673a54 +++ /dev/null @@ -1,3 +0,0 @@ -xy -xyz -)S)S \ No newline at end of file diff --git a/test/core/support/percent_encode_corpus/xyz b/test/core/support/percent_encode_corpus/xyz deleted file mode 100644 index cd470e6190..0000000000 --- a/test/core/support/percent_encode_corpus/xyz +++ /dev/null @@ -1 +0,0 @@ -xyz diff --git a/test/core/support/percent_encode_fuzzer.c b/test/core/support/percent_encode_fuzzer.c deleted file mode 100644 index c9548232b5..0000000000 --- a/test/core/support/percent_encode_fuzzer.c +++ /dev/null @@ -1,73 +0,0 @@ -/* - * - * Copyright 2016, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -#include -#include - -#include -#include - -#include "src/core/lib/support/percent_encoding.h" -#include "test/core/util/memory_counters.h" - -bool squelch = true; -bool leak_check = true; - -static void test(const uint8_t *data, size_t size, const uint8_t *dict) { - struct grpc_memory_counters counters; - grpc_memory_counters_init(); - gpr_slice input = gpr_slice_from_copied_buffer((const char *)data, size); - gpr_slice output = gpr_percent_encode_slice(input, dict); - gpr_slice decoded_output; - // encoder must always produce decodable output - GPR_ASSERT(gpr_strict_percent_decode_slice(output, dict, &decoded_output)); - gpr_slice permissive_decoded_output = - gpr_permissive_percent_decode_slice(output); - // and decoded output must always match the input - GPR_ASSERT(gpr_slice_cmp(input, decoded_output) == 0); - GPR_ASSERT(gpr_slice_cmp(input, permissive_decoded_output) == 0); - gpr_slice_unref(input); - gpr_slice_unref(output); - gpr_slice_unref(decoded_output); - gpr_slice_unref(permissive_decoded_output); - counters = grpc_memory_counters_snapshot(); - grpc_memory_counters_destroy(); - GPR_ASSERT(counters.total_size_relative == 0); -} - -int LLVMFuzzerTestOneInput(const uint8_t *data, size_t size) { - test(data, size, gpr_url_percent_encoding_unreserved_bytes); - test(data, size, gpr_compatible_percent_encoding_unreserved_bytes); - return 0; -} diff --git a/test/core/support/percent_encoding_test.c b/test/core/support/percent_encoding_test.c deleted file mode 100644 index ab5f3f2d14..0000000000 --- a/test/core/support/percent_encoding_test.c +++ /dev/null @@ -1,157 +0,0 @@ -/* - * - * Copyright 2016, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include "src/core/lib/support/percent_encoding.h" - -#include -#include - -#include "src/core/lib/support/string.h" -#include "test/core/util/test_config.h" - -#define TEST_VECTOR(raw, encoded, dict) \ - test_vector(raw, sizeof(raw) - 1, encoded, sizeof(encoded) - 1, dict) - -#define TEST_NONCONFORMANT_VECTOR(encoded, permissive_unencoded, dict) \ - test_nonconformant_vector(encoded, sizeof(encoded) - 1, \ - permissive_unencoded, \ - sizeof(permissive_unencoded) - 1, dict) - -static void test_vector(const char *raw, size_t raw_length, const char *encoded, - size_t encoded_length, const uint8_t *dict) { - char *raw_msg = gpr_dump(raw, raw_length, GPR_DUMP_HEX | GPR_DUMP_ASCII); - char *encoded_msg = - gpr_dump(encoded, encoded_length, GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_DEBUG, "Trial:\nraw = %s\nencoded = %s", raw_msg, encoded_msg); - gpr_free(raw_msg); - gpr_free(encoded_msg); - - gpr_slice raw_slice = gpr_slice_from_copied_buffer(raw, raw_length); - gpr_slice encoded_slice = - gpr_slice_from_copied_buffer(encoded, encoded_length); - gpr_slice raw2encoded_slice = gpr_percent_encode_slice(raw_slice, dict); - gpr_slice encoded2raw_slice; - GPR_ASSERT( - gpr_strict_percent_decode_slice(encoded_slice, dict, &encoded2raw_slice)); - gpr_slice encoded2raw_permissive_slice = - gpr_permissive_percent_decode_slice(encoded_slice); - - char *raw2encoded_msg = - gpr_dump_slice(raw2encoded_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); - char *encoded2raw_msg = - gpr_dump_slice(encoded2raw_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); - char *encoded2raw_permissive_msg = gpr_dump_slice( - encoded2raw_permissive_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_DEBUG, - "Result:\nraw2encoded = %s\nencoded2raw = %s\nencoded2raw_permissive " - "= %s", - raw2encoded_msg, encoded2raw_msg, encoded2raw_permissive_msg); - gpr_free(raw2encoded_msg); - gpr_free(encoded2raw_msg); - gpr_free(encoded2raw_permissive_msg); - - GPR_ASSERT(0 == gpr_slice_cmp(raw_slice, encoded2raw_slice)); - GPR_ASSERT(0 == gpr_slice_cmp(raw_slice, encoded2raw_permissive_slice)); - GPR_ASSERT(0 == gpr_slice_cmp(encoded_slice, raw2encoded_slice)); - - gpr_slice_unref(encoded2raw_slice); - gpr_slice_unref(encoded2raw_permissive_slice); - gpr_slice_unref(raw2encoded_slice); - gpr_slice_unref(raw_slice); - gpr_slice_unref(encoded_slice); -} - -static void test_nonconformant_vector(const char *encoded, - size_t encoded_length, - const char *permissive_unencoded, - size_t permissive_unencoded_length, - const uint8_t *dict) { - char *permissive_unencoded_msg = - gpr_dump(permissive_unencoded, permissive_unencoded_length, - GPR_DUMP_HEX | GPR_DUMP_ASCII); - char *encoded_msg = - gpr_dump(encoded, encoded_length, GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_DEBUG, "Trial:\nraw = %s\nencoded = %s", permissive_unencoded_msg, - encoded_msg); - gpr_free(permissive_unencoded_msg); - gpr_free(encoded_msg); - - gpr_slice permissive_unencoded_slice = gpr_slice_from_copied_buffer( - permissive_unencoded, permissive_unencoded_length); - gpr_slice encoded_slice = - gpr_slice_from_copied_buffer(encoded, encoded_length); - gpr_slice encoded2raw_slice; - GPR_ASSERT(!gpr_strict_percent_decode_slice(encoded_slice, dict, - &encoded2raw_slice)); - gpr_slice encoded2raw_permissive_slice = - gpr_permissive_percent_decode_slice(encoded_slice); - - char *encoded2raw_permissive_msg = gpr_dump_slice( - encoded2raw_permissive_slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); - gpr_log(GPR_DEBUG, "Result:\nencoded2raw_permissive = %s", - encoded2raw_permissive_msg); - gpr_free(encoded2raw_permissive_msg); - - GPR_ASSERT(0 == gpr_slice_cmp(permissive_unencoded_slice, - encoded2raw_permissive_slice)); - - gpr_slice_unref(permissive_unencoded_slice); - gpr_slice_unref(encoded2raw_permissive_slice); - gpr_slice_unref(encoded_slice); -} - -int main(int argc, char **argv) { - grpc_test_init(argc, argv); - TEST_VECTOR( - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~", - "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-_.~", - gpr_url_percent_encoding_unreserved_bytes); - TEST_VECTOR("\x00", "%00", gpr_url_percent_encoding_unreserved_bytes); - TEST_VECTOR("\x01", "%01", gpr_url_percent_encoding_unreserved_bytes); - TEST_VECTOR("a b", "a%20b", gpr_url_percent_encoding_unreserved_bytes); - TEST_VECTOR(" b", "%20b", gpr_url_percent_encoding_unreserved_bytes); - TEST_VECTOR("a b", "a b", gpr_compatible_percent_encoding_unreserved_bytes); - TEST_VECTOR(" b", " b", gpr_compatible_percent_encoding_unreserved_bytes); - TEST_VECTOR("\x0f", "%0F", gpr_url_percent_encoding_unreserved_bytes); - TEST_VECTOR("\xff", "%FF", gpr_url_percent_encoding_unreserved_bytes); - TEST_VECTOR("\xee", "%EE", gpr_url_percent_encoding_unreserved_bytes); - TEST_NONCONFORMANT_VECTOR("%", "%", - gpr_url_percent_encoding_unreserved_bytes); - TEST_NONCONFORMANT_VECTOR("%A", "%A", - gpr_url_percent_encoding_unreserved_bytes); - TEST_NONCONFORMANT_VECTOR("%AG", "%AG", - gpr_url_percent_encoding_unreserved_bytes); - TEST_NONCONFORMANT_VECTOR("\0", "\0", - gpr_url_percent_encoding_unreserved_bytes); - return 0; -} diff --git a/test/core/support/slice_buffer_test.c b/test/core/support/slice_buffer_test.c deleted file mode 100644 index cf2da84c2b..0000000000 --- a/test/core/support/slice_buffer_test.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include -#include -#include "test/core/util/test_config.h" - -void test_slice_buffer_add() { - gpr_slice_buffer buf; - gpr_slice aaa = gpr_slice_from_copied_string("aaa"); - gpr_slice bb = gpr_slice_from_copied_string("bb"); - size_t i; - - gpr_slice_buffer_init(&buf); - for (i = 0; i < 10; i++) { - gpr_slice_ref(aaa); - gpr_slice_ref(bb); - gpr_slice_buffer_add(&buf, aaa); - gpr_slice_buffer_add(&buf, bb); - } - GPR_ASSERT(buf.count > 0); - GPR_ASSERT(buf.length == 50); - gpr_slice_buffer_reset_and_unref(&buf); - GPR_ASSERT(buf.count == 0); - GPR_ASSERT(buf.length == 0); - for (i = 0; i < 10; i++) { - gpr_slice_ref(aaa); - gpr_slice_ref(bb); - gpr_slice_buffer_add(&buf, aaa); - gpr_slice_buffer_add(&buf, bb); - } - GPR_ASSERT(buf.count > 0); - GPR_ASSERT(buf.length == 50); - for (i = 0; i < 10; i++) { - gpr_slice_buffer_pop(&buf); - gpr_slice_unref(aaa); - gpr_slice_unref(bb); - } - GPR_ASSERT(buf.count == 0); - GPR_ASSERT(buf.length == 0); - gpr_slice_buffer_destroy(&buf); -} - -void test_slice_buffer_move_first() { - gpr_slice slices[3]; - gpr_slice_buffer src; - gpr_slice_buffer dst; - int idx = 0; - size_t src_len = 0; - size_t dst_len = 0; - - slices[0] = gpr_slice_from_copied_string("aaa"); - slices[1] = gpr_slice_from_copied_string("bbbb"); - slices[2] = gpr_slice_from_copied_string("ccc"); - - gpr_slice_buffer_init(&src); - gpr_slice_buffer_init(&dst); - for (idx = 0; idx < 3; idx++) { - gpr_slice_ref(slices[idx]); - /* For this test, it is important that we add each slice at a new - slice index */ - gpr_slice_buffer_add_indexed(&src, slices[idx]); - gpr_slice_buffer_add_indexed(&dst, slices[idx]); - } - - /* Case 1: Move more than the first slice's length from src to dst */ - src_len = src.length; - dst_len = dst.length; - gpr_slice_buffer_move_first(&src, 4, &dst); - src_len -= 4; - dst_len += 4; - GPR_ASSERT(src.length == src_len); - GPR_ASSERT(dst.length == dst_len); - - /* src now has two slices ["bbb"] and ["ccc"] */ - /* Case 2: Move the first slice from src to dst */ - gpr_slice_buffer_move_first(&src, 3, &dst); - src_len -= 3; - dst_len += 3; - GPR_ASSERT(src.length == src_len); - GPR_ASSERT(dst.length == dst_len); - - /* src now has one slice ["ccc"] */ - /* Case 3: Move less than the first slice's length from src to dst*/ - gpr_slice_buffer_move_first(&src, 2, &dst); - src_len -= 2; - dst_len += 2; - GPR_ASSERT(src.length == src.length); - GPR_ASSERT(dst.length == dst.length); -} - -int main(int argc, char **argv) { - grpc_test_init(argc, argv); - - test_slice_buffer_add(); - test_slice_buffer_move_first(); - - return 0; -} diff --git a/test/core/support/slice_test.c b/test/core/support/slice_test.c deleted file mode 100644 index 06c364b368..0000000000 --- a/test/core/support/slice_test.c +++ /dev/null @@ -1,265 +0,0 @@ -/* - * - * Copyright 2015, Google Inc. - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above - * copyright notice, this list of conditions and the following disclaimer - * in the documentation and/or other materials provided with the - * distribution. - * * Neither the name of Google Inc. nor the names of its - * contributors may be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT - * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * - */ - -#include - -#include - -#include -#include -#include "test/core/util/test_config.h" - -#define LOG_TEST_NAME(x) gpr_log(GPR_INFO, "%s", x); - -static void test_slice_malloc_returns_something_sensible(void) { - /* Calls gpr_slice_create for various lengths and verifies the internals for - consistency. */ - size_t length; - size_t i; - gpr_slice slice; - - LOG_TEST_NAME("test_slice_malloc_returns_something_sensible"); - - for (length = 0; length <= 1024; length++) { - slice = gpr_slice_malloc(length); - /* If there is a length, slice.data must be non-NULL. If length is zero - we don't care. */ - if (length) { - GPR_ASSERT(GPR_SLICE_START_PTR(slice)); - } - /* Returned slice length must be what was requested. */ - GPR_ASSERT(GPR_SLICE_LENGTH(slice) == length); - /* If the slice has a refcount, it must be destroyable. */ - if (slice.refcount) { - GPR_ASSERT(slice.refcount->ref != NULL); - GPR_ASSERT(slice.refcount->unref != NULL); - } - /* We must be able to write to every byte of the data */ - for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; - } - /* And finally we must succeed in destroying the slice */ - gpr_slice_unref(slice); - } -} - -static void do_nothing(void *ignored) {} - -static void test_slice_new_returns_something_sensible(void) { - uint8_t x; - - gpr_slice slice = gpr_slice_new(&x, 1, do_nothing); - GPR_ASSERT(slice.refcount); - GPR_ASSERT(slice.data.refcounted.bytes == &x); - GPR_ASSERT(slice.data.refcounted.length == 1); - gpr_slice_unref(slice); -} - -/* destroy function that sets a mark to indicate it was called. */ -static void set_mark(void *p) { *((int *)p) = 1; } - -static void test_slice_new_with_user_data(void) { - int marker = 0; - uint8_t buf[2]; - gpr_slice slice; - - buf[0] = 0; - buf[1] = 1; - slice = gpr_slice_new_with_user_data(buf, 2, set_mark, &marker); - GPR_ASSERT(marker == 0); - GPR_ASSERT(GPR_SLICE_LENGTH(slice) == 2); - GPR_ASSERT(GPR_SLICE_START_PTR(slice)[0] == 0); - GPR_ASSERT(GPR_SLICE_START_PTR(slice)[1] == 1); - - /* unref should cause destroy function to run. */ - gpr_slice_unref(slice); - GPR_ASSERT(marker == 1); -} - -static int do_nothing_with_len_1_calls = 0; - -static void do_nothing_with_len_1(void *ignored, size_t len) { - GPR_ASSERT(len == 1); - do_nothing_with_len_1_calls++; -} - -static void test_slice_new_with_len_returns_something_sensible(void) { - uint8_t x; - int num_refs = 5; /* To test adding/removing an arbitrary number of refs */ - int i; - - gpr_slice slice = gpr_slice_new_with_len(&x, 1, do_nothing_with_len_1); - GPR_ASSERT(slice.refcount); /* ref count is initialized to 1 at this point */ - GPR_ASSERT(slice.data.refcounted.bytes == &x); - GPR_ASSERT(slice.data.refcounted.length == 1); - GPR_ASSERT(do_nothing_with_len_1_calls == 0); - - /* Add an arbitrary number of refs to the slice and remoe the refs. This is to - make sure that that the destroy callback (i.e do_nothing_with_len_1()) is - not called until the last unref operation */ - for (i = 0; i < num_refs; i++) { - gpr_slice_ref(slice); - } - for (i = 0; i < num_refs; i++) { - gpr_slice_unref(slice); - } - GPR_ASSERT(do_nothing_with_len_1_calls == 0); /* Shouldn't be called yet */ - - /* last unref */ - gpr_slice_unref(slice); - GPR_ASSERT(do_nothing_with_len_1_calls == 1); -} - -static void test_slice_sub_works(unsigned length) { - gpr_slice slice; - gpr_slice sub; - unsigned i, j, k; - - LOG_TEST_NAME("test_slice_sub_works"); - gpr_log(GPR_INFO, "length=%d", length); - - /* Create a slice in which each byte is equal to the distance from it to the - beginning of the slice. */ - slice = gpr_slice_malloc(length); - for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; - } - - /* Ensure that for all subsets length is correct and that we start on the - correct byte. Additionally check that no copies were made. */ - for (i = 0; i < length; i++) { - for (j = i; j < length; j++) { - sub = gpr_slice_sub(slice, i, j); - GPR_ASSERT(GPR_SLICE_LENGTH(sub) == j - i); - for (k = 0; k < j - i; k++) { - GPR_ASSERT(GPR_SLICE_START_PTR(sub)[k] == (uint8_t)(i + k)); - } - gpr_slice_unref(sub); - } - } - gpr_slice_unref(slice); -} - -static void check_head_tail(gpr_slice slice, gpr_slice head, gpr_slice tail) { - GPR_ASSERT(GPR_SLICE_LENGTH(slice) == - GPR_SLICE_LENGTH(head) + GPR_SLICE_LENGTH(tail)); - GPR_ASSERT(0 == memcmp(GPR_SLICE_START_PTR(slice), GPR_SLICE_START_PTR(head), - GPR_SLICE_LENGTH(head))); - GPR_ASSERT(0 == memcmp(GPR_SLICE_START_PTR(slice) + GPR_SLICE_LENGTH(head), - GPR_SLICE_START_PTR(tail), GPR_SLICE_LENGTH(tail))); -} - -static void test_slice_split_head_works(size_t length) { - gpr_slice slice; - gpr_slice head, tail; - size_t i; - - LOG_TEST_NAME("test_slice_split_head_works"); - gpr_log(GPR_INFO, "length=%" PRIuPTR, length); - - /* Create a slice in which each byte is equal to the distance from it to the - beginning of the slice. */ - slice = gpr_slice_malloc(length); - for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; - } - - /* Ensure that for all subsets length is correct and that we start on the - correct byte. Additionally check that no copies were made. */ - for (i = 0; i < length; i++) { - tail = gpr_slice_ref(slice); - head = gpr_slice_split_head(&tail, i); - check_head_tail(slice, head, tail); - gpr_slice_unref(tail); - gpr_slice_unref(head); - } - - gpr_slice_unref(slice); -} - -static void test_slice_split_tail_works(size_t length) { - gpr_slice slice; - gpr_slice head, tail; - size_t i; - - LOG_TEST_NAME("test_slice_split_tail_works"); - gpr_log(GPR_INFO, "length=%" PRIuPTR, length); - - /* Create a slice in which each byte is equal to the distance from it to the - beginning of the slice. */ - slice = gpr_slice_malloc(length); - for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; - } - - /* Ensure that for all subsets length is correct and that we start on the - correct byte. Additionally check that no copies were made. */ - for (i = 0; i < length; i++) { - head = gpr_slice_ref(slice); - tail = gpr_slice_split_tail(&head, i); - check_head_tail(slice, head, tail); - gpr_slice_unref(tail); - gpr_slice_unref(head); - } - - gpr_slice_unref(slice); -} - -static void test_slice_from_copied_string_works(void) { - static const char *text = "HELLO WORLD!"; - gpr_slice slice; - - LOG_TEST_NAME("test_slice_from_copied_string_works"); - - slice = gpr_slice_from_copied_string(text); - GPR_ASSERT(strlen(text) == GPR_SLICE_LENGTH(slice)); - GPR_ASSERT(0 == - memcmp(text, GPR_SLICE_START_PTR(slice), GPR_SLICE_LENGTH(slice))); - gpr_slice_unref(slice); -} - -int main(int argc, char **argv) { - unsigned length; - grpc_test_init(argc, argv); - test_slice_malloc_returns_something_sensible(); - test_slice_new_returns_something_sensible(); - test_slice_new_with_user_data(); - test_slice_new_with_len_returns_something_sensible(); - for (length = 0; length < 128; length++) { - test_slice_sub_works(length); - test_slice_split_head_works(length); - test_slice_split_tail_works(length); - } - test_slice_from_copied_string_works(); - return 0; -} diff --git a/test/core/support/string_test.c b/test/core/support/string_test.c index 378e45a942..53709ed6f7 100644 --- a/test/core/support/string_test.c +++ b/test/core/support/string_test.c @@ -76,34 +76,6 @@ static void test_dump(void) { expect_dump("ab", 2, GPR_DUMP_HEX | GPR_DUMP_ASCII, "61 62 'ab'"); } -static void expect_slice_dump(gpr_slice slice, uint32_t flags, - const char *result) { - char *got = gpr_dump_slice(slice, flags); - GPR_ASSERT(0 == strcmp(got, result)); - gpr_free(got); - gpr_slice_unref(slice); -} - -static void test_dump_slice(void) { - static const char *text = "HELLO WORLD!"; - static const char *long_text = - "It was a bright cold day in April, and the clocks were striking " - "thirteen. Winston Smith, his chin nuzzled into his breast in an effort " - "to escape the vile wind, slipped quickly through the glass doors of " - "Victory Mansions, though not quickly enough to prevent a swirl of " - "gritty dust from entering along with him."; - - LOG_TEST_NAME("test_dump_slice"); - - expect_slice_dump(gpr_slice_from_copied_string(text), GPR_DUMP_ASCII, text); - expect_slice_dump(gpr_slice_from_copied_string(long_text), GPR_DUMP_ASCII, - long_text); - expect_slice_dump(gpr_slice_from_copied_buffer("\x01", 1), GPR_DUMP_HEX, - "01"); - expect_slice_dump(gpr_slice_from_copied_buffer("\x01", 1), - GPR_DUMP_HEX | GPR_DUMP_ASCII, "01 '.'"); -} - static void test_pu32_fail(const char *s) { uint32_t out; GPR_ASSERT(!gpr_parse_bytes_to_uint32(s, strlen(s), &out)); @@ -221,72 +193,6 @@ static void test_strjoin_sep(void) { gpr_free(joined); } -static void test_strsplit(void) { - gpr_slice_buffer *parts; - gpr_slice str; - - LOG_TEST_NAME("test_strsplit"); - - parts = gpr_malloc(sizeof(gpr_slice_buffer)); - gpr_slice_buffer_init(parts); - - str = gpr_slice_from_copied_string("one, two, three, four"); - gpr_slice_split(str, ", ", parts); - GPR_ASSERT(4 == parts->count); - GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], "one")); - GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[1], "two")); - GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[2], "three")); - GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[3], "four")); - gpr_slice_buffer_reset_and_unref(parts); - gpr_slice_unref(str); - - /* separator not present in string */ - str = gpr_slice_from_copied_string("one two three four"); - gpr_slice_split(str, ", ", parts); - GPR_ASSERT(1 == parts->count); - GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], "one two three four")); - gpr_slice_buffer_reset_and_unref(parts); - gpr_slice_unref(str); - - /* separator at the end */ - str = gpr_slice_from_copied_string("foo,"); - gpr_slice_split(str, ",", parts); - GPR_ASSERT(2 == parts->count); - GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], "foo")); - GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[1], "")); - gpr_slice_buffer_reset_and_unref(parts); - gpr_slice_unref(str); - - /* separator at the beginning */ - str = gpr_slice_from_copied_string(",foo"); - gpr_slice_split(str, ",", parts); - GPR_ASSERT(2 == parts->count); - GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], "")); - GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[1], "foo")); - gpr_slice_buffer_reset_and_unref(parts); - gpr_slice_unref(str); - - /* standalone separator */ - str = gpr_slice_from_copied_string(","); - gpr_slice_split(str, ",", parts); - GPR_ASSERT(2 == parts->count); - GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], "")); - GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[1], "")); - gpr_slice_buffer_reset_and_unref(parts); - gpr_slice_unref(str); - - /* empty input */ - str = gpr_slice_from_copied_string(""); - gpr_slice_split(str, ", ", parts); - GPR_ASSERT(1 == parts->count); - GPR_ASSERT(0 == gpr_slice_str_cmp(parts->slices[0], "")); - gpr_slice_buffer_reset_and_unref(parts); - gpr_slice_unref(str); - - gpr_slice_buffer_destroy(parts); - gpr_free(parts); -} - static void test_ltoa() { char *str; char buf[GPR_LTOA_MIN_BUFSIZE]; diff --git a/test/core/surface/byte_buffer_reader_test.c b/test/core/surface/byte_buffer_reader_test.c index 1ab1a06211..eafeb04b11 100644 --- a/test/core/surface/byte_buffer_reader_test.c +++ b/test/core/surface/byte_buffer_reader_test.c @@ -49,102 +49,102 @@ #define LOG_TEST(x) gpr_log(GPR_INFO, "%s", x) static void test_read_one_slice(void) { - gpr_slice slice; + grpc_slice slice; grpc_byte_buffer *buffer; grpc_byte_buffer_reader reader; - gpr_slice first_slice, second_slice; + grpc_slice first_slice, second_slice; int first_code, second_code; LOG_TEST("test_read_one_slice"); - slice = gpr_slice_from_copied_string("test"); + slice = grpc_slice_from_copied_string("test"); buffer = grpc_raw_byte_buffer_create(&slice, 1); - gpr_slice_unref(slice); + grpc_slice_unref(slice); GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, buffer) && "Couldn't init byte buffer reader"); first_code = grpc_byte_buffer_reader_next(&reader, &first_slice); GPR_ASSERT(first_code != 0); GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(first_slice), "test", 4) == 0); - gpr_slice_unref(first_slice); + grpc_slice_unref(first_slice); second_code = grpc_byte_buffer_reader_next(&reader, &second_slice); GPR_ASSERT(second_code == 0); grpc_byte_buffer_destroy(buffer); } static void test_read_one_slice_malloc(void) { - gpr_slice slice; + grpc_slice slice; grpc_byte_buffer *buffer; grpc_byte_buffer_reader reader; - gpr_slice first_slice, second_slice; + grpc_slice first_slice, second_slice; int first_code, second_code; LOG_TEST("test_read_one_slice_malloc"); - slice = gpr_slice_malloc(4); + slice = grpc_slice_malloc(4); memcpy(GPR_SLICE_START_PTR(slice), "test", 4); buffer = grpc_raw_byte_buffer_create(&slice, 1); - gpr_slice_unref(slice); + grpc_slice_unref(slice); GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, buffer) && "Couldn't init byte buffer reader"); first_code = grpc_byte_buffer_reader_next(&reader, &first_slice); GPR_ASSERT(first_code != 0); GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(first_slice), "test", 4) == 0); - gpr_slice_unref(first_slice); + grpc_slice_unref(first_slice); second_code = grpc_byte_buffer_reader_next(&reader, &second_slice); GPR_ASSERT(second_code == 0); grpc_byte_buffer_destroy(buffer); } static void test_read_none_compressed_slice(void) { - gpr_slice slice; + grpc_slice slice; grpc_byte_buffer *buffer; grpc_byte_buffer_reader reader; - gpr_slice first_slice, second_slice; + grpc_slice first_slice, second_slice; int first_code, second_code; LOG_TEST("test_read_none_compressed_slice"); - slice = gpr_slice_from_copied_string("test"); + slice = grpc_slice_from_copied_string("test"); buffer = grpc_raw_byte_buffer_create(&slice, 1); - gpr_slice_unref(slice); + grpc_slice_unref(slice); GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, buffer) && "Couldn't init byte buffer reader"); first_code = grpc_byte_buffer_reader_next(&reader, &first_slice); GPR_ASSERT(first_code != 0); GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(first_slice), "test", 4) == 0); - gpr_slice_unref(first_slice); + grpc_slice_unref(first_slice); second_code = grpc_byte_buffer_reader_next(&reader, &second_slice); GPR_ASSERT(second_code == 0); grpc_byte_buffer_destroy(buffer); } static void test_read_corrupted_slice(void) { - gpr_slice slice; + grpc_slice slice; grpc_byte_buffer *buffer; grpc_byte_buffer_reader reader; LOG_TEST("test_read_corrupted_slice"); - slice = gpr_slice_from_copied_string("test"); + slice = grpc_slice_from_copied_string("test"); buffer = grpc_raw_byte_buffer_create(&slice, 1); buffer->data.raw.compression = GRPC_COMPRESS_GZIP; /* lies! */ - gpr_slice_unref(slice); + grpc_slice_unref(slice); GPR_ASSERT(!grpc_byte_buffer_reader_init(&reader, buffer)); grpc_byte_buffer_destroy(buffer); } static void read_compressed_slice(grpc_compression_algorithm algorithm, size_t input_size) { - gpr_slice input_slice; - gpr_slice_buffer sliceb_in; - gpr_slice_buffer sliceb_out; + grpc_slice input_slice; + grpc_slice_buffer sliceb_in; + grpc_slice_buffer sliceb_out; grpc_byte_buffer *buffer; grpc_byte_buffer_reader reader; - gpr_slice read_slice; + grpc_slice read_slice; size_t read_count = 0; - gpr_slice_buffer_init(&sliceb_in); - gpr_slice_buffer_init(&sliceb_out); + grpc_slice_buffer_init(&sliceb_in); + grpc_slice_buffer_init(&sliceb_out); - input_slice = gpr_slice_malloc(input_size); + input_slice = grpc_slice_malloc(input_size); memset(GPR_SLICE_START_PTR(input_slice), 'a', input_size); - gpr_slice_buffer_add(&sliceb_in, input_slice); /* takes ownership */ + grpc_slice_buffer_add(&sliceb_in, input_slice); /* takes ownership */ GPR_ASSERT(grpc_msg_compress(algorithm, &sliceb_in, &sliceb_out)); buffer = grpc_raw_compressed_byte_buffer_create(sliceb_out.slices, @@ -157,13 +157,13 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm, GPR_SLICE_START_PTR(input_slice) + read_count, GPR_SLICE_LENGTH(read_slice)) == 0); read_count += GPR_SLICE_LENGTH(read_slice); - gpr_slice_unref(read_slice); + grpc_slice_unref(read_slice); } GPR_ASSERT(read_count == input_size); grpc_byte_buffer_reader_destroy(&reader); grpc_byte_buffer_destroy(buffer); - gpr_slice_buffer_destroy(&sliceb_out); - gpr_slice_buffer_destroy(&sliceb_in); + grpc_slice_buffer_destroy(&sliceb_out); + grpc_slice_buffer_destroy(&sliceb_in); } static void test_read_gzip_compressed_slice(void) { @@ -179,15 +179,15 @@ static void test_read_deflate_compressed_slice(void) { } static void test_byte_buffer_from_reader(void) { - gpr_slice slice; + grpc_slice slice; grpc_byte_buffer *buffer, *buffer_from_reader; grpc_byte_buffer_reader reader; LOG_TEST("test_byte_buffer_from_reader"); - slice = gpr_slice_malloc(4); + slice = grpc_slice_malloc(4); memcpy(GPR_SLICE_START_PTR(slice), "test", 4); buffer = grpc_raw_byte_buffer_create(&slice, 1); - gpr_slice_unref(slice); + grpc_slice_unref(slice); GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, buffer) && "Couldn't init byte buffer reader"); @@ -206,24 +206,24 @@ static void test_byte_buffer_from_reader(void) { static void test_readall(void) { char *lotsa_as[512]; char *lotsa_bs[1024]; - gpr_slice slices[2]; + grpc_slice slices[2]; grpc_byte_buffer *buffer; grpc_byte_buffer_reader reader; - gpr_slice slice_out; + grpc_slice slice_out; LOG_TEST("test_readall"); memset(lotsa_as, 'a', 512); memset(lotsa_bs, 'b', 1024); /* use slices large enough to overflow inlining */ - slices[0] = gpr_slice_malloc(512); + slices[0] = grpc_slice_malloc(512); memcpy(GPR_SLICE_START_PTR(slices[0]), lotsa_as, 512); - slices[1] = gpr_slice_malloc(1024); + slices[1] = grpc_slice_malloc(1024); memcpy(GPR_SLICE_START_PTR(slices[1]), lotsa_bs, 1024); buffer = grpc_raw_byte_buffer_create(slices, 2); - gpr_slice_unref(slices[0]); - gpr_slice_unref(slices[1]); + grpc_slice_unref(slices[0]); + grpc_slice_unref(slices[1]); GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, buffer) && "Couldn't init byte buffer reader"); @@ -233,32 +233,32 @@ static void test_readall(void) { GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(slice_out), lotsa_as, 512) == 0); GPR_ASSERT(memcmp(&(GPR_SLICE_START_PTR(slice_out)[512]), lotsa_bs, 1024) == 0); - gpr_slice_unref(slice_out); + grpc_slice_unref(slice_out); grpc_byte_buffer_destroy(buffer); } static void test_byte_buffer_copy(void) { char *lotsa_as[512]; char *lotsa_bs[1024]; - gpr_slice slices[2]; + grpc_slice slices[2]; grpc_byte_buffer *buffer; grpc_byte_buffer *copied_buffer; grpc_byte_buffer_reader reader; - gpr_slice slice_out; + grpc_slice slice_out; LOG_TEST("test_byte_buffer_copy"); memset(lotsa_as, 'a', 512); memset(lotsa_bs, 'b', 1024); /* use slices large enough to overflow inlining */ - slices[0] = gpr_slice_malloc(512); + slices[0] = grpc_slice_malloc(512); memcpy(GPR_SLICE_START_PTR(slices[0]), lotsa_as, 512); - slices[1] = gpr_slice_malloc(1024); + slices[1] = grpc_slice_malloc(1024); memcpy(GPR_SLICE_START_PTR(slices[1]), lotsa_bs, 1024); buffer = grpc_raw_byte_buffer_create(slices, 2); - gpr_slice_unref(slices[0]); - gpr_slice_unref(slices[1]); + grpc_slice_unref(slices[0]); + grpc_slice_unref(slices[1]); copied_buffer = grpc_byte_buffer_copy(buffer); GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, buffer) && @@ -269,7 +269,7 @@ static void test_byte_buffer_copy(void) { GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(slice_out), lotsa_as, 512) == 0); GPR_ASSERT(memcmp(&(GPR_SLICE_START_PTR(slice_out)[512]), lotsa_bs, 1024) == 0); - gpr_slice_unref(slice_out); + grpc_slice_unref(slice_out); grpc_byte_buffer_destroy(buffer); grpc_byte_buffer_destroy(copied_buffer); } diff --git a/test/core/transport/chttp2/bin_decoder_test.c b/test/core/transport/chttp2/bin_decoder_test.c index c4e6cd332f..3b111934ad 100644 --- a/test/core/transport/chttp2/bin_decoder_test.c +++ b/test/core/transport/chttp2/bin_decoder_test.c @@ -42,9 +42,9 @@ static int all_ok = 1; -static void expect_slice_eq(gpr_slice expected, gpr_slice slice, char *debug, +static void expect_slice_eq(grpc_slice expected, grpc_slice slice, char *debug, int line) { - if (0 != gpr_slice_cmp(slice, expected)) { + if (0 != grpc_slice_cmp(slice, expected)) { char *hs = gpr_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); char *he = gpr_dump_slice(expected, GPR_DUMP_HEX | GPR_DUMP_ASCII); gpr_log(GPR_ERROR, "FAILED:%d: %s\ngot: %s\nwant: %s", line, debug, hs, @@ -53,35 +53,35 @@ static void expect_slice_eq(gpr_slice expected, gpr_slice slice, char *debug, gpr_free(he); all_ok = 0; } - gpr_slice_unref(expected); - gpr_slice_unref(slice); + grpc_slice_unref(expected); + grpc_slice_unref(slice); } -static gpr_slice base64_encode(const char *s) { - gpr_slice ss = gpr_slice_from_copied_string(s); - gpr_slice out = grpc_chttp2_base64_encode(ss); - gpr_slice_unref(ss); +static grpc_slice base64_encode(const char *s) { + grpc_slice ss = grpc_slice_from_copied_string(s); + grpc_slice out = grpc_chttp2_base64_encode(ss); + grpc_slice_unref(ss); return out; } -static gpr_slice base64_decode(const char *s) { - gpr_slice ss = gpr_slice_from_copied_string(s); - gpr_slice out = grpc_chttp2_base64_decode(ss); - gpr_slice_unref(ss); +static grpc_slice base64_decode(const char *s) { + grpc_slice ss = grpc_slice_from_copied_string(s); + grpc_slice out = grpc_chttp2_base64_decode(ss); + grpc_slice_unref(ss); return out; } -static gpr_slice base64_decode_with_length(const char *s, +static grpc_slice base64_decode_with_length(const char *s, size_t output_length) { - gpr_slice ss = gpr_slice_from_copied_string(s); - gpr_slice out = grpc_chttp2_base64_decode_with_length(ss, output_length); - gpr_slice_unref(ss); + grpc_slice ss = grpc_slice_from_copied_string(s); + grpc_slice out = grpc_chttp2_base64_decode_with_length(ss, output_length); + grpc_slice_unref(ss); return out; } #define EXPECT_SLICE_EQ(expected, slice) \ expect_slice_eq( \ - gpr_slice_from_copied_buffer(expected, sizeof(expected) - 1), slice, \ + grpc_slice_from_copied_buffer(expected, sizeof(expected) - 1), slice, \ #slice, __LINE__); #define ENCODE_AND_DECODE(s) \ diff --git a/test/core/transport/chttp2/bin_encoder_test.c b/test/core/transport/chttp2/bin_encoder_test.c index 08d10735a5..f7df4452ce 100644 --- a/test/core/transport/chttp2/bin_encoder_test.c +++ b/test/core/transport/chttp2/bin_encoder_test.c @@ -45,9 +45,9 @@ static int all_ok = 1; -static void expect_slice_eq(gpr_slice expected, gpr_slice slice, char *debug, +static void expect_slice_eq(grpc_slice expected, grpc_slice slice, char *debug, int line) { - if (0 != gpr_slice_cmp(slice, expected)) { + if (0 != grpc_slice_cmp(slice, expected)) { char *hs = gpr_dump_slice(slice, GPR_DUMP_HEX | GPR_DUMP_ASCII); char *he = gpr_dump_slice(expected, GPR_DUMP_HEX | GPR_DUMP_ASCII); gpr_log(GPR_ERROR, "FAILED:%d: %s\ngot: %s\nwant: %s", line, debug, hs, @@ -56,35 +56,35 @@ static void expect_slice_eq(gpr_slice expected, gpr_slice slice, char *debug, gpr_free(he); all_ok = 0; } - gpr_slice_unref(expected); - gpr_slice_unref(slice); + grpc_slice_unref(expected); + grpc_slice_unref(slice); } -static gpr_slice B64(const char *s) { - gpr_slice ss = gpr_slice_from_copied_string(s); - gpr_slice out = grpc_chttp2_base64_encode(ss); - gpr_slice_unref(ss); +static grpc_slice B64(const char *s) { + grpc_slice ss = grpc_slice_from_copied_string(s); + grpc_slice out = grpc_chttp2_base64_encode(ss); + grpc_slice_unref(ss); return out; } -static gpr_slice HUFF(const char *s) { - gpr_slice ss = gpr_slice_from_copied_string(s); - gpr_slice out = grpc_chttp2_huffman_compress(ss); - gpr_slice_unref(ss); +static grpc_slice HUFF(const char *s) { + grpc_slice ss = grpc_slice_from_copied_string(s); + grpc_slice out = grpc_chttp2_huffman_compress(ss); + grpc_slice_unref(ss); return out; } #define EXPECT_SLICE_EQ(expected, slice) \ expect_slice_eq( \ - gpr_slice_from_copied_buffer(expected, sizeof(expected) - 1), slice, \ + grpc_slice_from_copied_buffer(expected, sizeof(expected) - 1), slice, \ #slice, __LINE__); static void expect_combined_equiv(const char *s, size_t len, int line) { - gpr_slice input = gpr_slice_from_copied_buffer(s, len); - gpr_slice base64 = grpc_chttp2_base64_encode(input); - gpr_slice expect = grpc_chttp2_huffman_compress(base64); - gpr_slice got = grpc_chttp2_base64_encode_and_huffman_compress_impl(input); - if (0 != gpr_slice_cmp(expect, got)) { + grpc_slice input = grpc_slice_from_copied_buffer(s, len); + grpc_slice base64 = grpc_chttp2_base64_encode(input); + grpc_slice expect = grpc_chttp2_huffman_compress(base64); + grpc_slice got = grpc_chttp2_base64_encode_and_huffman_compress_impl(input); + if (0 != grpc_slice_cmp(expect, got)) { char *t = gpr_dump_slice(input, GPR_DUMP_HEX | GPR_DUMP_ASCII); char *e = gpr_dump_slice(expect, GPR_DUMP_HEX | GPR_DUMP_ASCII); char *g = gpr_dump_slice(got, GPR_DUMP_HEX | GPR_DUMP_ASCII); @@ -95,10 +95,10 @@ static void expect_combined_equiv(const char *s, size_t len, int line) { gpr_free(g); all_ok = 0; } - gpr_slice_unref(input); - gpr_slice_unref(base64); - gpr_slice_unref(expect); - gpr_slice_unref(got); + grpc_slice_unref(input); + grpc_slice_unref(base64); + grpc_slice_unref(expect); + grpc_slice_unref(got); } #define EXPECT_COMBINED_EQUIV(x) \ diff --git a/test/core/transport/chttp2/hpack_encoder_test.c b/test/core/transport/chttp2/hpack_encoder_test.c index 1c1c74879b..2b4279673a 100644 --- a/test/core/transport/chttp2/hpack_encoder_test.c +++ b/test/core/transport/chttp2/hpack_encoder_test.c @@ -60,9 +60,9 @@ size_t cap_to_delete = 0; hexstring passed in */ static void verify(size_t window_available, int eof, size_t expect_window_used, const char *expected, size_t nheaders, ...) { - gpr_slice_buffer output; - gpr_slice merged; - gpr_slice expect = parse_hexstring(expected); + grpc_slice_buffer output; + grpc_slice merged; + grpc_slice expect = parse_hexstring(expected); size_t i; va_list l; grpc_linked_mdelem *e = gpr_malloc(sizeof(*e) * nheaders); @@ -93,17 +93,17 @@ static void verify(size_t window_available, int eof, size_t expect_window_used, } to_delete[num_to_delete++] = e; - gpr_slice_buffer_init(&output); + grpc_slice_buffer_init(&output); grpc_transport_one_way_stats stats; memset(&stats, 0, sizeof(stats)); grpc_chttp2_encode_header(&g_compressor, 0xdeadbeef, &b, eof, 16384, &stats, &output); merged = grpc_slice_merge(output.slices, output.count); - gpr_slice_buffer_destroy(&output); + grpc_slice_buffer_destroy(&output); grpc_metadata_batch_destroy(&b); - if (0 != gpr_slice_cmp(merged, expect)) { + if (0 != grpc_slice_cmp(merged, expect)) { char *expect_str = gpr_dump_slice(expect, GPR_DUMP_HEX | GPR_DUMP_ASCII); char *got_str = gpr_dump_slice(merged, GPR_DUMP_HEX | GPR_DUMP_ASCII); gpr_log(GPR_ERROR, "mismatched output for %s", expected); @@ -114,8 +114,8 @@ static void verify(size_t window_available, int eof, size_t expect_window_used, g_failure = 1; } - gpr_slice_unref(merged); - gpr_slice_unref(expect); + grpc_slice_unref(merged); + grpc_slice_unref(expect); } static void test_basic_headers(void) { @@ -186,7 +186,7 @@ static void test_decode_table_overflow(void) { static void verify_table_size_change_match_elem_size(const char *key, const char *value) { - gpr_slice_buffer output; + grpc_slice_buffer output; grpc_mdelem *elem = grpc_mdelem_from_strings(key, value); size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem); size_t initial_table_size = g_compressor.table_size; @@ -198,13 +198,13 @@ static void verify_table_size_change_match_elem_size(const char *key, e[0].next = NULL; b.list.head = &e[0]; b.list.tail = &e[0]; - gpr_slice_buffer_init(&output); + grpc_slice_buffer_init(&output); grpc_transport_one_way_stats stats; memset(&stats, 0, sizeof(stats)); grpc_chttp2_encode_header(&g_compressor, 0xdeadbeef, &b, 0, 16384, &stats, &output); - gpr_slice_buffer_destroy(&output); + grpc_slice_buffer_destroy(&output); grpc_metadata_batch_destroy(&b); GPR_ASSERT(g_compressor.table_size == elem_size + initial_table_size); diff --git a/test/core/transport/chttp2/hpack_parser_test.c b/test/core/transport/chttp2/hpack_parser_test.c index 55b64f5d99..ffea0e19e2 100644 --- a/test/core/transport/chttp2/hpack_parser_test.c +++ b/test/core/transport/chttp2/hpack_parser_test.c @@ -52,16 +52,16 @@ static void onhdr(grpc_exec_ctx *exec_ctx, void *ud, grpc_mdelem *md) { GPR_ASSERT(ekey); evalue = va_arg(chk->args, char *); GPR_ASSERT(evalue); - GPR_ASSERT(gpr_slice_str_cmp(md->key->slice, ekey) == 0); - GPR_ASSERT(gpr_slice_str_cmp(md->value->slice, evalue) == 0); + GPR_ASSERT(grpc_slice_str_cmp(md->key->slice, ekey) == 0); + GPR_ASSERT(grpc_slice_str_cmp(md->value->slice, evalue) == 0); GRPC_MDELEM_UNREF(md); } static void test_vector(grpc_chttp2_hpack_parser *parser, grpc_slice_split_mode mode, const char *hexstring, ... /* char *key, char *value */) { - gpr_slice input = parse_hexstring(hexstring); - gpr_slice *slices; + grpc_slice input = parse_hexstring(hexstring); + grpc_slice *slices; size_t nslices; size_t i; test_checker chk; @@ -72,7 +72,7 @@ static void test_vector(grpc_chttp2_hpack_parser *parser, parser->on_header_user_data = &chk; grpc_split_slices(mode, &input, 1, &slices, &nslices); - gpr_slice_unref(input); + grpc_slice_unref(input); for (i = 0; i < nslices; i++) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; @@ -83,7 +83,7 @@ static void test_vector(grpc_chttp2_hpack_parser *parser, } for (i = 0; i < nslices; i++) { - gpr_slice_unref(slices[i]); + grpc_slice_unref(slices[i]); } gpr_free(slices); diff --git a/test/core/transport/chttp2/hpack_table_test.c b/test/core/transport/chttp2/hpack_table_test.c index 75b0ef4629..1a7e2442ca 100644 --- a/test/core/transport/chttp2/hpack_table_test.c +++ b/test/core/transport/chttp2/hpack_table_test.c @@ -48,7 +48,7 @@ static void assert_str(const grpc_chttp2_hptbl *tbl, grpc_mdstr *mdstr, const char *str) { - GPR_ASSERT(gpr_slice_str_cmp(mdstr->slice, str) == 0); + GPR_ASSERT(grpc_slice_str_cmp(mdstr->slice, str) == 0); } static void assert_index(const grpc_chttp2_hptbl *tbl, uint32_t idx, diff --git a/test/core/transport/chttp2/varint_test.c b/test/core/transport/chttp2/varint_test.c index 3552bf0c59..28cb404ce2 100644 --- a/test/core/transport/chttp2/varint_test.c +++ b/test/core/transport/chttp2/varint_test.c @@ -41,16 +41,16 @@ static void test_varint(uint32_t value, uint32_t prefix_bits, uint8_t prefix_or, const char *expect_bytes, size_t expect_length) { uint32_t nbytes = GRPC_CHTTP2_VARINT_LENGTH(value, prefix_bits); - gpr_slice expect = gpr_slice_from_copied_buffer(expect_bytes, expect_length); - gpr_slice slice; + grpc_slice expect = grpc_slice_from_copied_buffer(expect_bytes, expect_length); + grpc_slice slice; gpr_log(GPR_DEBUG, "Test: 0x%08x", value); GPR_ASSERT(nbytes == expect_length); - slice = gpr_slice_malloc(nbytes); + slice = grpc_slice_malloc(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); + GPR_ASSERT(grpc_slice_cmp(expect, slice) == 0); + grpc_slice_unref(expect); + grpc_slice_unref(slice); } #define TEST_VARINT(value, prefix_bits, prefix_or, expect) \ diff --git a/test/core/transport/metadata_test.c b/test/core/transport/metadata_test.c index 007892930c..e47777ee72 100644 --- a/test/core/transport/metadata_test.c +++ b/test/core/transport/metadata_test.c @@ -68,8 +68,8 @@ static void test_create_string(void) { s3 = grpc_mdstr_from_string("very much not hello"); GPR_ASSERT(s1 == s2); GPR_ASSERT(s3 != s1); - GPR_ASSERT(gpr_slice_str_cmp(s1->slice, "hello") == 0); - GPR_ASSERT(gpr_slice_str_cmp(s3->slice, "very much not hello") == 0); + GPR_ASSERT(grpc_slice_str_cmp(s1->slice, "hello") == 0); + GPR_ASSERT(grpc_slice_str_cmp(s3->slice, "very much not hello") == 0); GRPC_MDSTR_UNREF(s1); GRPC_MDSTR_UNREF(s2); GRPC_MDSTR_UNREF(s3); @@ -89,9 +89,9 @@ static void test_create_metadata(void) { GPR_ASSERT(m3 != m1); GPR_ASSERT(m3->key == m1->key); GPR_ASSERT(m3->value != m1->value); - GPR_ASSERT(gpr_slice_str_cmp(m1->key->slice, "a") == 0); - GPR_ASSERT(gpr_slice_str_cmp(m1->value->slice, "b") == 0); - GPR_ASSERT(gpr_slice_str_cmp(m3->value->slice, "c") == 0); + GPR_ASSERT(grpc_slice_str_cmp(m1->key->slice, "a") == 0); + GPR_ASSERT(grpc_slice_str_cmp(m1->value->slice, "b") == 0); + GPR_ASSERT(grpc_slice_str_cmp(m3->value->slice, "c") == 0); GRPC_MDELEM_UNREF(m1); GRPC_MDELEM_UNREF(m2); GRPC_MDELEM_UNREF(m3); @@ -205,7 +205,7 @@ static void test_things_stick_around(void) { static void test_slices_work(void) { /* ensure no memory leaks when switching representation from mdstr to slice */ grpc_mdstr *str; - gpr_slice slice; + grpc_slice slice; LOG_TEST("test_slices_work"); @@ -213,14 +213,14 @@ static void test_slices_work(void) { str = grpc_mdstr_from_string( "123456789012345678901234567890123456789012345678901234567890"); - slice = gpr_slice_ref(str->slice); + slice = grpc_slice_ref(str->slice); GRPC_MDSTR_UNREF(str); - gpr_slice_unref(slice); + grpc_slice_unref(slice); str = grpc_mdstr_from_string( "123456789012345678901234567890123456789012345678901234567890"); - slice = gpr_slice_ref(str->slice); - gpr_slice_unref(slice); + slice = grpc_slice_ref(str->slice); + grpc_slice_unref(slice); GRPC_MDSTR_UNREF(str); grpc_shutdown(); @@ -228,8 +228,8 @@ static void test_slices_work(void) { static void test_base64_and_huffman_works(void) { grpc_mdstr *str; - gpr_slice slice1; - gpr_slice slice2; + grpc_slice slice1; + grpc_slice slice2; LOG_TEST("test_base64_and_huffman_works"); @@ -237,9 +237,9 @@ static void test_base64_and_huffman_works(void) { str = grpc_mdstr_from_string("abcdefg"); slice1 = grpc_mdstr_as_base64_encoded_and_huffman_compressed(str); slice2 = grpc_chttp2_base64_encode_and_huffman_compress(str->slice); - GPR_ASSERT(0 == gpr_slice_cmp(slice1, slice2)); + GPR_ASSERT(0 == grpc_slice_cmp(slice1, slice2)); - gpr_slice_unref(slice2); + grpc_slice_unref(slice2); GRPC_MDSTR_UNREF(str); grpc_shutdown(); } @@ -276,13 +276,13 @@ static void verify_binary_header_size(const char *key, const uint8_t *value, grpc_mdelem *elem = grpc_mdelem_from_string_and_buffer(key, value, value_len); GPR_ASSERT(grpc_is_binary_header(key, strlen(key))); size_t elem_size = grpc_mdelem_get_size_in_hpack_table(elem); - gpr_slice value_slice = - gpr_slice_from_copied_buffer((const char *)value, value_len); - gpr_slice base64_encoded = grpc_chttp2_base64_encode(value_slice); + grpc_slice value_slice = + grpc_slice_from_copied_buffer((const char *)value, value_len); + grpc_slice base64_encoded = grpc_chttp2_base64_encode(value_slice); size_t expected_size = 32 + strlen(key) + GPR_SLICE_LENGTH(base64_encoded); GPR_ASSERT(expected_size == elem_size); - gpr_slice_unref(value_slice); - gpr_slice_unref(base64_encoded); + grpc_slice_unref(value_slice); + grpc_slice_unref(base64_encoded); GRPC_MDELEM_UNREF(elem); } diff --git a/test/core/util/mock_endpoint.c b/test/core/util/mock_endpoint.c index 2b041a4484..6e09427c2b 100644 --- a/test/core/util/mock_endpoint.c +++ b/test/core/util/mock_endpoint.c @@ -42,19 +42,19 @@ typedef struct grpc_mock_endpoint { grpc_endpoint base; gpr_mu mu; int refs; - void (*on_write)(gpr_slice slice); - gpr_slice_buffer read_buffer; - gpr_slice_buffer *on_read_out; + 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_mock_endpoint; static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - gpr_slice_buffer *slices, grpc_closure *cb) { + 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) { - gpr_slice_buffer_swap(&m->read_buffer, slices); + grpc_slice_buffer_swap(&m->read_buffer, slices); grpc_exec_ctx_sched(exec_ctx, cb, GRPC_ERROR_NONE, NULL); } else { m->on_read = cb; @@ -64,7 +64,7 @@ static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, } static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - gpr_slice_buffer *slices, grpc_closure *cb) { + 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]); @@ -82,7 +82,7 @@ static void unref(grpc_exec_ctx *exec_ctx, grpc_mock_endpoint *m) { gpr_mu_lock(&m->mu); if (0 == --m->refs) { gpr_mu_unlock(&m->mu); - gpr_slice_buffer_destroy(&m->read_buffer); + grpc_slice_buffer_destroy(&m->read_buffer); grpc_resource_user_destroy(exec_ctx, &m->resource_user); gpr_free(m); } else { @@ -137,7 +137,7 @@ static const grpc_endpoint_vtable vtable = { me_get_peer, }; -grpc_endpoint *grpc_mock_endpoint_create(void (*on_write)(gpr_slice slice), +grpc_endpoint *grpc_mock_endpoint_create(void (*on_write)(grpc_slice slice), grpc_resource_quota *resource_quota) { grpc_mock_endpoint *m = gpr_malloc(sizeof(*m)); m->base.vtable = &vtable; @@ -146,7 +146,7 @@ grpc_endpoint *grpc_mock_endpoint_create(void (*on_write)(gpr_slice slice), gpr_asprintf(&name, "mock_endpoint_%" PRIxPTR, (intptr_t)m); grpc_resource_user_init(&m->resource_user, resource_quota, name); gpr_free(name); - gpr_slice_buffer_init(&m->read_buffer); + grpc_slice_buffer_init(&m->read_buffer); gpr_mu_init(&m->mu); m->on_write = on_write; m->on_read = NULL; @@ -154,15 +154,15 @@ grpc_endpoint *grpc_mock_endpoint_create(void (*on_write)(gpr_slice slice), } void grpc_mock_endpoint_put_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - gpr_slice slice) { + grpc_slice slice) { grpc_mock_endpoint *m = (grpc_mock_endpoint *)ep; gpr_mu_lock(&m->mu); if (m->on_read != NULL) { - gpr_slice_buffer_add(m->on_read_out, slice); + grpc_slice_buffer_add(m->on_read_out, slice); grpc_exec_ctx_sched(exec_ctx, m->on_read, GRPC_ERROR_NONE, NULL); m->on_read = NULL; } else { - gpr_slice_buffer_add(&m->read_buffer, slice); + grpc_slice_buffer_add(&m->read_buffer, slice); } gpr_mu_unlock(&m->mu); } diff --git a/test/core/util/mock_endpoint.h b/test/core/util/mock_endpoint.h index b3a464ca01..8f8d2a412d 100644 --- a/test/core/util/mock_endpoint.h +++ b/test/core/util/mock_endpoint.h @@ -36,9 +36,9 @@ #include "src/core/lib/iomgr/endpoint.h" -grpc_endpoint *grpc_mock_endpoint_create(void (*on_write)(gpr_slice slice), +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, gpr_slice slice); + 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 95ae4cf706..a07e83b775 100644 --- a/test/core/util/one_corpus_entry_fuzzer.c +++ b/test/core/util/one_corpus_entry_fuzzer.c @@ -42,12 +42,12 @@ extern bool squelch; extern bool leak_check; int main(int argc, char **argv) { - gpr_slice buffer; + grpc_slice buffer; squelch = false; leak_check = false; GPR_ASSERT( GRPC_LOG_IF_ERROR("load_file", grpc_load_file(argv[1], 0, &buffer))); LLVMFuzzerTestOneInput(GPR_SLICE_START_PTR(buffer), GPR_SLICE_LENGTH(buffer)); - gpr_slice_unref(buffer); + grpc_slice_unref(buffer); return 0; } diff --git a/test/core/util/parse_hexstring.c b/test/core/util/parse_hexstring.c index 3ad7ce5828..91149a691a 100644 --- a/test/core/util/parse_hexstring.c +++ b/test/core/util/parse_hexstring.c @@ -34,12 +34,12 @@ #include "test/core/util/parse_hexstring.h" #include -gpr_slice parse_hexstring(const char *hexstring) { +grpc_slice parse_hexstring(const char *hexstring) { size_t nibbles = 0; const char *p = 0; uint8_t *out; uint8_t temp; - gpr_slice slice; + grpc_slice slice; for (p = hexstring; *p; p++) { nibbles += (*p >= '0' && *p <= '9') || (*p >= 'a' && *p <= 'f'); @@ -47,7 +47,7 @@ gpr_slice parse_hexstring(const char *hexstring) { GPR_ASSERT((nibbles & 1) == 0); - slice = gpr_slice_malloc(nibbles / 2); + slice = grpc_slice_malloc(nibbles / 2); out = GPR_SLICE_START_PTR(slice); nibbles = 0; diff --git a/test/core/util/parse_hexstring.h b/test/core/util/parse_hexstring.h index ddbfe541c6..bfdc23299a 100644 --- a/test/core/util/parse_hexstring.h +++ b/test/core/util/parse_hexstring.h @@ -36,6 +36,6 @@ #include -gpr_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 ee6ef7da60..a5bac8aaa8 100644 --- a/test/core/util/passthru_endpoint.c +++ b/test/core/util/passthru_endpoint.c @@ -43,8 +43,8 @@ typedef struct passthru_endpoint passthru_endpoint; typedef struct { grpc_endpoint base; passthru_endpoint *parent; - gpr_slice_buffer read_buffer; - gpr_slice_buffer *on_read_out; + grpc_slice_buffer read_buffer; + grpc_slice_buffer *on_read_out; grpc_closure *on_read; grpc_resource_user resource_user; } half; @@ -58,14 +58,14 @@ struct passthru_endpoint { }; static void me_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - gpr_slice_buffer *slices, grpc_closure *cb) { + grpc_slice_buffer *slices, grpc_closure *cb) { half *m = (half *)ep; gpr_mu_lock(&m->parent->mu); if (m->parent->shutdown) { grpc_exec_ctx_sched(exec_ctx, cb, GRPC_ERROR_CREATE("Already shutdown"), NULL); } else if (m->read_buffer.count > 0) { - gpr_slice_buffer_swap(&m->read_buffer, slices); + grpc_slice_buffer_swap(&m->read_buffer, slices); grpc_exec_ctx_sched(exec_ctx, cb, GRPC_ERROR_NONE, NULL); } else { m->on_read = cb; @@ -80,7 +80,7 @@ static half *other_half(half *h) { } static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - gpr_slice_buffer *slices, grpc_closure *cb) { + 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; @@ -88,13 +88,13 @@ static void me_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, error = GRPC_ERROR_CREATE("Endpoint already shutdown"); } else if (m->on_read != NULL) { for (size_t i = 0; i < slices->count; i++) { - gpr_slice_buffer_add(m->on_read_out, gpr_slice_ref(slices->slices[i])); + grpc_slice_buffer_add(m->on_read_out, grpc_slice_ref(slices->slices[i])); } grpc_exec_ctx_sched(exec_ctx, m->on_read, GRPC_ERROR_NONE, NULL); m->on_read = NULL; } else { for (size_t i = 0; i < slices->count; i++) { - gpr_slice_buffer_add(&m->read_buffer, gpr_slice_ref(slices->slices[i])); + grpc_slice_buffer_add(&m->read_buffer, grpc_slice_ref(slices->slices[i])); } } gpr_mu_unlock(&m->parent->mu); @@ -132,8 +132,8 @@ static void me_really_destroy(grpc_exec_ctx *exec_ctx, void *ep, if (0 == --p->halves) { gpr_mu_unlock(&p->mu); gpr_mu_destroy(&p->mu); - gpr_slice_buffer_destroy(&p->client.read_buffer); - gpr_slice_buffer_destroy(&p->server.read_buffer); + grpc_slice_buffer_destroy(&p->client.read_buffer); + grpc_slice_buffer_destroy(&p->server.read_buffer); gpr_free(p); } else { gpr_mu_unlock(&p->mu); @@ -174,7 +174,7 @@ static void half_init(half *m, passthru_endpoint *parent, const char *half_name) { m->base.vtable = &vtable; m->parent = parent; - gpr_slice_buffer_init(&m->read_buffer); + grpc_slice_buffer_init(&m->read_buffer); m->on_read = NULL; char *name; gpr_asprintf(&name, "passthru_endpoint_%s_%" PRIxPTR, half_name, diff --git a/test/core/util/slice_splitter.c b/test/core/util/slice_splitter.c index 95b55a6505..6647b8fbb3 100644 --- a/test/core/util/slice_splitter.c +++ b/test/core/util/slice_splitter.c @@ -50,8 +50,8 @@ const char *grpc_slice_split_mode_name(grpc_slice_split_mode mode) { return "error"; } -void grpc_split_slices(grpc_slice_split_mode mode, gpr_slice *src_slices, - size_t src_slice_count, gpr_slice **dst_slices, +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; @@ -59,10 +59,10 @@ void grpc_split_slices(grpc_slice_split_mode mode, gpr_slice *src_slices, switch (mode) { case GRPC_SLICE_SPLIT_IDENTITY: *dst_slice_count = src_slice_count; - *dst_slices = gpr_malloc(sizeof(gpr_slice) * src_slice_count); + *dst_slices = gpr_malloc(sizeof(grpc_slice) * src_slice_count); for (i = 0; i < src_slice_count; i++) { (*dst_slices)[i] = src_slices[i]; - gpr_slice_ref((*dst_slices)[i]); + grpc_slice_ref((*dst_slices)[i]); } break; case GRPC_SLICE_SPLIT_MERGE_ALL: @@ -71,8 +71,8 @@ void grpc_split_slices(grpc_slice_split_mode mode, gpr_slice *src_slices, for (i = 0; i < src_slice_count; i++) { length += GPR_SLICE_LENGTH(src_slices[i]); } - *dst_slices = gpr_malloc(sizeof(gpr_slice)); - **dst_slices = gpr_slice_malloc(length); + *dst_slices = gpr_malloc(sizeof(grpc_slice)); + **dst_slices = grpc_slice_malloc(length); length = 0; for (i = 0; i < src_slice_count; i++) { memcpy(GPR_SLICE_START_PTR(**dst_slices) + length, @@ -87,11 +87,11 @@ void grpc_split_slices(grpc_slice_split_mode mode, gpr_slice *src_slices, length += GPR_SLICE_LENGTH(src_slices[i]); } *dst_slice_count = length; - *dst_slices = gpr_malloc(sizeof(gpr_slice) * length); + *dst_slices = gpr_malloc(sizeof(grpc_slice) * length); length = 0; for (i = 0; i < src_slice_count; i++) { for (j = 0; j < GPR_SLICE_LENGTH(src_slices[i]); j++) { - (*dst_slices)[length] = gpr_slice_sub(src_slices[i], j, j + 1); + (*dst_slices)[length] = grpc_slice_sub(src_slices[i], j, j + 1); length++; } } @@ -100,25 +100,25 @@ void grpc_split_slices(grpc_slice_split_mode mode, gpr_slice *src_slices, } void grpc_split_slices_to_buffer(grpc_slice_split_mode mode, - gpr_slice *src_slices, size_t src_slice_count, - gpr_slice_buffer *dst) { - gpr_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); for (i = 0; i < nslices; i++) { /* add indexed to avoid re-merging split slices */ - gpr_slice_buffer_add_indexed(dst, slices[i]); + grpc_slice_buffer_add_indexed(dst, slices[i]); } gpr_free(slices); } -void grpc_split_slice_buffer(grpc_slice_split_mode mode, gpr_slice_buffer *src, - gpr_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); } -gpr_slice grpc_slice_merge(gpr_slice *slices, size_t nslices) { +grpc_slice grpc_slice_merge(grpc_slice *slices, size_t nslices) { uint8_t *out = NULL; size_t length = 0; size_t capacity = 0; @@ -134,5 +134,5 @@ gpr_slice grpc_slice_merge(gpr_slice *slices, size_t nslices) { length += GPR_SLICE_LENGTH(slices[i]); } - return gpr_slice_new(out, length, gpr_free); + return grpc_slice_new(out, length, gpr_free); } diff --git a/test/core/util/slice_splitter.h b/test/core/util/slice_splitter.h index d030c2cb55..9e62dfa0f3 100644 --- a/test/core/util/slice_splitter.h +++ b/test/core/util/slice_splitter.h @@ -51,17 +51,17 @@ 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, gpr_slice *src_slices, - size_t src_slice_count, gpr_slice **dst_slices, +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, - gpr_slice *src_slices, size_t src_slice_count, - gpr_slice_buffer *dst); -void grpc_split_slice_buffer(grpc_slice_split_mode mode, gpr_slice_buffer *src, - gpr_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); -gpr_slice grpc_slice_merge(gpr_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); diff --git a/test/cpp/grpclb/grpclb_api_test.cc b/test/cpp/grpclb/grpclb_api_test.cc index e67189c69e..fed5a2cce1 100644 --- a/test/cpp/grpclb/grpclb_api_test.cc +++ b/test/cpp/grpclb/grpclb_api_test.cc @@ -71,12 +71,12 @@ TEST_F(GrpclbTest, CreateRequest) { const grpc::string service_name = "AServiceName"; LoadBalanceRequest request; grpc_grpclb_request* c_req = grpc_grpclb_request_create(service_name.c_str()); - gpr_slice slice = grpc_grpclb_request_encode(c_req); + grpc_slice slice = grpc_grpclb_request_encode(c_req); const int num_bytes_written = GPR_SLICE_LENGTH(slice); EXPECT_GT(num_bytes_written, 0); request.ParseFromArray(GPR_SLICE_START_PTR(slice), num_bytes_written); EXPECT_EQ(request.initial_request().name(), service_name); - gpr_slice_unref(slice); + grpc_slice_unref(slice); grpc_grpclb_request_destroy(c_req); } @@ -88,15 +88,15 @@ TEST_F(GrpclbTest, ParseInitialResponse) { client_stats_report_interval->set_seconds(123); client_stats_report_interval->set_nanos(456); const grpc::string encoded_response = response.SerializeAsString(); - gpr_slice encoded_slice = - gpr_slice_from_copied_string(encoded_response.c_str()); + grpc_slice encoded_slice = + grpc_slice_from_copied_string(encoded_response.c_str()); grpc_grpclb_initial_response* c_initial_response = grpc_grpclb_initial_response_parse(encoded_slice); EXPECT_FALSE(c_initial_response->has_load_balancer_delegate); EXPECT_EQ(c_initial_response->client_stats_report_interval.seconds, 123); EXPECT_EQ(c_initial_response->client_stats_report_interval.nanos, 456); - gpr_slice_unref(encoded_slice); + grpc_slice_unref(encoded_slice); grpc_grpclb_initial_response_destroy(c_initial_response); } @@ -116,7 +116,7 @@ TEST_F(GrpclbTest, ParseResponseServerList) { expiration_interval->set_nanos(999); const grpc::string encoded_response = response.SerializeAsString(); - const gpr_slice encoded_slice = gpr_slice_from_copied_buffer( + const grpc_slice encoded_slice = grpc_slice_from_copied_buffer( encoded_response.data(), encoded_response.size()); grpc_grpclb_serverlist* c_serverlist = grpc_grpclb_response_parse_serverlist(encoded_slice); @@ -137,7 +137,7 @@ TEST_F(GrpclbTest, ParseResponseServerList) { EXPECT_TRUE(c_serverlist->expiration_interval.has_nanos); EXPECT_EQ(c_serverlist->expiration_interval.nanos, 999); - gpr_slice_unref(encoded_slice); + grpc_slice_unref(encoded_slice); grpc_grpclb_destroy_serverlist(c_serverlist); } diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc index b6056f9ae4..a65e425625 100644 --- a/test/cpp/grpclb/grpclb_test.cc +++ b/test/cpp/grpclb/grpclb_test.cc @@ -109,7 +109,7 @@ typedef struct test_fixture { static void *tag(intptr_t t) { return (void *)t; } -static gpr_slice build_response_payload_slice( +static grpc_slice build_response_payload_slice( const char *host, int *ports, size_t nports, int64_t expiration_interval_secs, int32_t expiration_interval_nanos) { // server_list { @@ -148,7 +148,7 @@ static gpr_slice build_response_payload_slice( server->set_load_balance_token(token_data); } const grpc::string &enc_resp = response.SerializeAsString(); - return gpr_slice_from_copied_buffer(enc_resp.data(), enc_resp.size()); + return grpc_slice_from_copied_buffer(enc_resp.data(), enc_resp.size()); } static void drain_cq(grpc_completion_queue *cq) { @@ -210,17 +210,17 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports, // validate initial request. grpc_byte_buffer_reader bbr; grpc_byte_buffer_reader_init(&bbr, request_payload_recv); - gpr_slice request_payload_slice = grpc_byte_buffer_reader_readall(&bbr); + grpc_slice request_payload_slice = grpc_byte_buffer_reader_readall(&bbr); grpc::lb::v1::LoadBalanceRequest request; request.ParseFromArray(GPR_SLICE_START_PTR(request_payload_slice), GPR_SLICE_LENGTH(request_payload_slice)); GPR_ASSERT(request.has_initial_request()); GPR_ASSERT(request.initial_request().name() == sf->servers_hostport); - gpr_slice_unref(request_payload_slice); + grpc_slice_unref(request_payload_slice); grpc_byte_buffer_reader_destroy(&bbr); grpc_byte_buffer_destroy(request_payload_recv); - gpr_slice response_payload_slice; + grpc_slice response_payload_slice; op = ops; op->op = GRPC_OP_SEND_INITIAL_METADATA; op->data.send_initial_metadata.count = 0; @@ -264,7 +264,7 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports, sf->servers_hostport, i); grpc_byte_buffer_destroy(response_payload); - gpr_slice_unref(response_payload_slice); + grpc_slice_unref(response_payload_slice); } gpr_log(GPR_INFO, "LB Server[%s] shutting down", sf->servers_hostport); @@ -355,7 +355,7 @@ static void start_backend_server(server_fixture *sf) { gpr_log(GPR_INFO, "Server[%s] after tag 101", sf->servers_hostport); bool exit = false; - gpr_slice response_payload_slice = gpr_slice_from_copied_string(PAYLOAD); + grpc_slice response_payload_slice = grpc_slice_from_copied_string(PAYLOAD); while (!exit) { op = ops; op->op = GRPC_OP_RECV_MESSAGE; @@ -414,7 +414,7 @@ static void start_backend_server(server_fixture *sf) { ++sf->num_calls_serviced; gpr_log(GPR_INFO, "Server[%s] OUT OF THE LOOP", sf->servers_hostport); - gpr_slice_unref(response_payload_slice); + grpc_slice_unref(response_payload_slice); op = ops; op->op = GRPC_OP_SEND_STATUS_FROM_SERVER; @@ -456,7 +456,7 @@ static void perform_request(client_fixture *cf) { int i; memset(ops, 0, sizeof(ops)); - gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); c = grpc_channel_create_call(cf->client, NULL, GRPC_PROPAGATE_DEFAULTS, cf->cq, "/foo", "foo.test.google.fr:1234", @@ -515,7 +515,7 @@ static void perform_request(client_fixture *cf) { grpc_byte_buffer_destroy(response_payload_recv); } - gpr_slice_unref(request_payload_slice); + grpc_slice_unref(request_payload_slice); op = ops; op->op = GRPC_OP_SEND_CLOSE_FROM_CLIENT; diff --git a/test/cpp/qps/client.h b/test/cpp/qps/client.h index 9983c8a7b0..d63346a582 100644 --- a/test/cpp/qps/client.h +++ b/test/cpp/qps/client.h @@ -103,7 +103,7 @@ class ClientRequestCreator { if (payload_config.has_bytebuf_params()) { std::unique_ptr buf( new char[payload_config.bytebuf_params().req_size()]); - gpr_slice s = gpr_slice_from_copied_buffer( + grpc_slice s = grpc_slice_from_copied_buffer( buf.get(), payload_config.bytebuf_params().req_size()); Slice slice(s, Slice::STEAL_REF); *req = ByteBuffer(&slice, 1); diff --git a/test/cpp/qps/server_async.cc b/test/cpp/qps/server_async.cc index bc4c896d83..4fcdb4f083 100644 --- a/test/cpp/qps/server_async.cc +++ b/test/cpp/qps/server_async.cc @@ -380,7 +380,7 @@ static Status ProcessGenericRPC(const PayloadConfig &payload_config, ByteBuffer *response) { int resp_size = payload_config.bytebuf_params().resp_size(); std::unique_ptr buf(new char[resp_size]); - gpr_slice s = gpr_slice_from_copied_buffer(buf.get(), resp_size); + grpc_slice s = grpc_slice_from_copied_buffer(buf.get(), resp_size); Slice slice(s, Slice::STEAL_REF); *response = ByteBuffer(&slice, 1); return Status::OK; diff --git a/test/cpp/util/byte_buffer_proto_helper.cc b/test/cpp/util/byte_buffer_proto_helper.cc index d625d6f3f4..ab5ca261e6 100644 --- a/test/cpp/util/byte_buffer_proto_helper.cc +++ b/test/cpp/util/byte_buffer_proto_helper.cc @@ -51,7 +51,7 @@ std::unique_ptr SerializeToByteBuffer( grpc::protobuf::Message* message) { grpc::string buf; message->SerializeToString(&buf); - gpr_slice s = gpr_slice_from_copied_string(buf.c_str()); + grpc_slice s = grpc_slice_from_copied_string(buf.c_str()); Slice slice(s, Slice::STEAL_REF); return std::unique_ptr(new ByteBuffer(&slice, 1)); } diff --git a/test/cpp/util/byte_buffer_test.cc b/test/cpp/util/byte_buffer_test.cc index 2089a62011..f66f471d7e 100644 --- a/test/cpp/util/byte_buffer_test.cc +++ b/test/cpp/util/byte_buffer_test.cc @@ -49,14 +49,14 @@ const char* kContent2 = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy world"; class ByteBufferTest : public ::testing::Test {}; TEST_F(ByteBufferTest, CreateFromSingleSlice) { - gpr_slice hello = gpr_slice_from_copied_string(kContent1); + grpc_slice hello = grpc_slice_from_copied_string(kContent1); Slice s(hello, Slice::STEAL_REF); ByteBuffer buffer(&s, 1); } TEST_F(ByteBufferTest, CreateFromVector) { - gpr_slice hello = gpr_slice_from_copied_string(kContent1); - gpr_slice world = gpr_slice_from_copied_string(kContent2); + grpc_slice hello = grpc_slice_from_copied_string(kContent1); + grpc_slice world = grpc_slice_from_copied_string(kContent2); std::vector slices; slices.push_back(Slice(hello, Slice::STEAL_REF)); slices.push_back(Slice(world, Slice::STEAL_REF)); @@ -64,15 +64,15 @@ TEST_F(ByteBufferTest, CreateFromVector) { } TEST_F(ByteBufferTest, Clear) { - gpr_slice hello = gpr_slice_from_copied_string(kContent1); + grpc_slice hello = grpc_slice_from_copied_string(kContent1); Slice s(hello, Slice::STEAL_REF); ByteBuffer buffer(&s, 1); buffer.Clear(); } TEST_F(ByteBufferTest, Length) { - gpr_slice hello = gpr_slice_from_copied_string(kContent1); - gpr_slice world = gpr_slice_from_copied_string(kContent2); + grpc_slice hello = grpc_slice_from_copied_string(kContent1); + grpc_slice world = grpc_slice_from_copied_string(kContent2); std::vector slices; slices.push_back(Slice(hello, Slice::STEAL_REF)); slices.push_back(Slice(world, Slice::STEAL_REF)); @@ -80,7 +80,7 @@ TEST_F(ByteBufferTest, Length) { EXPECT_EQ(strlen(kContent1) + strlen(kContent2), buffer.Length()); } -bool SliceEqual(const Slice& a, gpr_slice b) { +bool SliceEqual(const Slice& a, grpc_slice b) { if (a.size() != GPR_SLICE_LENGTH(b)) { return false; } @@ -93,8 +93,8 @@ bool SliceEqual(const Slice& a, gpr_slice b) { } TEST_F(ByteBufferTest, Dump) { - gpr_slice hello = gpr_slice_from_copied_string(kContent1); - gpr_slice world = gpr_slice_from_copied_string(kContent2); + grpc_slice hello = grpc_slice_from_copied_string(kContent1); + grpc_slice world = grpc_slice_from_copied_string(kContent2); std::vector slices; slices.push_back(Slice(hello, Slice::STEAL_REF)); slices.push_back(Slice(world, Slice::STEAL_REF)); @@ -106,8 +106,8 @@ TEST_F(ByteBufferTest, Dump) { } TEST_F(ByteBufferTest, SerializationMakesCopy) { - gpr_slice hello = gpr_slice_from_copied_string(kContent1); - gpr_slice world = gpr_slice_from_copied_string(kContent2); + grpc_slice hello = grpc_slice_from_copied_string(kContent1); + grpc_slice world = grpc_slice_from_copied_string(kContent2); std::vector slices; slices.push_back(Slice(hello, Slice::STEAL_REF)); slices.push_back(Slice(world, Slice::STEAL_REF)); diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc index 1edffbe08e..e36475bc9e 100644 --- a/test/cpp/util/cli_call.cc +++ b/test/cpp/util/cli_call.cc @@ -72,7 +72,7 @@ Status CliCall::Call(std::shared_ptr channel, cq.Next(&got_tag, &ok); GPR_ASSERT(ok); - gpr_slice s = gpr_slice_from_copied_string(request.c_str()); + grpc_slice s = grpc_slice_from_copied_string(request.c_str()); grpc::Slice req_slice(s, grpc::Slice::STEAL_REF); grpc::ByteBuffer send_buffer(&req_slice, 1); call->Write(send_buffer, tag(2)); diff --git a/test/cpp/util/slice_test.cc b/test/cpp/util/slice_test.cc index 45799ae157..3e50700303 100644 --- a/test/cpp/util/slice_test.cc +++ b/test/cpp/util/slice_test.cc @@ -51,15 +51,15 @@ class SliceTest : public ::testing::Test { }; TEST_F(SliceTest, Steal) { - gpr_slice s = gpr_slice_from_copied_string(kContent); + grpc_slice s = grpc_slice_from_copied_string(kContent); Slice spp(s, Slice::STEAL_REF); CheckSlice(spp, kContent); } TEST_F(SliceTest, Add) { - gpr_slice s = gpr_slice_from_copied_string(kContent); + grpc_slice s = grpc_slice_from_copied_string(kContent); Slice spp(s, Slice::ADD_REF); - gpr_slice_unref(s); + grpc_slice_unref(s); CheckSlice(spp, kContent); } @@ -69,13 +69,13 @@ TEST_F(SliceTest, Empty) { } TEST_F(SliceTest, Cslice) { - gpr_slice s = gpr_slice_from_copied_string(kContent); + grpc_slice s = grpc_slice_from_copied_string(kContent); Slice spp(s, Slice::STEAL_REF); CheckSlice(spp, kContent); - gpr_slice c_slice = spp.c_slice(); + grpc_slice c_slice = spp.c_slice(); EXPECT_EQ(GPR_SLICE_START_PTR(s), GPR_SLICE_START_PTR(c_slice)); EXPECT_EQ(GPR_SLICE_END_PTR(s), GPR_SLICE_END_PTR(c_slice)); - gpr_slice_unref(c_slice); + grpc_slice_unref(c_slice); } } // namespace diff --git a/tools/run_tests/sources_and_headers.json b/tools/run_tests/sources_and_headers.json index 9a49c61480..9ae5627a77 100644 --- a/tools/run_tests/sources_and_headers.json +++ b/tools/run_tests/sources_and_headers.json @@ -754,7 +754,7 @@ "headers": [], "is_filegroup": false, "language": "c", - "name": "gpr_slice_buffer_test", + "name": "grpc_slice_buffer_test", "src": [ "test/core/support/slice_buffer_test.c" ], @@ -769,7 +769,7 @@ "headers": [], "is_filegroup": false, "language": "c", - "name": "gpr_slice_test", + "name": "grpc_slice_test", "src": [ "test/core/support/slice_test.c" ], diff --git a/tools/run_tests/tests.json b/tools/run_tests/tests.json index a1d59c0053..8713578f4a 100644 --- a/tools/run_tests/tests.json +++ b/tools/run_tests/tests.json @@ -815,7 +815,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "gpr_slice_buffer_test", + "name": "grpc_slice_buffer_test", "platforms": [ "linux", "mac", @@ -836,7 +836,7 @@ "flaky": false, "gtest": false, "language": "c", - "name": "gpr_slice_test", + "name": "grpc_slice_test", "platforms": [ "linux", "mac", diff --git a/vsprojects/buildtests_c.sln b/vsprojects/buildtests_c.sln index b1918809bf..08feb72861 100644 --- a/vsprojects/buildtests_c.sln +++ b/vsprojects/buildtests_c.sln @@ -433,7 +433,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr_percent_encoding_test", {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr_slice_buffer_test", "vcxproj\test\gpr_slice_buffer_test\gpr_slice_buffer_test.vcxproj", "{E679773D-DE89-AEBB-9787-59019989B825}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grpc_slice_buffer_test", "vcxproj\test\grpc_slice_buffer_test\grpc_slice_buffer_test.vcxproj", "{E679773D-DE89-AEBB-9787-59019989B825}" ProjectSection(myProperties) = preProject lib = "False" EndProjectSection @@ -442,7 +442,7 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr_slice_buffer_test", "vc {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} = {B23D3D1A-9438-4EDA-BEB6-9A0A03D17792} EndProjectSection EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "gpr_slice_test", "vcxproj\test\gpr_slice_test\gpr_slice_test.vcxproj", "{7F2D1623-AF04-DD98-BCE6-61ADB9A52366}" +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "grpc_slice_test", "vcxproj\test\grpc_slice_test\grpc_slice_test.vcxproj", "{7F2D1623-AF04-DD98-BCE6-61ADB9A52366}" ProjectSection(myProperties) = preProject lib = "False" EndProjectSection diff --git a/vsprojects/vcxproj/test/gpr_slice_buffer_test/gpr_slice_buffer_test.vcxproj b/vsprojects/vcxproj/test/gpr_slice_buffer_test/gpr_slice_buffer_test.vcxproj index 33926ff116..6343575915 100644 --- a/vsprojects/vcxproj/test/gpr_slice_buffer_test/gpr_slice_buffer_test.vcxproj +++ b/vsprojects/vcxproj/test/gpr_slice_buffer_test/gpr_slice_buffer_test.vcxproj @@ -60,14 +60,14 @@ - gpr_slice_buffer_test + grpc_slice_buffer_test static Debug static Debug - gpr_slice_buffer_test + grpc_slice_buffer_test static Release static diff --git a/vsprojects/vcxproj/test/gpr_slice_test/gpr_slice_test.vcxproj b/vsprojects/vcxproj/test/gpr_slice_test/gpr_slice_test.vcxproj index bb2badc35c..bfd3468ff9 100644 --- a/vsprojects/vcxproj/test/gpr_slice_test/gpr_slice_test.vcxproj +++ b/vsprojects/vcxproj/test/gpr_slice_test/gpr_slice_test.vcxproj @@ -60,14 +60,14 @@ - gpr_slice_test + grpc_slice_test static Debug static Debug - gpr_slice_test + grpc_slice_test static Release static -- cgit v1.2.3 From 618e67d655d8a0a345463d6e3e690e258dadd763 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 26 Oct 2016 21:08:10 -0700 Subject: s/GPR_SLICE/GRPC_SLICE/g --- include/grpc++/impl/codegen/proto_utils.h | 20 +++++------ include/grpc++/impl/codegen/thrift_serializer.h | 2 +- include/grpc++/support/slice.h | 6 ++-- include/grpc/impl/codegen/slice.h | 16 ++++----- src/core/ext/census/grpc_filter.c | 2 +- .../ext/client_channel/http_connect_handshaker.c | 4 +-- src/core/ext/lb_policy/grpclb/load_balancer_api.c | 10 +++--- .../chttp2/client/insecure/channel_create.c | 6 ++-- .../chttp2/client/secure/secure_channel_create.c | 6 ++-- .../ext/transport/chttp2/transport/bin_decoder.c | 30 ++++++++-------- .../ext/transport/chttp2/transport/bin_encoder.c | 30 ++++++++-------- .../transport/chttp2/transport/chttp2_transport.c | 22 ++++++------ .../ext/transport/chttp2/transport/frame_data.c | 6 ++-- .../ext/transport/chttp2/transport/frame_goaway.c | 12 +++---- .../ext/transport/chttp2/transport/frame_ping.c | 6 ++-- .../transport/chttp2/transport/frame_rst_stream.c | 6 ++-- .../transport/chttp2/transport/frame_settings.c | 10 +++--- .../chttp2/transport/frame_window_update.c | 6 ++-- .../ext/transport/chttp2/transport/hpack_encoder.c | 28 +++++++-------- .../ext/transport/chttp2/transport/hpack_parser.c | 8 ++--- .../ext/transport/chttp2/transport/hpack_table.c | 8 ++--- src/core/ext/transport/chttp2/transport/parsing.c | 4 +-- .../transport/cronet/transport/cronet_transport.c | 6 ++-- src/core/lib/channel/http_client_filter.c | 6 ++-- src/core/lib/compression/message_compress.c | 18 +++++----- src/core/lib/http/httpcli.c | 2 +- src/core/lib/http/parser.c | 4 +-- src/core/lib/iomgr/tcp_posix.c | 10 +++--- src/core/lib/iomgr/tcp_uv.c | 30 ++++++++-------- src/core/lib/iomgr/tcp_windows.c | 8 ++--- .../google_default/google_default_credentials.c | 2 +- .../lib/security/credentials/jwt/jwt_verifier.c | 22 ++++++------ src/core/lib/security/transport/handshake.c | 6 ++-- src/core/lib/security/transport/secure_endpoint.c | 32 ++++++++--------- .../lib/security/transport/security_connector.c | 8 ++--- .../lib/security/transport/server_auth_filter.c | 14 ++++---- src/core/lib/security/util/b64.c | 4 +-- src/core/lib/slice/percent_encoding.c | 28 +++++++-------- src/core/lib/slice/slice.c | 14 ++++---- src/core/lib/slice/slice_buffer.c | 22 ++++++------ src/core/lib/slice/slice_string_helpers.c | 8 ++--- src/core/lib/surface/byte_buffer_reader.c | 6 ++-- src/core/lib/surface/call.c | 12 +++---- src/core/lib/surface/server.c | 2 +- src/core/lib/transport/metadata.c | 28 +++++++-------- src/core/lib/transport/metadata.h | 2 +- src/csharp/ext/grpc_csharp_ext.c | 6 ++-- src/node/ext/byte_buffer.cc | 6 ++-- src/objective-c/GRPCClient/private/NSData+GRPC.m | 4 +-- src/php/ext/grpc/byte_buffer.c | 4 +-- src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi | 4 +-- src/ruby/ext/grpc/rb_byte_buffer.c | 4 +-- test/core/bad_client/tests/large_metadata.c | 2 +- test/core/bad_ssl/servers/cert.c | 4 +-- test/core/compression/message_compress_test.c | 12 +++---- test/core/end2end/cq_verifier.c | 14 ++++---- test/core/end2end/fixtures/http_proxy.c | 16 ++++----- test/core/end2end/fuzzers/api_fuzzer.c | 2 +- test/core/end2end/tests/invoke_large_request.c | 2 +- test/core/handshake/client_ssl.c | 6 ++-- test/core/handshake/server_ssl.c | 6 ++-- test/core/iomgr/endpoint_tests.c | 12 +++---- test/core/iomgr/load_file_test.c | 20 +++++------ test/core/iomgr/tcp_posix_test.c | 12 +++---- test/core/security/b64_test.c | 28 +++++++-------- test/core/security/create_jwt.c | 2 +- test/core/security/fetch_oauth2.c | 2 +- test/core/security/json_token_test.c | 18 +++++----- test/core/security/jwt_verifier_test.c | 14 ++++---- test/core/security/oauth2_utils.c | 8 ++--- test/core/security/secure_endpoint_test.c | 4 +-- test/core/security/security_connector_test.c | 2 +- test/core/slice/slice_test.c | 38 ++++++++++---------- test/core/surface/byte_buffer_reader_test.c | 42 +++++++++++----------- test/core/transport/chttp2/hpack_parser_test.c | 4 +-- test/core/transport/chttp2/varint_test.c | 2 +- test/core/transport/metadata_test.c | 2 +- test/core/util/one_corpus_entry_fuzzer.c | 2 +- test/core/util/parse_hexstring.c | 2 +- test/core/util/slice_splitter.c | 24 ++++++------- test/cpp/grpclb/grpclb_api_test.cc | 4 +-- test/cpp/grpclb/grpclb_test.cc | 4 +-- test/cpp/util/byte_buffer_test.cc | 4 +-- test/cpp/util/slice_test.cc | 4 +-- 84 files changed, 444 insertions(+), 444 deletions(-) (limited to 'test/core/end2end/tests') diff --git a/include/grpc++/impl/codegen/proto_utils.h b/include/grpc++/impl/codegen/proto_utils.h index 4885ea0ee7..d3be48984e 100644 --- a/include/grpc++/impl/codegen/proto_utils.h +++ b/include/grpc++/impl/codegen/proto_utils.h @@ -74,10 +74,10 @@ class GrpcBufferWriter GRPC_FINAL } else { slice_ = g_core_codegen_interface->grpc_slice_malloc(block_size_); } - *data = GPR_SLICE_START_PTR(slice_); + *data = GRPC_SLICE_START_PTR(slice_); // On win x64, int is only 32bit - GPR_CODEGEN_ASSERT(GPR_SLICE_LENGTH(slice_) <= INT_MAX); - byte_count_ += * size = (int)GPR_SLICE_LENGTH(slice_); + GPR_CODEGEN_ASSERT(GRPC_SLICE_LENGTH(slice_) <= INT_MAX); + byte_count_ += * size = (int)GRPC_SLICE_LENGTH(slice_); g_core_codegen_interface->grpc_slice_buffer_add(slice_buffer_, slice_); return true; } @@ -88,7 +88,7 @@ class GrpcBufferWriter GRPC_FINAL backup_slice_ = slice_; } else { backup_slice_ = g_core_codegen_interface->grpc_slice_split_tail( - &slice_, GPR_SLICE_LENGTH(slice_) - count); + &slice_, GRPC_SLICE_LENGTH(slice_) - count); g_core_codegen_interface->grpc_slice_buffer_add(slice_buffer_, slice_); } have_backup_ = true; @@ -126,7 +126,7 @@ class GrpcBufferReader GRPC_FINAL return false; } if (backup_count_ > 0) { - *data = GPR_SLICE_START_PTR(slice_) + GPR_SLICE_LENGTH(slice_) - + *data = GRPC_SLICE_START_PTR(slice_) + GRPC_SLICE_LENGTH(slice_) - backup_count_; GPR_CODEGEN_ASSERT(backup_count_ <= INT_MAX); *size = (int)backup_count_; @@ -138,10 +138,10 @@ class GrpcBufferReader GRPC_FINAL return false; } g_core_codegen_interface->grpc_slice_unref(slice_); - *data = GPR_SLICE_START_PTR(slice_); + *data = GRPC_SLICE_START_PTR(slice_); // On win x64, int is only 32bit - GPR_CODEGEN_ASSERT(GPR_SLICE_LENGTH(slice_) <= INT_MAX); - byte_count_ += * size = (int)GPR_SLICE_LENGTH(slice_); + GPR_CODEGEN_ASSERT(GRPC_SLICE_LENGTH(slice_) <= INT_MAX); + byte_count_ += * size = (int)GRPC_SLICE_LENGTH(slice_); return true; } @@ -188,8 +188,8 @@ class SerializationTraitsgrpc_slice_malloc(byte_size); GPR_CODEGEN_ASSERT( - GPR_SLICE_END_PTR(slice) == - msg.SerializeWithCachedSizesToArray(GPR_SLICE_START_PTR(slice))); + GRPC_SLICE_END_PTR(slice) == + msg.SerializeWithCachedSizesToArray(GRPC_SLICE_START_PTR(slice))); *bp = g_core_codegen_interface->grpc_raw_byte_buffer_create(&slice, 1); g_core_codegen_interface->grpc_slice_unref(slice); return g_core_codegen_interface->ok(); diff --git a/include/grpc++/impl/codegen/thrift_serializer.h b/include/grpc++/impl/codegen/thrift_serializer.h index 691ce1af48..4d3af91b02 100644 --- a/include/grpc++/impl/codegen/thrift_serializer.h +++ b/include/grpc++/impl/codegen/thrift_serializer.h @@ -159,7 +159,7 @@ class ThriftSerializer { grpc_slice slice = grpc_byte_buffer_reader_readall(&reader); uint32_t len = - Deserialize(GPR_SLICE_START_PTR(slice), GPR_SLICE_LENGTH(slice), msg); + Deserialize(GRPC_SLICE_START_PTR(slice), GRPC_SLICE_LENGTH(slice), msg); grpc_slice_unref(slice); diff --git a/include/grpc++/support/slice.h b/include/grpc++/support/slice.h index 699148ccda..6ee582275d 100644 --- a/include/grpc++/support/slice.h +++ b/include/grpc++/support/slice.h @@ -69,13 +69,13 @@ class Slice GRPC_FINAL { } /// Byte size. - size_t size() const { return GPR_SLICE_LENGTH(slice_); } + size_t size() const { return GRPC_SLICE_LENGTH(slice_); } /// Raw pointer to the beginning (first element) of the slice. - const uint8_t* begin() const { return GPR_SLICE_START_PTR(slice_); } + const uint8_t* begin() const { return GRPC_SLICE_START_PTR(slice_); } /// Raw pointer to the end (one byte \em past the last element) of the slice. - const uint8_t* end() const { return GPR_SLICE_END_PTR(slice_); } + const uint8_t* end() const { return GRPC_SLICE_END_PTR(slice_); } /// Raw C slice. Caller needs to call grpc_slice_unref when done. grpc_slice c_slice() const { return grpc_slice_ref(slice_); } diff --git a/include/grpc/impl/codegen/slice.h b/include/grpc/impl/codegen/slice.h index 79297ce23d..774ba0e95d 100644 --- a/include/grpc/impl/codegen/slice.h +++ b/include/grpc/impl/codegen/slice.h @@ -60,7 +60,7 @@ typedef struct grpc_slice_refcount { void (*unref)(void *); } grpc_slice_refcount; -#define GPR_SLICE_INLINED_SIZE (sizeof(size_t) + sizeof(uint8_t *) - 1) +#define GRPC_SLICE_INLINED_SIZE (sizeof(size_t) + sizeof(uint8_t *) - 1) /* A grpc_slice s, if initialized, represents the byte range s.bytes[0..s.length-1]. @@ -80,7 +80,7 @@ typedef struct grpc_slice { } refcounted; struct { uint8_t length; - uint8_t bytes[GPR_SLICE_INLINED_SIZE]; + uint8_t bytes[GRPC_SLICE_INLINED_SIZE]; } inlined; } data; } grpc_slice; @@ -102,17 +102,17 @@ typedef struct { grpc_slice inlined[GRPC_SLICE_BUFFER_INLINE_ELEMENTS]; } grpc_slice_buffer; -#define GPR_SLICE_START_PTR(slice) \ +#define GRPC_SLICE_START_PTR(slice) \ ((slice).refcount ? (slice).data.refcounted.bytes \ : (slice).data.inlined.bytes) -#define GPR_SLICE_LENGTH(slice) \ +#define GRPC_SLICE_LENGTH(slice) \ ((slice).refcount ? (slice).data.refcounted.length \ : (slice).data.inlined.length) -#define GPR_SLICE_SET_LENGTH(slice, newlen) \ +#define GRPC_SLICE_SET_LENGTH(slice, newlen) \ ((slice).refcount ? ((slice).data.refcounted.length = (size_t)(newlen)) \ : ((slice).data.inlined.length = (uint8_t)(newlen))) -#define GPR_SLICE_END_PTR(slice) \ - GPR_SLICE_START_PTR(slice) + GPR_SLICE_LENGTH(slice) -#define GPR_SLICE_IS_EMPTY(slice) (GPR_SLICE_LENGTH(slice) == 0) +#define GRPC_SLICE_END_PTR(slice) \ + GRPC_SLICE_START_PTR(slice) + GRPC_SLICE_LENGTH(slice) +#define GRPC_SLICE_IS_EMPTY(slice) (GRPC_SLICE_LENGTH(slice) == 0) #endif /* GRPC_IMPL_CODEGEN_SLICE_H */ diff --git a/src/core/ext/census/grpc_filter.c b/src/core/ext/census/grpc_filter.c index d84d715031..aa6d24e076 100644 --- a/src/core/ext/census/grpc_filter.c +++ b/src/core/ext/census/grpc_filter.c @@ -69,7 +69,7 @@ static void extract_and_annotate_method_tag(grpc_metadata_batch *md, for (m = md->list.head; m != NULL; m = m->next) { if (m->md->key == GRPC_MDSTR_PATH) { gpr_log(GPR_DEBUG, "%s", - (const char *)GPR_SLICE_START_PTR(m->md->value->slice)); + (const char *)GRPC_SLICE_START_PTR(m->md->value->slice)); /* Add method tag here */ } } diff --git a/src/core/ext/client_channel/http_connect_handshaker.c b/src/core/ext/client_channel/http_connect_handshaker.c index d80f710b72..6f1956add9 100644 --- a/src/core/ext/client_channel/http_connect_handshaker.c +++ b/src/core/ext/client_channel/http_connect_handshaker.c @@ -118,7 +118,7 @@ static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg, } // Add buffer to parser. for (size_t i = 0; i < handshaker->read_buffer->count; ++i) { - if (GPR_SLICE_LENGTH(handshaker->read_buffer->slices[i]) > 0) { + if (GRPC_SLICE_LENGTH(handshaker->read_buffer->slices[i]) > 0) { size_t body_start_offset = 0; error = grpc_http_parser_parse(&handshaker->http_parser, handshaker->read_buffer->slices[i], @@ -132,7 +132,7 @@ static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_slice_buffer tmp_buffer; grpc_slice_buffer_init(&tmp_buffer); if (body_start_offset < - GPR_SLICE_LENGTH(handshaker->read_buffer->slices[i])) { + GRPC_SLICE_LENGTH(handshaker->read_buffer->slices[i])) { grpc_slice_buffer_add( &tmp_buffer, grpc_slice_split_tail(&handshaker->read_buffer->slices[i], diff --git a/src/core/ext/lb_policy/grpclb/load_balancer_api.c b/src/core/ext/lb_policy/grpclb/load_balancer_api.c index f3860d119d..837e9c1113 100644 --- a/src/core/ext/lb_policy/grpclb/load_balancer_api.c +++ b/src/core/ext/lb_policy/grpclb/load_balancer_api.c @@ -101,7 +101,7 @@ grpc_slice grpc_grpclb_request_encode(const grpc_grpclb_request *request) { slice = grpc_slice_malloc(encoded_length); outputstream = - pb_ostream_from_buffer(GPR_SLICE_START_PTR(slice), encoded_length); + pb_ostream_from_buffer(GRPC_SLICE_START_PTR(slice), encoded_length); GPR_ASSERT(pb_encode(&outputstream, grpc_lb_v1_LoadBalanceRequest_fields, request) != 0); return slice; @@ -115,8 +115,8 @@ typedef grpc_lb_v1_LoadBalanceResponse grpc_grpclb_response; grpc_grpclb_initial_response *grpc_grpclb_initial_response_parse( grpc_slice encoded_grpc_grpclb_response) { pb_istream_t stream = - pb_istream_from_buffer(GPR_SLICE_START_PTR(encoded_grpc_grpclb_response), - GPR_SLICE_LENGTH(encoded_grpc_grpclb_response)); + pb_istream_from_buffer(GRPC_SLICE_START_PTR(encoded_grpc_grpclb_response), + GRPC_SLICE_LENGTH(encoded_grpc_grpclb_response)); grpc_grpclb_response res; memset(&res, 0, sizeof(grpc_grpclb_response)); if (!pb_decode(&stream, grpc_lb_v1_LoadBalanceResponse_fields, &res)) { @@ -136,8 +136,8 @@ grpc_grpclb_serverlist *grpc_grpclb_response_parse_serverlist( bool status; decode_serverlist_arg arg; pb_istream_t stream = - pb_istream_from_buffer(GPR_SLICE_START_PTR(encoded_grpc_grpclb_response), - GPR_SLICE_LENGTH(encoded_grpc_grpclb_response)); + pb_istream_from_buffer(GRPC_SLICE_START_PTR(encoded_grpc_grpclb_response), + GRPC_SLICE_LENGTH(encoded_grpc_grpclb_response)); pb_istream_t stream_at_start = stream; grpc_grpclb_response res; memset(&res, 0, sizeof(grpc_grpclb_response)); diff --git a/src/core/ext/transport/chttp2/client/insecure/channel_create.c b/src/core/ext/transport/chttp2/client/insecure/channel_create.c index 03dc955b27..8e03fd82c1 100644 --- a/src/core/ext/transport/chttp2/client/insecure/channel_create.c +++ b/src/core/ext/transport/chttp2/client/insecure/channel_create.c @@ -36,9 +36,9 @@ #include #include -#include #include #include +#include #include "src/core/ext/client_channel/client_channel.h" #include "src/core/ext/client_channel/http_connect_handshaker.h" @@ -117,12 +117,12 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { connector *c = arg; grpc_endpoint *tcp = c->tcp; if (tcp != NULL) { - if (!GPR_SLICE_IS_EMPTY(c->args.initial_connect_string)) { + if (!GRPC_SLICE_IS_EMPTY(c->args.initial_connect_string)) { grpc_closure_init(&c->initial_string_sent, on_initial_connect_string_sent, c); grpc_slice_buffer_init(&c->initial_string_buffer); grpc_slice_buffer_add(&c->initial_string_buffer, - c->args.initial_connect_string); + c->args.initial_connect_string); connector_ref(arg); grpc_endpoint_write(exec_ctx, tcp, &c->initial_string_buffer, &c->initial_string_sent); diff --git a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c index 7f9c365799..22d7ab0d14 100644 --- a/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c +++ b/src/core/ext/transport/chttp2/client/secure/secure_channel_create.c @@ -36,9 +36,9 @@ #include #include -#include #include #include +#include #include "src/core/ext/client_channel/client_channel.h" #include "src/core/ext/client_channel/http_connect_handshaker.h" @@ -166,12 +166,12 @@ static void connected(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { GPR_ASSERT(c->connecting_endpoint == NULL); c->connecting_endpoint = tcp; gpr_mu_unlock(&c->mu); - if (!GPR_SLICE_IS_EMPTY(c->args.initial_connect_string)) { + if (!GRPC_SLICE_IS_EMPTY(c->args.initial_connect_string)) { grpc_closure_init(&c->initial_string_sent, on_initial_connect_string_sent, c); grpc_slice_buffer_init(&c->initial_string_buffer); grpc_slice_buffer_add(&c->initial_string_buffer, - c->args.initial_connect_string); + c->args.initial_connect_string); grpc_endpoint_write(exec_ctx, tcp, &c->initial_string_buffer, &c->initial_string_sent); } else { diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.c b/src/core/ext/transport/chttp2/transport/bin_decoder.c index f8db92dff5..3eef80b557 100644 --- a/src/core/ext/transport/chttp2/transport/bin_decoder.c +++ b/src/core/ext/transport/chttp2/transport/bin_decoder.c @@ -144,7 +144,7 @@ bool grpc_base64_decode_partial(struct grpc_base64_decode_context *ctx) { } grpc_slice grpc_chttp2_base64_decode(grpc_slice input) { - size_t input_length = GPR_SLICE_LENGTH(input); + size_t input_length = GRPC_SLICE_LENGTH(input); size_t output_length = input_length / 4 * 3; struct grpc_base64_decode_context ctx; grpc_slice output; @@ -159,7 +159,7 @@ grpc_slice grpc_chttp2_base64_decode(grpc_slice input) { } if (input_length > 0) { - uint8_t *input_end = GPR_SLICE_END_PTR(input); + uint8_t *input_end = GRPC_SLICE_END_PTR(input); if (*(--input_end) == '=') { output_length--; if (*(--input_end) == '=') { @@ -169,10 +169,10 @@ grpc_slice grpc_chttp2_base64_decode(grpc_slice input) { } output = grpc_slice_malloc(output_length); - ctx.input_cur = GPR_SLICE_START_PTR(input); - ctx.input_end = GPR_SLICE_END_PTR(input); - ctx.output_cur = GPR_SLICE_START_PTR(output); - ctx.output_end = GPR_SLICE_END_PTR(output); + ctx.input_cur = GRPC_SLICE_START_PTR(input); + ctx.input_end = GRPC_SLICE_END_PTR(input); + ctx.output_cur = GRPC_SLICE_START_PTR(output); + ctx.output_end = GRPC_SLICE_END_PTR(output); ctx.contains_tail = false; if (!grpc_base64_decode_partial(&ctx)) { @@ -182,14 +182,14 @@ grpc_slice grpc_chttp2_base64_decode(grpc_slice input) { grpc_slice_unref(output); return gpr_empty_slice(); } - GPR_ASSERT(ctx.output_cur == GPR_SLICE_END_PTR(output)); - GPR_ASSERT(ctx.input_cur == GPR_SLICE_END_PTR(input)); + GPR_ASSERT(ctx.output_cur == GRPC_SLICE_END_PTR(output)); + GPR_ASSERT(ctx.input_cur == GRPC_SLICE_END_PTR(input)); return output; } grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input, size_t output_length) { - size_t input_length = GPR_SLICE_LENGTH(input); + size_t input_length = GRPC_SLICE_LENGTH(input); grpc_slice output = grpc_slice_malloc(output_length); struct grpc_base64_decode_context ctx; @@ -214,10 +214,10 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input, return gpr_empty_slice(); } - ctx.input_cur = GPR_SLICE_START_PTR(input); - ctx.input_end = GPR_SLICE_END_PTR(input); - ctx.output_cur = GPR_SLICE_START_PTR(output); - ctx.output_end = GPR_SLICE_END_PTR(output); + ctx.input_cur = GRPC_SLICE_START_PTR(input); + ctx.input_end = GRPC_SLICE_END_PTR(input); + ctx.output_cur = GRPC_SLICE_START_PTR(output); + ctx.output_end = GRPC_SLICE_END_PTR(output); ctx.contains_tail = true; if (!grpc_base64_decode_partial(&ctx)) { @@ -227,7 +227,7 @@ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input, grpc_slice_unref(output); return gpr_empty_slice(); } - GPR_ASSERT(ctx.output_cur == GPR_SLICE_END_PTR(output)); - GPR_ASSERT(ctx.input_cur <= GPR_SLICE_END_PTR(input)); + GPR_ASSERT(ctx.output_cur == GRPC_SLICE_END_PTR(output)); + GPR_ASSERT(ctx.input_cur <= GRPC_SLICE_END_PTR(input)); return output; } diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.c b/src/core/ext/transport/chttp2/transport/bin_encoder.c index 09b961533a..2baa1dc97b 100644 --- a/src/core/ext/transport/chttp2/transport/bin_encoder.c +++ b/src/core/ext/transport/chttp2/transport/bin_encoder.c @@ -62,13 +62,13 @@ static const b64_huff_sym huff_alphabet[64] = { static const uint8_t tail_xtra[3] = {0, 2, 3}; grpc_slice grpc_chttp2_base64_encode(grpc_slice input) { - size_t input_length = GPR_SLICE_LENGTH(input); + size_t input_length = GRPC_SLICE_LENGTH(input); size_t input_triplets = input_length / 3; size_t tail_case = input_length % 3; size_t output_length = input_triplets * 4 + tail_xtra[tail_case]; grpc_slice output = grpc_slice_malloc(output_length); - uint8_t *in = GPR_SLICE_START_PTR(input); - char *out = (char *)GPR_SLICE_START_PTR(output); + uint8_t *in = GRPC_SLICE_START_PTR(input); + char *out = (char *)GRPC_SLICE_START_PTR(output); size_t i; /* encode full triplets */ @@ -100,8 +100,8 @@ grpc_slice grpc_chttp2_base64_encode(grpc_slice input) { break; } - GPR_ASSERT(out == (char *)GPR_SLICE_END_PTR(output)); - GPR_ASSERT(in == GPR_SLICE_END_PTR(input)); + GPR_ASSERT(out == (char *)GRPC_SLICE_END_PTR(output)); + GPR_ASSERT(in == GRPC_SLICE_END_PTR(input)); return output; } @@ -114,13 +114,13 @@ grpc_slice grpc_chttp2_huffman_compress(grpc_slice input) { uint32_t temp_length = 0; nbits = 0; - for (in = GPR_SLICE_START_PTR(input); in != GPR_SLICE_END_PTR(input); ++in) { + for (in = GRPC_SLICE_START_PTR(input); in != GRPC_SLICE_END_PTR(input); ++in) { nbits += grpc_chttp2_huffsyms[*in].length; } output = grpc_slice_malloc(nbits / 8 + (nbits % 8 != 0)); - out = GPR_SLICE_START_PTR(output); - for (in = GPR_SLICE_START_PTR(input); in != GPR_SLICE_END_PTR(input); ++in) { + out = GRPC_SLICE_START_PTR(output); + for (in = GRPC_SLICE_START_PTR(input); in != GRPC_SLICE_END_PTR(input); ++in) { int sym = *in; temp <<= grpc_chttp2_huffsyms[sym].length; temp |= grpc_chttp2_huffsyms[sym].bits; @@ -141,7 +141,7 @@ grpc_slice grpc_chttp2_huffman_compress(grpc_slice input) { (uint8_t)(0xffu >> temp_length)); } - GPR_ASSERT(out == GPR_SLICE_END_PTR(output)); + GPR_ASSERT(out == GRPC_SLICE_END_PTR(output)); return output; } @@ -176,15 +176,15 @@ static void enc_add1(huff_out *out, uint8_t a) { } grpc_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(grpc_slice input) { - size_t input_length = GPR_SLICE_LENGTH(input); + size_t input_length = GRPC_SLICE_LENGTH(input); size_t input_triplets = input_length / 3; size_t tail_case = input_length % 3; size_t output_syms = input_triplets * 4 + tail_xtra[tail_case]; size_t max_output_bits = 11 * output_syms; size_t max_output_length = max_output_bits / 8 + (max_output_bits % 8 != 0); grpc_slice output = grpc_slice_malloc(max_output_length); - uint8_t *in = GPR_SLICE_START_PTR(input); - uint8_t *start_out = GPR_SLICE_START_PTR(output); + uint8_t *in = GRPC_SLICE_START_PTR(input); + uint8_t *start_out = GRPC_SLICE_START_PTR(output); huff_out out; size_t i; @@ -231,9 +231,9 @@ grpc_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(grpc_slice input) (uint8_t)(0xffu >> out.temp_length)); } - GPR_ASSERT(out.out <= GPR_SLICE_END_PTR(output)); - GPR_SLICE_SET_LENGTH(output, out.out - start_out); + GPR_ASSERT(out.out <= GRPC_SLICE_END_PTR(output)); + GRPC_SLICE_SET_LENGTH(output, out.out - start_out); - GPR_ASSERT(in == GPR_SLICE_END_PTR(input)); + GPR_ASSERT(in == GRPC_SLICE_END_PTR(input)); return output; } diff --git a/src/core/ext/transport/chttp2/transport/chttp2_transport.c b/src/core/ext/transport/chttp2/transport/chttp2_transport.c index 07639c1223..3df64faa1f 100644 --- a/src/core/ext/transport/chttp2/transport/chttp2_transport.c +++ b/src/core/ext/transport/chttp2/transport/chttp2_transport.c @@ -885,7 +885,7 @@ static void add_fetched_slice_locked(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_stream *s) { s->fetched_send_message_length += - (uint32_t)GPR_SLICE_LENGTH(s->fetching_slice); + (uint32_t)GRPC_SLICE_LENGTH(s->fetching_slice); grpc_slice_buffer_add(&s->flow_controlled_buffer, s->fetching_slice); if (s->id != 0) { grpc_chttp2_become_writable(exec_ctx, t, s, true, "op.send_message"); @@ -1602,7 +1602,7 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, compression and just write the uncompressed bytes onto the wire. */ status_hdr = grpc_slice_malloc(15 + (grpc_status >= 10)); - p = GPR_SLICE_START_PTR(status_hdr); + p = GRPC_SLICE_START_PTR(status_hdr); *p++ = 0x40; /* literal header */ *p++ = 11; /* len(grpc-status) */ *p++ = 'g'; @@ -1624,8 +1624,8 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, *p++ = (uint8_t)('0' + (grpc_status / 10)); *p++ = (uint8_t)('0' + (grpc_status % 10)); } - GPR_ASSERT(p == GPR_SLICE_END_PTR(status_hdr)); - len += (uint32_t)GPR_SLICE_LENGTH(status_hdr); + GPR_ASSERT(p == GRPC_SLICE_END_PTR(status_hdr)); + len += (uint32_t)GRPC_SLICE_LENGTH(status_hdr); const char *optional_message = grpc_error_get_str(error, GRPC_ERROR_STR_GRPC_MESSAGE); @@ -1634,7 +1634,7 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, size_t msg_len = strlen(optional_message); GPR_ASSERT(msg_len < 127); message_pfx = grpc_slice_malloc(15); - p = GPR_SLICE_START_PTR(message_pfx); + p = GRPC_SLICE_START_PTR(message_pfx); *p++ = 0x40; *p++ = 12; /* len(grpc-message) */ *p++ = 'g'; @@ -1650,13 +1650,13 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, *p++ = 'g'; *p++ = 'e'; *p++ = (uint8_t)msg_len; - GPR_ASSERT(p == GPR_SLICE_END_PTR(message_pfx)); - len += (uint32_t)GPR_SLICE_LENGTH(message_pfx); + GPR_ASSERT(p == GRPC_SLICE_END_PTR(message_pfx)); + len += (uint32_t)GRPC_SLICE_LENGTH(message_pfx); len += (uint32_t)msg_len; } hdr = grpc_slice_malloc(9); - p = GPR_SLICE_START_PTR(hdr); + p = GRPC_SLICE_START_PTR(hdr); *p++ = (uint8_t)(len >> 16); *p++ = (uint8_t)(len >> 8); *p++ = (uint8_t)(len); @@ -1666,7 +1666,7 @@ static void close_from_api(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, *p++ = (uint8_t)(s->id >> 16); *p++ = (uint8_t)(s->id >> 8); *p++ = (uint8_t)(s->id); - GPR_ASSERT(p == GPR_SLICE_END_PTR(hdr)); + GPR_ASSERT(p == GRPC_SLICE_END_PTR(hdr)); grpc_slice_buffer_add(&t->qbuf, hdr); grpc_slice_buffer_add(&t->qbuf, status_hdr); @@ -2043,11 +2043,11 @@ void grpc_chttp2_incoming_byte_stream_push(grpc_exec_ctx *exec_ctx, grpc_chttp2_incoming_byte_stream *bs, grpc_slice slice) { gpr_mu_lock(&bs->slice_mu); - if (bs->remaining_bytes < GPR_SLICE_LENGTH(slice)) { + if (bs->remaining_bytes < GRPC_SLICE_LENGTH(slice)) { incoming_byte_stream_publish_error( exec_ctx, bs, GRPC_ERROR_CREATE("Too many bytes in stream")); } else { - bs->remaining_bytes -= (uint32_t)GPR_SLICE_LENGTH(slice); + bs->remaining_bytes -= (uint32_t)GRPC_SLICE_LENGTH(slice); if (bs->on_next != NULL) { *bs->next = slice; grpc_exec_ctx_sched(exec_ctx, bs->on_next, GRPC_ERROR_NONE, NULL); diff --git a/src/core/ext/transport/chttp2/transport/frame_data.c b/src/core/ext/transport/chttp2/transport/frame_data.c index 5700a01a9a..f9b9e1b309 100644 --- a/src/core/ext/transport/chttp2/transport/frame_data.c +++ b/src/core/ext/transport/chttp2/transport/frame_data.c @@ -122,7 +122,7 @@ void grpc_chttp2_encode_data(uint32_t id, grpc_slice_buffer *inbuf, static const size_t header_size = 9; hdr = grpc_slice_malloc(header_size); - p = GPR_SLICE_START_PTR(hdr); + p = GRPC_SLICE_START_PTR(hdr); GPR_ASSERT(write_bytes < (1 << 24)); *p++ = (uint8_t)(write_bytes >> 16); *p++ = (uint8_t)(write_bytes >> 8); @@ -145,8 +145,8 @@ static grpc_error *parse_inner(grpc_exec_ctx *exec_ctx, grpc_chttp2_data_parser *p, grpc_chttp2_transport *t, grpc_chttp2_stream *s, grpc_slice slice) { - uint8_t *const beg = GPR_SLICE_START_PTR(slice); - uint8_t *const end = GPR_SLICE_END_PTR(slice); + uint8_t *const beg = GRPC_SLICE_START_PTR(slice); + uint8_t *const end = GRPC_SLICE_END_PTR(slice); uint8_t *cur = beg; uint32_t message_flags; grpc_chttp2_incoming_byte_stream *incoming_byte_stream; diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.c b/src/core/ext/transport/chttp2/transport/frame_goaway.c index 16c6819aca..d99d486c1b 100644 --- a/src/core/ext/transport/chttp2/transport/frame_goaway.c +++ b/src/core/ext/transport/chttp2/transport/frame_goaway.c @@ -72,8 +72,8 @@ grpc_error *grpc_chttp2_goaway_parser_parse(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_stream *s, grpc_slice slice, int is_last) { - uint8_t *const beg = GPR_SLICE_START_PTR(slice); - uint8_t *const end = GPR_SLICE_END_PTR(slice); + uint8_t *const beg = GRPC_SLICE_START_PTR(slice); + uint8_t *const end = GRPC_SLICE_END_PTR(slice); uint8_t *cur = beg; grpc_chttp2_goaway_parser *p = parser; @@ -163,10 +163,10 @@ void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code, grpc_slice debug_data, grpc_slice_buffer *slice_buffer) { grpc_slice header = grpc_slice_malloc(9 + 4 + 4); - uint8_t *p = GPR_SLICE_START_PTR(header); + uint8_t *p = GRPC_SLICE_START_PTR(header); uint32_t frame_length; - GPR_ASSERT(GPR_SLICE_LENGTH(debug_data) < UINT32_MAX - 4 - 4); - frame_length = 4 + 4 + (uint32_t)GPR_SLICE_LENGTH(debug_data); + GPR_ASSERT(GRPC_SLICE_LENGTH(debug_data) < UINT32_MAX - 4 - 4); + frame_length = 4 + 4 + (uint32_t)GRPC_SLICE_LENGTH(debug_data); /* frame header: length */ *p++ = (uint8_t)(frame_length >> 16); @@ -191,7 +191,7 @@ void grpc_chttp2_goaway_append(uint32_t last_stream_id, uint32_t error_code, *p++ = (uint8_t)(error_code >> 16); *p++ = (uint8_t)(error_code >> 8); *p++ = (uint8_t)(error_code); - GPR_ASSERT(p == GPR_SLICE_END_PTR(header)); + GPR_ASSERT(p == GRPC_SLICE_END_PTR(header)); grpc_slice_buffer_add(slice_buffer, header); grpc_slice_buffer_add(slice_buffer, debug_data); } diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.c b/src/core/ext/transport/chttp2/transport/frame_ping.c index f8d73539ae..18ecb4d1e9 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.c +++ b/src/core/ext/transport/chttp2/transport/frame_ping.c @@ -42,7 +42,7 @@ grpc_slice grpc_chttp2_ping_create(uint8_t ack, uint8_t *opaque_8bytes) { grpc_slice slice = grpc_slice_malloc(9 + 8); - uint8_t *p = GPR_SLICE_START_PTR(slice); + uint8_t *p = GRPC_SLICE_START_PTR(slice); *p++ = 0; *p++ = 0; @@ -77,8 +77,8 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t, grpc_chttp2_stream *s, grpc_slice slice, int is_last) { - uint8_t *const beg = GPR_SLICE_START_PTR(slice); - uint8_t *const end = GPR_SLICE_END_PTR(slice); + uint8_t *const beg = GRPC_SLICE_START_PTR(slice); + uint8_t *const end = GRPC_SLICE_END_PTR(slice); uint8_t *cur = beg; grpc_chttp2_ping_parser *p = parser; diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.c b/src/core/ext/transport/chttp2/transport/frame_rst_stream.c index 7def454915..75e4101035 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.c @@ -47,7 +47,7 @@ grpc_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code, static const size_t frame_size = 13; grpc_slice slice = grpc_slice_malloc(frame_size); stats->framing_bytes += frame_size; - uint8_t *p = GPR_SLICE_START_PTR(slice); + uint8_t *p = GRPC_SLICE_START_PTR(slice); // Frame size. *p++ = 0; @@ -90,8 +90,8 @@ grpc_error *grpc_chttp2_rst_stream_parser_parse(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_chttp2_stream *s, grpc_slice slice, int is_last) { - uint8_t *const beg = GPR_SLICE_START_PTR(slice); - uint8_t *const end = GPR_SLICE_END_PTR(slice); + uint8_t *const beg = GRPC_SLICE_START_PTR(slice); + uint8_t *const end = GRPC_SLICE_END_PTR(slice); uint8_t *cur = beg; grpc_chttp2_rst_stream_parser *p = parser; diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.c b/src/core/ext/transport/chttp2/transport/frame_settings.c index d9ea1f91a7..d3b235183b 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.c +++ b/src/core/ext/transport/chttp2/transport/frame_settings.c @@ -94,7 +94,7 @@ grpc_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new, } output = grpc_slice_malloc(9 + 6 * n); - p = fill_header(GPR_SLICE_START_PTR(output), 6 * n, 0); + p = fill_header(GRPC_SLICE_START_PTR(output), 6 * n, 0); for (i = 0; i < count; i++) { if (new[i] != old[i] || (force_mask & (1u << i)) != 0) { @@ -109,14 +109,14 @@ grpc_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new, } } - GPR_ASSERT(p == GPR_SLICE_END_PTR(output)); + GPR_ASSERT(p == GRPC_SLICE_END_PTR(output)); return output; } grpc_slice grpc_chttp2_settings_ack_create(void) { grpc_slice output = grpc_slice_malloc(9); - fill_header(GPR_SLICE_START_PTR(output), 0, GRPC_CHTTP2_FLAG_ACK); + fill_header(GRPC_SLICE_START_PTR(output), 0, GRPC_CHTTP2_FLAG_ACK); return output; } @@ -148,8 +148,8 @@ grpc_error *grpc_chttp2_settings_parser_parse(grpc_exec_ctx *exec_ctx, void *p, grpc_chttp2_stream *s, grpc_slice slice, int is_last) { grpc_chttp2_settings_parser *parser = p; - const uint8_t *cur = GPR_SLICE_START_PTR(slice); - const uint8_t *end = GPR_SLICE_END_PTR(slice); + const uint8_t *cur = GRPC_SLICE_START_PTR(slice); + const uint8_t *end = GRPC_SLICE_END_PTR(slice); char *msg; if (parser->is_ack) { diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.c b/src/core/ext/transport/chttp2/transport/frame_window_update.c index b32f1403e1..31a31c2871 100644 --- a/src/core/ext/transport/chttp2/transport/frame_window_update.c +++ b/src/core/ext/transport/chttp2/transport/frame_window_update.c @@ -43,7 +43,7 @@ grpc_slice grpc_chttp2_window_update_create( static const size_t frame_size = 13; grpc_slice slice = grpc_slice_malloc(frame_size); stats->header_bytes += frame_size; - uint8_t *p = GPR_SLICE_START_PTR(slice); + uint8_t *p = GRPC_SLICE_START_PTR(slice); GPR_ASSERT(window_update); @@ -82,8 +82,8 @@ grpc_error *grpc_chttp2_window_update_parser_begin_frame( grpc_error *grpc_chttp2_window_update_parser_parse( grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_transport *t, grpc_chttp2_stream *s, grpc_slice slice, int is_last) { - uint8_t *const beg = GPR_SLICE_START_PTR(slice); - uint8_t *const end = GPR_SLICE_END_PTR(slice); + uint8_t *const beg = GRPC_SLICE_START_PTR(slice); + uint8_t *const end = GRPC_SLICE_END_PTR(slice); uint8_t *cur = beg; grpc_chttp2_window_update_parser *p = parser; diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.c b/src/core/ext/transport/chttp2/transport/hpack_encoder.c index d8de7d0719..3c5bcd3412 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.c +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.c @@ -104,7 +104,7 @@ static void finish_frame(framer_state *st, int is_header_boundary, type = st->is_first_frame ? GRPC_CHTTP2_FRAME_HEADER : GRPC_CHTTP2_FRAME_CONTINUATION; fill_header( - GPR_SLICE_START_PTR(st->output->slices[st->header_idx]), type, + GRPC_SLICE_START_PTR(st->output->slices[st->header_idx]), type, st->stream_id, st->output->length - st->output_length_at_start_of_frame, (uint8_t)((is_last_in_stream ? GRPC_CHTTP2_DATA_FLAG_END_STREAM : 0) | (is_header_boundary ? GRPC_CHTTP2_DATA_FLAG_END_HEADERS : 0))); @@ -148,7 +148,7 @@ static void inc_filter(uint8_t idx, uint32_t *sum, uint8_t *elems) { } static void add_header_data(framer_state *st, grpc_slice slice) { - size_t len = GPR_SLICE_LENGTH(slice); + size_t len = GRPC_SLICE_LENGTH(slice); size_t remaining; if (len == 0) return; remaining = st->max_frame_size + st->output_length_at_start_of_frame - @@ -269,8 +269,8 @@ static void emit_indexed(grpc_chttp2_hpack_compressor *c, uint32_t elem_index, } static grpc_slice get_wire_value(grpc_mdelem *elem, uint8_t *huffman_prefix) { - if (grpc_is_binary_header((const char *)GPR_SLICE_START_PTR(elem->key->slice), - GPR_SLICE_LENGTH(elem->key->slice))) { + if (grpc_is_binary_header((const char *)GRPC_SLICE_START_PTR(elem->key->slice), + GRPC_SLICE_LENGTH(elem->key->slice))) { *huffman_prefix = 0x80; return grpc_mdstr_as_base64_encoded_and_huffman_compressed(elem->value); } @@ -285,7 +285,7 @@ static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c, uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2); uint8_t huffman_prefix; grpc_slice value_slice = get_wire_value(elem, &huffman_prefix); - size_t len_val = GPR_SLICE_LENGTH(value_slice); + size_t len_val = GRPC_SLICE_LENGTH(value_slice); uint32_t len_val_len; GPR_ASSERT(len_val <= UINT32_MAX); len_val_len = GRPC_CHTTP2_VARINT_LENGTH((uint32_t)len_val, 1); @@ -302,7 +302,7 @@ static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c, uint32_t len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4); uint8_t huffman_prefix; grpc_slice value_slice = get_wire_value(elem, &huffman_prefix); - size_t len_val = GPR_SLICE_LENGTH(value_slice); + size_t len_val = GRPC_SLICE_LENGTH(value_slice); uint32_t len_val_len; GPR_ASSERT(len_val <= UINT32_MAX); len_val_len = GRPC_CHTTP2_VARINT_LENGTH((uint32_t)len_val, 1); @@ -315,14 +315,14 @@ static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c, static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem, framer_state *st) { - uint32_t len_key = (uint32_t)GPR_SLICE_LENGTH(elem->key->slice); + uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(elem->key->slice); uint8_t huffman_prefix; grpc_slice value_slice = get_wire_value(elem, &huffman_prefix); - uint32_t len_val = (uint32_t)GPR_SLICE_LENGTH(value_slice); + uint32_t len_val = (uint32_t)GRPC_SLICE_LENGTH(value_slice); uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); GPR_ASSERT(len_key <= UINT32_MAX); - GPR_ASSERT(GPR_SLICE_LENGTH(value_slice) <= UINT32_MAX); + GPR_ASSERT(GRPC_SLICE_LENGTH(value_slice) <= UINT32_MAX); *add_tiny_header_data(st, 1) = 0x40; GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, add_tiny_header_data(st, len_key_len), len_key_len); @@ -334,14 +334,14 @@ static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor *c, static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem, framer_state *st) { - uint32_t len_key = (uint32_t)GPR_SLICE_LENGTH(elem->key->slice); + uint32_t len_key = (uint32_t)GRPC_SLICE_LENGTH(elem->key->slice); uint8_t huffman_prefix; grpc_slice value_slice = get_wire_value(elem, &huffman_prefix); - uint32_t len_val = (uint32_t)GPR_SLICE_LENGTH(value_slice); + uint32_t len_val = (uint32_t)GRPC_SLICE_LENGTH(value_slice); uint32_t len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); uint32_t len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); GPR_ASSERT(len_key <= UINT32_MAX); - GPR_ASSERT(GPR_SLICE_LENGTH(value_slice) <= UINT32_MAX); + GPR_ASSERT(GRPC_SLICE_LENGTH(value_slice) <= UINT32_MAX); *add_tiny_header_data(st, 1) = 0x00; GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, add_tiny_header_data(st, len_key_len), len_key_len); @@ -373,8 +373,8 @@ static void hpack_enc(grpc_chttp2_hpack_compressor *c, grpc_mdelem *elem, uint32_t indices_key; int should_add_elem; - GPR_ASSERT(GPR_SLICE_LENGTH(elem->key->slice) > 0); - if (GPR_SLICE_START_PTR(elem->key->slice)[0] != ':') { /* regular header */ + GPR_ASSERT(GRPC_SLICE_LENGTH(elem->key->slice) > 0); + if (GRPC_SLICE_START_PTR(elem->key->slice)[0] != ':') { /* regular header */ st->seen_regular_header = 1; } else { GPR_ASSERT( diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.c b/src/core/ext/transport/chttp2/transport/hpack_parser.c index 0e721b181a..3c1c6ba5a6 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.c +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.c @@ -1502,8 +1502,8 @@ static grpc_error *is_binary_indexed_header(grpc_chttp2_hpack_parser *p, GRPC_ERROR_INT_SIZE, (intptr_t)p->table.num_ents); } *is = - grpc_is_binary_header((const char *)GPR_SLICE_START_PTR(elem->key->slice), - GPR_SLICE_LENGTH(elem->key->slice)); + grpc_is_binary_header((const char *)GRPC_SLICE_START_PTR(elem->key->slice), + GRPC_SLICE_LENGTH(elem->key->slice)); return GRPC_ERROR_NONE; } @@ -1586,10 +1586,10 @@ grpc_error *grpc_chttp2_header_parser_parse(grpc_exec_ctx *exec_ctx, grpc_chttp2_hpack_parser *parser = hpack_parser; GPR_TIMER_BEGIN("grpc_chttp2_hpack_parser_parse", 0); if (s != NULL) { - s->stats.incoming.header_bytes += GPR_SLICE_LENGTH(slice); + s->stats.incoming.header_bytes += GRPC_SLICE_LENGTH(slice); } grpc_error *error = grpc_chttp2_hpack_parser_parse( - exec_ctx, parser, GPR_SLICE_START_PTR(slice), GPR_SLICE_END_PTR(slice)); + exec_ctx, parser, GRPC_SLICE_START_PTR(slice), GRPC_SLICE_END_PTR(slice)); if (error != GRPC_ERROR_NONE) { GPR_TIMER_END("grpc_chttp2_hpack_parser_parse", 0); return error; diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.c b/src/core/ext/transport/chttp2/transport/hpack_table.c index 2b73ec969e..2dc793d304 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.c +++ b/src/core/ext/transport/chttp2/transport/hpack_table.c @@ -226,8 +226,8 @@ grpc_mdelem *grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl, /* Evict one element from the table */ static void evict1(grpc_chttp2_hptbl *tbl) { grpc_mdelem *first_ent = tbl->ents[tbl->first_ent]; - size_t elem_bytes = GPR_SLICE_LENGTH(first_ent->key->slice) + - GPR_SLICE_LENGTH(first_ent->value->slice) + + size_t elem_bytes = GRPC_SLICE_LENGTH(first_ent->key->slice) + + GRPC_SLICE_LENGTH(first_ent->value->slice) + GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD; GPR_ASSERT(elem_bytes <= tbl->mem_used); tbl->mem_used -= (uint32_t)elem_bytes; @@ -298,8 +298,8 @@ grpc_error *grpc_chttp2_hptbl_set_current_table_size(grpc_chttp2_hptbl *tbl, grpc_error *grpc_chttp2_hptbl_add(grpc_chttp2_hptbl *tbl, grpc_mdelem *md) { /* determine how many bytes of buffer this entry represents */ - size_t elem_bytes = GPR_SLICE_LENGTH(md->key->slice) + - GPR_SLICE_LENGTH(md->value->slice) + + size_t elem_bytes = GRPC_SLICE_LENGTH(md->key->slice) + + GRPC_SLICE_LENGTH(md->value->slice) + GRPC_CHTTP2_HPACK_ENTRY_OVERHEAD; if (tbl->current_table_bytes > tbl->max_bytes) { diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index 6941a1e397..cb88fd5baf 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -73,8 +73,8 @@ static grpc_error *parse_frame_slice(grpc_exec_ctx *exec_ctx, grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, grpc_slice slice) { - uint8_t *beg = GPR_SLICE_START_PTR(slice); - uint8_t *end = GPR_SLICE_END_PTR(slice); + uint8_t *beg = GRPC_SLICE_START_PTR(slice); + uint8_t *end = GRPC_SLICE_END_PTR(slice); uint8_t *cur = beg; grpc_error *err; diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 6f55b69c84..73fda07ee1 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -521,7 +521,7 @@ static void create_grpc_frame(grpc_slice_buffer *write_slice_buffer, char **pp_write_buffer, size_t *p_write_buffer_size) { grpc_slice slice = grpc_slice_buffer_take_first(write_slice_buffer); - size_t length = GPR_SLICE_LENGTH(slice); + size_t length = GRPC_SLICE_LENGTH(slice); *p_write_buffer_size = length + GRPC_HEADER_SIZE_IN_BYTES; /* This is freed in the on_write_completed callback */ char *write_buffer = gpr_malloc(length + GRPC_HEADER_SIZE_IN_BYTES); @@ -534,7 +534,7 @@ static void create_grpc_frame(grpc_slice_buffer *write_slice_buffer, *p++ = (uint8_t)(length >> 8); *p++ = (uint8_t)(length); /* append actual data */ - memcpy(p, GPR_SLICE_START_PTR(slice), length); + memcpy(p, GRPC_SLICE_START_PTR(slice), length); } /* @@ -920,7 +920,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, CRONET_LOG(GPR_DEBUG, "read operation complete"); grpc_slice read_data_slice = grpc_slice_malloc((uint32_t)stream_state->rs.length_field); - uint8_t *dst_p = GPR_SLICE_START_PTR(read_data_slice); + uint8_t *dst_p = GRPC_SLICE_START_PTR(read_data_slice); memcpy(dst_p, stream_state->rs.read_buffer, (size_t)stream_state->rs.length_field); free_read_buffer(s); diff --git a/src/core/lib/channel/http_client_filter.c b/src/core/lib/channel/http_client_filter.c index 110c1cb546..0714f31bdd 100644 --- a/src/core/lib/channel/http_client_filter.c +++ b/src/core/lib/channel/http_client_filter.c @@ -176,9 +176,9 @@ static void continue_send_message(grpc_exec_ctx *exec_ctx, while (grpc_byte_stream_next(exec_ctx, calld->send_op.send_message, &calld->incoming_slice, ~(size_t)0, &calld->got_slice)) { - memcpy(wrptr, GPR_SLICE_START_PTR(calld->incoming_slice), - GPR_SLICE_LENGTH(calld->incoming_slice)); - wrptr += GPR_SLICE_LENGTH(calld->incoming_slice); + memcpy(wrptr, GRPC_SLICE_START_PTR(calld->incoming_slice), + GRPC_SLICE_LENGTH(calld->incoming_slice)); + wrptr += GRPC_SLICE_LENGTH(calld->incoming_slice); grpc_slice_buffer_add(&calld->slices, calld->incoming_slice); if (calld->send_length == calld->slices.length) { calld->send_message_blocked = false; diff --git a/src/core/lib/compression/message_compress.c b/src/core/lib/compression/message_compress.c index 501cb8be69..6c245acf61 100644 --- a/src/core/lib/compression/message_compress.c +++ b/src/core/lib/compression/message_compress.c @@ -51,22 +51,22 @@ static int zlib_body(z_stream* zs, grpc_slice_buffer* input, grpc_slice outbuf = grpc_slice_malloc(OUTPUT_BLOCK_SIZE); const uInt uint_max = ~(uInt)0; - GPR_ASSERT(GPR_SLICE_LENGTH(outbuf) <= uint_max); - zs->avail_out = (uInt)GPR_SLICE_LENGTH(outbuf); - zs->next_out = GPR_SLICE_START_PTR(outbuf); + GPR_ASSERT(GRPC_SLICE_LENGTH(outbuf) <= uint_max); + zs->avail_out = (uInt)GRPC_SLICE_LENGTH(outbuf); + zs->next_out = GRPC_SLICE_START_PTR(outbuf); flush = Z_NO_FLUSH; for (i = 0; i < input->count; i++) { if (i == input->count - 1) flush = Z_FINISH; - GPR_ASSERT(GPR_SLICE_LENGTH(input->slices[i]) <= uint_max); - zs->avail_in = (uInt)GPR_SLICE_LENGTH(input->slices[i]); - zs->next_in = GPR_SLICE_START_PTR(input->slices[i]); + GPR_ASSERT(GRPC_SLICE_LENGTH(input->slices[i]) <= uint_max); + zs->avail_in = (uInt)GRPC_SLICE_LENGTH(input->slices[i]); + zs->next_in = GRPC_SLICE_START_PTR(input->slices[i]); do { if (zs->avail_out == 0) { grpc_slice_buffer_add_indexed(output, outbuf); outbuf = grpc_slice_malloc(OUTPUT_BLOCK_SIZE); - GPR_ASSERT(GPR_SLICE_LENGTH(outbuf) <= uint_max); - zs->avail_out = (uInt)GPR_SLICE_LENGTH(outbuf); - zs->next_out = GPR_SLICE_START_PTR(outbuf); + GPR_ASSERT(GRPC_SLICE_LENGTH(outbuf) <= uint_max); + zs->avail_out = (uInt)GRPC_SLICE_LENGTH(outbuf); + zs->next_out = GRPC_SLICE_START_PTR(outbuf); } r = flate(zs, flush); if (r < 0 && r != Z_BUF_ERROR /* not fatal */) { diff --git a/src/core/lib/http/httpcli.c b/src/core/lib/http/httpcli.c index 31294efcc6..fdb8abaa2d 100644 --- a/src/core/lib/http/httpcli.c +++ b/src/core/lib/http/httpcli.c @@ -144,7 +144,7 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data, size_t i; for (i = 0; i < req->incoming.count; i++) { - if (GPR_SLICE_LENGTH(req->incoming.slices[i])) { + if (GRPC_SLICE_LENGTH(req->incoming.slices[i])) { req->have_read_byte = 1; grpc_error *err = grpc_http_parser_parse(&req->parser, req->incoming.slices[i], NULL); diff --git a/src/core/lib/http/parser.c b/src/core/lib/http/parser.c index 14abb1da69..2f84adc187 100644 --- a/src/core/lib/http/parser.c +++ b/src/core/lib/http/parser.c @@ -335,10 +335,10 @@ void grpc_http_response_destroy(grpc_http_response *response) { grpc_error *grpc_http_parser_parse(grpc_http_parser *parser, grpc_slice slice, size_t *start_of_body) { - for (size_t i = 0; i < GPR_SLICE_LENGTH(slice); i++) { + for (size_t i = 0; i < GRPC_SLICE_LENGTH(slice); i++) { bool found_body_start = false; grpc_error *err = - addbyte(parser, GPR_SLICE_START_PTR(slice)[i], &found_body_start); + 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; } diff --git a/src/core/lib/iomgr/tcp_posix.c b/src/core/lib/iomgr/tcp_posix.c index 0d8bd04af9..584fc2fe2e 100644 --- a/src/core/lib/iomgr/tcp_posix.c +++ b/src/core/lib/iomgr/tcp_posix.c @@ -217,8 +217,8 @@ static void tcp_do_read(grpc_exec_ctx *exec_ctx, grpc_tcp *tcp) { GPR_TIMER_BEGIN("tcp_continue_read", 0); for (i = 0; i < tcp->incoming_buffer->count; i++) { - iov[i].iov_base = GPR_SLICE_START_PTR(tcp->incoming_buffer->slices[i]); - iov[i].iov_len = GPR_SLICE_LENGTH(tcp->incoming_buffer->slices[i]); + iov[i].iov_base = GRPC_SLICE_START_PTR(tcp->incoming_buffer->slices[i]); + iov[i].iov_len = GRPC_SLICE_LENGTH(tcp->incoming_buffer->slices[i]); } msg.msg_name = NULL; @@ -348,11 +348,11 @@ static bool tcp_flush(grpc_tcp *tcp, grpc_error **error) { iov_size != MAX_WRITE_IOVEC; iov_size++) { iov[iov_size].iov_base = - GPR_SLICE_START_PTR( + GRPC_SLICE_START_PTR( tcp->outgoing_buffer->slices[tcp->outgoing_slice_idx]) + tcp->outgoing_byte_idx; iov[iov_size].iov_len = - GPR_SLICE_LENGTH( + GRPC_SLICE_LENGTH( tcp->outgoing_buffer->slices[tcp->outgoing_slice_idx]) - tcp->outgoing_byte_idx; sending_length += iov[iov_size].iov_len; @@ -393,7 +393,7 @@ static bool tcp_flush(grpc_tcp *tcp, grpc_error **error) { size_t slice_length; tcp->outgoing_slice_idx--; - slice_length = GPR_SLICE_LENGTH( + slice_length = GRPC_SLICE_LENGTH( tcp->outgoing_buffer->slices[tcp->outgoing_slice_idx]); if (slice_length > trailing) { tcp->outgoing_byte_idx = slice_length - trailing; diff --git a/src/core/lib/iomgr/tcp_uv.c b/src/core/lib/iomgr/tcp_uv.c index 05d6eeb240..f44829959d 100644 --- a/src/core/lib/iomgr/tcp_uv.c +++ b/src/core/lib/iomgr/tcp_uv.c @@ -59,9 +59,9 @@ typedef struct { grpc_closure *read_cb; grpc_closure *write_cb; - gpr_slice read_slice; - gpr_slice_buffer *read_slices; - gpr_slice_buffer *write_slices; + GRPC_SLICE read_slice; + GRPC_SLICE_buffer *read_slices; + GRPC_SLICE_buffer *write_slices; uv_buf_t *write_buffers; bool shutting_down; @@ -108,14 +108,14 @@ static void alloc_uv_buf(uv_handle_t *handle, size_t suggested_size, uv_buf_t *buf) { grpc_tcp *tcp = handle->data; (void)suggested_size; - tcp->read_slice = gpr_slice_malloc(GRPC_TCP_DEFAULT_READ_SLICE_SIZE); - buf->base = (char *)GPR_SLICE_START_PTR(tcp->read_slice); - buf->len = GPR_SLICE_LENGTH(tcp->read_slice); + tcp->read_slice = GRPC_SLICE_malloc(GRPC_TCP_DEFAULT_READ_SLICE_SIZE); + buf->base = (char *)GRPC_SLICE_START_PTR(tcp->read_slice); + buf->len = GRPC_SLICE_LENGTH(tcp->read_slice); } static void read_callback(uv_stream_t *stream, ssize_t nread, const uv_buf_t *buf) { - gpr_slice sub; + GRPC_SLICE sub; grpc_error *error; grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; grpc_tcp *tcp = stream->data; @@ -132,8 +132,8 @@ static void read_callback(uv_stream_t *stream, ssize_t nread, error = GRPC_ERROR_CREATE("EOF"); } else if (nread > 0) { // Successful read - sub = gpr_slice_sub_no_ref(tcp->read_slice, 0, (size_t)nread); - gpr_slice_buffer_add(tcp->read_slices, sub); + sub = GRPC_SLICE_sub_no_ref(tcp->read_slice, 0, (size_t)nread); + GRPC_SLICE_buffer_add(tcp->read_slices, sub); error = GRPC_ERROR_NONE; if (grpc_tcp_trace) { size_t i; @@ -157,14 +157,14 @@ static void read_callback(uv_stream_t *stream, ssize_t nread, } static void uv_endpoint_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - gpr_slice_buffer *read_slices, grpc_closure *cb) { + GRPC_SLICE_buffer *read_slices, grpc_closure *cb) { grpc_tcp *tcp = (grpc_tcp *)ep; int status; grpc_error *error = GRPC_ERROR_NONE; GPR_ASSERT(tcp->read_cb == NULL); tcp->read_cb = cb; tcp->read_slices = read_slices; - gpr_slice_buffer_reset_and_unref(read_slices); + GRPC_SLICE_buffer_reset_and_unref(read_slices); TCP_REF(tcp, "read"); // TODO(murgatroid99): figure out what the return value here means status = @@ -204,13 +204,13 @@ static void write_callback(uv_write_t *req, int status) { } static void uv_endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, - gpr_slice_buffer *write_slices, + GRPC_SLICE_buffer *write_slices, grpc_closure *cb) { grpc_tcp *tcp = (grpc_tcp *)ep; uv_buf_t *buffers; unsigned int buffer_count; unsigned int i; - gpr_slice *slice; + GRPC_SLICE *slice; uv_write_t *write_req; if (grpc_tcp_trace) { @@ -245,8 +245,8 @@ static void uv_endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, buffers = gpr_malloc(sizeof(uv_buf_t) * buffer_count); for (i = 0; i < buffer_count; i++) { slice = &tcp->write_slices->slices[i]; - buffers[i].base = (char *)GPR_SLICE_START_PTR(*slice); - buffers[i].len = GPR_SLICE_LENGTH(*slice); + buffers[i].base = (char *)GRPC_SLICE_START_PTR(*slice); + buffers[i].len = GRPC_SLICE_LENGTH(*slice); } write_req = gpr_malloc(sizeof(uv_write_t)); write_req->data = tcp; diff --git a/src/core/lib/iomgr/tcp_windows.c b/src/core/lib/iomgr/tcp_windows.c index fda26f52a9..9fe7662e96 100644 --- a/src/core/lib/iomgr/tcp_windows.c +++ b/src/core/lib/iomgr/tcp_windows.c @@ -209,9 +209,9 @@ static void win_read(grpc_exec_ctx *exec_ctx, grpc_endpoint *ep, tcp->read_slice = grpc_slice_malloc(8192); - buffer.len = (ULONG)GPR_SLICE_LENGTH( + buffer.len = (ULONG)GRPC_SLICE_LENGTH( tcp->read_slice); // we know slice size fits in 32bit. - buffer.buf = (char *)GPR_SLICE_START_PTR(tcp->read_slice); + buffer.buf = (char *)GRPC_SLICE_START_PTR(tcp->read_slice); TCP_REF(tcp, "read"); @@ -300,10 +300,10 @@ 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]); + len = GRPC_SLICE_LENGTH(tcp->write_slices->slices[i]); GPR_ASSERT(len <= ULONG_MAX); buffers[i].len = (ULONG)len; - buffers[i].buf = (char *)GPR_SLICE_START_PTR(tcp->write_slices->slices[i]); + buffers[i].buf = (char *)GRPC_SLICE_START_PTR(tcp->write_slices->slices[i]); } /* First, let's try a synchronous, non-blocking write. */ diff --git a/src/core/lib/security/credentials/google_default/google_default_credentials.c b/src/core/lib/security/credentials/google_default/google_default_credentials.c index aaa82976fb..afe0e3d357 100644 --- a/src/core/lib/security/credentials/google_default/google_default_credentials.c +++ b/src/core/lib/security/credentials/google_default/google_default_credentials.c @@ -186,7 +186,7 @@ static grpc_error *create_default_creds_from_path( goto end; } json = grpc_json_parse_string_with_len( - (char *)GPR_SLICE_START_PTR(creds_data), GPR_SLICE_LENGTH(creds_data)); + (char *)GRPC_SLICE_START_PTR(creds_data), GRPC_SLICE_LENGTH(creds_data)); if (json == NULL) { char *dump = grpc_dump_slice(creds_data, GPR_DUMP_HEX | GPR_DUMP_ASCII); error = grpc_error_set_str(GRPC_ERROR_CREATE("Failed to parse JSON"), diff --git a/src/core/lib/security/credentials/jwt/jwt_verifier.c b/src/core/lib/security/credentials/jwt/jwt_verifier.c index 9cb8cd64f6..42bd89dd0a 100644 --- a/src/core/lib/security/credentials/jwt/jwt_verifier.c +++ b/src/core/lib/security/credentials/jwt/jwt_verifier.c @@ -89,12 +89,12 @@ static grpc_json *parse_json_part_from_jwt(const char *str, size_t len, grpc_json *json; *buffer = grpc_base64_decode_with_len(str, len, 1); - if (GPR_SLICE_IS_EMPTY(*buffer)) { + if (GRPC_SLICE_IS_EMPTY(*buffer)) { gpr_log(GPR_ERROR, "Invalid base64."); return NULL; } - json = grpc_json_parse_string_with_len((char *)GPR_SLICE_START_PTR(*buffer), - GPR_SLICE_LENGTH(*buffer)); + json = grpc_json_parse_string_with_len((char *)GRPC_SLICE_START_PTR(*buffer), + GRPC_SLICE_LENGTH(*buffer)); if (json == NULL) { grpc_slice_unref(*buffer); gpr_log(GPR_ERROR, "JSON parsing error."); @@ -453,12 +453,12 @@ static BIGNUM *bignum_from_base64(const char *b64) { if (b64 == NULL) return NULL; bin = grpc_base64_decode(b64, 1); - if (GPR_SLICE_IS_EMPTY(bin)) { + if (GRPC_SLICE_IS_EMPTY(bin)) { gpr_log(GPR_ERROR, "Invalid base64 for big num."); return NULL; } - result = BN_bin2bn(GPR_SLICE_START_PTR(bin), - TSI_SIZE_AS_SIZE(GPR_SLICE_LENGTH(bin)), NULL); + result = BN_bin2bn(GRPC_SLICE_START_PTR(bin), + TSI_SIZE_AS_SIZE(GRPC_SLICE_LENGTH(bin)), NULL); grpc_slice_unref(bin); return result; } @@ -567,13 +567,13 @@ static int verify_jwt_signature(EVP_PKEY *key, const char *alg, gpr_log(GPR_ERROR, "EVP_DigestVerifyInit failed."); goto end; } - if (EVP_DigestVerifyUpdate(md_ctx, GPR_SLICE_START_PTR(signed_data), - GPR_SLICE_LENGTH(signed_data)) != 1) { + if (EVP_DigestVerifyUpdate(md_ctx, GRPC_SLICE_START_PTR(signed_data), + GRPC_SLICE_LENGTH(signed_data)) != 1) { gpr_log(GPR_ERROR, "EVP_DigestVerifyUpdate failed."); goto end; } - if (EVP_DigestVerifyFinal(md_ctx, GPR_SLICE_START_PTR(signature), - GPR_SLICE_LENGTH(signature)) != 1) { + if (EVP_DigestVerifyFinal(md_ctx, GRPC_SLICE_START_PTR(signature), + GRPC_SLICE_LENGTH(signature)) != 1) { gpr_log(GPR_ERROR, "JWT signature verification failed."); goto end; } @@ -824,7 +824,7 @@ void grpc_jwt_verifier_verify(grpc_exec_ctx *exec_ctx, signed_jwt_len = (size_t)(dot - jwt); cur = dot + 1; signature = grpc_base64_decode(cur, 1); - if (GPR_SLICE_IS_EMPTY(signature)) goto error; + if (GRPC_SLICE_IS_EMPTY(signature)) goto error; retrieve_key_and_verify( exec_ctx, verifier_cb_ctx_create(verifier, pollset, header, claims, audience, diff --git a/src/core/lib/security/transport/handshake.c b/src/core/lib/security/transport/handshake.c index 58d896b32e..07f16df51f 100644 --- a/src/core/lib/security/transport/handshake.c +++ b/src/core/lib/security/transport/handshake.c @@ -239,9 +239,9 @@ static void on_handshake_data_received_from_peer(grpc_exec_ctx *exec_ctx, } for (i = 0; i < h->incoming.count; i++) { - consumed_slice_size = GPR_SLICE_LENGTH(h->incoming.slices[i]); + consumed_slice_size = GRPC_SLICE_LENGTH(h->incoming.slices[i]); result = tsi_handshaker_process_bytes_from_peer( - h->handshaker, GPR_SLICE_START_PTR(h->incoming.slices[i]), + h->handshaker, GRPC_SLICE_START_PTR(h->incoming.slices[i]), &consumed_slice_size); if (!tsi_handshaker_is_in_progress(h->handshaker)) break; } @@ -267,7 +267,7 @@ static void on_handshake_data_received_from_peer(grpc_exec_ctx *exec_ctx, /* Handshake is done and successful this point. */ has_left_overs_in_current_slice = - (consumed_slice_size < GPR_SLICE_LENGTH(h->incoming.slices[i])); + (consumed_slice_size < GRPC_SLICE_LENGTH(h->incoming.slices[i])); num_left_overs = (has_left_overs_in_current_slice ? 1 : 0) + h->incoming.count - i - 1; if (num_left_overs == 0) { diff --git a/src/core/lib/security/transport/secure_endpoint.c b/src/core/lib/security/transport/secure_endpoint.c index 9acfd421a7..fba3314812 100644 --- a/src/core/lib/security/transport/secure_endpoint.c +++ b/src/core/lib/security/transport/secure_endpoint.c @@ -124,8 +124,8 @@ static void flush_read_staging_buffer(secure_endpoint *ep, uint8_t **cur, uint8_t **end) { grpc_slice_buffer_add(ep->read_buffer, ep->read_staging_buffer); ep->read_staging_buffer = grpc_slice_malloc(STAGING_BUFFER_SIZE); - *cur = GPR_SLICE_START_PTR(ep->read_staging_buffer); - *end = GPR_SLICE_END_PTR(ep->read_staging_buffer); + *cur = GRPC_SLICE_START_PTR(ep->read_staging_buffer); + *end = GRPC_SLICE_END_PTR(ep->read_staging_buffer); } static void call_read_cb(grpc_exec_ctx *exec_ctx, secure_endpoint *ep, @@ -150,8 +150,8 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data, uint8_t keep_looping = 0; tsi_result result = TSI_OK; secure_endpoint *ep = (secure_endpoint *)user_data; - uint8_t *cur = GPR_SLICE_START_PTR(ep->read_staging_buffer); - uint8_t *end = GPR_SLICE_END_PTR(ep->read_staging_buffer); + uint8_t *cur = GRPC_SLICE_START_PTR(ep->read_staging_buffer); + uint8_t *end = GRPC_SLICE_END_PTR(ep->read_staging_buffer); if (error != GRPC_ERROR_NONE) { grpc_slice_buffer_reset_and_unref(ep->read_buffer); @@ -163,8 +163,8 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data, /* TODO(yangg) check error, maybe bail out early */ for (i = 0; i < ep->source_buffer.count; i++) { grpc_slice encrypted = ep->source_buffer.slices[i]; - uint8_t *message_bytes = GPR_SLICE_START_PTR(encrypted); - size_t message_size = GPR_SLICE_LENGTH(encrypted); + uint8_t *message_bytes = GRPC_SLICE_START_PTR(encrypted); + size_t message_size = GRPC_SLICE_LENGTH(encrypted); while (message_size > 0 || keep_looping) { size_t unprotected_buffer_size_written = (size_t)(end - cur); @@ -199,12 +199,12 @@ static void on_read(grpc_exec_ctx *exec_ctx, void *user_data, if (result != TSI_OK) break; } - if (cur != GPR_SLICE_START_PTR(ep->read_staging_buffer)) { + if (cur != GRPC_SLICE_START_PTR(ep->read_staging_buffer)) { grpc_slice_buffer_add( ep->read_buffer, grpc_slice_split_head( &ep->read_staging_buffer, - (size_t)(cur - GPR_SLICE_START_PTR(ep->read_staging_buffer)))); + (size_t)(cur - GRPC_SLICE_START_PTR(ep->read_staging_buffer)))); } /* TODO(yangg) experiment with moving this block after read_cb to see if it @@ -244,8 +244,8 @@ static void flush_write_staging_buffer(secure_endpoint *ep, uint8_t **cur, uint8_t **end) { grpc_slice_buffer_add(&ep->output_buffer, ep->write_staging_buffer); ep->write_staging_buffer = grpc_slice_malloc(STAGING_BUFFER_SIZE); - *cur = GPR_SLICE_START_PTR(ep->write_staging_buffer); - *end = GPR_SLICE_END_PTR(ep->write_staging_buffer); + *cur = GRPC_SLICE_START_PTR(ep->write_staging_buffer); + *end = GRPC_SLICE_END_PTR(ep->write_staging_buffer); } static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep, @@ -255,8 +255,8 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep, unsigned i; tsi_result result = TSI_OK; secure_endpoint *ep = (secure_endpoint *)secure_ep; - uint8_t *cur = GPR_SLICE_START_PTR(ep->write_staging_buffer); - uint8_t *end = GPR_SLICE_END_PTR(ep->write_staging_buffer); + uint8_t *cur = GRPC_SLICE_START_PTR(ep->write_staging_buffer); + uint8_t *end = GRPC_SLICE_END_PTR(ep->write_staging_buffer); grpc_slice_buffer_reset_and_unref(&ep->output_buffer); @@ -271,8 +271,8 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep, for (i = 0; i < slices->count; i++) { grpc_slice plain = slices->slices[i]; - uint8_t *message_bytes = GPR_SLICE_START_PTR(plain); - size_t message_size = GPR_SLICE_LENGTH(plain); + uint8_t *message_bytes = GRPC_SLICE_START_PTR(plain); + size_t message_size = GRPC_SLICE_LENGTH(plain); while (message_size > 0) { size_t protected_buffer_size_to_send = (size_t)(end - cur); size_t processed_message_size = message_size; @@ -311,12 +311,12 @@ static void endpoint_write(grpc_exec_ctx *exec_ctx, grpc_endpoint *secure_ep, flush_write_staging_buffer(ep, &cur, &end); } } while (still_pending_size > 0); - if (cur != GPR_SLICE_START_PTR(ep->write_staging_buffer)) { + if (cur != GRPC_SLICE_START_PTR(ep->write_staging_buffer)) { grpc_slice_buffer_add( &ep->output_buffer, grpc_slice_split_head( &ep->write_staging_buffer, - (size_t)(cur - GPR_SLICE_START_PTR(ep->write_staging_buffer)))); + (size_t)(cur - GRPC_SLICE_START_PTR(ep->write_staging_buffer)))); } } diff --git a/src/core/lib/security/transport/security_connector.c b/src/core/lib/security/transport/security_connector.c index cea94bfbba..3d39cf5dda 100644 --- a/src/core/lib/security/transport/security_connector.c +++ b/src/core/lib/security/transport/security_connector.c @@ -656,7 +656,7 @@ static grpc_slice compute_default_pem_root_certs_once(void) { /* Try overridden roots if needed. */ grpc_ssl_roots_override_result ovrd_res = GRPC_SSL_ROOTS_OVERRIDE_FAIL; - if (GPR_SLICE_IS_EMPTY(result) && ssl_roots_override_cb != NULL) { + if (GRPC_SLICE_IS_EMPTY(result) && ssl_roots_override_cb != NULL) { char *pem_root_certs = NULL; ovrd_res = ssl_roots_override_cb(&pem_root_certs); if (ovrd_res == GRPC_SSL_ROOTS_OVERRIDE_OK) { @@ -666,7 +666,7 @@ static grpc_slice compute_default_pem_root_certs_once(void) { } /* Fall back to installed certs if needed. */ - if (GPR_SLICE_IS_EMPTY(result) && + if (GRPC_SLICE_IS_EMPTY(result) && ovrd_res != GRPC_SSL_ROOTS_OVERRIDE_FAIL_PERMANENTLY) { GRPC_LOG_IF_ERROR("load_file", grpc_load_file(installed_roots_path, 0, &result)); @@ -714,8 +714,8 @@ size_t grpc_get_default_ssl_roots(const unsigned char **pem_root_certs) { loading all the roots once for the lifetime of the process. */ static gpr_once once = GPR_ONCE_INIT; gpr_once_init(&once, init_default_pem_root_certs); - *pem_root_certs = GPR_SLICE_START_PTR(default_pem_root_certs); - return GPR_SLICE_LENGTH(default_pem_root_certs); + *pem_root_certs = GRPC_SLICE_START_PTR(default_pem_root_certs); + return GRPC_SLICE_LENGTH(default_pem_root_certs); } grpc_security_status grpc_ssl_channel_security_connector_create( diff --git a/src/core/lib/security/transport/server_auth_filter.c b/src/core/lib/security/transport/server_auth_filter.c index 39973ab036..dd465be6f5 100644 --- a/src/core/lib/security/transport/server_auth_filter.c +++ b/src/core/lib/security/transport/server_auth_filter.c @@ -78,7 +78,7 @@ static grpc_metadata_array metadata_batch_to_md_array( usr_md = &result.metadata[result.count++]; usr_md->key = grpc_mdstr_as_c_string(key); usr_md->value = grpc_mdstr_as_c_string(value); - usr_md->value_length = GPR_SLICE_LENGTH(value->slice); + usr_md->value_length = GRPC_SLICE_LENGTH(value->slice); } return result; } @@ -92,14 +92,14 @@ static grpc_mdelem *remove_consumed_md(void *user_data, grpc_mdelem *md) { /* Maybe we could do a pointer comparison but we do not have any guarantee that the metadata processor used the same pointers for consumed_md in the callback. */ - if (GPR_SLICE_LENGTH(md->key->slice) != strlen(consumed_md->key) || - GPR_SLICE_LENGTH(md->value->slice) != consumed_md->value_length) { + if (GRPC_SLICE_LENGTH(md->key->slice) != strlen(consumed_md->key) || + GRPC_SLICE_LENGTH(md->value->slice) != consumed_md->value_length) { continue; } - if (memcmp(GPR_SLICE_START_PTR(md->key->slice), consumed_md->key, - GPR_SLICE_LENGTH(md->key->slice)) == 0 && - memcmp(GPR_SLICE_START_PTR(md->value->slice), consumed_md->value, - GPR_SLICE_LENGTH(md->value->slice)) == 0) { + if (memcmp(GRPC_SLICE_START_PTR(md->key->slice), consumed_md->key, + GRPC_SLICE_LENGTH(md->key->slice)) == 0 && + memcmp(GRPC_SLICE_START_PTR(md->value->slice), consumed_md->value, + GRPC_SLICE_LENGTH(md->value->slice)) == 0) { return NULL; /* Delete. */ } } diff --git a/src/core/lib/security/util/b64.c b/src/core/lib/security/util/b64.c index f4f0092c3d..6270277914 100644 --- a/src/core/lib/security/util/b64.c +++ b/src/core/lib/security/util/b64.c @@ -185,7 +185,7 @@ static int decode_group(const unsigned char *codes, size_t num_codes, grpc_slice grpc_base64_decode_with_len(const char *b64, size_t b64_len, int url_safe) { grpc_slice result = grpc_slice_malloc(b64_len); - unsigned char *current = GPR_SLICE_START_PTR(result); + unsigned char *current = GRPC_SLICE_START_PTR(result); size_t result_size = 0; unsigned char codes[4]; size_t num_codes = 0; @@ -224,7 +224,7 @@ grpc_slice grpc_base64_decode_with_len(const char *b64, size_t b64_len, !decode_group(codes, num_codes, current, &result_size)) { goto fail; } - GPR_SLICE_SET_LENGTH(result, result_size); + GRPC_SLICE_SET_LENGTH(result, result_size); return result; fail: diff --git a/src/core/lib/slice/percent_encoding.c b/src/core/lib/slice/percent_encoding.c index 19f5f96cc3..b9e35f1c71 100644 --- a/src/core/lib/slice/percent_encoding.c +++ b/src/core/lib/slice/percent_encoding.c @@ -55,8 +55,8 @@ grpc_slice grpc_percent_encode_slice(grpc_slice slice, // first pass: count the number of bytes needed to output this string size_t output_length = 0; - const uint8_t *slice_start = GPR_SLICE_START_PTR(slice); - const uint8_t *slice_end = GPR_SLICE_END_PTR(slice); + const uint8_t *slice_start = GRPC_SLICE_START_PTR(slice); + const uint8_t *slice_end = GRPC_SLICE_END_PTR(slice); const uint8_t *p; bool any_reserved_bytes = false; for (p = slice_start; p < slice_end; p++) { @@ -70,7 +70,7 @@ grpc_slice grpc_percent_encode_slice(grpc_slice slice, } // second pass: actually encode grpc_slice out = grpc_slice_malloc(output_length); - uint8_t *q = GPR_SLICE_START_PTR(out); + uint8_t *q = GRPC_SLICE_START_PTR(out); for (p = slice_start; p < slice_end; p++) { if (is_unreserved_character(*p, unreserved_bytes)) { *q++ = *p; @@ -80,7 +80,7 @@ grpc_slice grpc_percent_encode_slice(grpc_slice slice, *q++ = hex[*p & 15]; } } - GPR_ASSERT(q == GPR_SLICE_END_PTR(out)); + GPR_ASSERT(q == GRPC_SLICE_END_PTR(out)); return out; } @@ -100,8 +100,8 @@ static uint8_t dehex(uint8_t c) { bool grpc_strict_percent_decode_slice(grpc_slice slice_in, const uint8_t *unreserved_bytes, grpc_slice *slice_out) { - const uint8_t *p = GPR_SLICE_START_PTR(slice_in); - const uint8_t *in_end = GPR_SLICE_END_PTR(slice_in); + const uint8_t *p = GRPC_SLICE_START_PTR(slice_in); + const uint8_t *in_end = GRPC_SLICE_END_PTR(slice_in); size_t out_length = 0; bool any_percent_encoded_stuff = false; while (p != in_end) { @@ -122,9 +122,9 @@ bool grpc_strict_percent_decode_slice(grpc_slice slice_in, *slice_out = grpc_slice_ref(slice_in); return true; } - p = GPR_SLICE_START_PTR(slice_in); + p = GRPC_SLICE_START_PTR(slice_in); *slice_out = grpc_slice_malloc(out_length); - uint8_t *q = GPR_SLICE_START_PTR(*slice_out); + uint8_t *q = GRPC_SLICE_START_PTR(*slice_out); while (p != in_end) { if (*p == '%') { *q++ = (uint8_t)(dehex(p[1]) << 4) | (dehex(p[2])); @@ -133,13 +133,13 @@ bool grpc_strict_percent_decode_slice(grpc_slice slice_in, *q++ = *p++; } } - GPR_ASSERT(q == GPR_SLICE_END_PTR(*slice_out)); + GPR_ASSERT(q == GRPC_SLICE_END_PTR(*slice_out)); return true; } grpc_slice grpc_permissive_percent_decode_slice(grpc_slice slice_in) { - const uint8_t *p = GPR_SLICE_START_PTR(slice_in); - const uint8_t *in_end = GPR_SLICE_END_PTR(slice_in); + const uint8_t *p = GRPC_SLICE_START_PTR(slice_in); + const uint8_t *in_end = GRPC_SLICE_END_PTR(slice_in); size_t out_length = 0; bool any_percent_encoded_stuff = false; while (p != in_end) { @@ -160,9 +160,9 @@ grpc_slice grpc_permissive_percent_decode_slice(grpc_slice slice_in) { if (!any_percent_encoded_stuff) { return grpc_slice_ref(slice_in); } - p = GPR_SLICE_START_PTR(slice_in); + p = GRPC_SLICE_START_PTR(slice_in); grpc_slice out = grpc_slice_malloc(out_length); - uint8_t *q = GPR_SLICE_START_PTR(out); + uint8_t *q = GRPC_SLICE_START_PTR(out); while (p != in_end) { if (*p == '%') { if (!valid_hex(p + 1, in_end) || !valid_hex(p + 2, in_end)) { @@ -175,6 +175,6 @@ grpc_slice grpc_permissive_percent_decode_slice(grpc_slice slice_in) { *q++ = *p++; } } - GPR_ASSERT(q == GPR_SLICE_END_PTR(out)); + GPR_ASSERT(q == GRPC_SLICE_END_PTR(out)); return out; } diff --git a/src/core/lib/slice/slice.c b/src/core/lib/slice/slice.c index 1db1211938..54ff6f6baa 100644 --- a/src/core/lib/slice/slice.c +++ b/src/core/lib/slice/slice.c @@ -159,7 +159,7 @@ grpc_slice grpc_slice_new_with_len(void *p, size_t len, grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t length) { grpc_slice slice = grpc_slice_malloc(length); - memcpy(GPR_SLICE_START_PTR(slice), source, length); + memcpy(GRPC_SLICE_START_PTR(slice), source, length); return slice; } @@ -252,7 +252,7 @@ grpc_slice grpc_slice_sub(grpc_slice source, size_t begin, size_t end) { if (end - begin <= sizeof(subset.data.inlined.bytes)) { subset.refcount = NULL; subset.data.inlined.length = (uint8_t)(end - begin); - memcpy(subset.data.inlined.bytes, GPR_SLICE_START_PTR(source) + begin, + memcpy(subset.data.inlined.bytes, GRPC_SLICE_START_PTR(source) + begin, end - begin); } else { subset = grpc_slice_sub_no_ref(source, begin, end); @@ -336,15 +336,15 @@ grpc_slice grpc_slice_split_head(grpc_slice *source, size_t split) { } int grpc_slice_cmp(grpc_slice a, grpc_slice b) { - int d = (int)(GPR_SLICE_LENGTH(a) - GPR_SLICE_LENGTH(b)); + int d = (int)(GRPC_SLICE_LENGTH(a) - GRPC_SLICE_LENGTH(b)); if (d != 0) return d; - return memcmp(GPR_SLICE_START_PTR(a), GPR_SLICE_START_PTR(b), - GPR_SLICE_LENGTH(a)); + return memcmp(GRPC_SLICE_START_PTR(a), GRPC_SLICE_START_PTR(b), + GRPC_SLICE_LENGTH(a)); } int grpc_slice_str_cmp(grpc_slice a, const char *b) { size_t b_length = strlen(b); - int d = (int)(GPR_SLICE_LENGTH(a) - b_length); + int d = (int)(GRPC_SLICE_LENGTH(a) - b_length); if (d != 0) return d; - return memcmp(GPR_SLICE_START_PTR(a), b, b_length); + return memcmp(GRPC_SLICE_START_PTR(a), b, b_length); } diff --git a/src/core/lib/slice/slice_buffer.c b/src/core/lib/slice/slice_buffer.c index a18309f3c4..8416237631 100644 --- a/src/core/lib/slice/slice_buffer.c +++ b/src/core/lib/slice/slice_buffer.c @@ -98,7 +98,7 @@ size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer *sb, grpc_slice s) { size_t out = sb->count; maybe_embiggen(sb); sb->slices[out] = s; - sb->length += GPR_SLICE_LENGTH(s); + sb->length += GRPC_SLICE_LENGTH(s); sb->count = out + 1; return out; } @@ -112,18 +112,18 @@ void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice s) { writes */ if (!s.refcount && n) { grpc_slice *back = &sb->slices[n - 1]; - if (!back->refcount && back->data.inlined.length < GPR_SLICE_INLINED_SIZE) { + if (!back->refcount && back->data.inlined.length < GRPC_SLICE_INLINED_SIZE) { if (s.data.inlined.length + back->data.inlined.length <= - GPR_SLICE_INLINED_SIZE) { + GRPC_SLICE_INLINED_SIZE) { memcpy(back->data.inlined.bytes + back->data.inlined.length, s.data.inlined.bytes, s.data.inlined.length); back->data.inlined.length = (uint8_t)(back->data.inlined.length + s.data.inlined.length); } else { - size_t cp1 = GPR_SLICE_INLINED_SIZE - back->data.inlined.length; + size_t cp1 = GRPC_SLICE_INLINED_SIZE - back->data.inlined.length; memcpy(back->data.inlined.bytes + back->data.inlined.length, s.data.inlined.bytes, cp1); - back->data.inlined.length = GPR_SLICE_INLINED_SIZE; + back->data.inlined.length = GRPC_SLICE_INLINED_SIZE; maybe_embiggen(sb); back = &sb->slices[n]; sb->count = n + 1; @@ -149,7 +149,7 @@ void grpc_slice_buffer_addn(grpc_slice_buffer *sb, grpc_slice *s, size_t n) { void grpc_slice_buffer_pop(grpc_slice_buffer *sb) { if (sb->count != 0) { size_t count = --sb->count; - sb->length -= GPR_SLICE_LENGTH(sb->slices[count]); + sb->length -= GRPC_SLICE_LENGTH(sb->slices[count]); } } @@ -222,7 +222,7 @@ void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n, src_idx = 0; while (src_idx < src->capacity) { grpc_slice slice = src->slices[src_idx]; - size_t slice_len = GPR_SLICE_LENGTH(slice); + size_t slice_len = GRPC_SLICE_LENGTH(slice); if (n > slice_len) { grpc_slice_buffer_add(dst, slice); n -= slice_len; @@ -233,8 +233,8 @@ void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n, break; } else { /* n < slice_len */ src->slices[src_idx] = grpc_slice_split_tail(&slice, n); - GPR_ASSERT(GPR_SLICE_LENGTH(slice) == n); - GPR_ASSERT(GPR_SLICE_LENGTH(src->slices[src_idx]) == slice_len - n); + GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == n); + GPR_ASSERT(GRPC_SLICE_LENGTH(src->slices[src_idx]) == slice_len - n); grpc_slice_buffer_add(dst, slice); break; } @@ -254,7 +254,7 @@ void grpc_slice_buffer_trim_end(grpc_slice_buffer *sb, size_t n, for (;;) { size_t idx = sb->count - 1; grpc_slice slice = sb->slices[idx]; - size_t slice_len = GPR_SLICE_LENGTH(slice); + size_t slice_len = GRPC_SLICE_LENGTH(slice); if (slice_len > n) { sb->slices[idx] = grpc_slice_split_head(&slice, slice_len - n); grpc_slice_buffer_add_indexed(garbage, slice); @@ -277,6 +277,6 @@ grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer *sb) { slice = sb->slices[0]; memmove(&sb->slices[0], &sb->slices[1], (sb->count - 1) * sizeof(grpc_slice)); sb->count--; - sb->length -= GPR_SLICE_LENGTH(slice); + sb->length -= GRPC_SLICE_LENGTH(slice); return slice; } diff --git a/src/core/lib/slice/slice_string_helpers.c b/src/core/lib/slice/slice_string_helpers.c index eaffb63686..4731762ece 100644 --- a/src/core/lib/slice/slice_string_helpers.c +++ b/src/core/lib/slice/slice_string_helpers.c @@ -40,7 +40,7 @@ #include "src/core/lib/support/string.h" char *grpc_dump_slice(grpc_slice s, uint32_t flags) { - return gpr_dump((const char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s), + return gpr_dump((const char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s), flags); } @@ -53,8 +53,8 @@ static int slice_find_separator_offset(const grpc_slice str, const char *sep, const size_t read_offset, size_t *begin, size_t *end) { size_t i; - const uint8_t *str_ptr = GPR_SLICE_START_PTR(str) + read_offset; - const size_t str_len = GPR_SLICE_LENGTH(str) - read_offset; + const uint8_t *str_ptr = GRPC_SLICE_START_PTR(str) + read_offset; + const size_t str_len = GRPC_SLICE_LENGTH(str) - read_offset; const size_t sep_len = strlen(sep); if (str_len < sep_len) { return 0; @@ -82,7 +82,7 @@ void grpc_slice_split(grpc_slice str, const char *sep, grpc_slice_buffer *dst) { } while (slice_find_separator_offset(str, sep, end + sep_len, &begin, &end) != 0); grpc_slice_buffer_add_indexed( - dst, grpc_slice_sub(str, end + sep_len, GPR_SLICE_LENGTH(str))); + dst, grpc_slice_sub(str, end + sep_len, GRPC_SLICE_LENGTH(str))); } else { /* no sep found, add whole input */ grpc_slice_buffer_add_indexed(dst, grpc_slice_ref(str)); } diff --git a/src/core/lib/surface/byte_buffer_reader.c b/src/core/lib/surface/byte_buffer_reader.c index 6bf3c01e65..6a1ef2ba2d 100644 --- a/src/core/lib/surface/byte_buffer_reader.c +++ b/src/core/lib/surface/byte_buffer_reader.c @@ -119,11 +119,11 @@ grpc_slice grpc_byte_buffer_reader_readall(grpc_byte_buffer_reader *reader) { size_t bytes_read = 0; const size_t input_size = grpc_byte_buffer_length(reader->buffer_out); grpc_slice out_slice = grpc_slice_malloc(input_size); - uint8_t *const outbuf = GPR_SLICE_START_PTR(out_slice); /* just an alias */ + uint8_t *const outbuf = GRPC_SLICE_START_PTR(out_slice); /* just an alias */ while (grpc_byte_buffer_reader_next(reader, &in_slice) != 0) { - const size_t slice_length = GPR_SLICE_LENGTH(in_slice); - memcpy(&(outbuf[bytes_read]), GPR_SLICE_START_PTR(in_slice), slice_length); + const size_t slice_length = GRPC_SLICE_LENGTH(in_slice); + memcpy(&(outbuf[bytes_read]), GRPC_SLICE_START_PTR(in_slice), slice_length); bytes_read += slice_length; grpc_slice_unref(in_slice); GPR_ASSERT(bytes_read <= input_size); diff --git a/src/core/lib/surface/call.c b/src/core/lib/surface/call.c index 278f04a7f5..62c0ec83a1 100644 --- a/src/core/lib/surface/call.c +++ b/src/core/lib/surface/call.c @@ -518,8 +518,8 @@ static void set_encodings_accepted_by_peer(grpc_call *call, grpc_mdelem *mdel) { const grpc_slice *accept_encoding_entry_slice = &accept_encoding_parts.slices[i]; if (grpc_compression_algorithm_parse( - (const char *)GPR_SLICE_START_PTR(*accept_encoding_entry_slice), - GPR_SLICE_LENGTH(*accept_encoding_entry_slice), &algorithm)) { + (const char *)GRPC_SLICE_START_PTR(*accept_encoding_entry_slice), + GRPC_SLICE_LENGTH(*accept_encoding_entry_slice), &algorithm)) { GPR_BITSET(&call->encodings_accepted_by_peer, algorithm); } else { char *accept_encoding_entry_str = @@ -553,13 +553,13 @@ static void get_final_details(grpc_call *call, char **out_details, if (call->status[i].is_set) { if (call->status[i].details) { grpc_slice details = call->status[i].details->slice; - size_t len = GPR_SLICE_LENGTH(details); + size_t len = GRPC_SLICE_LENGTH(details); if (len + 1 > *out_details_capacity) { *out_details_capacity = GPR_MAX(len + 1, *out_details_capacity * 3 / 2); *out_details = gpr_realloc(*out_details, *out_details_capacity); } - memcpy(*out_details, GPR_SLICE_START_PTR(details), len); + memcpy(*out_details, GRPC_SLICE_START_PTR(details), len); (*out_details)[len] = 0; } else { goto no_details; @@ -901,7 +901,7 @@ static uint32_t decode_status(grpc_mdelem *md) { status = ((uint32_t)(intptr_t)user_data) - STATUS_OFFSET; } else { if (!gpr_parse_bytes_to_uint32(grpc_mdstr_as_c_string(md->value), - GPR_SLICE_LENGTH(md->value->slice), + GRPC_SLICE_LENGTH(md->value->slice), &status)) { status = GRPC_STATUS_UNKNOWN; /* could not parse status code */ } @@ -954,7 +954,7 @@ static grpc_mdelem *publish_app_metadata(grpc_call *call, grpc_mdelem *elem, mdusr = &dest->metadata[dest->count++]; mdusr->key = grpc_mdstr_as_c_string(elem->key); mdusr->value = grpc_mdstr_as_c_string(elem->value); - mdusr->value_length = GPR_SLICE_LENGTH(elem->value->slice); + mdusr->value_length = GRPC_SLICE_LENGTH(elem->value->slice); GPR_TIMER_END("publish_app_metadata", 0); return elem; } diff --git a/src/core/lib/surface/server.c b/src/core/lib/surface/server.c index 2045e59e53..5d763b3875 100644 --- a/src/core/lib/surface/server.c +++ b/src/core/lib/surface/server.c @@ -460,7 +460,7 @@ static void destroy_channel(grpc_exec_ctx *exec_ctx, channel_data *chand, static void cpstr(char **dest, size_t *capacity, grpc_mdstr *value) { grpc_slice slice = value->slice; - size_t len = GPR_SLICE_LENGTH(slice); + size_t len = GRPC_SLICE_LENGTH(slice); if (len + 1 > *capacity) { *capacity = GPR_MAX(len + 1, *capacity * 2); diff --git a/src/core/lib/transport/metadata.c b/src/core/lib/transport/metadata.c index b8364c4cb7..a1748c033b 100644 --- a/src/core/lib/transport/metadata.c +++ b/src/core/lib/transport/metadata.c @@ -351,8 +351,8 @@ grpc_mdstr *grpc_mdstr_from_string(const char *str) { } grpc_mdstr *grpc_mdstr_from_slice(grpc_slice slice) { - grpc_mdstr *result = grpc_mdstr_from_buffer(GPR_SLICE_START_PTR(slice), - GPR_SLICE_LENGTH(slice)); + grpc_mdstr *result = grpc_mdstr_from_buffer(GRPC_SLICE_START_PTR(slice), + GRPC_SLICE_LENGTH(slice)); grpc_slice_unref(slice); return result; } @@ -373,9 +373,9 @@ grpc_mdstr *grpc_mdstr_from_buffer(const uint8_t *buf, size_t length) { idx = (hash + i) % GPR_ARRAY_SIZE(g_static_strtab); ss = g_static_strtab[idx]; if (ss == NULL) break; - if (ss->hash == hash && GPR_SLICE_LENGTH(ss->slice) == length && + if (ss->hash == hash && GRPC_SLICE_LENGTH(ss->slice) == length && (length == 0 || - 0 == memcmp(buf, GPR_SLICE_START_PTR(ss->slice), length))) { + 0 == memcmp(buf, GRPC_SLICE_START_PTR(ss->slice), length))) { GPR_TIMER_END("grpc_mdstr_from_buffer", 0); return ss; } @@ -386,8 +386,8 @@ grpc_mdstr *grpc_mdstr_from_buffer(const uint8_t *buf, size_t length) { /* search for an existing string */ idx = TABLE_IDX(hash, LOG2_STRTAB_SHARD_COUNT, shard->capacity); for (s = shard->strs[idx]; s; s = s->bucket_next) { - if (s->hash == hash && GPR_SLICE_LENGTH(s->slice) == length && - 0 == memcmp(buf, GPR_SLICE_START_PTR(s->slice), length)) { + if (s->hash == hash && GRPC_SLICE_LENGTH(s->slice) == length && + 0 == memcmp(buf, GRPC_SLICE_START_PTR(s->slice), length)) { if (gpr_atm_full_fetch_add(&s->refcnt, 1) == 0) { /* If we get here, we've added a ref to something that was about to * die - drop it immediately. @@ -404,7 +404,7 @@ grpc_mdstr *grpc_mdstr_from_buffer(const uint8_t *buf, size_t length) { } /* not found: create a new string */ - if (length + 1 < GPR_SLICE_INLINED_SIZE) { + if (length + 1 < GRPC_SLICE_INLINED_SIZE) { /* string data goes directly into the slice */ s = gpr_malloc(sizeof(internal_string)); gpr_atm_rel_store(&s->refcnt, 1); @@ -607,12 +607,12 @@ static size_t get_base64_encoded_size(size_t raw_length) { } size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem *elem) { - size_t overhead_and_key = 32 + GPR_SLICE_LENGTH(elem->key->slice); - size_t value_len = GPR_SLICE_LENGTH(elem->value->slice); + size_t overhead_and_key = 32 + GRPC_SLICE_LENGTH(elem->key->slice); + size_t value_len = GRPC_SLICE_LENGTH(elem->value->slice); if (is_mdstr_static(elem->value)) { if (grpc_is_binary_header( - (const char *)GPR_SLICE_START_PTR(elem->key->slice), - GPR_SLICE_LENGTH(elem->key->slice))) { + (const char *)GRPC_SLICE_START_PTR(elem->key->slice), + GRPC_SLICE_LENGTH(elem->key->slice))) { return overhead_and_key + get_base64_encoded_size(value_len); } else { return overhead_and_key + value_len; @@ -622,8 +622,8 @@ size_t grpc_mdelem_get_size_in_hpack_table(grpc_mdelem *elem) { gpr_atm current_size = gpr_atm_acq_load(&is->size_in_decoder_table); if (current_size == SIZE_IN_DECODER_TABLE_NOT_SET) { if (grpc_is_binary_header( - (const char *)GPR_SLICE_START_PTR(elem->key->slice), - GPR_SLICE_LENGTH(elem->key->slice))) { + (const char *)GRPC_SLICE_START_PTR(elem->key->slice), + GRPC_SLICE_LENGTH(elem->key->slice))) { current_size = (gpr_atm)get_base64_encoded_size(value_len); } else { current_size = (gpr_atm)value_len; @@ -679,7 +679,7 @@ void grpc_mdelem_unref(grpc_mdelem *gmd DEBUG_ARGS) { } const char *grpc_mdstr_as_c_string(const grpc_mdstr *s) { - return (const char *)GPR_SLICE_START_PTR(s->slice); + return (const char *)GRPC_SLICE_START_PTR(s->slice); } size_t grpc_mdstr_length(const grpc_mdstr *s) { return GRPC_MDSTR_LENGTH(s); } diff --git a/src/core/lib/transport/metadata.h b/src/core/lib/transport/metadata.h index c63bce8310..8dcfbb98bb 100644 --- a/src/core/lib/transport/metadata.h +++ b/src/core/lib/transport/metadata.h @@ -149,7 +149,7 @@ void grpc_mdelem_unref(grpc_mdelem *md); Does not promise that the returned string has no embedded nulls however. */ const char *grpc_mdstr_as_c_string(const grpc_mdstr *s); -#define GRPC_MDSTR_LENGTH(s) (GPR_SLICE_LENGTH(s->slice)) +#define GRPC_MDSTR_LENGTH(s) (GRPC_SLICE_LENGTH(s->slice)) /* We add 32 bytes of padding as per RFC-7540 section 6.5.2. */ #define GRPC_MDELEM_LENGTH(e) \ diff --git a/src/csharp/ext/grpc_csharp_ext.c b/src/csharp/ext/grpc_csharp_ext.c index a178776d73..0bf5b0acf3 100644 --- a/src/csharp/ext/grpc_csharp_ext.c +++ b/src/csharp/ext/grpc_csharp_ext.c @@ -288,10 +288,10 @@ GPR_EXPORT void GPR_CALLTYPE grpcsharp_batch_context_recv_message_to_buffer( GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, ctx->recv_message)); while (grpc_byte_buffer_reader_next(&reader, &slice)) { - size_t len = GPR_SLICE_LENGTH(slice); + size_t len = GRPC_SLICE_LENGTH(slice); GPR_ASSERT(offset + len <= buffer_len); - memcpy(buffer + offset, GPR_SLICE_START_PTR(slice), - GPR_SLICE_LENGTH(slice)); + memcpy(buffer + offset, GRPC_SLICE_START_PTR(slice), + GRPC_SLICE_LENGTH(slice)); offset += len; grpc_slice_unref(slice); } diff --git a/src/node/ext/byte_buffer.cc b/src/node/ext/byte_buffer.cc index 76aa611a5d..399cdcd814 100644 --- a/src/node/ext/byte_buffer.cc +++ b/src/node/ext/byte_buffer.cc @@ -57,7 +57,7 @@ grpc_byte_buffer *BufferToByteBuffer(Local buffer) { int length = ::node::Buffer::Length(buffer); char *data = ::node::Buffer::Data(buffer); grpc_slice slice = grpc_slice_malloc(length); - memcpy(GPR_SLICE_START_PTR(slice), data, length); + memcpy(GRPC_SLICE_START_PTR(slice), data, length); grpc_byte_buffer *byte_buffer(grpc_raw_byte_buffer_create(&slice, 1)); grpc_slice_unref(slice); return byte_buffer; @@ -78,9 +78,9 @@ Local ByteBufferToBuffer(grpc_byte_buffer *buffer) { return scope.Escape(Nan::Undefined()); } grpc_slice slice = grpc_byte_buffer_reader_readall(&reader); - size_t length = GPR_SLICE_LENGTH(slice); + size_t length = GRPC_SLICE_LENGTH(slice); char *result = new char[length]; - memcpy(result, GPR_SLICE_START_PTR(slice), length); + memcpy(result, GRPC_SLICE_START_PTR(slice), length); grpc_slice_unref(slice); return scope.Escape(MakeFastBuffer( Nan::NewBuffer(result, length, delete_buffer, NULL).ToLocalChecked())); diff --git a/src/objective-c/GRPCClient/private/NSData+GRPC.m b/src/objective-c/GRPCClient/private/NSData+GRPC.m index 45d23d8651..6d2ad0a3bd 100644 --- a/src/objective-c/GRPCClient/private/NSData+GRPC.m +++ b/src/objective-c/GRPCClient/private/NSData+GRPC.m @@ -54,10 +54,10 @@ static void MallocAndCopyByteBufferToCharArray(grpc_byte_buffer *buffer, // The slice contains uncompressed data even if compressed data was received // because the reader takes care of automatically decompressing it grpc_slice slice = grpc_byte_buffer_reader_readall(&reader); - size_t uncompressed_length = GPR_SLICE_LENGTH(slice); + size_t uncompressed_length = GRPC_SLICE_LENGTH(slice); char *result = malloc(uncompressed_length); if (result) { - memcpy(result, GPR_SLICE_START_PTR(slice), uncompressed_length); + memcpy(result, GRPC_SLICE_START_PTR(slice), uncompressed_length); } grpc_slice_unref(slice); *array = result; diff --git a/src/php/ext/grpc/byte_buffer.c b/src/php/ext/grpc/byte_buffer.c index 2d48841dfa..b0269854e8 100644 --- a/src/php/ext/grpc/byte_buffer.c +++ b/src/php/ext/grpc/byte_buffer.c @@ -67,9 +67,9 @@ void byte_buffer_to_string(grpc_byte_buffer *buffer, char **out_string, } grpc_slice slice = grpc_byte_buffer_reader_readall(&reader); - size_t length = GPR_SLICE_LENGTH(slice); + size_t length = GRPC_SLICE_LENGTH(slice); char *string = ecalloc(length + 1, sizeof(char)); - memcpy(string, GPR_SLICE_START_PTR(slice), length); + memcpy(string, GRPC_SLICE_START_PTR(slice), length); grpc_slice_unref(slice); *out_string = string; diff --git a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi index ba26284b2c..ad766186bd 100644 --- a/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi +++ b/src/python/grpcio/grpc/_cython/_cygrpc/grpc.pxi @@ -68,8 +68,8 @@ cdef extern from "grpc/grpc.h": grpc_slice grpc_slice_from_copied_buffer(const char *source, size_t len) nogil # Declare functions for function-like macros (because Cython)... - void *grpc_slice_start_ptr "GPR_SLICE_START_PTR" (grpc_slice s) nogil - size_t grpc_slice_length "GPR_SLICE_LENGTH" (grpc_slice s) nogil + void *grpc_slice_start_ptr "GRPC_SLICE_START_PTR" (grpc_slice s) nogil + size_t grpc_slice_length "GRPC_SLICE_LENGTH" (grpc_slice s) nogil ctypedef enum gpr_clock_type: GPR_CLOCK_MONOTONIC diff --git a/src/ruby/ext/grpc/rb_byte_buffer.c b/src/ruby/ext/grpc/rb_byte_buffer.c index f0bacc3d7c..f97890e4a2 100644 --- a/src/ruby/ext/grpc/rb_byte_buffer.c +++ b/src/ruby/ext/grpc/rb_byte_buffer.c @@ -61,8 +61,8 @@ VALUE grpc_rb_byte_buffer_to_s(grpc_byte_buffer *buffer) { return Qnil; } while (grpc_byte_buffer_reader_next(&reader, &next) != 0) { - rb_str_cat(rb_string, (const char *) GPR_SLICE_START_PTR(next), - GPR_SLICE_LENGTH(next)); + rb_str_cat(rb_string, (const char *) GRPC_SLICE_START_PTR(next), + GRPC_SLICE_LENGTH(next)); grpc_slice_unref(next); } return rb_string; diff --git a/test/core/bad_client/tests/large_metadata.c b/test/core/bad_client/tests/large_metadata.c index 124035c070..9c804e78c1 100644 --- a/test/core/bad_client/tests/large_metadata.c +++ b/test/core/bad_client/tests/large_metadata.c @@ -192,7 +192,7 @@ static void client_validator(grpc_slice_buffer *incoming) { grpc_slice last_frame = last_frame_buffer.slices[0]; // Construct expected frame. grpc_slice expected = grpc_slice_malloc(13); - uint8_t *p = GPR_SLICE_START_PTR(expected); + uint8_t *p = GRPC_SLICE_START_PTR(expected); // Length. *p++ = 0; *p++ = 0; diff --git a/test/core/bad_ssl/servers/cert.c b/test/core/bad_ssl/servers/cert.c index 52922f5d6b..9aadf452e2 100644 --- a/test/core/bad_ssl/servers/cert.c +++ b/test/core/bad_ssl/servers/cert.c @@ -61,8 +61,8 @@ int main(int argc, char **argv) { GPR_ASSERT(GRPC_LOG_IF_ERROR( "load_file", grpc_load_file("src/core/lib/tsi/test_creds/badserver.key", 1, &key_slice))); - pem_key_cert_pair.private_key = (const char *)GPR_SLICE_START_PTR(key_slice); - pem_key_cert_pair.cert_chain = (const char *)GPR_SLICE_START_PTR(cert_slice); + pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice); + pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice); ssl_creds = grpc_ssl_server_credentials_create(NULL, &pem_key_cert_pair, 1, 0, NULL); diff --git a/test/core/compression/message_compress_test.c b/test/core/compression/message_compress_test.c index c6963df85d..680850af33 100644 --- a/test/core/compression/message_compress_test.c +++ b/test/core/compression/message_compress_test.c @@ -70,8 +70,8 @@ static void assert_passthrough(grpc_slice value, GPR_INFO, "assert_passthrough: value_length=%" PRIuPTR " value_hash=0x%08x " "algorithm='%s' uncompressed_split='%s' compressed_split='%s'", - GPR_SLICE_LENGTH(value), - gpr_murmur_hash3(GPR_SLICE_START_PTR(value), GPR_SLICE_LENGTH(value), 0), + GRPC_SLICE_LENGTH(value), + gpr_murmur_hash3(GRPC_SLICE_START_PTR(value), GRPC_SLICE_LENGTH(value), 0), algorithm_name, grpc_slice_split_mode_name(uncompressed_split_mode), grpc_slice_split_mode_name(compressed_split_mode)); @@ -114,7 +114,7 @@ static void assert_passthrough(grpc_slice value, static grpc_slice repeated(char c, size_t length) { grpc_slice out = grpc_slice_malloc(length); - memset(GPR_SLICE_START_PTR(out), c, length); + memset(GRPC_SLICE_START_PTR(out), c, length); return out; } @@ -184,9 +184,9 @@ static void test_bad_decompression_data_crc(void) { grpc_msg_compress(GRPC_COMPRESS_GZIP, &input, &corrupted); /* corrupt the output by smashing the CRC */ GPR_ASSERT(corrupted.count > 1); - GPR_ASSERT(GPR_SLICE_LENGTH(corrupted.slices[1]) > 8); - idx = GPR_SLICE_LENGTH(corrupted.slices[1]) - 8; - memcpy(GPR_SLICE_START_PTR(corrupted.slices[1]) + idx, &bad, 4); + GPR_ASSERT(GRPC_SLICE_LENGTH(corrupted.slices[1]) > 8); + idx = GRPC_SLICE_LENGTH(corrupted.slices[1]) - 8; + memcpy(GRPC_SLICE_START_PTR(corrupted.slices[1]) + idx, &bad, 4); /* try (and fail) to decompress the corrupted compresed buffer */ GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_GZIP, &corrupted, &output)); diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c index 3b9aa24368..4fb89eb96e 100644 --- a/test/core/end2end/cq_verifier.c +++ b/test/core/end2end/cq_verifier.c @@ -112,15 +112,15 @@ static grpc_slice merge_slices(grpc_slice *slices, size_t nslices) { grpc_slice out; for (i = 0; i < nslices; i++) { - len += GPR_SLICE_LENGTH(slices[i]); + len += GRPC_SLICE_LENGTH(slices[i]); } out = grpc_slice_malloc(len); - cursor = GPR_SLICE_START_PTR(out); + cursor = GRPC_SLICE_START_PTR(out); for (i = 0; i < nslices; i++) { - memcpy(cursor, GPR_SLICE_START_PTR(slices[i]), GPR_SLICE_LENGTH(slices[i])); - cursor += GPR_SLICE_LENGTH(slices[i]); + memcpy(cursor, GRPC_SLICE_START_PTR(slices[i]), GRPC_SLICE_LENGTH(slices[i])); + cursor += GRPC_SLICE_LENGTH(slices[i]); } return out; @@ -134,9 +134,9 @@ int raw_byte_buffer_eq_slice(grpc_byte_buffer *rbb, grpc_slice b) { a = merge_slices(rbb->data.raw.slice_buffer.slices, rbb->data.raw.slice_buffer.count); - ok = GPR_SLICE_LENGTH(a) == GPR_SLICE_LENGTH(b) && - 0 == memcmp(GPR_SLICE_START_PTR(a), GPR_SLICE_START_PTR(b), - GPR_SLICE_LENGTH(a)); + ok = GRPC_SLICE_LENGTH(a) == GRPC_SLICE_LENGTH(b) && + 0 == memcmp(GRPC_SLICE_START_PTR(a), GRPC_SLICE_START_PTR(b), + GRPC_SLICE_LENGTH(a)); grpc_slice_unref(a); grpc_slice_unref(b); return ok; diff --git a/test/core/end2end/fixtures/http_proxy.c b/test/core/end2end/fixtures/http_proxy.c index 80b9677577..57fc4a38f8 100644 --- a/test/core/end2end/fixtures/http_proxy.c +++ b/test/core/end2end/fixtures/http_proxy.c @@ -37,11 +37,11 @@ #include +#include #include #include #include #include -#include #include #include #include @@ -151,7 +151,7 @@ static void on_client_write_done(grpc_exec_ctx* exec_ctx, void* arg, // write that data now. if (conn->client_deferred_write_buffer.length > 0) { grpc_slice_buffer_move_into(&conn->client_deferred_write_buffer, - &conn->client_write_buffer); + &conn->client_write_buffer); grpc_endpoint_write(exec_ctx, conn->client_endpoint, &conn->client_write_buffer, &conn->on_client_write_done); @@ -176,7 +176,7 @@ static void on_server_write_done(grpc_exec_ctx* exec_ctx, void* arg, // write that data now. if (conn->server_deferred_write_buffer.length > 0) { grpc_slice_buffer_move_into(&conn->server_deferred_write_buffer, - &conn->server_write_buffer); + &conn->server_write_buffer); grpc_endpoint_write(exec_ctx, conn->server_endpoint, &conn->server_write_buffer, &conn->on_server_write_done); @@ -204,10 +204,10 @@ static void on_client_read_done(grpc_exec_ctx* exec_ctx, void* arg, // Otherwise, move the read data into the write buffer and write it. if (conn->server_write_buffer.length > 0) { grpc_slice_buffer_move_into(&conn->client_read_buffer, - &conn->server_deferred_write_buffer); + &conn->server_deferred_write_buffer); } else { grpc_slice_buffer_move_into(&conn->client_read_buffer, - &conn->server_write_buffer); + &conn->server_write_buffer); gpr_ref(&conn->refcount); grpc_endpoint_write(exec_ctx, conn->server_endpoint, &conn->server_write_buffer, @@ -236,10 +236,10 @@ static void on_server_read_done(grpc_exec_ctx* exec_ctx, void* arg, // Otherwise, move the read data into the write buffer and write it. if (conn->client_write_buffer.length > 0) { grpc_slice_buffer_move_into(&conn->server_read_buffer, - &conn->client_deferred_write_buffer); + &conn->client_deferred_write_buffer); } else { grpc_slice_buffer_move_into(&conn->server_read_buffer, - &conn->client_write_buffer); + &conn->client_write_buffer); gpr_ref(&conn->refcount); grpc_endpoint_write(exec_ctx, conn->client_endpoint, &conn->client_write_buffer, @@ -313,7 +313,7 @@ static void on_read_request_done(grpc_exec_ctx* exec_ctx, void* arg, } // Read request and feed it to the parser. for (size_t i = 0; i < conn->client_read_buffer.count; ++i) { - if (GPR_SLICE_LENGTH(conn->client_read_buffer.slices[i]) > 0) { + if (GRPC_SLICE_LENGTH(conn->client_read_buffer.slices[i]) > 0) { error = grpc_http_parser_parse(&conn->http_parser, conn->client_read_buffer.slices[i], NULL); if (error != GRPC_ERROR_NONE) { diff --git a/test/core/end2end/fuzzers/api_fuzzer.c b/test/core/end2end/fuzzers/api_fuzzer.c index 6834922299..4c8aafd8b3 100644 --- a/test/core/end2end/fuzzers/api_fuzzer.c +++ b/test/core/end2end/fuzzers/api_fuzzer.c @@ -138,7 +138,7 @@ static uint32_t read_uint32(input_stream *inp) { static grpc_byte_buffer *read_message(input_stream *inp) { grpc_slice slice = grpc_slice_malloc(read_uint22(inp)); - memset(GPR_SLICE_START_PTR(slice), 0, GPR_SLICE_LENGTH(slice)); + memset(GRPC_SLICE_START_PTR(slice), 0, GRPC_SLICE_LENGTH(slice)); grpc_byte_buffer *out = grpc_raw_byte_buffer_create(&slice, 1); grpc_slice_unref(slice); return out; diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index 0a4d87c2fb..41d5627b59 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -96,7 +96,7 @@ static void end_test(grpc_end2end_test_fixture *f) { static grpc_slice large_slice(void) { grpc_slice slice = grpc_slice_malloc(1000000); - memset(GPR_SLICE_START_PTR(slice), 'x', GPR_SLICE_LENGTH(slice)); + memset(GRPC_SLICE_START_PTR(slice), 'x', GRPC_SLICE_LENGTH(slice)); return slice; } diff --git a/test/core/handshake/client_ssl.c b/test/core/handshake/client_ssl.c index fdece99720..44efe4dbac 100644 --- a/test/core/handshake/client_ssl.c +++ b/test/core/handshake/client_ssl.c @@ -238,9 +238,9 @@ static bool client_ssl_test(char *server_alpn_preferred) { grpc_load_file(SSL_CERT_PATH, 1, &cert_slice))); GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file", grpc_load_file(SSL_KEY_PATH, 1, &key_slice))); - const char *ca_cert = (const char *)GPR_SLICE_START_PTR(ca_slice); - pem_key_cert_pair.private_key = (const char *)GPR_SLICE_START_PTR(key_slice); - pem_key_cert_pair.cert_chain = (const char *)GPR_SLICE_START_PTR(cert_slice); + const char *ca_cert = (const char *)GRPC_SLICE_START_PTR(ca_slice); + pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice); + pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice); grpc_channel_credentials *ssl_creds = grpc_ssl_credentials_create(ca_cert, &pem_key_cert_pair, NULL); diff --git a/test/core/handshake/server_ssl.c b/test/core/handshake/server_ssl.c index f49f98ad9a..f39b0040a6 100644 --- a/test/core/handshake/server_ssl.c +++ b/test/core/handshake/server_ssl.c @@ -91,9 +91,9 @@ static void server_thread(void *arg) { grpc_load_file(SSL_CERT_PATH, 1, &cert_slice))); GPR_ASSERT(GRPC_LOG_IF_ERROR("load_file", grpc_load_file(SSL_KEY_PATH, 1, &key_slice))); - const char *ca_cert = (const char *)GPR_SLICE_START_PTR(ca_slice); - pem_key_cert_pair.private_key = (const char *)GPR_SLICE_START_PTR(key_slice); - pem_key_cert_pair.cert_chain = (const char *)GPR_SLICE_START_PTR(cert_slice); + const char *ca_cert = (const char *)GRPC_SLICE_START_PTR(ca_slice); + pem_key_cert_pair.private_key = (const char *)GRPC_SLICE_START_PTR(key_slice); + pem_key_cert_pair.cert_chain = (const char *)GRPC_SLICE_START_PTR(cert_slice); grpc_server_credentials *ssl_creds = grpc_ssl_server_credentials_create( ca_cert, &pem_key_cert_pair, 1, 0, NULL); diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c index 86afdfba72..8a1699608e 100644 --- a/test/core/iomgr/endpoint_tests.c +++ b/test/core/iomgr/endpoint_tests.c @@ -68,12 +68,12 @@ size_t count_slices(grpc_slice *slices, size_t nslices, int *current_data) { size_t j; unsigned char *buf; for (i = 0; i < nslices; ++i) { - buf = GPR_SLICE_START_PTR(slices[i]); - for (j = 0; j < GPR_SLICE_LENGTH(slices[i]); ++j) { + buf = GRPC_SLICE_START_PTR(slices[i]); + for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) { GPR_ASSERT(buf[j] == *current_data); *current_data = (*current_data + 1) % 256; } - num_bytes += GPR_SLICE_LENGTH(slices[i]); + num_bytes += GRPC_SLICE_LENGTH(slices[i]); } return num_bytes; } @@ -100,9 +100,9 @@ static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size, for (i = 0; i < nslices; ++i) { slices[i] = grpc_slice_malloc(slice_size > num_bytes_left ? num_bytes_left : slice_size); - num_bytes_left -= GPR_SLICE_LENGTH(slices[i]); - buf = GPR_SLICE_START_PTR(slices[i]); - for (j = 0; j < GPR_SLICE_LENGTH(slices[i]); ++j) { + num_bytes_left -= GRPC_SLICE_LENGTH(slices[i]); + buf = GRPC_SLICE_START_PTR(slices[i]); + for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) { buf[j] = *current_data; (*current_data)++; } diff --git a/test/core/iomgr/load_file_test.c b/test/core/iomgr/load_file_test.c index b4e1b52d05..af822466d7 100644 --- a/test/core/iomgr/load_file_test.c +++ b/test/core/iomgr/load_file_test.c @@ -63,12 +63,12 @@ static void test_load_empty_file(void) { error = grpc_load_file(tmp_name, 0, &slice); GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(GPR_SLICE_LENGTH(slice) == 0); + GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == 0); error = grpc_load_file(tmp_name, 1, &slice_with_null_term); GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(GPR_SLICE_LENGTH(slice_with_null_term) == 1); - GPR_ASSERT(GPR_SLICE_START_PTR(slice_with_null_term)[0] == 0); + GPR_ASSERT(GRPC_SLICE_LENGTH(slice_with_null_term) == 1); + GPR_ASSERT(GRPC_SLICE_START_PTR(slice_with_null_term)[0] == 0); remove(tmp_name); gpr_free(tmp_name); @@ -93,7 +93,7 @@ static void test_load_failure(void) { error = grpc_load_file(tmp_name, 0, &slice); GPR_ASSERT(error != GRPC_ERROR_NONE); GRPC_ERROR_UNREF(error); - GPR_ASSERT(GPR_SLICE_LENGTH(slice) == 0); + GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == 0); gpr_free(tmp_name); grpc_slice_unref(slice); } @@ -116,13 +116,13 @@ static void test_load_small_file(void) { error = grpc_load_file(tmp_name, 0, &slice); GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(GPR_SLICE_LENGTH(slice) == strlen(blah)); - GPR_ASSERT(!memcmp(GPR_SLICE_START_PTR(slice), blah, strlen(blah))); + GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == strlen(blah)); + GPR_ASSERT(!memcmp(GRPC_SLICE_START_PTR(slice), blah, strlen(blah))); error = grpc_load_file(tmp_name, 1, &slice_with_null_term); GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(GPR_SLICE_LENGTH(slice_with_null_term) == (strlen(blah) + 1)); - GPR_ASSERT(strcmp((const char *)GPR_SLICE_START_PTR(slice_with_null_term), + GPR_ASSERT(GRPC_SLICE_LENGTH(slice_with_null_term) == (strlen(blah) + 1)); + GPR_ASSERT(strcmp((const char *)GRPC_SLICE_START_PTR(slice_with_null_term), blah) == 0); remove(tmp_name); @@ -153,8 +153,8 @@ static void test_load_big_file(void) { error = grpc_load_file(tmp_name, 0, &slice); GPR_ASSERT(error == GRPC_ERROR_NONE); - GPR_ASSERT(GPR_SLICE_LENGTH(slice) == buffer_size); - current = GPR_SLICE_START_PTR(slice); + GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == buffer_size); + current = GRPC_SLICE_START_PTR(slice); for (i = 0; i < buffer_size; i++) { GPR_ASSERT(current[i] == 42); } diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c index f23e23f03e..bba1900987 100644 --- a/test/core/iomgr/tcp_posix_test.c +++ b/test/core/iomgr/tcp_posix_test.c @@ -134,12 +134,12 @@ static size_t count_slices(grpc_slice *slices, size_t nslices, unsigned i, j; unsigned char *buf; for (i = 0; i < nslices; ++i) { - buf = GPR_SLICE_START_PTR(slices[i]); - for (j = 0; j < GPR_SLICE_LENGTH(slices[i]); ++j) { + buf = GRPC_SLICE_START_PTR(slices[i]); + for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) { GPR_ASSERT(buf[j] == *current_data); *current_data = (*current_data + 1) % 256; } - num_bytes += GPR_SLICE_LENGTH(slices[i]); + num_bytes += GRPC_SLICE_LENGTH(slices[i]); } return num_bytes; } @@ -285,9 +285,9 @@ static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size, for (i = 0; i < nslices; ++i) { slices[i] = grpc_slice_malloc(slice_size > num_bytes_left ? num_bytes_left : slice_size); - num_bytes_left -= GPR_SLICE_LENGTH(slices[i]); - buf = GPR_SLICE_START_PTR(slices[i]); - for (j = 0; j < GPR_SLICE_LENGTH(slices[i]); ++j) { + num_bytes_left -= GRPC_SLICE_LENGTH(slices[i]); + buf = GRPC_SLICE_START_PTR(slices[i]); + for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) { buf[j] = *current_data; (*current_data)++; } diff --git a/test/core/security/b64_test.c b/test/core/security/b64_test.c index b5c123b4b8..dea0f56266 100644 --- a/test/core/security/b64_test.c +++ b/test/core/security/b64_test.c @@ -58,9 +58,9 @@ static void test_simple_encode_decode_b64(int url_safe, int multiline) { char *hello_b64 = grpc_base64_encode(hello, strlen(hello), url_safe, multiline); grpc_slice hello_slice = grpc_base64_decode(hello_b64, url_safe); - GPR_ASSERT(GPR_SLICE_LENGTH(hello_slice) == strlen(hello)); - GPR_ASSERT(strncmp((const char *)GPR_SLICE_START_PTR(hello_slice), hello, - GPR_SLICE_LENGTH(hello_slice)) == 0); + GPR_ASSERT(GRPC_SLICE_LENGTH(hello_slice) == strlen(hello)); + GPR_ASSERT(strncmp((const char *)GRPC_SLICE_START_PTR(hello_slice), hello, + GRPC_SLICE_LENGTH(hello_slice)) == 0); grpc_slice_unref(hello_slice); gpr_free(hello_b64); @@ -77,8 +77,8 @@ static void test_full_range_encode_decode_b64(int url_safe, int multiline) { for (i = 0; i < 3; i++) { b64 = grpc_base64_encode(orig, sizeof(orig) - i, url_safe, multiline); orig_decoded = grpc_base64_decode(b64, url_safe); - GPR_ASSERT(GPR_SLICE_LENGTH(orig_decoded) == (sizeof(orig) - i)); - GPR_ASSERT(buffers_are_equal(orig, GPR_SLICE_START_PTR(orig_decoded), + GPR_ASSERT(GRPC_SLICE_LENGTH(orig_decoded) == (sizeof(orig) - i)); + GPR_ASSERT(buffers_are_equal(orig, GRPC_SLICE_START_PTR(orig_decoded), sizeof(orig) - i)); grpc_slice_unref(orig_decoded); gpr_free(b64); @@ -127,13 +127,13 @@ static void test_url_safe_unsafe_mismtach_failure(void) { b64 = grpc_base64_encode(orig, sizeof(orig), url_safe, 0); orig_decoded = grpc_base64_decode(b64, !url_safe); - GPR_ASSERT(GPR_SLICE_IS_EMPTY(orig_decoded)); + GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded)); gpr_free(b64); grpc_slice_unref(orig_decoded); b64 = grpc_base64_encode(orig, sizeof(orig), !url_safe, 0); orig_decoded = grpc_base64_decode(b64, url_safe); - GPR_ASSERT(GPR_SLICE_IS_EMPTY(orig_decoded)); + GPR_ASSERT(GRPC_SLICE_IS_EMPTY(orig_decoded)); gpr_free(b64); grpc_slice_unref(orig_decoded); } @@ -174,37 +174,37 @@ static void test_unpadded_decode(void) { grpc_slice decoded; decoded = grpc_base64_decode("Zm9vYmFy", 0); - GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); GPR_ASSERT(grpc_slice_str_cmp(decoded, "foobar") == 0); grpc_slice_unref(decoded); decoded = grpc_base64_decode("Zm9vYmE", 0); - GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); GPR_ASSERT(grpc_slice_str_cmp(decoded, "fooba") == 0); grpc_slice_unref(decoded); decoded = grpc_base64_decode("Zm9vYg", 0); - GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); GPR_ASSERT(grpc_slice_str_cmp(decoded, "foob") == 0); grpc_slice_unref(decoded); decoded = grpc_base64_decode("Zm9v", 0); - GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); GPR_ASSERT(grpc_slice_str_cmp(decoded, "foo") == 0); grpc_slice_unref(decoded); decoded = grpc_base64_decode("Zm8", 0); - GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); GPR_ASSERT(grpc_slice_str_cmp(decoded, "fo") == 0); grpc_slice_unref(decoded); decoded = grpc_base64_decode("Zg", 0); - GPR_ASSERT(!GPR_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(decoded)); GPR_ASSERT(grpc_slice_str_cmp(decoded, "f") == 0); grpc_slice_unref(decoded); decoded = grpc_base64_decode("", 0); - GPR_ASSERT(GPR_SLICE_IS_EMPTY(decoded)); + GPR_ASSERT(GRPC_SLICE_IS_EMPTY(decoded)); } int main(int argc, char **argv) { diff --git a/test/core/security/create_jwt.c b/test/core/security/create_jwt.c index 157e78092d..0303b791ae 100644 --- a/test/core/security/create_jwt.c +++ b/test/core/security/create_jwt.c @@ -50,7 +50,7 @@ void create_jwt(const char *json_key_file_path, const char *service_url, GPR_ASSERT(GRPC_LOG_IF_ERROR( "load_file", grpc_load_file(json_key_file_path, 1, &json_key_data))); key = grpc_auth_json_key_create_from_string( - (const char *)GPR_SLICE_START_PTR(json_key_data)); + (const char *)GRPC_SLICE_START_PTR(json_key_data)); grpc_slice_unref(json_key_data); if (!grpc_auth_json_key_is_valid(&key)) { fprintf(stderr, "Could not parse json key.\n"); diff --git a/test/core/security/fetch_oauth2.c b/test/core/security/fetch_oauth2.c index 95706a5b81..ca093095c3 100644 --- a/test/core/security/fetch_oauth2.c +++ b/test/core/security/fetch_oauth2.c @@ -53,7 +53,7 @@ static grpc_call_credentials *create_refresh_token_creds( "load_file", grpc_load_file(json_refresh_token_file_path, 1, &refresh_token))); return grpc_google_refresh_token_credentials_create( - (const char *)GPR_SLICE_START_PTR(refresh_token), NULL); + (const char *)GRPC_SLICE_START_PTR(refresh_token), NULL); } int main(int argc, char **argv) { diff --git a/test/core/security/json_token_test.c b/test/core/security/json_token_test.c index c5b0ae9425..593b79855f 100644 --- a/test/core/security/json_token_test.c +++ b/test/core/security/json_token_test.c @@ -228,11 +228,11 @@ static grpc_json *parse_json_part_from_jwt(const char *str, size_t len, strncpy(b64, str, len); b64[len] = '\0'; slice = grpc_base64_decode(b64, 1); - GPR_ASSERT(!GPR_SLICE_IS_EMPTY(slice)); - decoded = gpr_malloc(GPR_SLICE_LENGTH(slice) + 1); - strncpy(decoded, (const char *)GPR_SLICE_START_PTR(slice), - GPR_SLICE_LENGTH(slice)); - decoded[GPR_SLICE_LENGTH(slice)] = '\0'; + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(slice)); + decoded = gpr_malloc(GRPC_SLICE_LENGTH(slice) + 1); + strncpy(decoded, (const char *)GRPC_SLICE_START_PTR(slice), + GRPC_SLICE_LENGTH(slice)); + decoded[GRPC_SLICE_LENGTH(slice)] = '\0'; json = grpc_json_parse_string(decoded); gpr_free(b64); *scratchpad = decoded; @@ -342,8 +342,8 @@ static void check_jwt_signature(const char *b64_signature, RSA *rsa_key, EVP_PKEY *key = EVP_PKEY_new(); grpc_slice sig = grpc_base64_decode(b64_signature, 1); - GPR_ASSERT(!GPR_SLICE_IS_EMPTY(sig)); - GPR_ASSERT(GPR_SLICE_LENGTH(sig) == 128); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(sig)); + GPR_ASSERT(GRPC_SLICE_LENGTH(sig) == 128); GPR_ASSERT(md_ctx != NULL); GPR_ASSERT(key != NULL); @@ -352,8 +352,8 @@ static void check_jwt_signature(const char *b64_signature, RSA *rsa_key, GPR_ASSERT(EVP_DigestVerifyInit(md_ctx, NULL, EVP_sha256(), NULL, key) == 1); GPR_ASSERT(EVP_DigestVerifyUpdate(md_ctx, signed_data, signed_data_size) == 1); - GPR_ASSERT(EVP_DigestVerifyFinal(md_ctx, GPR_SLICE_START_PTR(sig), - GPR_SLICE_LENGTH(sig)) == 1); + GPR_ASSERT(EVP_DigestVerifyFinal(md_ctx, GRPC_SLICE_START_PTR(sig), + GRPC_SLICE_LENGTH(sig)) == 1); grpc_slice_unref(sig); if (key != NULL) EVP_PKEY_free(key); diff --git a/test/core/security/jwt_verifier_test.c b/test/core/security/jwt_verifier_test.c index 5c716235cd..01fe436f27 100644 --- a/test/core/security/jwt_verifier_test.c +++ b/test/core/security/jwt_verifier_test.c @@ -183,7 +183,7 @@ static void test_claims_success(void) { grpc_jwt_claims *claims; grpc_slice s = grpc_slice_from_copied_string(claims_without_time_constraint); grpc_json *json = grpc_json_parse_string_with_len( - (char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s)); + (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s)); GPR_ASSERT(json != NULL); claims = grpc_jwt_claims_from_json(json, s); GPR_ASSERT(claims != NULL); @@ -201,7 +201,7 @@ static void test_expired_claims_failure(void) { grpc_jwt_claims *claims; grpc_slice s = grpc_slice_from_copied_string(expired_claims); grpc_json *json = grpc_json_parse_string_with_len( - (char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s)); + (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s)); gpr_timespec exp_iat = {100, 0, GPR_CLOCK_REALTIME}; gpr_timespec exp_exp = {120, 0, GPR_CLOCK_REALTIME}; gpr_timespec exp_nbf = {60, 0, GPR_CLOCK_REALTIME}; @@ -225,7 +225,7 @@ static void test_expired_claims_failure(void) { static void test_invalid_claims_failure(void) { grpc_slice s = grpc_slice_from_copied_string(invalid_claims); grpc_json *json = grpc_json_parse_string_with_len( - (char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s)); + (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s)); GPR_ASSERT(grpc_jwt_claims_from_json(json, s) == NULL); } @@ -233,7 +233,7 @@ static void test_bad_audience_claims_failure(void) { grpc_jwt_claims *claims; grpc_slice s = grpc_slice_from_copied_string(claims_without_time_constraint); grpc_json *json = grpc_json_parse_string_with_len( - (char *)GPR_SLICE_START_PTR(s), GPR_SLICE_LENGTH(s)); + (char *)GRPC_SLICE_START_PTR(s), GRPC_SLICE_LENGTH(s)); GPR_ASSERT(json != NULL); claims = grpc_jwt_claims_from_json(json, s); GPR_ASSERT(claims != NULL); @@ -484,11 +484,11 @@ static void corrupt_jwt_sig(char *jwt) { char *last_dot = strrchr(jwt, '.'); GPR_ASSERT(last_dot != NULL); sig = grpc_base64_decode(last_dot + 1, 1); - GPR_ASSERT(!GPR_SLICE_IS_EMPTY(sig)); - sig_bytes = GPR_SLICE_START_PTR(sig); + GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(sig)); + sig_bytes = GRPC_SLICE_START_PTR(sig); (*sig_bytes)++; /* Corrupt first byte. */ bad_b64_sig = - grpc_base64_encode(GPR_SLICE_START_PTR(sig), GPR_SLICE_LENGTH(sig), 1, 0); + grpc_base64_encode(GRPC_SLICE_START_PTR(sig), GRPC_SLICE_LENGTH(sig), 1, 0); memcpy(last_dot + 1, bad_b64_sig, strlen(bad_b64_sig)); gpr_free(bad_b64_sig); grpc_slice_unref(sig); diff --git a/test/core/security/oauth2_utils.c b/test/core/security/oauth2_utils.c index 92059bf270..22dbf0428d 100644 --- a/test/core/security/oauth2_utils.c +++ b/test/core/security/oauth2_utils.c @@ -63,10 +63,10 @@ static void on_oauth2_response(grpc_exec_ctx *exec_ctx, void *user_data, } else { GPR_ASSERT(num_md == 1); token_slice = md_elems[0].value; - token = gpr_malloc(GPR_SLICE_LENGTH(token_slice) + 1); - memcpy(token, GPR_SLICE_START_PTR(token_slice), - GPR_SLICE_LENGTH(token_slice)); - token[GPR_SLICE_LENGTH(token_slice)] = '\0'; + token = gpr_malloc(GRPC_SLICE_LENGTH(token_slice) + 1); + memcpy(token, GRPC_SLICE_START_PTR(token_slice), + GRPC_SLICE_LENGTH(token_slice)); + token[GRPC_SLICE_LENGTH(token_slice)] = '\0'; } gpr_mu_lock(request->mu); request->is_done = 1; diff --git a/test/core/security/secure_endpoint_test.c b/test/core/security/secure_endpoint_test.c index e12ca48c2f..b5d95004fe 100644 --- a/test/core/security/secure_endpoint_test.c +++ b/test/core/security/secure_endpoint_test.c @@ -77,8 +77,8 @@ static grpc_endpoint_test_fixture secure_endpoint_create_fixture_tcp_socketpair( grpc_slice encrypted_leftover; for (i = 0; i < leftover_nslices; i++) { grpc_slice plain = leftover_slices[i]; - uint8_t *message_bytes = GPR_SLICE_START_PTR(plain); - size_t message_size = GPR_SLICE_LENGTH(plain); + uint8_t *message_bytes = GRPC_SLICE_START_PTR(plain); + size_t message_size = GRPC_SLICE_LENGTH(plain); while (message_size > 0) { size_t protected_buffer_size_to_send = buffer_size; size_t processed_message_size = message_size; diff --git a/test/core/security/security_connector_test.c b/test/core/security/security_connector_test.c index 898aeb6f42..8872cbe278 100644 --- a/test/core/security/security_connector_test.c +++ b/test/core/security/security_connector_test.c @@ -397,7 +397,7 @@ static void test_default_ssl_roots(void) { an empty slice. */ grpc_set_ssl_roots_override_callback(override_roots_permanent_failure); roots = grpc_get_default_ssl_roots_for_testing(); - GPR_ASSERT(GPR_SLICE_IS_EMPTY(roots)); + GPR_ASSERT(GRPC_SLICE_IS_EMPTY(roots)); /* Cleanup. */ remove(roots_env_var_file_path); diff --git a/test/core/slice/slice_test.c b/test/core/slice/slice_test.c index 19c4657cde..e6d29e7459 100644 --- a/test/core/slice/slice_test.c +++ b/test/core/slice/slice_test.c @@ -55,10 +55,10 @@ static void test_slice_malloc_returns_something_sensible(void) { /* If there is a length, slice.data must be non-NULL. If length is zero we don't care. */ if (length) { - GPR_ASSERT(GPR_SLICE_START_PTR(slice)); + GPR_ASSERT(GRPC_SLICE_START_PTR(slice)); } /* Returned slice length must be what was requested. */ - GPR_ASSERT(GPR_SLICE_LENGTH(slice) == length); + GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == length); /* If the slice has a refcount, it must be destroyable. */ if (slice.refcount) { GPR_ASSERT(slice.refcount->ref != NULL); @@ -66,7 +66,7 @@ static void test_slice_malloc_returns_something_sensible(void) { } /* We must be able to write to every byte of the data */ for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; + GRPC_SLICE_START_PTR(slice)[i] = (uint8_t)i; } /* And finally we must succeed in destroying the slice */ grpc_slice_unref(slice); @@ -97,9 +97,9 @@ static void test_slice_new_with_user_data(void) { buf[1] = 1; slice = grpc_slice_new_with_user_data(buf, 2, set_mark, &marker); GPR_ASSERT(marker == 0); - GPR_ASSERT(GPR_SLICE_LENGTH(slice) == 2); - GPR_ASSERT(GPR_SLICE_START_PTR(slice)[0] == 0); - GPR_ASSERT(GPR_SLICE_START_PTR(slice)[1] == 1); + GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == 2); + GPR_ASSERT(GRPC_SLICE_START_PTR(slice)[0] == 0); + GPR_ASSERT(GRPC_SLICE_START_PTR(slice)[1] == 1); /* unref should cause destroy function to run. */ grpc_slice_unref(slice); @@ -152,7 +152,7 @@ static void test_slice_sub_works(unsigned length) { beginning of the slice. */ slice = grpc_slice_malloc(length); for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; + GRPC_SLICE_START_PTR(slice)[i] = (uint8_t)i; } /* Ensure that for all subsets length is correct and that we start on the @@ -160,9 +160,9 @@ static void test_slice_sub_works(unsigned length) { for (i = 0; i < length; i++) { for (j = i; j < length; j++) { sub = grpc_slice_sub(slice, i, j); - GPR_ASSERT(GPR_SLICE_LENGTH(sub) == j - i); + GPR_ASSERT(GRPC_SLICE_LENGTH(sub) == j - i); for (k = 0; k < j - i; k++) { - GPR_ASSERT(GPR_SLICE_START_PTR(sub)[k] == (uint8_t)(i + k)); + GPR_ASSERT(GRPC_SLICE_START_PTR(sub)[k] == (uint8_t)(i + k)); } grpc_slice_unref(sub); } @@ -171,12 +171,12 @@ static void test_slice_sub_works(unsigned length) { } static void check_head_tail(grpc_slice slice, grpc_slice head, grpc_slice tail) { - GPR_ASSERT(GPR_SLICE_LENGTH(slice) == - GPR_SLICE_LENGTH(head) + GPR_SLICE_LENGTH(tail)); - GPR_ASSERT(0 == memcmp(GPR_SLICE_START_PTR(slice), GPR_SLICE_START_PTR(head), - GPR_SLICE_LENGTH(head))); - GPR_ASSERT(0 == memcmp(GPR_SLICE_START_PTR(slice) + GPR_SLICE_LENGTH(head), - GPR_SLICE_START_PTR(tail), GPR_SLICE_LENGTH(tail))); + GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == + GRPC_SLICE_LENGTH(head) + GRPC_SLICE_LENGTH(tail)); + GPR_ASSERT(0 == memcmp(GRPC_SLICE_START_PTR(slice), GRPC_SLICE_START_PTR(head), + GRPC_SLICE_LENGTH(head))); + GPR_ASSERT(0 == memcmp(GRPC_SLICE_START_PTR(slice) + GRPC_SLICE_LENGTH(head), + GRPC_SLICE_START_PTR(tail), GRPC_SLICE_LENGTH(tail))); } static void test_slice_split_head_works(size_t length) { @@ -191,7 +191,7 @@ static void test_slice_split_head_works(size_t length) { beginning of the slice. */ slice = grpc_slice_malloc(length); for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; + GRPC_SLICE_START_PTR(slice)[i] = (uint8_t)i; } /* Ensure that for all subsets length is correct and that we start on the @@ -219,7 +219,7 @@ static void test_slice_split_tail_works(size_t length) { beginning of the slice. */ slice = grpc_slice_malloc(length); for (i = 0; i < length; i++) { - GPR_SLICE_START_PTR(slice)[i] = (uint8_t)i; + GRPC_SLICE_START_PTR(slice)[i] = (uint8_t)i; } /* Ensure that for all subsets length is correct and that we start on the @@ -242,9 +242,9 @@ static void test_slice_from_copied_string_works(void) { LOG_TEST_NAME("test_slice_from_copied_string_works"); slice = grpc_slice_from_copied_string(text); - GPR_ASSERT(strlen(text) == GPR_SLICE_LENGTH(slice)); + GPR_ASSERT(strlen(text) == GRPC_SLICE_LENGTH(slice)); GPR_ASSERT(0 == - memcmp(text, GPR_SLICE_START_PTR(slice), GPR_SLICE_LENGTH(slice))); + memcmp(text, GRPC_SLICE_START_PTR(slice), GRPC_SLICE_LENGTH(slice))); grpc_slice_unref(slice); } diff --git a/test/core/surface/byte_buffer_reader_test.c b/test/core/surface/byte_buffer_reader_test.c index fe70f22c2b..d8d7a52d15 100644 --- a/test/core/surface/byte_buffer_reader_test.c +++ b/test/core/surface/byte_buffer_reader_test.c @@ -63,7 +63,7 @@ static void test_read_one_slice(void) { "Couldn't init byte buffer reader"); first_code = grpc_byte_buffer_reader_next(&reader, &first_slice); GPR_ASSERT(first_code != 0); - GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(first_slice), "test", 4) == 0); + GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(first_slice), "test", 4) == 0); grpc_slice_unref(first_slice); second_code = grpc_byte_buffer_reader_next(&reader, &second_slice); GPR_ASSERT(second_code == 0); @@ -79,14 +79,14 @@ static void test_read_one_slice_malloc(void) { LOG_TEST("test_read_one_slice_malloc"); slice = grpc_slice_malloc(4); - memcpy(GPR_SLICE_START_PTR(slice), "test", 4); + memcpy(GRPC_SLICE_START_PTR(slice), "test", 4); buffer = grpc_raw_byte_buffer_create(&slice, 1); grpc_slice_unref(slice); GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, buffer) && "Couldn't init byte buffer reader"); first_code = grpc_byte_buffer_reader_next(&reader, &first_slice); GPR_ASSERT(first_code != 0); - GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(first_slice), "test", 4) == 0); + GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(first_slice), "test", 4) == 0); grpc_slice_unref(first_slice); second_code = grpc_byte_buffer_reader_next(&reader, &second_slice); GPR_ASSERT(second_code == 0); @@ -108,7 +108,7 @@ static void test_read_none_compressed_slice(void) { "Couldn't init byte buffer reader"); first_code = grpc_byte_buffer_reader_next(&reader, &first_slice); GPR_ASSERT(first_code != 0); - GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(first_slice), "test", 4) == 0); + GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(first_slice), "test", 4) == 0); grpc_slice_unref(first_slice); second_code = grpc_byte_buffer_reader_next(&reader, &second_slice); GPR_ASSERT(second_code == 0); @@ -143,7 +143,7 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm, grpc_slice_buffer_init(&sliceb_out); input_slice = grpc_slice_malloc(input_size); - memset(GPR_SLICE_START_PTR(input_slice), 'a', input_size); + memset(GRPC_SLICE_START_PTR(input_slice), 'a', input_size); grpc_slice_buffer_add(&sliceb_in, input_slice); /* takes ownership */ GPR_ASSERT(grpc_msg_compress(algorithm, &sliceb_in, &sliceb_out)); @@ -153,10 +153,10 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm, "Couldn't init byte buffer reader"); while (grpc_byte_buffer_reader_next(&reader, &read_slice)) { - GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(read_slice), - GPR_SLICE_START_PTR(input_slice) + read_count, - GPR_SLICE_LENGTH(read_slice)) == 0); - read_count += GPR_SLICE_LENGTH(read_slice); + GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(read_slice), + GRPC_SLICE_START_PTR(input_slice) + read_count, + GRPC_SLICE_LENGTH(read_slice)) == 0); + read_count += GRPC_SLICE_LENGTH(read_slice); grpc_slice_unref(read_slice); } GPR_ASSERT(read_count == input_size); @@ -185,7 +185,7 @@ static void test_byte_buffer_from_reader(void) { LOG_TEST("test_byte_buffer_from_reader"); slice = grpc_slice_malloc(4); - memcpy(GPR_SLICE_START_PTR(slice), "test", 4); + memcpy(GRPC_SLICE_START_PTR(slice), "test", 4); buffer = grpc_raw_byte_buffer_create(&slice, 1); grpc_slice_unref(slice); GPR_ASSERT(grpc_byte_buffer_reader_init(&reader, buffer) && @@ -195,7 +195,7 @@ static void test_byte_buffer_from_reader(void) { GPR_ASSERT(buffer->type == buffer_from_reader->type); GPR_ASSERT(buffer_from_reader->data.raw.compression == GRPC_COMPRESS_NONE); GPR_ASSERT(buffer_from_reader->data.raw.slice_buffer.count == 1); - GPR_ASSERT(memcmp(GPR_SLICE_START_PTR( + GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR( buffer_from_reader->data.raw.slice_buffer.slices[0]), "test", 4) == 0); @@ -217,9 +217,9 @@ static void test_readall(void) { memset(lotsa_bs, 'b', 1024); /* use slices large enough to overflow inlining */ slices[0] = grpc_slice_malloc(512); - memcpy(GPR_SLICE_START_PTR(slices[0]), lotsa_as, 512); + memcpy(GRPC_SLICE_START_PTR(slices[0]), lotsa_as, 512); slices[1] = grpc_slice_malloc(1024); - memcpy(GPR_SLICE_START_PTR(slices[1]), lotsa_bs, 1024); + memcpy(GRPC_SLICE_START_PTR(slices[1]), lotsa_bs, 1024); buffer = grpc_raw_byte_buffer_create(slices, 2); grpc_slice_unref(slices[0]); @@ -229,9 +229,9 @@ static void test_readall(void) { "Couldn't init byte buffer reader"); slice_out = grpc_byte_buffer_reader_readall(&reader); - GPR_ASSERT(GPR_SLICE_LENGTH(slice_out) == 512 + 1024); - GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(slice_out), lotsa_as, 512) == 0); - GPR_ASSERT(memcmp(&(GPR_SLICE_START_PTR(slice_out)[512]), lotsa_bs, 1024) == + GPR_ASSERT(GRPC_SLICE_LENGTH(slice_out) == 512 + 1024); + GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(slice_out), lotsa_as, 512) == 0); + GPR_ASSERT(memcmp(&(GRPC_SLICE_START_PTR(slice_out)[512]), lotsa_bs, 1024) == 0); grpc_slice_unref(slice_out); grpc_byte_buffer_destroy(buffer); @@ -252,9 +252,9 @@ static void test_byte_buffer_copy(void) { memset(lotsa_bs, 'b', 1024); /* use slices large enough to overflow inlining */ slices[0] = grpc_slice_malloc(512); - memcpy(GPR_SLICE_START_PTR(slices[0]), lotsa_as, 512); + memcpy(GRPC_SLICE_START_PTR(slices[0]), lotsa_as, 512); slices[1] = grpc_slice_malloc(1024); - memcpy(GPR_SLICE_START_PTR(slices[1]), lotsa_bs, 1024); + memcpy(GRPC_SLICE_START_PTR(slices[1]), lotsa_bs, 1024); buffer = grpc_raw_byte_buffer_create(slices, 2); grpc_slice_unref(slices[0]); @@ -265,9 +265,9 @@ static void test_byte_buffer_copy(void) { "Couldn't init byte buffer reader"); slice_out = grpc_byte_buffer_reader_readall(&reader); - GPR_ASSERT(GPR_SLICE_LENGTH(slice_out) == 512 + 1024); - GPR_ASSERT(memcmp(GPR_SLICE_START_PTR(slice_out), lotsa_as, 512) == 0); - GPR_ASSERT(memcmp(&(GPR_SLICE_START_PTR(slice_out)[512]), lotsa_bs, 1024) == + GPR_ASSERT(GRPC_SLICE_LENGTH(slice_out) == 512 + 1024); + GPR_ASSERT(memcmp(GRPC_SLICE_START_PTR(slice_out), lotsa_as, 512) == 0); + GPR_ASSERT(memcmp(&(GRPC_SLICE_START_PTR(slice_out)[512]), lotsa_bs, 1024) == 0); grpc_slice_unref(slice_out); grpc_byte_buffer_destroy(buffer); diff --git a/test/core/transport/chttp2/hpack_parser_test.c b/test/core/transport/chttp2/hpack_parser_test.c index a051dc8cf3..c7e8f3a050 100644 --- a/test/core/transport/chttp2/hpack_parser_test.c +++ b/test/core/transport/chttp2/hpack_parser_test.c @@ -77,8 +77,8 @@ static void test_vector(grpc_chttp2_hpack_parser *parser, for (i = 0; i < nslices; i++) { grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; GPR_ASSERT(grpc_chttp2_hpack_parser_parse( - &exec_ctx, parser, GPR_SLICE_START_PTR(slices[i]), - GPR_SLICE_END_PTR(slices[i])) == GRPC_ERROR_NONE); + &exec_ctx, parser, GRPC_SLICE_START_PTR(slices[i]), + GRPC_SLICE_END_PTR(slices[i])) == GRPC_ERROR_NONE); grpc_exec_ctx_finish(&exec_ctx); } diff --git a/test/core/transport/chttp2/varint_test.c b/test/core/transport/chttp2/varint_test.c index 0d9460afc1..5b831c71b2 100644 --- a/test/core/transport/chttp2/varint_test.c +++ b/test/core/transport/chttp2/varint_test.c @@ -47,7 +47,7 @@ static void test_varint(uint32_t value, uint32_t prefix_bits, uint8_t prefix_or, GPR_ASSERT(nbytes == expect_length); slice = grpc_slice_malloc(nbytes); GRPC_CHTTP2_WRITE_VARINT(value, prefix_bits, prefix_or, - GPR_SLICE_START_PTR(slice), nbytes); + GRPC_SLICE_START_PTR(slice), nbytes); GPR_ASSERT(grpc_slice_cmp(expect, slice) == 0); grpc_slice_unref(expect); grpc_slice_unref(slice); diff --git a/test/core/transport/metadata_test.c b/test/core/transport/metadata_test.c index e47777ee72..5c89d8530a 100644 --- a/test/core/transport/metadata_test.c +++ b/test/core/transport/metadata_test.c @@ -279,7 +279,7 @@ static void verify_binary_header_size(const char *key, const uint8_t *value, grpc_slice value_slice = grpc_slice_from_copied_buffer((const char *)value, value_len); grpc_slice base64_encoded = grpc_chttp2_base64_encode(value_slice); - size_t expected_size = 32 + strlen(key) + GPR_SLICE_LENGTH(base64_encoded); + size_t expected_size = 32 + strlen(key) + GRPC_SLICE_LENGTH(base64_encoded); GPR_ASSERT(expected_size == elem_size); grpc_slice_unref(value_slice); grpc_slice_unref(base64_encoded); diff --git a/test/core/util/one_corpus_entry_fuzzer.c b/test/core/util/one_corpus_entry_fuzzer.c index a07e83b775..6b572bb3c3 100644 --- a/test/core/util/one_corpus_entry_fuzzer.c +++ b/test/core/util/one_corpus_entry_fuzzer.c @@ -47,7 +47,7 @@ int main(int argc, char **argv) { leak_check = false; GPR_ASSERT( GRPC_LOG_IF_ERROR("load_file", grpc_load_file(argv[1], 0, &buffer))); - LLVMFuzzerTestOneInput(GPR_SLICE_START_PTR(buffer), GPR_SLICE_LENGTH(buffer)); + LLVMFuzzerTestOneInput(GRPC_SLICE_START_PTR(buffer), GRPC_SLICE_LENGTH(buffer)); grpc_slice_unref(buffer); return 0; } diff --git a/test/core/util/parse_hexstring.c b/test/core/util/parse_hexstring.c index 91149a691a..60ab1bb0c4 100644 --- a/test/core/util/parse_hexstring.c +++ b/test/core/util/parse_hexstring.c @@ -48,7 +48,7 @@ grpc_slice parse_hexstring(const char *hexstring) { GPR_ASSERT((nibbles & 1) == 0); slice = grpc_slice_malloc(nibbles / 2); - out = GPR_SLICE_START_PTR(slice); + out = GRPC_SLICE_START_PTR(slice); nibbles = 0; temp = 0; diff --git a/test/core/util/slice_splitter.c b/test/core/util/slice_splitter.c index 6647b8fbb3..177c9892a5 100644 --- a/test/core/util/slice_splitter.c +++ b/test/core/util/slice_splitter.c @@ -69,28 +69,28 @@ void grpc_split_slices(grpc_slice_split_mode mode, grpc_slice *src_slices, *dst_slice_count = 1; length = 0; for (i = 0; i < src_slice_count; i++) { - length += GPR_SLICE_LENGTH(src_slices[i]); + length += GRPC_SLICE_LENGTH(src_slices[i]); } *dst_slices = gpr_malloc(sizeof(grpc_slice)); **dst_slices = grpc_slice_malloc(length); length = 0; for (i = 0; i < src_slice_count; i++) { - memcpy(GPR_SLICE_START_PTR(**dst_slices) + length, - GPR_SLICE_START_PTR(src_slices[i]), - GPR_SLICE_LENGTH(src_slices[i])); - length += GPR_SLICE_LENGTH(src_slices[i]); + memcpy(GRPC_SLICE_START_PTR(**dst_slices) + length, + GRPC_SLICE_START_PTR(src_slices[i]), + GRPC_SLICE_LENGTH(src_slices[i])); + length += GRPC_SLICE_LENGTH(src_slices[i]); } break; case GRPC_SLICE_SPLIT_ONE_BYTE: length = 0; for (i = 0; i < src_slice_count; i++) { - length += GPR_SLICE_LENGTH(src_slices[i]); + length += GRPC_SLICE_LENGTH(src_slices[i]); } *dst_slice_count = length; *dst_slices = gpr_malloc(sizeof(grpc_slice) * length); length = 0; for (i = 0; i < src_slice_count; i++) { - for (j = 0; j < GPR_SLICE_LENGTH(src_slices[i]); j++) { + for (j = 0; j < GRPC_SLICE_LENGTH(src_slices[i]); j++) { (*dst_slices)[length] = grpc_slice_sub(src_slices[i], j, j + 1); length++; } @@ -125,13 +125,13 @@ grpc_slice grpc_slice_merge(grpc_slice *slices, size_t nslices) { size_t i; for (i = 0; i < nslices; i++) { - if (GPR_SLICE_LENGTH(slices[i]) + length > capacity) { - capacity = GPR_MAX(capacity * 2, GPR_SLICE_LENGTH(slices[i]) + length); + if (GRPC_SLICE_LENGTH(slices[i]) + length > capacity) { + capacity = GPR_MAX(capacity * 2, GRPC_SLICE_LENGTH(slices[i]) + length); out = gpr_realloc(out, capacity); } - memcpy(out + length, GPR_SLICE_START_PTR(slices[i]), - GPR_SLICE_LENGTH(slices[i])); - length += GPR_SLICE_LENGTH(slices[i]); + memcpy(out + length, GRPC_SLICE_START_PTR(slices[i]), + GRPC_SLICE_LENGTH(slices[i])); + length += GRPC_SLICE_LENGTH(slices[i]); } return grpc_slice_new(out, length, gpr_free); diff --git a/test/cpp/grpclb/grpclb_api_test.cc b/test/cpp/grpclb/grpclb_api_test.cc index fed5a2cce1..191d729a9e 100644 --- a/test/cpp/grpclb/grpclb_api_test.cc +++ b/test/cpp/grpclb/grpclb_api_test.cc @@ -72,9 +72,9 @@ TEST_F(GrpclbTest, CreateRequest) { LoadBalanceRequest request; grpc_grpclb_request* c_req = grpc_grpclb_request_create(service_name.c_str()); grpc_slice slice = grpc_grpclb_request_encode(c_req); - const int num_bytes_written = GPR_SLICE_LENGTH(slice); + const int num_bytes_written = GRPC_SLICE_LENGTH(slice); EXPECT_GT(num_bytes_written, 0); - request.ParseFromArray(GPR_SLICE_START_PTR(slice), num_bytes_written); + request.ParseFromArray(GRPC_SLICE_START_PTR(slice), num_bytes_written); EXPECT_EQ(request.initial_request().name(), service_name); grpc_slice_unref(slice); grpc_grpclb_request_destroy(c_req); diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc index a65e425625..a56667585f 100644 --- a/test/cpp/grpclb/grpclb_test.cc +++ b/test/cpp/grpclb/grpclb_test.cc @@ -212,8 +212,8 @@ static void start_lb_server(server_fixture *sf, int *ports, size_t nports, grpc_byte_buffer_reader_init(&bbr, request_payload_recv); grpc_slice request_payload_slice = grpc_byte_buffer_reader_readall(&bbr); grpc::lb::v1::LoadBalanceRequest request; - request.ParseFromArray(GPR_SLICE_START_PTR(request_payload_slice), - GPR_SLICE_LENGTH(request_payload_slice)); + request.ParseFromArray(GRPC_SLICE_START_PTR(request_payload_slice), + GRPC_SLICE_LENGTH(request_payload_slice)); GPR_ASSERT(request.has_initial_request()); GPR_ASSERT(request.initial_request().name() == sf->servers_hostport); grpc_slice_unref(request_payload_slice); diff --git a/test/cpp/util/byte_buffer_test.cc b/test/cpp/util/byte_buffer_test.cc index 2630c76e87..470ce0cbf4 100644 --- a/test/cpp/util/byte_buffer_test.cc +++ b/test/cpp/util/byte_buffer_test.cc @@ -81,11 +81,11 @@ TEST_F(ByteBufferTest, Length) { } bool SliceEqual(const Slice& a, grpc_slice b) { - if (a.size() != GPR_SLICE_LENGTH(b)) { + if (a.size() != GRPC_SLICE_LENGTH(b)) { return false; } for (size_t i = 0; i < a.size(); i++) { - if (a.begin()[i] != GPR_SLICE_START_PTR(b)[i]) { + if (a.begin()[i] != GRPC_SLICE_START_PTR(b)[i]) { return false; } } diff --git a/test/cpp/util/slice_test.cc b/test/cpp/util/slice_test.cc index df8179586a..8926fb7d5a 100644 --- a/test/cpp/util/slice_test.cc +++ b/test/cpp/util/slice_test.cc @@ -73,8 +73,8 @@ TEST_F(SliceTest, Cslice) { Slice spp(s, Slice::STEAL_REF); CheckSlice(spp, kContent); grpc_slice c_slice = spp.c_slice(); - EXPECT_EQ(GPR_SLICE_START_PTR(s), GPR_SLICE_START_PTR(c_slice)); - EXPECT_EQ(GPR_SLICE_END_PTR(s), GPR_SLICE_END_PTR(c_slice)); + EXPECT_EQ(GRPC_SLICE_START_PTR(s), GRPC_SLICE_START_PTR(c_slice)); + EXPECT_EQ(GRPC_SLICE_END_PTR(s), GRPC_SLICE_END_PTR(c_slice)); grpc_slice_unref(c_slice); } -- cgit v1.2.3 From 28b72428a84ae7d23c106fb282478fa94951c9c0 Mon Sep 17 00:00:00 2001 From: Craig Tiller Date: Wed, 26 Oct 2016 21:15:29 -0700 Subject: clang-format --- include/grpc++/impl/codegen/core_codegen.h | 2 +- .../grpc++/impl/codegen/core_codegen_interface.h | 3 +- include/grpc/slice_buffer.h | 10 ++--- src/core/ext/census/grpc_filter.c | 2 +- .../ext/client_channel/http_connect_handshaker.c | 8 ++-- .../ext/transport/chttp2/transport/bin_decoder.h | 2 +- .../ext/transport/chttp2/transport/bin_encoder.c | 9 ++-- .../ext/transport/chttp2/transport/bin_encoder.h | 3 +- src/core/ext/transport/chttp2/transport/frame.h | 2 +- .../ext/transport/chttp2/transport/frame_goaway.h | 2 +- .../ext/transport/chttp2/transport/frame_ping.c | 2 +- .../transport/chttp2/transport/frame_rst_stream.c | 2 +- .../transport/chttp2/transport/frame_rst_stream.h | 2 +- .../transport/chttp2/transport/frame_settings.c | 2 +- .../transport/chttp2/transport/frame_settings.h | 4 +- .../chttp2/transport/frame_window_update.h | 4 +- .../ext/transport/chttp2/transport/hpack_encoder.c | 5 ++- .../ext/transport/chttp2/transport/hpack_encoder.h | 2 +- .../ext/transport/chttp2/transport/hpack_parser.c | 6 +-- .../ext/transport/chttp2/transport/hpack_table.h | 2 +- src/core/ext/transport/chttp2/transport/internal.h | 3 +- src/core/ext/transport/chttp2/transport/parsing.c | 18 ++++---- src/core/ext/transport/chttp2/transport/writing.c | 10 ++--- .../transport/cronet/transport/cronet_transport.c | 4 +- src/core/lib/channel/compress_filter.c | 2 +- src/core/lib/channel/connected_channel.c | 2 +- src/core/lib/channel/handshaker.c | 4 +- src/core/lib/channel/http_server_filter.c | 2 +- src/core/lib/http/format_request.c | 9 ++-- src/core/lib/http/format_request.h | 4 +- src/core/lib/http/parser.h | 2 +- src/core/lib/iomgr/resource_quota.c | 2 +- src/core/lib/iomgr/tcp_client_windows.c | 2 +- src/core/lib/iomgr/tcp_windows.c | 2 +- src/core/lib/security/transport/handshake.c | 2 +- .../lib/security/transport/security_connector.c | 2 +- src/core/lib/security/util/b64.c | 2 +- src/core/lib/security/util/b64.h | 2 +- src/core/lib/slice/slice.c | 10 ++--- src/core/lib/slice/slice_buffer.c | 12 +++--- src/core/lib/surface/byte_buffer.c | 3 +- src/core/lib/surface/byte_buffer_reader.c | 2 +- src/core/lib/transport/metadata_batch.h | 2 +- src/cpp/client/channel_cc.cc | 2 +- src/cpp/common/core_codegen.cc | 11 +++-- test/core/compression/message_compress_test.c | 14 +++---- test/core/end2end/cq_verifier.c | 3 +- test/core/end2end/invalid_call_argument_test.c | 3 +- test/core/end2end/tests/binary_metadata.c | 6 ++- test/core/end2end/tests/call_creds.c | 9 ++-- test/core/end2end/tests/cancel_after_accept.c | 6 ++- test/core/end2end/tests/cancel_after_client_done.c | 6 ++- test/core/end2end/tests/cancel_after_invoke.c | 3 +- test/core/end2end/tests/cancel_before_invoke.c | 3 +- test/core/end2end/tests/compressed_payload.c | 3 +- test/core/end2end/tests/filter_call_init_fails.c | 3 +- test/core/end2end/tests/filter_causes_close.c | 3 +- test/core/end2end/tests/large_metadata.c | 3 +- test/core/end2end/tests/load_reporting_hook.c | 3 +- test/core/end2end/tests/max_message_length.c | 3 +- test/core/end2end/tests/network_status_change.c | 3 +- test/core/end2end/tests/payload.c | 3 +- test/core/end2end/tests/ping_pong_streaming.c | 6 ++- test/core/end2end/tests/request_with_flags.c | 3 +- test/core/end2end/tests/request_with_payload.c | 3 +- test/core/end2end/tests/resource_quota_server.c | 3 +- test/core/end2end/tests/simple_cacheable_request.c | 6 ++- test/core/end2end/tests/simple_metadata.c | 6 ++- test/core/end2end/tests/trailing_metadata.c | 6 ++- test/core/http/format_request_test.c | 48 +++++++++++----------- test/core/iomgr/endpoint_tests.c | 6 +-- test/core/iomgr/load_file_test.c | 2 +- test/core/iomgr/tcp_posix_test.c | 4 +- test/core/security/b64_test.c | 2 +- test/core/security/create_jwt.c | 2 +- test/core/security/credentials_test.c | 7 ++-- test/core/security/fetch_oauth2.c | 2 +- test/core/security/json_token_test.c | 2 +- test/core/security/jwt_verifier_test.c | 6 +-- test/core/security/oauth2_utils.c | 2 +- .../security/print_google_default_creds_token.c | 2 +- test/core/security/verify_jwt.c | 2 +- test/core/slice/slice_buffer_test.c | 2 +- test/core/slice/slice_test.c | 11 ++--- test/core/transport/chttp2/hpack_parser_test.c | 2 +- test/core/transport/chttp2/varint_test.c | 5 ++- test/core/util/mock_endpoint.h | 3 +- test/core/util/one_corpus_entry_fuzzer.c | 3 +- test/cpp/grpclb/grpclb_test.cc | 3 +- test/cpp/util/cli_call.cc | 2 +- 90 files changed, 235 insertions(+), 183 deletions(-) (limited to 'test/core/end2end/tests') diff --git a/include/grpc++/impl/codegen/core_codegen.h b/include/grpc++/impl/codegen/core_codegen.h index c2127a771a..6ab0e17db9 100644 --- a/include/grpc++/impl/codegen/core_codegen.h +++ b/include/grpc++/impl/codegen/core_codegen.h @@ -82,7 +82,7 @@ class CoreCodegen : public CoreCodegenInterface { void grpc_slice_unref(grpc_slice slice) GRPC_OVERRIDE; grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split) GRPC_OVERRIDE; void grpc_slice_buffer_add(grpc_slice_buffer* sb, - grpc_slice slice) GRPC_OVERRIDE; + grpc_slice slice) GRPC_OVERRIDE; void grpc_slice_buffer_pop(grpc_slice_buffer* sb) GRPC_OVERRIDE; void grpc_metadata_array_init(grpc_metadata_array* array) GRPC_OVERRIDE; diff --git a/include/grpc++/impl/codegen/core_codegen_interface.h b/include/grpc++/impl/codegen/core_codegen_interface.h index 743f528373..4783a43454 100644 --- a/include/grpc++/impl/codegen/core_codegen_interface.h +++ b/include/grpc++/impl/codegen/core_codegen_interface.h @@ -96,7 +96,8 @@ class CoreCodegenInterface { virtual grpc_slice grpc_slice_malloc(size_t length) = 0; virtual void grpc_slice_unref(grpc_slice slice) = 0; virtual grpc_slice grpc_slice_split_tail(grpc_slice* s, size_t split) = 0; - virtual void grpc_slice_buffer_add(grpc_slice_buffer* sb, grpc_slice slice) = 0; + virtual void grpc_slice_buffer_add(grpc_slice_buffer* sb, + grpc_slice slice) = 0; virtual void grpc_slice_buffer_pop(grpc_slice_buffer* sb) = 0; virtual void grpc_metadata_array_init(grpc_metadata_array* array) = 0; diff --git a/include/grpc/slice_buffer.h b/include/grpc/slice_buffer.h index 44876f5a30..f1de653af4 100644 --- a/include/grpc/slice_buffer.h +++ b/include/grpc/slice_buffer.h @@ -56,9 +56,9 @@ GPRAPI void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice slice); The implementation MAY decide to concatenate data at the end of a small slice added in this fashion. */ GPRAPI size_t grpc_slice_buffer_add_indexed(grpc_slice_buffer *sb, - grpc_slice slice); + grpc_slice slice); GPRAPI void grpc_slice_buffer_addn(grpc_slice_buffer *sb, grpc_slice *slices, - size_t n); + size_t n); /* add a very small (less than 8 bytes) amount of data to the end of a slice buffer: returns a pointer into which to add the data */ GPRAPI uint8_t *grpc_slice_buffer_tiny_add(grpc_slice_buffer *sb, size_t len); @@ -70,13 +70,13 @@ GPRAPI void grpc_slice_buffer_reset_and_unref(grpc_slice_buffer *sb); GPRAPI void grpc_slice_buffer_swap(grpc_slice_buffer *a, grpc_slice_buffer *b); /* move all of the elements of src into dst */ GPRAPI void grpc_slice_buffer_move_into(grpc_slice_buffer *src, - grpc_slice_buffer *dst); + grpc_slice_buffer *dst); /* remove n bytes from the end of a slice buffer */ GPRAPI void grpc_slice_buffer_trim_end(grpc_slice_buffer *src, size_t n, - grpc_slice_buffer *garbage); + grpc_slice_buffer *garbage); /* move the first n bytes of src into dst */ GPRAPI void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n, - grpc_slice_buffer *dst); + grpc_slice_buffer *dst); /* take the first slice in the slice buffer */ GPRAPI grpc_slice grpc_slice_buffer_take_first(grpc_slice_buffer *src); diff --git a/src/core/ext/census/grpc_filter.c b/src/core/ext/census/grpc_filter.c index aa6d24e076..5a283de468 100644 --- a/src/core/ext/census/grpc_filter.c +++ b/src/core/ext/census/grpc_filter.c @@ -37,9 +37,9 @@ #include #include +#include #include #include -#include #include #include "src/core/ext/census/census_interface.h" diff --git a/src/core/ext/client_channel/http_connect_handshaker.c b/src/core/ext/client_channel/http_connect_handshaker.c index 6f1956add9..82042897b2 100644 --- a/src/core/ext/client_channel/http_connect_handshaker.c +++ b/src/core/ext/client_channel/http_connect_handshaker.c @@ -35,9 +35,9 @@ #include +#include #include #include -#include #include #include "src/core/ext/client_channel/uri_parser.h" @@ -136,11 +136,11 @@ static void on_read_done(grpc_exec_ctx* exec_ctx, void* arg, grpc_slice_buffer_add( &tmp_buffer, grpc_slice_split_tail(&handshaker->read_buffer->slices[i], - body_start_offset)); + body_start_offset)); } grpc_slice_buffer_addn(&tmp_buffer, - &handshaker->read_buffer->slices[i + 1], - handshaker->read_buffer->count - i - 1); + &handshaker->read_buffer->slices[i + 1], + handshaker->read_buffer->count - i - 1); grpc_slice_buffer_swap(handshaker->read_buffer, &tmp_buffer); grpc_slice_buffer_destroy(&tmp_buffer); break; diff --git a/src/core/ext/transport/chttp2/transport/bin_decoder.h b/src/core/ext/transport/chttp2/transport/bin_decoder.h index 5e00fd8143..83a90be519 100644 --- a/src/core/ext/transport/chttp2/transport/bin_decoder.h +++ b/src/core/ext/transport/chttp2/transport/bin_decoder.h @@ -61,6 +61,6 @@ grpc_slice grpc_chttp2_base64_decode(grpc_slice input); slice, does not take ownership of the input. Returns an empty slice if decoding is failed. */ grpc_slice grpc_chttp2_base64_decode_with_length(grpc_slice input, - size_t output_length); + size_t output_length); #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_DECODER_H */ diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.c b/src/core/ext/transport/chttp2/transport/bin_encoder.c index 2baa1dc97b..af25a4352a 100644 --- a/src/core/ext/transport/chttp2/transport/bin_encoder.c +++ b/src/core/ext/transport/chttp2/transport/bin_encoder.c @@ -114,13 +114,15 @@ grpc_slice grpc_chttp2_huffman_compress(grpc_slice input) { uint32_t temp_length = 0; nbits = 0; - for (in = GRPC_SLICE_START_PTR(input); in != GRPC_SLICE_END_PTR(input); ++in) { + for (in = GRPC_SLICE_START_PTR(input); in != GRPC_SLICE_END_PTR(input); + ++in) { nbits += grpc_chttp2_huffsyms[*in].length; } output = grpc_slice_malloc(nbits / 8 + (nbits % 8 != 0)); out = GRPC_SLICE_START_PTR(output); - for (in = GRPC_SLICE_START_PTR(input); in != GRPC_SLICE_END_PTR(input); ++in) { + for (in = GRPC_SLICE_START_PTR(input); in != GRPC_SLICE_END_PTR(input); + ++in) { int sym = *in; temp <<= grpc_chttp2_huffsyms[sym].length; temp |= grpc_chttp2_huffsyms[sym].bits; @@ -175,7 +177,8 @@ static void enc_add1(huff_out *out, uint8_t a) { enc_flush_some(out); } -grpc_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(grpc_slice input) { +grpc_slice grpc_chttp2_base64_encode_and_huffman_compress_impl( + grpc_slice input) { size_t input_length = GRPC_SLICE_LENGTH(input); size_t input_triplets = input_length / 3; size_t tail_case = input_length % 3; diff --git a/src/core/ext/transport/chttp2/transport/bin_encoder.h b/src/core/ext/transport/chttp2/transport/bin_encoder.h index 3d86a41a11..9e143b46e2 100644 --- a/src/core/ext/transport/chttp2/transport/bin_encoder.h +++ b/src/core/ext/transport/chttp2/transport/bin_encoder.h @@ -49,6 +49,7 @@ grpc_slice grpc_chttp2_huffman_compress(grpc_slice input); grpc_slice y = grpc_chttp2_huffman_compress(x); grpc_slice_unref(x); return y; */ -grpc_slice grpc_chttp2_base64_encode_and_huffman_compress_impl(grpc_slice input); +grpc_slice grpc_chttp2_base64_encode_and_huffman_compress_impl( + grpc_slice input); #endif /* GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_BIN_ENCODER_H */ diff --git a/src/core/ext/transport/chttp2/transport/frame.h b/src/core/ext/transport/chttp2/transport/frame.h index 0b3842b4a1..ffd4d9669b 100644 --- a/src/core/ext/transport/chttp2/transport/frame.h +++ b/src/core/ext/transport/chttp2/transport/frame.h @@ -34,8 +34,8 @@ #ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H #define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_H -#include #include +#include #include "src/core/lib/iomgr/error.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_goaway.h b/src/core/ext/transport/chttp2/transport/frame_goaway.h index 927b7fbd48..21fe819488 100644 --- a/src/core/ext/transport/chttp2/transport/frame_goaway.h +++ b/src/core/ext/transport/chttp2/transport/frame_goaway.h @@ -34,9 +34,9 @@ #ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H #define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_GOAWAY_H -#include #include #include +#include #include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/lib/iomgr/exec_ctx.h" diff --git a/src/core/ext/transport/chttp2/transport/frame_ping.c b/src/core/ext/transport/chttp2/transport/frame_ping.c index 18ecb4d1e9..7de5f6362d 100644 --- a/src/core/ext/transport/chttp2/transport/frame_ping.c +++ b/src/core/ext/transport/chttp2/transport/frame_ping.c @@ -94,7 +94,7 @@ grpc_error *grpc_chttp2_ping_parser_parse(grpc_exec_ctx *exec_ctx, void *parser, grpc_chttp2_ack_ping(exec_ctx, t, p->opaque_8bytes); } else { grpc_slice_buffer_add(&t->qbuf, - grpc_chttp2_ping_create(1, p->opaque_8bytes)); + grpc_chttp2_ping_create(1, p->opaque_8bytes)); grpc_chttp2_initiate_write(exec_ctx, t, false, "ping response"); } } diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.c b/src/core/ext/transport/chttp2/transport/frame_rst_stream.c index 75e4101035..b4c5ed769b 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.c +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.c @@ -43,7 +43,7 @@ #include "src/core/ext/transport/chttp2/transport/status_conversion.h" grpc_slice grpc_chttp2_rst_stream_create(uint32_t id, uint32_t code, - grpc_transport_one_way_stats *stats) { + grpc_transport_one_way_stats *stats) { static const size_t frame_size = 13; grpc_slice slice = grpc_slice_malloc(frame_size); stats->framing_bytes += frame_size; diff --git a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h index f39002a3e9..779507a617 100644 --- a/src/core/ext/transport/chttp2/transport/frame_rst_stream.h +++ b/src/core/ext/transport/chttp2/transport/frame_rst_stream.h @@ -45,7 +45,7 @@ typedef struct { } grpc_chttp2_rst_stream_parser; grpc_slice grpc_chttp2_rst_stream_create(uint32_t stream_id, uint32_t code, - grpc_transport_one_way_stats *stats); + grpc_transport_one_way_stats *stats); grpc_error *grpc_chttp2_rst_stream_parser_begin_frame( grpc_chttp2_rst_stream_parser *parser, uint32_t length, uint8_t flags); diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.c b/src/core/ext/transport/chttp2/transport/frame_settings.c index d3b235183b..98facae87f 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.c +++ b/src/core/ext/transport/chttp2/transport/frame_settings.c @@ -83,7 +83,7 @@ static uint8_t *fill_header(uint8_t *out, uint32_t length, uint8_t flags) { } grpc_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new, - uint32_t force_mask, size_t count) { + uint32_t force_mask, size_t count) { size_t i; uint32_t n = 0; grpc_slice output; diff --git a/src/core/ext/transport/chttp2/transport/frame_settings.h b/src/core/ext/transport/chttp2/transport/frame_settings.h index bbbecec518..a29dc82106 100644 --- a/src/core/ext/transport/chttp2/transport/frame_settings.h +++ b/src/core/ext/transport/chttp2/transport/frame_settings.h @@ -34,8 +34,8 @@ #ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H #define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_FRAME_SETTINGS_H -#include #include +#include #include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/lib/iomgr/exec_ctx.h" @@ -88,7 +88,7 @@ extern const grpc_chttp2_setting_parameters /* Create a settings frame by diffing old & new, and updating old to be new */ grpc_slice grpc_chttp2_settings_create(uint32_t *old, const uint32_t *new, - uint32_t force_mask, size_t count); + uint32_t force_mask, size_t count); /* Create an ack settings frame */ grpc_slice grpc_chttp2_settings_ack_create(void); diff --git a/src/core/ext/transport/chttp2/transport/frame_window_update.h b/src/core/ext/transport/chttp2/transport/frame_window_update.h index b5f40335a4..f75dfb3d87 100644 --- a/src/core/ext/transport/chttp2/transport/frame_window_update.h +++ b/src/core/ext/transport/chttp2/transport/frame_window_update.h @@ -45,8 +45,8 @@ typedef struct { uint32_t amount; } grpc_chttp2_window_update_parser; -grpc_slice grpc_chttp2_window_update_create(uint32_t id, uint32_t window_delta, - grpc_transport_one_way_stats *stats); +grpc_slice grpc_chttp2_window_update_create( + uint32_t id, uint32_t window_delta, grpc_transport_one_way_stats *stats); grpc_error *grpc_chttp2_window_update_parser_begin_frame( grpc_chttp2_window_update_parser *parser, uint32_t length, uint8_t flags); diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.c b/src/core/ext/transport/chttp2/transport/hpack_encoder.c index 3c5bcd3412..eb68fe3138 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.c +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.c @@ -269,8 +269,9 @@ static void emit_indexed(grpc_chttp2_hpack_compressor *c, uint32_t elem_index, } static grpc_slice get_wire_value(grpc_mdelem *elem, uint8_t *huffman_prefix) { - if (grpc_is_binary_header((const char *)GRPC_SLICE_START_PTR(elem->key->slice), - GRPC_SLICE_LENGTH(elem->key->slice))) { + if (grpc_is_binary_header( + (const char *)GRPC_SLICE_START_PTR(elem->key->slice), + GRPC_SLICE_LENGTH(elem->key->slice))) { *huffman_prefix = 0x80; return grpc_mdstr_as_base64_encoded_and_huffman_compressed(elem->value); } diff --git a/src/core/ext/transport/chttp2/transport/hpack_encoder.h b/src/core/ext/transport/chttp2/transport/hpack_encoder.h index 9188d9c6c5..bcbd675ca2 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_encoder.h +++ b/src/core/ext/transport/chttp2/transport/hpack_encoder.h @@ -34,9 +34,9 @@ #ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H #define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_ENCODER_H -#include #include #include +#include #include "src/core/ext/transport/chttp2/transport/frame.h" #include "src/core/lib/transport/metadata.h" #include "src/core/lib/transport/metadata_batch.h" diff --git a/src/core/ext/transport/chttp2/transport/hpack_parser.c b/src/core/ext/transport/chttp2/transport/hpack_parser.c index 3c1c6ba5a6..1046c31dda 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_parser.c +++ b/src/core/ext/transport/chttp2/transport/hpack_parser.c @@ -1501,9 +1501,9 @@ static grpc_error *is_binary_indexed_header(grpc_chttp2_hpack_parser *p, GRPC_ERROR_INT_INDEX, (intptr_t)p->index), GRPC_ERROR_INT_SIZE, (intptr_t)p->table.num_ents); } - *is = - grpc_is_binary_header((const char *)GRPC_SLICE_START_PTR(elem->key->slice), - GRPC_SLICE_LENGTH(elem->key->slice)); + *is = grpc_is_binary_header( + (const char *)GRPC_SLICE_START_PTR(elem->key->slice), + GRPC_SLICE_LENGTH(elem->key->slice)); return GRPC_ERROR_NONE; } diff --git a/src/core/ext/transport/chttp2/transport/hpack_table.h b/src/core/ext/transport/chttp2/transport/hpack_table.h index bc5a2d2463..2ca130e64b 100644 --- a/src/core/ext/transport/chttp2/transport/hpack_table.h +++ b/src/core/ext/transport/chttp2/transport/hpack_table.h @@ -34,8 +34,8 @@ #ifndef GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H #define GRPC_CORE_EXT_TRANSPORT_CHTTP2_TRANSPORT_HPACK_TABLE_H -#include #include +#include #include "src/core/lib/iomgr/error.h" #include "src/core/lib/transport/metadata.h" diff --git a/src/core/ext/transport/chttp2/transport/internal.h b/src/core/ext/transport/chttp2/transport/internal.h index 18fa2b4890..b74233d992 100644 --- a/src/core/ext/transport/chttp2/transport/internal.h +++ b/src/core/ext/transport/chttp2/transport/internal.h @@ -466,7 +466,8 @@ void grpc_chttp2_end_write(grpc_exec_ctx *exec_ctx, grpc_chttp2_transport *t, /** Process one slice of incoming data; return 1 if the connection is still viable after reading, or 0 if the connection should be torn down */ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx, - grpc_chttp2_transport *t, grpc_slice slice); + grpc_chttp2_transport *t, + grpc_slice slice); bool grpc_chttp2_list_add_writable_stream(grpc_chttp2_transport *t, grpc_chttp2_stream *s); diff --git a/src/core/ext/transport/chttp2/transport/parsing.c b/src/core/ext/transport/chttp2/transport/parsing.c index cb88fd5baf..b9c405158f 100644 --- a/src/core/ext/transport/chttp2/transport/parsing.c +++ b/src/core/ext/transport/chttp2/transport/parsing.c @@ -229,10 +229,10 @@ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx, case GRPC_DTS_FRAME: GPR_ASSERT(cur < end); if ((uint32_t)(end - cur) == t->incoming_frame_size) { - err = parse_frame_slice(exec_ctx, t, - grpc_slice_sub_no_ref(slice, (size_t)(cur - beg), - (size_t)(end - beg)), - 1); + err = parse_frame_slice( + exec_ctx, t, grpc_slice_sub_no_ref(slice, (size_t)(cur - beg), + (size_t)(end - beg)), + 1); if (err != GRPC_ERROR_NONE) { return err; } @@ -244,7 +244,7 @@ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx, err = parse_frame_slice( exec_ctx, t, grpc_slice_sub_no_ref(slice, cur_offset, - cur_offset + t->incoming_frame_size), + cur_offset + t->incoming_frame_size), 1); if (err != GRPC_ERROR_NONE) { return err; @@ -253,10 +253,10 @@ grpc_error *grpc_chttp2_perform_read(grpc_exec_ctx *exec_ctx, t->incoming_stream = NULL; goto dts_fh_0; /* loop */ } else { - err = parse_frame_slice(exec_ctx, t, - grpc_slice_sub_no_ref(slice, (size_t)(cur - beg), - (size_t)(end - beg)), - 0); + err = parse_frame_slice( + exec_ctx, t, grpc_slice_sub_no_ref(slice, (size_t)(cur - beg), + (size_t)(end - beg)), + 0); if (err != GRPC_ERROR_NONE) { return err; } diff --git a/src/core/ext/transport/chttp2/transport/writing.c b/src/core/ext/transport/chttp2/transport/writing.c index 1486a7edb4..139e7387c4 100644 --- a/src/core/ext/transport/chttp2/transport/writing.c +++ b/src/core/ext/transport/chttp2/transport/writing.c @@ -131,8 +131,8 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, if (s->announce_window > 0) { uint32_t announce = s->announce_window; grpc_slice_buffer_add(&t->outbuf, - grpc_chttp2_window_update_create( - s->id, s->announce_window, &s->stats.outgoing)); + grpc_chttp2_window_update_create( + s->id, s->announce_window, &s->stats.outgoing)); GRPC_CHTTP2_FLOW_DEBIT_STREAM("write", t, s, announce_window, announce); } if (sent_initial_metadata) { @@ -163,8 +163,8 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, s->sent_trailing_metadata = true; if (!t->is_client && !s->read_closed) { grpc_slice_buffer_add(&t->outbuf, grpc_chttp2_rst_stream_create( - s->id, GRPC_CHTTP2_NO_ERROR, - &s->stats.outgoing)); + s->id, GRPC_CHTTP2_NO_ERROR, + &s->stats.outgoing)); } } s->sending_bytes += send_bytes; @@ -221,7 +221,7 @@ bool grpc_chttp2_begin_write(grpc_exec_ctx *exec_ctx, announced); grpc_transport_one_way_stats throwaway_stats; grpc_slice_buffer_add(&t->outbuf, grpc_chttp2_window_update_create( - 0, announced, &throwaway_stats)); + 0, announced, &throwaway_stats)); } GPR_TIMER_END("grpc_chttp2_begin_write", 0); diff --git a/src/core/ext/transport/cronet/transport/cronet_transport.c b/src/core/ext/transport/cronet/transport/cronet_transport.c index 73fda07ee1..1e5377c2b4 100644 --- a/src/core/ext/transport/cronet/transport/cronet_transport.c +++ b/src/core/ext/transport/cronet/transport/cronet_transport.c @@ -34,10 +34,10 @@ #include #include +#include #include #include #include -#include #include #include @@ -926,7 +926,7 @@ static enum e_op_result execute_stream_op(grpc_exec_ctx *exec_ctx, free_read_buffer(s); grpc_slice_buffer_init(&stream_state->rs.read_slice_buffer); grpc_slice_buffer_add(&stream_state->rs.read_slice_buffer, - read_data_slice); + read_data_slice); grpc_slice_buffer_stream_init(&stream_state->rs.sbs, &stream_state->rs.read_slice_buffer, 0); *((grpc_byte_buffer **)stream_op->recv_message) = diff --git a/src/core/lib/channel/compress_filter.c b/src/core/lib/channel/compress_filter.c index c42a81b3b5..de71bcc22b 100644 --- a/src/core/lib/channel/compress_filter.c +++ b/src/core/lib/channel/compress_filter.c @@ -35,9 +35,9 @@ #include #include +#include #include #include -#include #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/channel/compress_filter.h" diff --git a/src/core/lib/channel/connected_channel.c b/src/core/lib/channel/connected_channel.c index 2ae86f5507..0e62d58475 100644 --- a/src/core/lib/channel/connected_channel.c +++ b/src/core/lib/channel/connected_channel.c @@ -38,9 +38,9 @@ #include #include +#include #include #include -#include #include "src/core/lib/profiling/timers.h" #include "src/core/lib/support/string.h" #include "src/core/lib/transport/transport.h" diff --git a/src/core/lib/channel/handshaker.c b/src/core/lib/channel/handshaker.c index 00d39764d7..a45a39981c 100644 --- a/src/core/lib/channel/handshaker.c +++ b/src/core/lib/channel/handshaker.c @@ -146,8 +146,8 @@ void grpc_handshake_manager_shutdown(grpc_exec_ctx* exec_ctx, static void call_next_handshaker(grpc_exec_ctx* exec_ctx, grpc_endpoint* endpoint, grpc_channel_args* args, - grpc_slice_buffer* read_buffer, void* user_data, - grpc_error* error) { + grpc_slice_buffer* read_buffer, + void* user_data, grpc_error* error) { grpc_handshake_manager* mgr = user_data; GPR_ASSERT(mgr->state != NULL); GPR_ASSERT(mgr->state->index < mgr->count); diff --git a/src/core/lib/channel/http_server_filter.c b/src/core/lib/channel/http_server_filter.c index 1a73a07b81..10631850cd 100644 --- a/src/core/lib/channel/http_server_filter.c +++ b/src/core/lib/channel/http_server_filter.c @@ -164,7 +164,7 @@ static grpc_mdelem *server_filter(void *user_data, grpc_mdelem *md) { calld->seen_payload_bin = 1; grpc_slice_buffer_init(&calld->read_slice_buffer); grpc_slice_buffer_add(&calld->read_slice_buffer, - grpc_slice_ref(md->value->slice)); + grpc_slice_ref(md->value->slice)); grpc_slice_buffer_stream_init(&calld->read_stream, &calld->read_slice_buffer, 0); return NULL; diff --git a/src/core/lib/http/format_request.c b/src/core/lib/http/format_request.c index 59ff28f67f..024664b6ee 100644 --- a/src/core/lib/http/format_request.c +++ b/src/core/lib/http/format_request.c @@ -37,8 +37,8 @@ #include #include -#include #include +#include #include #include #include "src/core/lib/support/string.h" @@ -65,7 +65,8 @@ static void fill_common_header(const grpc_httpcli_request *request, } } -grpc_slice grpc_httpcli_format_get_request(const grpc_httpcli_request *request) { +grpc_slice grpc_httpcli_format_get_request( + const grpc_httpcli_request *request) { gpr_strvec out; char *flat; size_t flat_len; @@ -82,8 +83,8 @@ grpc_slice grpc_httpcli_format_get_request(const grpc_httpcli_request *request) } grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request, - const char *body_bytes, - size_t body_size) { + const char *body_bytes, + size_t body_size) { gpr_strvec out; char *tmp; size_t out_len; diff --git a/src/core/lib/http/format_request.h b/src/core/lib/http/format_request.h index ad51701bbb..1c8e3f68c5 100644 --- a/src/core/lib/http/format_request.h +++ b/src/core/lib/http/format_request.h @@ -39,8 +39,8 @@ grpc_slice grpc_httpcli_format_get_request(const grpc_httpcli_request *request); grpc_slice grpc_httpcli_format_post_request(const grpc_httpcli_request *request, - const char *body_bytes, - size_t body_size); + const char *body_bytes, + size_t body_size); grpc_slice grpc_httpcli_format_connect_request( const grpc_httpcli_request *request); diff --git a/src/core/lib/http/parser.h b/src/core/lib/http/parser.h index 6d003cd68c..a68011dd43 100644 --- a/src/core/lib/http/parser.h +++ b/src/core/lib/http/parser.h @@ -34,8 +34,8 @@ #ifndef GRPC_CORE_LIB_HTTP_PARSER_H #define GRPC_CORE_LIB_HTTP_PARSER_H -#include #include +#include #include "src/core/lib/iomgr/error.h" /* Maximum length of a header string of the form 'Key: Value\r\n' */ diff --git a/src/core/lib/iomgr/resource_quota.c b/src/core/lib/iomgr/resource_quota.c index f047f45b43..6d7e549bb7 100644 --- a/src/core/lib/iomgr/resource_quota.c +++ b/src/core/lib/iomgr/resource_quota.c @@ -300,7 +300,7 @@ static void ru_slice_unref(void *p) { } static grpc_slice ru_slice_create(grpc_resource_user *resource_user, - size_t size) { + size_t size) { ru_slice_refcount *rc = gpr_malloc(sizeof(ru_slice_refcount) + size); rc->base.ref = ru_slice_ref; rc->base.unref = ru_slice_unref; diff --git a/src/core/lib/iomgr/tcp_client_windows.c b/src/core/lib/iomgr/tcp_client_windows.c index 9f28c056d9..598c012589 100644 --- a/src/core/lib/iomgr/tcp_client_windows.c +++ b/src/core/lib/iomgr/tcp_client_windows.c @@ -37,10 +37,10 @@ #include "src/core/lib/iomgr/sockaddr_windows.h" +#include #include #include #include -#include #include #include "src/core/lib/iomgr/iocp_windows.h" diff --git a/src/core/lib/iomgr/tcp_windows.c b/src/core/lib/iomgr/tcp_windows.c index 9fe7662e96..bc1b91e109 100644 --- a/src/core/lib/iomgr/tcp_windows.c +++ b/src/core/lib/iomgr/tcp_windows.c @@ -40,10 +40,10 @@ #include "src/core/lib/iomgr/network_status_tracker.h" #include "src/core/lib/iomgr/sockaddr_windows.h" +#include #include #include #include -#include #include #include diff --git a/src/core/lib/security/transport/handshake.c b/src/core/lib/security/transport/handshake.c index 07f16df51f..01e7fab773 100644 --- a/src/core/lib/security/transport/handshake.c +++ b/src/core/lib/security/transport/handshake.c @@ -36,9 +36,9 @@ #include #include +#include #include #include -#include #include "src/core/lib/iomgr/timer.h" #include "src/core/lib/security/context/security_context.h" #include "src/core/lib/security/transport/secure_endpoint.h" diff --git a/src/core/lib/security/transport/security_connector.c b/src/core/lib/security/transport/security_connector.c index 3d39cf5dda..f7e3264bda 100644 --- a/src/core/lib/security/transport/security_connector.c +++ b/src/core/lib/security/transport/security_connector.c @@ -36,10 +36,10 @@ #include #include +#include #include #include #include -#include #include #include "src/core/ext/transport/chttp2/alpn/alpn.h" diff --git a/src/core/lib/security/util/b64.c b/src/core/lib/security/util/b64.c index 6270277914..4892e8e621 100644 --- a/src/core/lib/security/util/b64.c +++ b/src/core/lib/security/util/b64.c @@ -183,7 +183,7 @@ static int decode_group(const unsigned char *codes, size_t num_codes, } grpc_slice grpc_base64_decode_with_len(const char *b64, size_t b64_len, - int url_safe) { + int url_safe) { grpc_slice result = grpc_slice_malloc(b64_len); unsigned char *current = GRPC_SLICE_START_PTR(result); size_t result_size = 0; diff --git a/src/core/lib/security/util/b64.h b/src/core/lib/security/util/b64.h index f3218b9c4f..6ea0b5365b 100644 --- a/src/core/lib/security/util/b64.h +++ b/src/core/lib/security/util/b64.h @@ -47,6 +47,6 @@ grpc_slice grpc_base64_decode(const char *b64, int url_safe); /* Same as above except that the length is provided by the caller. */ grpc_slice grpc_base64_decode_with_len(const char *b64, size_t b64_len, - int url_safe); + int url_safe); #endif /* GRPC_CORE_LIB_SECURITY_UTIL_B64_H */ diff --git a/src/core/lib/slice/slice.c b/src/core/lib/slice/slice.c index 54ff6f6baa..3dac18df61 100644 --- a/src/core/lib/slice/slice.c +++ b/src/core/lib/slice/slice.c @@ -31,9 +31,9 @@ * */ +#include #include #include -#include #include @@ -62,7 +62,7 @@ void grpc_slice_unref(grpc_slice slice) { static void noop_ref_or_unref(void *unused) {} static grpc_slice_refcount noop_refcount = {noop_ref_or_unref, - noop_ref_or_unref}; + noop_ref_or_unref}; grpc_slice grpc_slice_from_static_string(const char *s) { grpc_slice slice; @@ -95,8 +95,8 @@ static void new_slice_unref(void *p) { } grpc_slice grpc_slice_new_with_user_data(void *p, size_t len, - void (*destroy)(void *), - void *user_data) { + void (*destroy)(void *), + void *user_data) { grpc_slice slice; new_slice_refcount *rc = gpr_malloc(sizeof(new_slice_refcount)); gpr_ref_init(&rc->refs, 1); @@ -140,7 +140,7 @@ static void new_with_len_unref(void *p) { } grpc_slice grpc_slice_new_with_len(void *p, size_t len, - void (*destroy)(void *, size_t)) { + void (*destroy)(void *, size_t)) { grpc_slice slice; new_with_len_slice_refcount *rc = gpr_malloc(sizeof(new_with_len_slice_refcount)); diff --git a/src/core/lib/slice/slice_buffer.c b/src/core/lib/slice/slice_buffer.c index 8416237631..990ef128bd 100644 --- a/src/core/lib/slice/slice_buffer.c +++ b/src/core/lib/slice/slice_buffer.c @@ -31,8 +31,8 @@ * */ -#include #include +#include #include @@ -112,7 +112,8 @@ void grpc_slice_buffer_add(grpc_slice_buffer *sb, grpc_slice s) { writes */ if (!s.refcount && n) { grpc_slice *back = &sb->slices[n - 1]; - if (!back->refcount && back->data.inlined.length < GRPC_SLICE_INLINED_SIZE) { + if (!back->refcount && + back->data.inlined.length < GRPC_SLICE_INLINED_SIZE) { if (s.data.inlined.length + back->data.inlined.length <= GRPC_SLICE_INLINED_SIZE) { memcpy(back->data.inlined.bytes + back->data.inlined.length, @@ -193,7 +194,8 @@ void grpc_slice_buffer_swap(grpc_slice_buffer *a, grpc_slice_buffer *b) { } } -void grpc_slice_buffer_move_into(grpc_slice_buffer *src, grpc_slice_buffer *dst) { +void grpc_slice_buffer_move_into(grpc_slice_buffer *src, + grpc_slice_buffer *dst) { /* anything to move? */ if (src->count == 0) { return; @@ -210,7 +212,7 @@ void grpc_slice_buffer_move_into(grpc_slice_buffer *src, grpc_slice_buffer *dst) } void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n, - grpc_slice_buffer *dst) { + grpc_slice_buffer *dst) { size_t src_idx; size_t output_len = dst->length + n; size_t new_input_len = src->length - n; @@ -248,7 +250,7 @@ void grpc_slice_buffer_move_first(grpc_slice_buffer *src, size_t n, } void grpc_slice_buffer_trim_end(grpc_slice_buffer *sb, size_t n, - grpc_slice_buffer *garbage) { + grpc_slice_buffer *garbage) { GPR_ASSERT(n <= sb->length); sb->length -= n; for (;;) { diff --git a/src/core/lib/surface/byte_buffer.c b/src/core/lib/surface/byte_buffer.c index 5ae7e3264b..d646591a65 100644 --- a/src/core/lib/surface/byte_buffer.c +++ b/src/core/lib/surface/byte_buffer.c @@ -42,7 +42,8 @@ grpc_byte_buffer *grpc_raw_byte_buffer_create(grpc_slice *slices, } grpc_byte_buffer *grpc_raw_compressed_byte_buffer_create( - grpc_slice *slices, size_t nslices, grpc_compression_algorithm compression) { + grpc_slice *slices, size_t nslices, + grpc_compression_algorithm compression) { size_t i; grpc_byte_buffer *bb = gpr_malloc(sizeof(grpc_byte_buffer)); bb->type = GRPC_BB_RAW; diff --git a/src/core/lib/surface/byte_buffer_reader.c b/src/core/lib/surface/byte_buffer_reader.c index 6a1ef2ba2d..0089959fbb 100644 --- a/src/core/lib/surface/byte_buffer_reader.c +++ b/src/core/lib/surface/byte_buffer_reader.c @@ -37,9 +37,9 @@ #include #include #include +#include #include #include -#include #include "src/core/lib/compression/message_compress.h" diff --git a/src/core/lib/transport/metadata_batch.h b/src/core/lib/transport/metadata_batch.h index 1b5525e631..7a9ccb4bc8 100644 --- a/src/core/lib/transport/metadata_batch.h +++ b/src/core/lib/transport/metadata_batch.h @@ -37,8 +37,8 @@ #include #include -#include #include +#include #include #include "src/core/lib/transport/metadata.h" diff --git a/src/cpp/client/channel_cc.cc b/src/cpp/client/channel_cc.cc index e18f9f527c..d4afb1f00e 100644 --- a/src/cpp/client/channel_cc.cc +++ b/src/cpp/client/channel_cc.cc @@ -47,8 +47,8 @@ #include #include #include -#include #include +#include #include "src/core/lib/profiling/timers.h" namespace grpc { diff --git a/src/cpp/common/core_codegen.cc b/src/cpp/common/core_codegen.cc index fef8cc3d22..a07ad54376 100644 --- a/src/cpp/common/core_codegen.cc +++ b/src/cpp/common/core_codegen.cc @@ -39,11 +39,11 @@ #include #include #include +#include +#include #include #include #include -#include -#include #include #include "src/core/lib/profiling/timers.h" @@ -115,13 +115,16 @@ grpc_slice CoreCodegen::grpc_slice_malloc(size_t length) { return ::grpc_slice_malloc(length); } -void CoreCodegen::grpc_slice_unref(grpc_slice slice) { ::grpc_slice_unref(slice); } +void CoreCodegen::grpc_slice_unref(grpc_slice slice) { + ::grpc_slice_unref(slice); +} grpc_slice CoreCodegen::grpc_slice_split_tail(grpc_slice* s, size_t split) { return ::grpc_slice_split_tail(s, split); } -void CoreCodegen::grpc_slice_buffer_add(grpc_slice_buffer* sb, grpc_slice slice) { +void CoreCodegen::grpc_slice_buffer_add(grpc_slice_buffer* sb, + grpc_slice slice) { ::grpc_slice_buffer_add(sb, slice); } diff --git a/test/core/compression/message_compress_test.c b/test/core/compression/message_compress_test.c index 680850af33..fc53cd9d36 100644 --- a/test/core/compression/message_compress_test.c +++ b/test/core/compression/message_compress_test.c @@ -70,8 +70,8 @@ static void assert_passthrough(grpc_slice value, GPR_INFO, "assert_passthrough: value_length=%" PRIuPTR " value_hash=0x%08x " "algorithm='%s' uncompressed_split='%s' compressed_split='%s'", - GRPC_SLICE_LENGTH(value), - gpr_murmur_hash3(GRPC_SLICE_START_PTR(value), GRPC_SLICE_LENGTH(value), 0), + GRPC_SLICE_LENGTH(value), gpr_murmur_hash3(GRPC_SLICE_START_PTR(value), + GRPC_SLICE_LENGTH(value), 0), algorithm_name, grpc_slice_split_mode_name(uncompressed_split_mode), grpc_slice_split_mode_name(compressed_split_mode)); @@ -221,7 +221,7 @@ static void test_bad_decompression_data_stream(void) { grpc_slice_buffer_init(&input); grpc_slice_buffer_init(&output); grpc_slice_buffer_add(&input, - grpc_slice_from_copied_buffer("\x78\xda\xff\xff", 4)); + grpc_slice_from_copied_buffer("\x78\xda\xff\xff", 4)); /* try (and fail) to decompress the invalid compresed buffer */ GPR_ASSERT(0 == grpc_msg_decompress(GRPC_COMPRESS_DEFLATE, &input, &output)); @@ -237,8 +237,8 @@ static void test_bad_compression_algorithm(void) { grpc_slice_buffer_init(&input); grpc_slice_buffer_init(&output); - grpc_slice_buffer_add(&input, - grpc_slice_from_copied_string("Never gonna give you up")); + grpc_slice_buffer_add( + &input, grpc_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); @@ -259,8 +259,8 @@ static void test_bad_decompression_algorithm(void) { grpc_slice_buffer_init(&input); grpc_slice_buffer_init(&output); grpc_slice_buffer_add(&input, - grpc_slice_from_copied_string( - "I'm not really compressed but it doesn't matter")); + grpc_slice_from_copied_string( + "I'm not really compressed but it doesn't matter")); was_decompressed = grpc_msg_decompress(GRPC_COMPRESS_ALGORITHMS_COUNT, &input, &output); GPR_ASSERT(0 == was_decompressed); diff --git a/test/core/end2end/cq_verifier.c b/test/core/end2end/cq_verifier.c index 4fb89eb96e..57373970c4 100644 --- a/test/core/end2end/cq_verifier.c +++ b/test/core/end2end/cq_verifier.c @@ -119,7 +119,8 @@ static grpc_slice merge_slices(grpc_slice *slices, size_t nslices) { cursor = GRPC_SLICE_START_PTR(out); for (i = 0; i < nslices; i++) { - memcpy(cursor, GRPC_SLICE_START_PTR(slices[i]), GRPC_SLICE_LENGTH(slices[i])); + memcpy(cursor, GRPC_SLICE_START_PTR(slices[i]), + GRPC_SLICE_LENGTH(slices[i])); cursor += GRPC_SLICE_LENGTH(slices[i]); } diff --git a/test/core/end2end/invalid_call_argument_test.c b/test/core/end2end/invalid_call_argument_test.c index 6cc7d28489..765b6ad1be 100644 --- a/test/core/end2end/invalid_call_argument_test.c +++ b/test/core/end2end/invalid_call_argument_test.c @@ -251,7 +251,8 @@ static void test_send_messages_at_the_same_time() { gpr_log(GPR_INFO, "test_send_messages_at_the_same_time"); grpc_op *op; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); prepare_test(1); diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.c index 317ca3110b..b0d18191e0 100644 --- a/test/core/end2end/tests/binary_metadata.c +++ b/test/core/end2end/tests/binary_metadata.c @@ -100,8 +100,10 @@ static void test_request_response_with_metadata_and_payload( grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = + grpc_slice_from_copied_string("hello you"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_byte_buffer *response_payload = diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index 8f8b7d5119..05a379cf1b 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -135,8 +135,10 @@ static void request_response_with_payload_and_call_creds( override_mode mode) { grpc_call *c; grpc_call *s; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = + grpc_slice_from_copied_string("hello you"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_byte_buffer *response_payload = @@ -389,7 +391,8 @@ static void test_request_with_server_rejecting_client_creds( char *details = NULL; size_t details_capacity = 0; grpc_byte_buffer *response_payload_recv = NULL; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_call_credentials *creds; diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index 4bf55c8725..f67da2d90d 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -118,8 +118,10 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, size_t details_capacity = 0; grpc_byte_buffer *request_payload_recv = NULL; grpc_byte_buffer *response_payload_recv = NULL; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = + grpc_slice_from_copied_string("hello you"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_byte_buffer *response_payload = diff --git a/test/core/end2end/tests/cancel_after_client_done.c b/test/core/end2end/tests/cancel_after_client_done.c index afb17b0719..44be85435d 100644 --- a/test/core/end2end/tests/cancel_after_client_done.c +++ b/test/core/end2end/tests/cancel_after_client_done.c @@ -117,8 +117,10 @@ static void test_cancel_after_accept_and_writes_closed( size_t details_capacity = 0; grpc_byte_buffer *request_payload_recv = NULL; grpc_byte_buffer *response_payload_recv = NULL; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = + grpc_slice_from_copied_string("hello you"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_byte_buffer *response_payload = diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index fe0e0d689c..c276f5e2fa 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -116,7 +116,8 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, char *details = NULL; size_t details_capacity = 0; grpc_byte_buffer *response_payload_recv = NULL; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c index 3a0b83c4d2..e33b120a5b 100644 --- a/test/core/end2end/tests/cancel_before_invoke.c +++ b/test/core/end2end/tests/cancel_before_invoke.c @@ -114,7 +114,8 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, char *details = NULL; size_t details_capacity = 0; grpc_byte_buffer *response_payload_recv = NULL; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index 92788dd8fa..4ed24baf67 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -308,7 +308,8 @@ static void request_with_payload_template( response_str[1023] = '\0'; request_payload_slice = grpc_slice_from_copied_string(request_str); - grpc_slice response_payload_slice = grpc_slice_from_copied_string(response_str); + grpc_slice response_payload_slice = + grpc_slice_from_copied_string(response_str); client_args = grpc_channel_args_set_compression_algorithm( NULL, default_client_channel_compression_algorithm); diff --git a/test/core/end2end/tests/filter_call_init_fails.c b/test/core/end2end/tests/filter_call_init_fails.c index 36f98694b6..b180957d4f 100644 --- a/test/core/end2end/tests/filter_call_init_fails.c +++ b/test/core/end2end/tests/filter_call_init_fails.c @@ -108,7 +108,8 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test_request(grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); diff --git a/test/core/end2end/tests/filter_causes_close.c b/test/core/end2end/tests/filter_causes_close.c index 66449558c7..943a3df90d 100644 --- a/test/core/end2end/tests/filter_causes_close.c +++ b/test/core/end2end/tests/filter_causes_close.c @@ -104,7 +104,8 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test_request(grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c index 29dcafb985..26a4eef7d9 100644 --- a/test/core/end2end/tests/large_metadata.c +++ b/test/core/end2end/tests/large_metadata.c @@ -99,7 +99,8 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test_request_with_large_metadata(grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); diff --git a/test/core/end2end/tests/load_reporting_hook.c b/test/core/end2end/tests/load_reporting_hook.c index 1dba200c02..046e0c321b 100644 --- a/test/core/end2end/tests/load_reporting_hook.c +++ b/test/core/end2end/tests/load_reporting_hook.c @@ -128,7 +128,8 @@ static void request_response_with_payload(grpc_end2end_test_fixture f, grpc_metadata *initial_lr_metadata, grpc_metadata *trailing_lr_metadata) { grpc_slice request_payload_slice = grpc_slice_from_static_string(request_msg); - grpc_slice response_payload_slice = grpc_slice_from_static_string(response_msg); + grpc_slice response_payload_slice = + grpc_slice_from_static_string(response_msg); grpc_call *c; grpc_call *s; grpc_byte_buffer *request_payload = diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index cdf52f9838..559b00d828 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -116,7 +116,8 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, cq_verifier *cqv; grpc_op ops[6]; grpc_op *op; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_byte_buffer *recv_payload = NULL; diff --git a/test/core/end2end/tests/network_status_change.c b/test/core/end2end/tests/network_status_change.c index e9528ff105..84447e6a2f 100644 --- a/test/core/end2end/tests/network_status_change.c +++ b/test/core/end2end/tests/network_status_change.c @@ -102,7 +102,8 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test_invoke_network_status_change(grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c index 5a19950726..01ba964ef0 100644 --- a/test/core/end2end/tests/payload.c +++ b/test/core/end2end/tests/payload.c @@ -95,7 +95,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -/* Creates and returns a grpc_slice containing random alphanumeric characters. */ +/* Creates and returns a grpc_slice containing random alphanumeric characters. + */ static grpc_slice generate_random_slice() { size_t i; static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890"; diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index 3398a9cff7..317788f7fa 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -120,8 +120,10 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, grpc_byte_buffer *response_payload; grpc_byte_buffer *response_payload_recv; int i; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = + grpc_slice_from_copied_string("hello you"); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", "foo.test.google.fr:1234", deadline, diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c index a37fc645b4..8649c1563f 100644 --- a/test/core/end2end/tests/request_with_flags.c +++ b/test/core/end2end/tests/request_with_flags.c @@ -100,7 +100,8 @@ static void test_invoke_request_with_flags( grpc_end2end_test_config config, uint32_t *flags_for_op, grpc_call_error call_start_batch_expected_result) { grpc_call *c; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index 3e2bbb3b0e..144cd58ec0 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -99,7 +99,8 @@ static void end_test(grpc_end2end_test_fixture *f) { static void test_invoke_request_with_payload(grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); gpr_timespec deadline = five_seconds_time(); diff --git a/test/core/end2end/tests/resource_quota_server.c b/test/core/end2end/tests/resource_quota_server.c index 280bad5749..cf81b06692 100644 --- a/test/core/end2end/tests/resource_quota_server.c +++ b/test/core/end2end/tests/resource_quota_server.c @@ -95,7 +95,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -/* Creates and returns a grpc_slice containing random alphanumeric characters. */ +/* Creates and returns a grpc_slice containing random alphanumeric characters. + */ static grpc_slice generate_random_slice() { size_t i; static const char chars[] = "abcdefghijklmnopqrstuvwxyz1234567890"; diff --git a/test/core/end2end/tests/simple_cacheable_request.c b/test/core/end2end/tests/simple_cacheable_request.c index 40dd3983e1..4284175214 100644 --- a/test/core/end2end/tests/simple_cacheable_request.c +++ b/test/core/end2end/tests/simple_cacheable_request.c @@ -102,8 +102,10 @@ static void test_cacheable_request_response_with_metadata_and_payload( grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = + grpc_slice_from_copied_string("hello you"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_byte_buffer *response_payload = diff --git a/test/core/end2end/tests/simple_metadata.c b/test/core/end2end/tests/simple_metadata.c index 1ac9dc8210..e11981f92b 100644 --- a/test/core/end2end/tests/simple_metadata.c +++ b/test/core/end2end/tests/simple_metadata.c @@ -100,8 +100,10 @@ static void test_request_response_with_metadata_and_payload( grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = + grpc_slice_from_copied_string("hello you"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_byte_buffer *response_payload = diff --git a/test/core/end2end/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.c index 0bbf0879cc..f88d5edeae 100644 --- a/test/core/end2end/tests/trailing_metadata.c +++ b/test/core/end2end/tests/trailing_metadata.c @@ -100,8 +100,10 @@ static void test_request_response_with_metadata_and_payload( grpc_end2end_test_config config) { grpc_call *c; grpc_call *s; - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); - grpc_slice response_payload_slice = grpc_slice_from_copied_string("hello you"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); + grpc_slice response_payload_slice = + grpc_slice_from_copied_string("hello you"); grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); grpc_byte_buffer *response_payload = diff --git a/test/core/http/format_request_test.c b/test/core/http/format_request_test.c index bd31e5e8ab..290990c906 100644 --- a/test/core/http/format_request_test.c +++ b/test/core/http/format_request_test.c @@ -52,13 +52,13 @@ static void test_format_get_request(void) { slice = grpc_httpcli_format_get_request(&req); GPR_ASSERT(0 == grpc_slice_str_cmp(slice, - "GET /index.html HTTP/1.0\r\n" - "Host: example.com\r\n" - "Connection: close\r\n" - "User-Agent: " GRPC_HTTPCLI_USER_AGENT - "\r\n" - "x-yz: abc\r\n" - "\r\n")); + "GET /index.html HTTP/1.0\r\n" + "Host: example.com\r\n" + "Connection: close\r\n" + "User-Agent: " GRPC_HTTPCLI_USER_AGENT + "\r\n" + "x-yz: abc\r\n" + "\r\n")); grpc_slice_unref(slice); } @@ -79,16 +79,16 @@ static void test_format_post_request(void) { slice = grpc_httpcli_format_post_request(&req, body_bytes, body_len); GPR_ASSERT(0 == grpc_slice_str_cmp(slice, - "POST /index.html HTTP/1.0\r\n" - "Host: example.com\r\n" - "Connection: close\r\n" - "User-Agent: " GRPC_HTTPCLI_USER_AGENT - "\r\n" - "x-yz: abc\r\n" - "Content-Type: text/plain\r\n" - "Content-Length: 9\r\n" - "\r\n" - "fake body")); + "POST /index.html HTTP/1.0\r\n" + "Host: example.com\r\n" + "Connection: close\r\n" + "User-Agent: " GRPC_HTTPCLI_USER_AGENT + "\r\n" + "x-yz: abc\r\n" + "Content-Type: text/plain\r\n" + "Content-Length: 9\r\n" + "\r\n" + "fake body")); grpc_slice_unref(slice); } @@ -107,13 +107,13 @@ static void test_format_post_request_no_body(void) { slice = grpc_httpcli_format_post_request(&req, NULL, 0); GPR_ASSERT(0 == grpc_slice_str_cmp(slice, - "POST /index.html HTTP/1.0\r\n" - "Host: example.com\r\n" - "Connection: close\r\n" - "User-Agent: " GRPC_HTTPCLI_USER_AGENT - "\r\n" - "x-yz: abc\r\n" - "\r\n")); + "POST /index.html HTTP/1.0\r\n" + "Host: example.com\r\n" + "Connection: close\r\n" + "User-Agent: " GRPC_HTTPCLI_USER_AGENT + "\r\n" + "x-yz: abc\r\n" + "\r\n")); grpc_slice_unref(slice); } diff --git a/test/core/iomgr/endpoint_tests.c b/test/core/iomgr/endpoint_tests.c index 8a1699608e..8186ea7e85 100644 --- a/test/core/iomgr/endpoint_tests.c +++ b/test/core/iomgr/endpoint_tests.c @@ -36,9 +36,9 @@ #include #include +#include #include #include -#include #include #include #include "test/core/util/test_config.h" @@ -88,7 +88,7 @@ static grpc_endpoint_test_fixture begin_test(grpc_endpoint_test_config config, static void end_test(grpc_endpoint_test_config config) { config.clean_up(); } static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size, - size_t *num_blocks, uint8_t *current_data) { + size_t *num_blocks, uint8_t *current_data) { size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1 : 0); grpc_slice *slices = gpr_malloc(sizeof(grpc_slice) * nslices); size_t num_bytes_left = num_bytes; @@ -99,7 +99,7 @@ static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size, for (i = 0; i < nslices; ++i) { slices[i] = grpc_slice_malloc(slice_size > num_bytes_left ? num_bytes_left - : slice_size); + : slice_size); num_bytes_left -= GRPC_SLICE_LENGTH(slices[i]); buf = GRPC_SLICE_START_PTR(slices[i]); for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) { diff --git a/test/core/iomgr/load_file_test.c b/test/core/iomgr/load_file_test.c index af822466d7..8714e1f368 100644 --- a/test/core/iomgr/load_file_test.c +++ b/test/core/iomgr/load_file_test.c @@ -34,9 +34,9 @@ #include #include +#include #include #include -#include #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/support/string.h" diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c index bba1900987..5eafa570bb 100644 --- a/test/core/iomgr/tcp_posix_test.c +++ b/test/core/iomgr/tcp_posix_test.c @@ -274,7 +274,7 @@ struct write_socket_state { }; static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size, - size_t *num_blocks, uint8_t *current_data) { + size_t *num_blocks, uint8_t *current_data) { size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1u : 0u); grpc_slice *slices = gpr_malloc(sizeof(grpc_slice) * nslices); size_t num_bytes_left = num_bytes; @@ -284,7 +284,7 @@ static grpc_slice *allocate_blocks(size_t num_bytes, size_t slice_size, for (i = 0; i < nslices; ++i) { slices[i] = grpc_slice_malloc(slice_size > num_bytes_left ? num_bytes_left - : slice_size); + : slice_size); num_bytes_left -= GRPC_SLICE_LENGTH(slices[i]); buf = GRPC_SLICE_START_PTR(slices[i]); for (j = 0; j < GRPC_SLICE_LENGTH(slices[i]); ++j) { diff --git a/test/core/security/b64_test.c b/test/core/security/b64_test.c index dea0f56266..af883f51e9 100644 --- a/test/core/security/b64_test.c +++ b/test/core/security/b64_test.c @@ -35,9 +35,9 @@ #include +#include #include #include -#include #include "test/core/util/test_config.h" static int buffers_are_equal(const unsigned char *buf1, diff --git a/test/core/security/create_jwt.c b/test/core/security/create_jwt.c index 0303b791ae..741ace9bdd 100644 --- a/test/core/security/create_jwt.c +++ b/test/core/security/create_jwt.c @@ -37,10 +37,10 @@ #include "src/core/lib/iomgr/load_file.h" #include "src/core/lib/security/credentials/jwt/jwt_credentials.h" +#include #include #include #include -#include void create_jwt(const char *json_key_file_path, const char *service_url, const char *scope) { diff --git a/test/core/security/credentials_test.c b/test/core/security/credentials_test.c index 0637215915..d4c755088d 100644 --- a/test/core/security/credentials_test.c +++ b/test/core/security/credentials_test.c @@ -243,9 +243,10 @@ static void test_oauth2_token_fetcher_creds_parsing_ok(void) { GPR_ASSERT(token_lifetime.tv_sec == 3599); GPR_ASSERT(token_lifetime.tv_nsec == 0); GPR_ASSERT(token_md->num_entries == 1); - GPR_ASSERT(grpc_slice_str_cmp(token_md->entries[0].key, "authorization") == 0); + GPR_ASSERT(grpc_slice_str_cmp(token_md->entries[0].key, "authorization") == + 0); GPR_ASSERT(grpc_slice_str_cmp(token_md->entries[0].value, - "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_") == + "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_") == 0); grpc_credentials_md_store_unref(token_md); grpc_http_response_destroy(&response); @@ -530,7 +531,7 @@ static void on_oauth2_creds_get_metadata_success( GPR_ASSERT(num_md == 1); GPR_ASSERT(grpc_slice_str_cmp(md_elems[0].key, "authorization") == 0); GPR_ASSERT(grpc_slice_str_cmp(md_elems[0].value, - "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_") == + "Bearer ya29.AHES6ZRN3-HlhAPya30GnW_bHSb_") == 0); GPR_ASSERT(user_data != NULL); GPR_ASSERT(strcmp((const char *)user_data, test_user_data) == 0); diff --git a/test/core/security/fetch_oauth2.c b/test/core/security/fetch_oauth2.c index ca093095c3..e9e211206c 100644 --- a/test/core/security/fetch_oauth2.c +++ b/test/core/security/fetch_oauth2.c @@ -36,10 +36,10 @@ #include #include +#include #include #include #include -#include #include #include "src/core/lib/iomgr/load_file.h" diff --git a/test/core/security/json_token_test.c b/test/core/security/json_token_test.c index 593b79855f..201655881f 100644 --- a/test/core/security/json_token_test.c +++ b/test/core/security/json_token_test.c @@ -37,9 +37,9 @@ #include #include +#include #include #include -#include #include "src/core/lib/json/json.h" #include "src/core/lib/security/credentials/oauth2/oauth2_credentials.h" diff --git a/test/core/security/jwt_verifier_test.c b/test/core/security/jwt_verifier_test.c index 01fe436f27..f8afba8d6d 100644 --- a/test/core/security/jwt_verifier_test.c +++ b/test/core/security/jwt_verifier_test.c @@ -37,9 +37,9 @@ #include +#include #include #include -#include #include #include "src/core/lib/http/httpcli.h" @@ -487,8 +487,8 @@ static void corrupt_jwt_sig(char *jwt) { GPR_ASSERT(!GRPC_SLICE_IS_EMPTY(sig)); sig_bytes = GRPC_SLICE_START_PTR(sig); (*sig_bytes)++; /* Corrupt first byte. */ - bad_b64_sig = - grpc_base64_encode(GRPC_SLICE_START_PTR(sig), GRPC_SLICE_LENGTH(sig), 1, 0); + bad_b64_sig = grpc_base64_encode(GRPC_SLICE_START_PTR(sig), + GRPC_SLICE_LENGTH(sig), 1, 0); memcpy(last_dot + 1, bad_b64_sig, strlen(bad_b64_sig)); gpr_free(bad_b64_sig); grpc_slice_unref(sig); diff --git a/test/core/security/oauth2_utils.c b/test/core/security/oauth2_utils.c index 22dbf0428d..44a209258d 100644 --- a/test/core/security/oauth2_utils.c +++ b/test/core/security/oauth2_utils.c @@ -37,9 +37,9 @@ #include #include +#include #include #include -#include #include #include "src/core/lib/security/credentials/credentials.h" diff --git a/test/core/security/print_google_default_creds_token.c b/test/core/security/print_google_default_creds_token.c index 3a04c6e3eb..157b7bf5ff 100644 --- a/test/core/security/print_google_default_creds_token.c +++ b/test/core/security/print_google_default_creds_token.c @@ -36,10 +36,10 @@ #include #include +#include #include #include #include -#include #include #include "src/core/lib/security/credentials/composite/composite_credentials.h" diff --git a/test/core/security/verify_jwt.c b/test/core/security/verify_jwt.c index 4d0ff242ea..043d29e6bb 100644 --- a/test/core/security/verify_jwt.c +++ b/test/core/security/verify_jwt.c @@ -36,10 +36,10 @@ #include #include +#include #include #include #include -#include #include #include "src/core/lib/security/credentials/jwt/jwt_verifier.h" diff --git a/test/core/slice/slice_buffer_test.c b/test/core/slice/slice_buffer_test.c index 4c26113d05..bf9ae197d2 100644 --- a/test/core/slice/slice_buffer_test.c +++ b/test/core/slice/slice_buffer_test.c @@ -31,8 +31,8 @@ * */ -#include #include +#include #include "test/core/util/test_config.h" void test_slice_buffer_add() { diff --git a/test/core/slice/slice_test.c b/test/core/slice/slice_test.c index e6d29e7459..ca44becfd0 100644 --- a/test/core/slice/slice_test.c +++ b/test/core/slice/slice_test.c @@ -170,11 +170,12 @@ static void test_slice_sub_works(unsigned length) { grpc_slice_unref(slice); } -static void check_head_tail(grpc_slice slice, grpc_slice head, grpc_slice tail) { +static void check_head_tail(grpc_slice slice, grpc_slice head, + grpc_slice tail) { GPR_ASSERT(GRPC_SLICE_LENGTH(slice) == GRPC_SLICE_LENGTH(head) + GRPC_SLICE_LENGTH(tail)); - GPR_ASSERT(0 == memcmp(GRPC_SLICE_START_PTR(slice), GRPC_SLICE_START_PTR(head), - GRPC_SLICE_LENGTH(head))); + GPR_ASSERT(0 == memcmp(GRPC_SLICE_START_PTR(slice), + GRPC_SLICE_START_PTR(head), GRPC_SLICE_LENGTH(head))); GPR_ASSERT(0 == memcmp(GRPC_SLICE_START_PTR(slice) + GRPC_SLICE_LENGTH(head), GRPC_SLICE_START_PTR(tail), GRPC_SLICE_LENGTH(tail))); } @@ -243,8 +244,8 @@ static void test_slice_from_copied_string_works(void) { slice = grpc_slice_from_copied_string(text); GPR_ASSERT(strlen(text) == GRPC_SLICE_LENGTH(slice)); - GPR_ASSERT(0 == - memcmp(text, GRPC_SLICE_START_PTR(slice), GRPC_SLICE_LENGTH(slice))); + GPR_ASSERT( + 0 == memcmp(text, GRPC_SLICE_START_PTR(slice), GRPC_SLICE_LENGTH(slice))); grpc_slice_unref(slice); } diff --git a/test/core/transport/chttp2/hpack_parser_test.c b/test/core/transport/chttp2/hpack_parser_test.c index c7e8f3a050..e2813df70c 100644 --- a/test/core/transport/chttp2/hpack_parser_test.c +++ b/test/core/transport/chttp2/hpack_parser_test.c @@ -36,9 +36,9 @@ #include #include +#include #include #include -#include #include "test/core/util/parse_hexstring.h" #include "test/core/util/slice_splitter.h" #include "test/core/util/test_config.h" diff --git a/test/core/transport/chttp2/varint_test.c b/test/core/transport/chttp2/varint_test.c index 5b831c71b2..e29be4b056 100644 --- a/test/core/transport/chttp2/varint_test.c +++ b/test/core/transport/chttp2/varint_test.c @@ -33,15 +33,16 @@ #include "src/core/ext/transport/chttp2/transport/varint.h" -#include #include +#include #include "test/core/util/test_config.h" static void test_varint(uint32_t value, uint32_t prefix_bits, uint8_t prefix_or, const char *expect_bytes, size_t expect_length) { uint32_t nbytes = GRPC_CHTTP2_VARINT_LENGTH(value, prefix_bits); - grpc_slice expect = grpc_slice_from_copied_buffer(expect_bytes, expect_length); + grpc_slice expect = + grpc_slice_from_copied_buffer(expect_bytes, expect_length); grpc_slice slice; gpr_log(GPR_DEBUG, "Test: 0x%08x", value); GPR_ASSERT(nbytes == expect_length); diff --git a/test/core/util/mock_endpoint.h b/test/core/util/mock_endpoint.h index 8f8d2a412d..ec7f0fcfcd 100644 --- a/test/core/util/mock_endpoint.h +++ b/test/core/util/mock_endpoint.h @@ -39,6 +39,7 @@ 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); + 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 6b572bb3c3..c016ebb536 100644 --- a/test/core/util/one_corpus_entry_fuzzer.c +++ b/test/core/util/one_corpus_entry_fuzzer.c @@ -47,7 +47,8 @@ int main(int argc, char **argv) { leak_check = false; GPR_ASSERT( GRPC_LOG_IF_ERROR("load_file", grpc_load_file(argv[1], 0, &buffer))); - LLVMFuzzerTestOneInput(GRPC_SLICE_START_PTR(buffer), GRPC_SLICE_LENGTH(buffer)); + LLVMFuzzerTestOneInput(GRPC_SLICE_START_PTR(buffer), + GRPC_SLICE_LENGTH(buffer)); grpc_slice_unref(buffer); return 0; } diff --git a/test/cpp/grpclb/grpclb_test.cc b/test/cpp/grpclb/grpclb_test.cc index a56667585f..f3cfe53bda 100644 --- a/test/cpp/grpclb/grpclb_test.cc +++ b/test/cpp/grpclb/grpclb_test.cc @@ -456,7 +456,8 @@ static void perform_request(client_fixture *cf) { int i; memset(ops, 0, sizeof(ops)); - grpc_slice request_payload_slice = grpc_slice_from_copied_string("hello world"); + grpc_slice request_payload_slice = + grpc_slice_from_copied_string("hello world"); c = grpc_channel_create_call(cf->client, NULL, GRPC_PROPAGATE_DEFAULTS, cf->cq, "/foo", "foo.test.google.fr:1234", diff --git a/test/cpp/util/cli_call.cc b/test/cpp/util/cli_call.cc index 0517610f10..a02a8b2ee2 100644 --- a/test/cpp/util/cli_call.cc +++ b/test/cpp/util/cli_call.cc @@ -41,8 +41,8 @@ #include #include #include -#include #include +#include namespace grpc { namespace testing { -- cgit v1.2.3 From b2d24886196c5000cc15bb5953659ff50b09ad87 Mon Sep 17 00:00:00 2001 From: "Mark D. Roth" Date: Thu, 27 Oct 2016 15:44:07 -0700 Subject: Add grpc_channel_get_info() to C-core API. --- include/grpc/grpc.h | 4 +++ include/grpc/impl/codegen/grpc_types.h | 7 ++++++ src/core/ext/census/grpc_filter.c | 2 ++ src/core/ext/client_channel/client_channel.c | 29 +++++++++++++++++++--- .../ext/load_reporting/load_reporting_filter.c | 1 + src/core/lib/channel/channel_stack.c | 7 ++++++ src/core/lib/channel/channel_stack.h | 8 ++++++ src/core/lib/channel/compress_filter.c | 1 + src/core/lib/channel/connected_channel.c | 6 +++++ src/core/lib/channel/deadline_filter.c | 2 ++ src/core/lib/channel/http_client_filter.c | 1 + src/core/lib/channel/http_server_filter.c | 1 + src/core/lib/channel/message_size_filter.c | 1 + .../lib/security/transport/client_auth_filter.c | 1 + .../lib/security/transport/server_auth_filter.c | 1 + src/core/lib/surface/channel.c | 9 +++++++ src/core/lib/surface/lame_client.c | 5 ++++ src/core/lib/surface/server.c | 1 + test/core/client_channel/lb_policies_test.c | 16 ++++++++++++ test/core/end2end/tests/filter_call_init_fails.c | 1 + test/core/end2end/tests/filter_causes_close.c | 1 + 21 files changed, 101 insertions(+), 4 deletions(-) (limited to 'test/core/end2end/tests') diff --git a/include/grpc/grpc.h b/include/grpc/grpc.h index 587d86c98f..dbd125e57a 100644 --- a/include/grpc/grpc.h +++ b/include/grpc/grpc.h @@ -237,6 +237,10 @@ GRPCAPI struct census_context *grpc_census_call_get_context(grpc_call *call); created for. */ GRPCAPI char *grpc_channel_get_target(grpc_channel *channel); +/** Request info about the channel. */ +GRPCAPI void grpc_channel_get_info(grpc_channel *channel, + grpc_channel_info *channel_info); + /** Create a client channel to 'target'. Additional channel level configuration MAY be provided by grpc_channel_args, though the expectation is that most clients will want to simply pass NULL. See grpc_channel_args definition for diff --git a/include/grpc/impl/codegen/grpc_types.h b/include/grpc/impl/codegen/grpc_types.h index 0be7ab2ad2..0fc86b57cc 100644 --- a/include/grpc/impl/codegen/grpc_types.h +++ b/include/grpc/impl/codegen/grpc_types.h @@ -467,6 +467,13 @@ typedef struct grpc_op { } data; } grpc_op; +/** Information requested from the channel. */ +typedef struct { + /* If non-NULL, will be set to point to a string indicating the LB + * policy name. Caller takes ownership. */ + char **lb_policy_name; +} grpc_channel_info; + #ifdef __cplusplus } #endif diff --git a/src/core/ext/census/grpc_filter.c b/src/core/ext/census/grpc_filter.c index a4cf6f37bd..7ace2f671e 100644 --- a/src/core/ext/census/grpc_filter.c +++ b/src/core/ext/census/grpc_filter.c @@ -191,6 +191,7 @@ const grpc_channel_filter grpc_client_census_filter = { init_channel_elem, destroy_channel_elem, grpc_call_next_get_peer, + grpc_channel_next_get_info, "census-client"}; const grpc_channel_filter grpc_server_census_filter = { @@ -204,4 +205,5 @@ const grpc_channel_filter grpc_server_census_filter = { init_channel_elem, destroy_channel_elem, grpc_call_next_get_peer, + grpc_channel_next_get_info, "census-server"}; diff --git a/src/core/ext/client_channel/client_channel.c b/src/core/ext/client_channel/client_channel.c index 80b4f048c2..d15af0b438 100644 --- a/src/core/ext/client_channel/client_channel.c +++ b/src/core/ext/client_channel/client_channel.c @@ -39,6 +39,7 @@ #include #include +#include #include #include @@ -123,6 +124,7 @@ typedef struct client_channel_channel_data { /** mutex protecting all variables below in this data structure */ gpr_mu mu; /** currently active load balancer */ + char* lb_policy_name; grpc_lb_policy *lb_policy; /** maps method names to method_parameters structs */ grpc_mdstr_hash_table *method_params_table; @@ -223,6 +225,7 @@ static void watch_lb_policy(grpc_exec_ctx *exec_ctx, channel_data *chand, static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, grpc_error *error) { channel_data *chand = arg; + char *lb_policy_name = NULL; grpc_lb_policy *lb_policy = NULL; grpc_lb_policy *old_lb_policy; grpc_mdstr_hash_table *method_params_table = NULL; @@ -236,12 +239,11 @@ static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, lb_policy_args.client_channel_factory = chand->client_channel_factory; // Find LB policy name. - const char *lb_policy_name = NULL; const grpc_arg *channel_arg = grpc_channel_args_find(lb_policy_args.args, GRPC_ARG_LB_POLICY_NAME); if (channel_arg != NULL) { GPR_ASSERT(channel_arg->type == GRPC_ARG_STRING); - lb_policy_name = channel_arg->value.string; + lb_policy_name = gpr_strdup(channel_arg->value.string); } // Special case: If all of the addresses are balancer addresses, // assume that we should use the grpclb policy, regardless of what the @@ -265,13 +267,14 @@ static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, "addresses, no backend addresses -- forcing use of grpclb LB " "policy", lb_policy_name); + gpr_free(lb_policy_name); } - lb_policy_name = "grpclb"; + lb_policy_name = gpr_strdup("grpclb"); } } // Use pick_first if nothing was specified and we didn't select grpclb // above. - if (lb_policy_name == NULL) lb_policy_name = "pick_first"; + if (lb_policy_name == NULL) lb_policy_name = gpr_strdup("pick_first"); lb_policy = grpc_lb_policy_create(exec_ctx, lb_policy_name, &lb_policy_args); @@ -299,6 +302,10 @@ static void on_resolver_result_changed(grpc_exec_ctx *exec_ctx, void *arg, } gpr_mu_lock(&chand->mu); + if (lb_policy_name != NULL) { + gpr_free(chand->lb_policy_name); + chand->lb_policy_name = lb_policy_name; + } old_lb_policy = chand->lb_policy; chand->lb_policy = lb_policy; if (chand->method_params_table != NULL) { @@ -426,6 +433,18 @@ static void cc_start_transport_op(grpc_exec_ctx *exec_ctx, gpr_mu_unlock(&chand->mu); } +static void cc_get_channel_info(grpc_exec_ctx *exec_ctx, + grpc_channel_element *elem, + grpc_channel_info *info) { + channel_data *chand = elem->channel_data; + gpr_mu_lock(&chand->mu); + if (info->lb_policy_name != NULL) { + *info->lb_policy_name = chand->lb_policy_name == NULL + ? NULL : gpr_strdup(chand->lb_policy_name); + } + gpr_mu_unlock(&chand->mu); +} + /* Constructor for channel_data */ static void cc_init_channel_elem(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, @@ -465,6 +484,7 @@ static void cc_destroy_channel_elem(grpc_exec_ctx *exec_ctx, chand->interested_parties); GRPC_LB_POLICY_UNREF(exec_ctx, chand->lb_policy, "channel"); } + gpr_free(chand->lb_policy_name); if (chand->method_params_table != NULL) { grpc_mdstr_hash_table_unref(chand->method_params_table); } @@ -1048,6 +1068,7 @@ const grpc_channel_filter grpc_client_channel_filter = { cc_init_channel_elem, cc_destroy_channel_elem, cc_get_peer, + cc_get_channel_info, "client-channel", }; diff --git a/src/core/ext/load_reporting/load_reporting_filter.c b/src/core/ext/load_reporting/load_reporting_filter.c index eeae2400fb..b810e20bb9 100644 --- a/src/core/ext/load_reporting/load_reporting_filter.c +++ b/src/core/ext/load_reporting/load_reporting_filter.c @@ -232,4 +232,5 @@ const grpc_channel_filter grpc_load_reporting_filter = { init_channel_elem, destroy_channel_elem, grpc_call_next_get_peer, + grpc_channel_next_get_info, "load_reporting"}; diff --git a/src/core/lib/channel/channel_stack.c b/src/core/lib/channel/channel_stack.c index 2c5367901d..3370f0ef45 100644 --- a/src/core/lib/channel/channel_stack.c +++ b/src/core/lib/channel/channel_stack.c @@ -255,6 +255,13 @@ char *grpc_call_next_get_peer(grpc_exec_ctx *exec_ctx, return next_elem->filter->get_peer(exec_ctx, next_elem); } +void grpc_channel_next_get_info(grpc_exec_ctx *exec_ctx, + grpc_channel_element *elem, + grpc_channel_info *channel_info) { + grpc_channel_element *next_elem = elem + 1; + return next_elem->filter->get_channel_info(exec_ctx, next_elem, channel_info); +} + void grpc_channel_next_op(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_transport_op *op) { grpc_channel_element *next_elem = elem + 1; diff --git a/src/core/lib/channel/channel_stack.h b/src/core/lib/channel/channel_stack.h index 27f3be7b29..6fbcd87064 100644 --- a/src/core/lib/channel/channel_stack.h +++ b/src/core/lib/channel/channel_stack.h @@ -156,6 +156,10 @@ typedef struct { /* Implement grpc_call_get_peer() */ char *(*get_peer)(grpc_exec_ctx *exec_ctx, grpc_call_element *elem); + /* Implement grpc_channel_get_info() */ + void (*get_channel_info)(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, + grpc_channel_info *channel_info); + /* The name of this filter */ const char *name; } grpc_channel_filter; @@ -273,6 +277,10 @@ void grpc_channel_next_op(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_transport_op *op); /* Pass through a request to get_peer to the next child element */ char *grpc_call_next_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem); +/* Pass through a request to get_channel_info() to the next child element */ +void grpc_channel_next_get_info(grpc_exec_ctx *exec_ctx, + grpc_channel_element *elem, + grpc_channel_info *channel_info); /* Given the top element of a channel stack, get the channel stack itself */ grpc_channel_stack *grpc_channel_stack_from_top_element( diff --git a/src/core/lib/channel/compress_filter.c b/src/core/lib/channel/compress_filter.c index 0981d59f63..7968cf7e26 100644 --- a/src/core/lib/channel/compress_filter.c +++ b/src/core/lib/channel/compress_filter.c @@ -328,4 +328,5 @@ const grpc_channel_filter grpc_compress_filter = { init_channel_elem, destroy_channel_elem, grpc_call_next_get_peer, + grpc_channel_next_get_info, "compress"}; diff --git a/src/core/lib/channel/connected_channel.c b/src/core/lib/channel/connected_channel.c index 918379c845..6ae2b3b6b7 100644 --- a/src/core/lib/channel/connected_channel.c +++ b/src/core/lib/channel/connected_channel.c @@ -134,6 +134,11 @@ static char *con_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) { return grpc_transport_get_peer(exec_ctx, chand->transport); } +/* No-op. */ +static void con_get_channel_info(grpc_exec_ctx *exec_ctx, + grpc_channel_element *elem, + grpc_channel_info *channel_info) {} + static const grpc_channel_filter connected_channel_filter = { con_start_transport_stream_op, con_start_transport_op, @@ -145,6 +150,7 @@ static const grpc_channel_filter connected_channel_filter = { init_channel_elem, destroy_channel_elem, con_get_peer, + con_get_channel_info, "connected", }; diff --git a/src/core/lib/channel/deadline_filter.c b/src/core/lib/channel/deadline_filter.c index d2ea5250f6..224c823a4f 100644 --- a/src/core/lib/channel/deadline_filter.c +++ b/src/core/lib/channel/deadline_filter.c @@ -316,6 +316,7 @@ const grpc_channel_filter grpc_client_deadline_filter = { init_channel_elem, destroy_channel_elem, grpc_call_next_get_peer, + grpc_channel_next_get_info, "deadline", }; @@ -330,5 +331,6 @@ const grpc_channel_filter grpc_server_deadline_filter = { init_channel_elem, destroy_channel_elem, grpc_call_next_get_peer, + grpc_channel_next_get_info, "deadline", }; diff --git a/src/core/lib/channel/http_client_filter.c b/src/core/lib/channel/http_client_filter.c index 1dc05fb20d..b5ab4dd5ca 100644 --- a/src/core/lib/channel/http_client_filter.c +++ b/src/core/lib/channel/http_client_filter.c @@ -448,4 +448,5 @@ const grpc_channel_filter grpc_http_client_filter = { init_channel_elem, destroy_channel_elem, grpc_call_next_get_peer, + grpc_channel_next_get_info, "http-client"}; diff --git a/src/core/lib/channel/http_server_filter.c b/src/core/lib/channel/http_server_filter.c index f2221fb0fb..d02a765d0d 100644 --- a/src/core/lib/channel/http_server_filter.c +++ b/src/core/lib/channel/http_server_filter.c @@ -344,4 +344,5 @@ const grpc_channel_filter grpc_http_server_filter = { init_channel_elem, destroy_channel_elem, grpc_call_next_get_peer, + grpc_channel_next_get_info, "http-server"}; diff --git a/src/core/lib/channel/message_size_filter.c b/src/core/lib/channel/message_size_filter.c index 7dc5ae0df1..bbcd2a2145 100644 --- a/src/core/lib/channel/message_size_filter.c +++ b/src/core/lib/channel/message_size_filter.c @@ -248,4 +248,5 @@ const grpc_channel_filter grpc_message_size_filter = { init_channel_elem, destroy_channel_elem, grpc_call_next_get_peer, + grpc_channel_next_get_info, "message_size"}; diff --git a/src/core/lib/security/transport/client_auth_filter.c b/src/core/lib/security/transport/client_auth_filter.c index b366d1410f..3a96af2c69 100644 --- a/src/core/lib/security/transport/client_auth_filter.c +++ b/src/core/lib/security/transport/client_auth_filter.c @@ -351,4 +351,5 @@ const grpc_channel_filter grpc_client_auth_filter = {auth_start_transport_op, init_channel_elem, destroy_channel_elem, grpc_call_next_get_peer, + grpc_channel_next_get_info, "client-auth"}; diff --git a/src/core/lib/security/transport/server_auth_filter.c b/src/core/lib/security/transport/server_auth_filter.c index b2c6815af8..8ecc5fd088 100644 --- a/src/core/lib/security/transport/server_auth_filter.c +++ b/src/core/lib/security/transport/server_auth_filter.c @@ -278,4 +278,5 @@ const grpc_channel_filter grpc_server_auth_filter = { init_channel_elem, destroy_channel_elem, grpc_call_next_get_peer, + grpc_channel_next_get_info, "server-auth"}; diff --git a/src/core/lib/surface/channel.c b/src/core/lib/surface/channel.c index 92d783b78d..22bf85b126 100644 --- a/src/core/lib/surface/channel.c +++ b/src/core/lib/surface/channel.c @@ -175,6 +175,15 @@ char *grpc_channel_get_target(grpc_channel *channel) { return gpr_strdup(channel->target); } +void grpc_channel_get_info(grpc_channel *channel, + grpc_channel_info *channel_info) { + grpc_exec_ctx exec_ctx = GRPC_EXEC_CTX_INIT; + grpc_channel_element *elem = + grpc_channel_stack_element(CHANNEL_STACK_FROM_CHANNEL(channel), 0); + elem->filter->get_channel_info(&exec_ctx, elem, channel_info); + grpc_exec_ctx_finish(&exec_ctx); +} + static grpc_call *grpc_channel_create_call_internal( grpc_channel *channel, grpc_call *parent_call, uint32_t propagation_mask, grpc_completion_queue *cq, grpc_pollset_set *pollset_set_alternative, diff --git a/src/core/lib/surface/lame_client.c b/src/core/lib/surface/lame_client.c index d32c884e8e..6fd1dd921c 100644 --- a/src/core/lib/surface/lame_client.c +++ b/src/core/lib/surface/lame_client.c @@ -88,6 +88,10 @@ static char *lame_get_peer(grpc_exec_ctx *exec_ctx, grpc_call_element *elem) { return NULL; } +static void lame_get_channel_info(grpc_exec_ctx *exec_ctx, + grpc_channel_element *elem, + grpc_channel_info *channel_info) {} + static void lame_start_transport_op(grpc_exec_ctx *exec_ctx, grpc_channel_element *elem, grpc_transport_op *op) { @@ -140,6 +144,7 @@ const grpc_channel_filter grpc_lame_filter = { init_channel_elem, destroy_channel_elem, lame_get_peer, + lame_get_channel_info, "lame-client", }; diff --git a/src/core/lib/surface/server.c b/src/core/lib/surface/server.c index 3a90308058..914b62e176 100644 --- a/src/core/lib/surface/server.c +++ b/src/core/lib/surface/server.c @@ -965,6 +965,7 @@ const grpc_channel_filter grpc_server_top_filter = { init_channel_elem, destroy_channel_elem, grpc_call_next_get_peer, + grpc_channel_next_get_info, "server", }; diff --git a/test/core/client_channel/lb_policies_test.c b/test/core/client_channel/lb_policies_test.c index 844db5e6cb..857ba6bd52 100644 --- a/test/core/client_channel/lb_policies_test.c +++ b/test/core/client_channel/lb_policies_test.c @@ -638,6 +638,21 @@ static void test_pending_calls(size_t concurrent_calls) { test_spec_destroy(spec); } +static void test_get_channel_info() { + grpc_channel *channel = grpc_insecure_channel_create( + "test:127.0.0.1:1234?lb_policy=round_robin", NULL, NULL); + // Ensures that resolver returns. + grpc_channel_check_connectivity_state(channel, true /* try_to_connect */); + char *lb_policy_name = NULL; + grpc_channel_info channel_info; + channel_info.lb_policy_name = &lb_policy_name; + grpc_channel_get_info(channel, &channel_info); + GPR_ASSERT(lb_policy_name != NULL); + GPR_ASSERT(strcmp(lb_policy_name, "round_robin") == 0); + gpr_free(lb_policy_name); + grpc_channel_destroy(channel); +} + static void print_failed_expectations(const int *expected_connection_sequence, const int *actual_connection_sequence, const size_t expected_seq_length, @@ -933,6 +948,7 @@ int main(int argc, char **argv) { test_pending_calls(4); test_ping(); + test_get_channel_info(); grpc_exec_ctx_finish(&exec_ctx); grpc_shutdown(); diff --git a/test/core/end2end/tests/filter_call_init_fails.c b/test/core/end2end/tests/filter_call_init_fails.c index 0e5692f4c9..2f8a2a4d04 100644 --- a/test/core/end2end/tests/filter_call_init_fails.c +++ b/test/core/end2end/tests/filter_call_init_fails.c @@ -231,6 +231,7 @@ static const grpc_channel_filter test_filter = { init_channel_elem, destroy_channel_elem, grpc_call_next_get_peer, + grpc_channel_next_get_info, "filter_call_init_fails"}; /******************************************************************************* diff --git a/test/core/end2end/tests/filter_causes_close.c b/test/core/end2end/tests/filter_causes_close.c index d5eddc7330..da554142e8 100644 --- a/test/core/end2end/tests/filter_causes_close.c +++ b/test/core/end2end/tests/filter_causes_close.c @@ -258,6 +258,7 @@ static const grpc_channel_filter test_filter = { init_channel_elem, destroy_channel_elem, grpc_call_next_get_peer, + grpc_channel_next_get_info, "filter_causes_close"}; /******************************************************************************* -- cgit v1.2.3 From df1da9ffc0be338742481b4e1a5e2a20c04e3d99 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Sun, 30 Oct 2016 22:10:18 -0700 Subject: Convert validate_host_override_string into a function and rename into get_host_override_string --- test/core/end2end/end2end_nosec_tests.c | 4 ++++ test/core/end2end/end2end_tests.c | 4 ++++ test/core/end2end/end2end_tests.h | 5 ++--- test/core/end2end/tests/binary_metadata.c | 4 ++-- test/core/end2end/tests/call_creds.c | 4 ++-- test/core/end2end/tests/cancel_after_accept.c | 4 ++-- test/core/end2end/tests/cancel_after_client_done.c | 4 ++-- test/core/end2end/tests/cancel_after_invoke.c | 4 ++-- test/core/end2end/tests/cancel_before_invoke.c | 4 ++-- test/core/end2end/tests/cancel_in_a_vacuum.c | 4 ++-- test/core/end2end/tests/cancel_with_status.c | 4 ++-- test/core/end2end/tests/compressed_payload.c | 4 ++-- test/core/end2end/tests/disappearing_server.c | 4 ++-- test/core/end2end/tests/empty_batch.c | 4 ++-- test/core/end2end/tests/filter_call_init_fails.c | 4 ++-- test/core/end2end/tests/filter_causes_close.c | 4 ++-- test/core/end2end/tests/graceful_server_shutdown.c | 4 ++-- test/core/end2end/tests/high_initial_seqno.c | 4 ++-- test/core/end2end/tests/hpack_size.c | 4 ++-- test/core/end2end/tests/idempotent_request.c | 4 ++-- test/core/end2end/tests/invoke_large_request.c | 4 ++-- test/core/end2end/tests/large_metadata.c | 4 ++-- test/core/end2end/tests/load_reporting_hook.c | 4 ++-- test/core/end2end/tests/max_concurrent_streams.c | 4 ++-- test/core/end2end/tests/max_message_length.c | 4 ++-- test/core/end2end/tests/negative_deadline.c | 4 ++-- test/core/end2end/tests/network_status_change.c | 4 ++-- test/core/end2end/tests/no_logging.c | 4 ++-- test/core/end2end/tests/payload.c | 4 ++-- test/core/end2end/tests/ping_pong_streaming.c | 4 ++-- test/core/end2end/tests/registered_call.c | 4 ++-- test/core/end2end/tests/request_with_flags.c | 4 ++-- test/core/end2end/tests/request_with_payload.c | 4 ++-- test/core/end2end/tests/server_finishes_request.c | 4 ++-- test/core/end2end/tests/shutdown_finishes_calls.c | 4 ++-- test/core/end2end/tests/simple_cacheable_request.c | 4 ++-- test/core/end2end/tests/simple_delayed_request.c | 4 ++-- test/core/end2end/tests/simple_metadata.c | 4 ++-- test/core/end2end/tests/simple_request.c | 4 ++-- test/core/end2end/tests/streaming_error_response.c | 4 ++-- test/core/end2end/tests/trailing_metadata.c | 4 ++-- 41 files changed, 86 insertions(+), 79 deletions(-) (limited to 'test/core/end2end/tests') diff --git a/test/core/end2end/end2end_nosec_tests.c b/test/core/end2end/end2end_nosec_tests.c index a630262197..00ee3ef9bc 100644 --- a/test/core/end2end/end2end_nosec_tests.c +++ b/test/core/end2end/end2end_nosec_tests.c @@ -408,3 +408,7 @@ void grpc_end2end_tests(int argc, char **argv, abort(); } } + +const char *get_host_override_string(const char *str, grpc_end2end_test_config config) { + return (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER ? str : NULL); +} diff --git a/test/core/end2end/end2end_tests.c b/test/core/end2end/end2end_tests.c index 925872a71f..9ec3b6f3fa 100644 --- a/test/core/end2end/end2end_tests.c +++ b/test/core/end2end/end2end_tests.c @@ -416,3 +416,7 @@ void grpc_end2end_tests(int argc, char **argv, abort(); } } + +const char *get_host_override_string(const char *str, grpc_end2end_test_config config) { + return (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER ? str : NULL); +} diff --git a/test/core/end2end/end2end_tests.h b/test/core/end2end/end2end_tests.h index 6380b96f33..d1758063a7 100644 --- a/test/core/end2end/end2end_tests.h +++ b/test/core/end2end/end2end_tests.h @@ -47,9 +47,6 @@ typedef struct grpc_end2end_test_config grpc_end2end_test_config; #define FAIL_AUTH_CHECK_SERVER_ARG_NAME "fail_auth_check" -#define validate_host_override_string(str, config) \ - ((config).feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER ? (str) : NULL) - struct grpc_end2end_test_fixture { grpc_completion_queue *cq; grpc_server *server; @@ -72,4 +69,6 @@ struct grpc_end2end_test_config { void grpc_end2end_tests_pre_init(void); void grpc_end2end_tests(int argc, char **argv, grpc_end2end_test_config config); +const char *get_host_override_string(const char *str, grpc_end2end_test_config config); + #endif /* GRPC_TEST_CORE_END2END_END2END_TESTS_H */ diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.c index c5c862bbf2..357b182fca 100644 --- a/test/core/end2end/tests/binary_metadata.c +++ b/test/core/end2end/tests/binary_metadata.c @@ -43,7 +43,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -290,7 +290,7 @@ static void test_request_response_with_metadata_and_payload( } void binary_metadata(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); test_request_response_with_metadata_and_payload(config); } diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index ab8efa488b..ae3c3e7795 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -51,7 +51,7 @@ static const char iam_selector[] = "selector"; static const char overridden_iam_token[] = "overridden_token"; static const char overridden_iam_selector[] = "overridden_selector"; -static char *authority; +static const char *authority; typedef enum { NONE, OVERRIDE, DESTROY } override_mode; @@ -475,7 +475,7 @@ static void test_request_with_server_rejecting_client_creds( void call_creds(grpc_end2end_test_config config) { if (config.feature_mask & FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); test_request_response_with_payload_and_call_creds(config); test_request_response_with_payload_and_overridden_call_creds(config); test_request_response_with_payload_and_deleted_call_creds(config); diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index dd1d5bcf46..238e603633 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -44,7 +44,7 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -static void *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -231,7 +231,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, void cancel_after_accept(grpc_end2end_test_config config) { unsigned i; - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { test_cancel_after_accept(config, cancellation_modes[i]); } diff --git a/test/core/end2end/tests/cancel_after_client_done.c b/test/core/end2end/tests/cancel_after_client_done.c index 90a84d1d0f..91b2589441 100644 --- a/test/core/end2end/tests/cancel_after_client_done.c +++ b/test/core/end2end/tests/cancel_after_client_done.c @@ -44,7 +44,7 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -235,7 +235,7 @@ static void test_cancel_after_accept_and_writes_closed( void cancel_after_client_done(grpc_end2end_test_config config) { unsigned i; - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { test_cancel_after_accept_and_writes_closed(config, cancellation_modes[i]); } diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index 346e41edae..b10a8756d4 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -44,7 +44,7 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -194,7 +194,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, void cancel_after_invoke(grpc_end2end_test_config config) { unsigned i, j; - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); for (j = 2; j < 6; j++) { for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { test_cancel_after_invoke(config, cancellation_modes[i], j); diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c index b446264f9d..e97ddd63ca 100644 --- a/test/core/end2end/tests/cancel_before_invoke.c +++ b/test/core/end2end/tests/cancel_before_invoke.c @@ -43,7 +43,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -191,7 +191,7 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, void cancel_before_invoke(grpc_end2end_test_config config) { size_t i; - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); for (i = 1; i <= 6; i++) { test_cancel_before_invoke(config, i); } diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.c b/test/core/end2end/tests/cancel_in_a_vacuum.c index 02e5fa555d..f78d4cc891 100644 --- a/test/core/end2end/tests/cancel_in_a_vacuum.c +++ b/test/core/end2end/tests/cancel_in_a_vacuum.c @@ -44,7 +44,7 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -123,7 +123,7 @@ static void test_cancel_in_a_vacuum(grpc_end2end_test_config config, void cancel_in_a_vacuum(grpc_end2end_test_config config) { unsigned i; - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { test_cancel_in_a_vacuum(config, cancellation_modes[i]); } diff --git a/test/core/end2end/tests/cancel_with_status.c b/test/core/end2end/tests/cancel_with_status.c index 4ab4f1e92f..ebd7cb216f 100644 --- a/test/core/end2end/tests/cancel_with_status.c +++ b/test/core/end2end/tests/cancel_with_status.c @@ -45,7 +45,7 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -178,7 +178,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config, void cancel_with_status(grpc_end2end_test_config config) { size_t i; - authority = validate_host_override_string("foo.test.google.fr:1234", config); + authority = get_host_override_string("foo.test.google.fr:1234", config); for (i = 1; i <= 4; i++) { test_invoke_simple_request(config, i); } diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index 7a9d9a706b..4607940e6c 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -50,7 +50,7 @@ #include "src/core/lib/surface/call_test_only.h" #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -600,7 +600,7 @@ static void test_invoke_request_with_disabled_algorithm( } void compressed_payload(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); test_invoke_request_with_exceptionally_uncompressed_payload(config); test_invoke_request_with_uncompressed_payload(config); test_invoke_request_with_compressed_payload(config); diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c index 624e148785..a934a9e5fe 100644 --- a/test/core/end2end/tests/disappearing_server.c +++ b/test/core/end2end/tests/disappearing_server.c @@ -43,7 +43,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -213,7 +213,7 @@ static void disappearing_server_test(grpc_end2end_test_config config) { } void disappearing_server(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr:1234", config); + authority = get_host_override_string("foo.test.google.fr:1234", config); GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); disappearing_server_test(config); } diff --git a/test/core/end2end/tests/empty_batch.c b/test/core/end2end/tests/empty_batch.c index 230ee204f8..146f83b080 100644 --- a/test/core/end2end/tests/empty_batch.c +++ b/test/core/end2end/tests/empty_batch.c @@ -45,7 +45,7 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -130,7 +130,7 @@ static void test_invoke_empty_body(grpc_end2end_test_config config) { } void empty_batch(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); test_invoke_empty_body(config); } diff --git a/test/core/end2end/tests/filter_call_init_fails.c b/test/core/end2end/tests/filter_call_init_fails.c index 6569110c67..892e92e764 100644 --- a/test/core/end2end/tests/filter_call_init_fails.c +++ b/test/core/end2end/tests/filter_call_init_fails.c @@ -49,7 +49,7 @@ enum { TIMEOUT = 200000 }; -static char *authority; +static const char *authority; static bool g_enable_filter = false; @@ -265,7 +265,7 @@ static void init_plugin(void) { static void destroy_plugin(void) {} void filter_call_init_fails(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); g_enable_filter = true; test_request(config); g_enable_filter = false; diff --git a/test/core/end2end/tests/filter_causes_close.c b/test/core/end2end/tests/filter_causes_close.c index c8a94c440c..163dbf87f0 100644 --- a/test/core/end2end/tests/filter_causes_close.c +++ b/test/core/end2end/tests/filter_causes_close.c @@ -46,7 +46,7 @@ #include "src/core/lib/surface/channel_init.h" #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static bool g_enable_filter = false; @@ -284,7 +284,7 @@ static void init_plugin(void) { static void destroy_plugin(void) {} void filter_causes_close(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); g_enable_filter = true; test_request(config); g_enable_filter = false; diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c index 4c5ecb9f5c..5204c90b27 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.c +++ b/test/core/end2end/tests/graceful_server_shutdown.c @@ -43,7 +43,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -212,7 +212,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( } void graceful_server_shutdown(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); test_early_server_shutdown_finishes_inflight_calls(config); } diff --git a/test/core/end2end/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.c index 4a0d59f326..b9cfbd8b71 100644 --- a/test/core/end2end/tests/high_initial_seqno.c +++ b/test/core/end2end/tests/high_initial_seqno.c @@ -47,7 +47,7 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -241,7 +241,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config, } void high_initial_seqno(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr:1234", config); + authority = get_host_override_string("foo.test.google.fr:1234", config); test_invoke_10_simple_requests(config, 16777213); if (config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION) { test_invoke_10_simple_requests(config, 2147483645); diff --git a/test/core/end2end/tests/hpack_size.c b/test/core/end2end/tests/hpack_size.c index 80513e764c..5b23d6b1e7 100644 --- a/test/core/end2end/tests/hpack_size.c +++ b/test/core/end2end/tests/hpack_size.c @@ -47,7 +47,7 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -398,7 +398,7 @@ void hpack_size(grpc_end2end_test_config config) { 1000, 32768, 4 * 1024 * 1024}; size_t i, j; - authority = validate_host_override_string("foo.test.google.fr:1234", config); + authority = get_host_override_string("foo.test.google.fr:1234", config); for (i = 0; i < GPR_ARRAY_SIZE(interesting_sizes); i++) { for (j = 0; j < GPR_ARRAY_SIZE(interesting_sizes); j++) { test_size(config, interesting_sizes[i], interesting_sizes[j]); diff --git a/test/core/end2end/tests/idempotent_request.c b/test/core/end2end/tests/idempotent_request.c index 6582eaf034..5b02e4410a 100644 --- a/test/core/end2end/tests/idempotent_request.c +++ b/test/core/end2end/tests/idempotent_request.c @@ -45,7 +45,7 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -244,7 +244,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { void idempotent_request(grpc_end2end_test_config config) { int i; - authority = validate_host_override_string("foo.test.google.fr:1234", config); + authority = get_host_override_string("foo.test.google.fr:1234", config); for (i = 0; i < 10; i++) { test_invoke_simple_request(config); } diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index b807c94564..c55bac4830 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -44,7 +44,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -274,7 +274,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config, } void invoke_large_request(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); test_invoke_large_request(config, 16384, 65536); test_invoke_large_request(config, 32768, 65536); diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c index c0819d090a..b19b6f8b80 100644 --- a/test/core/end2end/tests/large_metadata.c +++ b/test/core/end2end/tests/large_metadata.c @@ -43,7 +43,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -257,7 +257,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { } void large_metadata(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); test_request_with_large_metadata(config); } diff --git a/test/core/end2end/tests/load_reporting_hook.c b/test/core/end2end/tests/load_reporting_hook.c index e8bbbd9725..1f353ce7c9 100644 --- a/test/core/end2end/tests/load_reporting_hook.c +++ b/test/core/end2end/tests/load_reporting_hook.c @@ -48,7 +48,7 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/transport/static_metadata.h" -static char *authority; +static const char *authority; enum { TIMEOUT = 200000 }; @@ -316,7 +316,7 @@ static void test_load_reporting_hook(grpc_end2end_test_config config) { } void load_reporting_hook(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); test_load_reporting_hook(config); } diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index c6f634c457..707be0950a 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -43,7 +43,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -441,7 +441,7 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { } void max_concurrent_streams(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr:1234", config); + authority = get_host_override_string("foo.test.google.fr:1234", config); test_max_concurrent_streams(config); } diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index eb1fc440f7..62e4cb35db 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -43,7 +43,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -397,7 +397,7 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, } void max_message_length(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr:1234", config); + authority = get_host_override_string("foo.test.google.fr:1234", config); test_max_message_length_on_request(config, false /* send_limit */); test_max_message_length_on_request(config, true /* send_limit */); test_max_message_length_on_response(config, false /* send_limit */); diff --git a/test/core/end2end/tests/negative_deadline.c b/test/core/end2end/tests/negative_deadline.c index ec45841e5f..a715c434bd 100644 --- a/test/core/end2end/tests/negative_deadline.c +++ b/test/core/end2end/tests/negative_deadline.c @@ -45,7 +45,7 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -175,7 +175,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config, void negative_deadline(grpc_end2end_test_config config) { size_t i; - authority = validate_host_override_string("foo.test.google.fr:1234", config); + authority = get_host_override_string("foo.test.google.fr:1234", config); for (i = 1; i <= 4; i++) { test_invoke_simple_request(config, i); } diff --git a/test/core/end2end/tests/network_status_change.c b/test/core/end2end/tests/network_status_change.c index 7bf003cb4a..b55bebbf0f 100644 --- a/test/core/end2end/tests/network_status_change.c +++ b/test/core/end2end/tests/network_status_change.c @@ -43,7 +43,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; /* this is a private API but exposed here for testing*/ extern void grpc_network_status_shutdown_all_endpoints(); @@ -238,7 +238,7 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) { } void network_status_change(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); test_invoke_network_status_change(config); } diff --git a/test/core/end2end/tests/no_logging.c b/test/core/end2end/tests/no_logging.c index 0ddb4a5a05..e299abe599 100644 --- a/test/core/end2end/tests/no_logging.c +++ b/test/core/end2end/tests/no_logging.c @@ -47,7 +47,7 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; enum { TIMEOUT = 200000 }; @@ -296,7 +296,7 @@ static void test_no_logging_in_one_request(grpc_end2end_test_config config) { } void no_logging(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr:1234", config); + authority = get_host_override_string("foo.test.google.fr:1234", config); gpr_set_log_function(log_dispatcher_func); test_no_logging_in_one_request(config); test_no_error_logging_in_entire_process(config); diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c index 292a92eeb8..9d593617ed 100644 --- a/test/core/end2end/tests/payload.c +++ b/test/core/end2end/tests/payload.c @@ -43,7 +43,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -270,7 +270,7 @@ static void test_invoke_10_request_response_with_payload( } void payload(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); test_invoke_request_response_with_payload(config); test_invoke_10_request_response_with_payload(config); } diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index 46fa0063f3..f53a288890 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -43,7 +43,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -277,7 +277,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, void ping_pong_streaming(grpc_end2end_test_config config) { int i; - authority = validate_host_override_string("foo.test.google.fr:1234", config); + authority = get_host_override_string("foo.test.google.fr:1234", config); for (i = 1; i < 10; i++) { test_pingpong_streaming(config, i); } diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c index d710b9e56f..fd1557a5d9 100644 --- a/test/core/end2end/tests/registered_call.c +++ b/test/core/end2end/tests/registered_call.c @@ -45,7 +45,7 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -230,7 +230,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { } void registered_call(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr:1234", config); + authority = get_host_override_string("foo.test.google.fr:1234", config); test_invoke_simple_request(config); test_invoke_10_simple_requests(config); } diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c index 623def9fd3..1ef0dbeb3f 100644 --- a/test/core/end2end/tests/request_with_flags.c +++ b/test/core/end2end/tests/request_with_flags.c @@ -44,7 +44,7 @@ #include "src/core/lib/transport/byte_stream.h" #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -188,7 +188,7 @@ static void test_invoke_request_with_flags( void request_with_flags(grpc_end2end_test_config config) { size_t i; - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); uint32_t flags_for_op[GRPC_OP_RECV_CLOSE_ON_SERVER + 1]; { diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index a0da85496d..9cbe9869f8 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -43,7 +43,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -235,7 +235,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { } void request_with_payload(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); test_invoke_request_with_payload(config); } diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c index a824e6e1e4..a85e9d425b 100644 --- a/test/core/end2end/tests/server_finishes_request.c +++ b/test/core/end2end/tests/server_finishes_request.c @@ -45,7 +45,7 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -211,7 +211,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) { } void server_finishes_request(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr:1234", config); + authority = get_host_override_string("foo.test.google.fr:1234", config); test_invoke_simple_request(config); } diff --git a/test/core/end2end/tests/shutdown_finishes_calls.c b/test/core/end2end/tests/shutdown_finishes_calls.c index f08d0f2e10..62fe068fa9 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.c +++ b/test/core/end2end/tests/shutdown_finishes_calls.c @@ -43,7 +43,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -194,7 +194,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( } void shutdown_finishes_calls(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); test_early_server_shutdown_finishes_inflight_calls(config); } diff --git a/test/core/end2end/tests/simple_cacheable_request.c b/test/core/end2end/tests/simple_cacheable_request.c index 997177cd4a..c1fef2768c 100644 --- a/test/core/end2end/tests/simple_cacheable_request.c +++ b/test/core/end2end/tests/simple_cacheable_request.c @@ -43,7 +43,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; enum { TIMEOUT = 200000 }; @@ -274,7 +274,7 @@ static void test_cacheable_request_response_with_metadata_and_payload( } void simple_cacheable_request(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); test_cacheable_request_response_with_metadata_and_payload(config); } diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c index b21fafa845..b76a53eb68 100644 --- a/test/core/end2end/tests/simple_delayed_request.c +++ b/test/core/end2end/tests/simple_delayed_request.c @@ -43,7 +43,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -221,7 +221,7 @@ static void test_simple_delayed_request_long(grpc_end2end_test_config config) { } void simple_delayed_request(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); test_simple_delayed_request_short(config); test_simple_delayed_request_long(config); diff --git a/test/core/end2end/tests/simple_metadata.c b/test/core/end2end/tests/simple_metadata.c index a115ae665c..ede19b6a14 100644 --- a/test/core/end2end/tests/simple_metadata.c +++ b/test/core/end2end/tests/simple_metadata.c @@ -43,7 +43,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -266,7 +266,7 @@ static void test_request_response_with_metadata_and_payload( } void simple_metadata(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); test_request_response_with_metadata_and_payload(config); } diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c index 8c311d3e7a..bdda097878 100644 --- a/test/core/end2end/tests/simple_request.c +++ b/test/core/end2end/tests/simple_request.c @@ -45,7 +45,7 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -244,7 +244,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { void simple_request(grpc_end2end_test_config config) { int i; - authority = validate_host_override_string("foo.test.google.fr:1234", config); + authority = get_host_override_string("foo.test.google.fr:1234", config); for (i = 0; i < 10; i++) { test_invoke_simple_request(config); } diff --git a/test/core/end2end/tests/streaming_error_response.c b/test/core/end2end/tests/streaming_error_response.c index 13b7a372dd..2eaa4a4d1b 100644 --- a/test/core/end2end/tests/streaming_error_response.c +++ b/test/core/end2end/tests/streaming_error_response.c @@ -43,7 +43,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -273,7 +273,7 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { } void streaming_error_response(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); test(config, false); test(config, true); } diff --git a/test/core/end2end/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.c index 11af60ffdd..892a424777 100644 --- a/test/core/end2end/tests/trailing_metadata.c +++ b/test/core/end2end/tests/trailing_metadata.c @@ -43,7 +43,7 @@ #include #include "test/core/end2end/cq_verifier.h" -static char *authority; +static const char *authority; static void *tag(intptr_t t) { return (void *)t; } @@ -271,7 +271,7 @@ static void test_request_response_with_metadata_and_payload( } void trailing_metadata(grpc_end2end_test_config config) { - authority = validate_host_override_string("foo.test.google.fr", config); + authority = get_host_override_string("foo.test.google.fr", config); test_request_response_with_metadata_and_payload(config); } -- cgit v1.2.3 From 56456c38e070aa07bbef7748b46cacfae5d3c671 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Sun, 30 Oct 2016 23:11:11 -0700 Subject: Use get_host_override_string function inline --- test/core/end2end/tests/binary_metadata.c | 5 +---- test/core/end2end/tests/call_creds.c | 7 ++----- test/core/end2end/tests/cancel_after_accept.c | 5 +---- test/core/end2end/tests/cancel_after_client_done.c | 5 +---- test/core/end2end/tests/cancel_after_invoke.c | 5 +---- test/core/end2end/tests/cancel_before_invoke.c | 5 +---- test/core/end2end/tests/cancel_in_a_vacuum.c | 5 +---- test/core/end2end/tests/cancel_with_status.c | 9 +++------ test/core/end2end/tests/compressed_payload.c | 7 ++----- test/core/end2end/tests/disappearing_server.c | 12 +++++------- test/core/end2end/tests/empty_batch.c | 10 ++++------ test/core/end2end/tests/filter_call_init_fails.c | 5 +---- test/core/end2end/tests/filter_causes_close.c | 5 +---- test/core/end2end/tests/graceful_server_shutdown.c | 5 +---- test/core/end2end/tests/high_initial_seqno.c | 10 ++++------ test/core/end2end/tests/hpack_size.c | 9 +++------ test/core/end2end/tests/idempotent_request.c | 11 ++++------- test/core/end2end/tests/invoke_large_request.c | 5 +---- test/core/end2end/tests/large_metadata.c | 5 +---- test/core/end2end/tests/load_reporting_hook.c | 11 ++++------- test/core/end2end/tests/max_concurrent_streams.c | 16 +++++++--------- test/core/end2end/tests/max_message_length.c | 5 +---- test/core/end2end/tests/negative_deadline.c | 9 +++------ test/core/end2end/tests/network_status_change.c | 5 +---- test/core/end2end/tests/no_logging.c | 17 +++++++---------- test/core/end2end/tests/payload.c | 11 ++++------- test/core/end2end/tests/ping_pong_streaming.c | 5 +---- test/core/end2end/tests/registered_call.c | 7 ++----- test/core/end2end/tests/request_with_flags.c | 5 +---- test/core/end2end/tests/request_with_payload.c | 5 +---- test/core/end2end/tests/server_finishes_request.c | 9 +++------ test/core/end2end/tests/shutdown_finishes_calls.c | 5 +---- test/core/end2end/tests/simple_cacheable_request.c | 5 +---- test/core/end2end/tests/simple_delayed_request.c | 5 +---- test/core/end2end/tests/simple_metadata.c | 5 +---- test/core/end2end/tests/simple_request.c | 11 ++++------- test/core/end2end/tests/streaming_error_response.c | 5 +---- test/core/end2end/tests/trailing_metadata.c | 5 +---- 38 files changed, 83 insertions(+), 193 deletions(-) (limited to 'test/core/end2end/tests') diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.c index 357b182fca..f2038d7cbc 100644 --- a/test/core/end2end/tests/binary_metadata.c +++ b/test/core/end2end/tests/binary_metadata.c @@ -43,8 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -149,7 +147,7 @@ static void test_request_response_with_metadata_and_payload( int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -290,7 +288,6 @@ static void test_request_response_with_metadata_and_payload( } void binary_metadata(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); test_request_response_with_metadata_and_payload(config); } diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index ae3c3e7795..027c5fdfd5 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -51,8 +51,6 @@ static const char iam_selector[] = "selector"; static const char overridden_iam_token[] = "overridden_token"; static const char overridden_iam_selector[] = "overridden_selector"; -static const char *authority; - typedef enum { NONE, OVERRIDE, DESTROY } override_mode; static void *tag(intptr_t t) { return (void *)t; } @@ -167,7 +165,7 @@ static void request_response_with_payload_and_call_creds( cqv = cq_verifier_create(f.cq); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); creds = grpc_google_iam_credentials_create(iam_token, iam_selector, NULL); GPR_ASSERT(creds != NULL); @@ -402,7 +400,7 @@ static void test_request_with_server_rejecting_client_creds( cqv = cq_verifier_create(f.cq); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); creds = grpc_google_iam_credentials_create(iam_token, iam_selector, NULL); @@ -475,7 +473,6 @@ static void test_request_with_server_rejecting_client_creds( void call_creds(grpc_end2end_test_config config) { if (config.feature_mask & FEATURE_MASK_SUPPORTS_PER_CALL_CREDENTIALS) { - authority = get_host_override_string("foo.test.google.fr", config); test_request_response_with_payload_and_call_creds(config); test_request_response_with_payload_and_overridden_call_creds(config); test_request_response_with_payload_and_deleted_call_creds(config); diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index 238e603633..010ad08812 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -44,8 +44,6 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -128,7 +126,7 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -231,7 +229,6 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, void cancel_after_accept(grpc_end2end_test_config config) { unsigned i; - authority = get_host_override_string("foo.test.google.fr", config); for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { test_cancel_after_accept(config, cancellation_modes[i]); } diff --git a/test/core/end2end/tests/cancel_after_client_done.c b/test/core/end2end/tests/cancel_after_client_done.c index 91b2589441..7644658b19 100644 --- a/test/core/end2end/tests/cancel_after_client_done.c +++ b/test/core/end2end/tests/cancel_after_client_done.c @@ -44,8 +44,6 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -128,7 +126,7 @@ static void test_cancel_after_accept_and_writes_closed( int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -235,7 +233,6 @@ static void test_cancel_after_accept_and_writes_closed( void cancel_after_client_done(grpc_end2end_test_config config) { unsigned i; - authority = get_host_override_string("foo.test.google.fr", config); for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { test_cancel_after_accept_and_writes_closed(config, cancellation_modes[i]); } diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index b10a8756d4..1628f0d560 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -44,8 +44,6 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -123,7 +121,7 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, grpc_raw_byte_buffer_create(&request_payload_slice, 1); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -194,7 +192,6 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, void cancel_after_invoke(grpc_end2end_test_config config) { unsigned i, j; - authority = get_host_override_string("foo.test.google.fr", config); for (j = 2; j < 6; j++) { for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { test_cancel_after_invoke(config, cancellation_modes[i], j); diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c index e97ddd63ca..7e1d4ca1fb 100644 --- a/test/core/end2end/tests/cancel_before_invoke.c +++ b/test/core/end2end/tests/cancel_before_invoke.c @@ -43,8 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -121,7 +119,7 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, grpc_raw_byte_buffer_create(&request_payload_slice, 1); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); GPR_ASSERT(GRPC_CALL_OK == grpc_call_cancel(c, NULL)); @@ -191,7 +189,6 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, void cancel_before_invoke(grpc_end2end_test_config config) { size_t i; - authority = get_host_override_string("foo.test.google.fr", config); for (i = 1; i <= 6; i++) { test_cancel_before_invoke(config, i); } diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.c b/test/core/end2end/tests/cancel_in_a_vacuum.c index f78d4cc891..780d693ac5 100644 --- a/test/core/end2end/tests/cancel_in_a_vacuum.c +++ b/test/core/end2end/tests/cancel_in_a_vacuum.c @@ -44,8 +44,6 @@ #include "test/core/end2end/cq_verifier.h" #include "test/core/end2end/tests/cancel_test_helpers.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -108,7 +106,7 @@ static void test_cancel_in_a_vacuum(grpc_end2end_test_config config, cq_verifier *v_client = cq_verifier_create(f.cq); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL)); @@ -123,7 +121,6 @@ static void test_cancel_in_a_vacuum(grpc_end2end_test_config config, void cancel_in_a_vacuum(grpc_end2end_test_config config) { unsigned i; - authority = get_host_override_string("foo.test.google.fr", config); for (i = 0; i < GPR_ARRAY_SIZE(cancellation_modes); i++) { test_cancel_in_a_vacuum(config, cancellation_modes[i]); } diff --git a/test/core/end2end/tests/cancel_with_status.c b/test/core/end2end/tests/cancel_with_status.c index ebd7cb216f..15de1eaaf7 100644 --- a/test/core/end2end/tests/cancel_with_status.c +++ b/test/core/end2end/tests/cancel_with_status.c @@ -45,8 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -99,7 +97,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) { +static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f, size_t num_ops) { grpc_call *c; gpr_timespec deadline = five_seconds_time(); cq_verifier *cqv = cq_verifier_create(f.cq); @@ -115,7 +113,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) { gpr_log(GPR_DEBUG, "test with %" PRIuPTR " ops", num_ops); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -171,14 +169,13 @@ static void test_invoke_simple_request(grpc_end2end_test_config config, grpc_end2end_test_fixture f; f = begin_test(config, "test_invoke_simple_request", NULL, NULL); - simple_request_body(f, num_ops); + simple_request_body(config, f, num_ops); end_test(&f); config.tear_down_data(&f); } void cancel_with_status(grpc_end2end_test_config config) { size_t i; - authority = get_host_override_string("foo.test.google.fr:1234", config); for (i = 1; i <= 4; i++) { test_invoke_simple_request(config, i); } diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index 4607940e6c..5925ce7b81 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -50,8 +50,6 @@ #include "src/core/lib/surface/call_test_only.h" #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -149,7 +147,7 @@ static void request_for_disabled_algorithm( cqv = cq_verifier_create(f.cq); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -323,7 +321,7 @@ static void request_with_payload_template( cqv = cq_verifier_create(f.cq); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -600,7 +598,6 @@ static void test_invoke_request_with_disabled_algorithm( } void compressed_payload(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); test_invoke_request_with_exceptionally_uncompressed_payload(config); test_invoke_request_with_uncompressed_payload(config); test_invoke_request_with_compressed_payload(config); diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c index a934a9e5fe..6b32b36d2c 100644 --- a/test/core/end2end/tests/disappearing_server.c +++ b/test/core/end2end/tests/disappearing_server.c @@ -43,8 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static gpr_timespec n_seconds_time(int n) { @@ -81,7 +79,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f, +static void do_request_and_shutdown_server(grpc_end2end_test_config config, + grpc_end2end_test_fixture *f, cq_verifier *cqv) { grpc_call *c; grpc_call *s; @@ -99,7 +98,7 @@ static void do_request_and_shutdown_server(grpc_end2end_test_fixture *f, int was_cancelled = 2; c = grpc_channel_create_call(f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -199,12 +198,12 @@ static void disappearing_server_test(grpc_end2end_test_config config) { config.init_client(&f, NULL); config.init_server(&f, NULL); - do_request_and_shutdown_server(&f, cqv); + do_request_and_shutdown_server(config, &f, cqv); /* now destroy and recreate the server */ config.init_server(&f, NULL); - do_request_and_shutdown_server(&f, cqv); + do_request_and_shutdown_server(config, &f, cqv); cq_verifier_destroy(cqv); @@ -213,7 +212,6 @@ static void disappearing_server_test(grpc_end2end_test_config config) { } void disappearing_server(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr:1234", config); GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); disappearing_server_test(config); } diff --git a/test/core/end2end/tests/empty_batch.c b/test/core/end2end/tests/empty_batch.c index 146f83b080..580cbac67d 100644 --- a/test/core/end2end/tests/empty_batch.c +++ b/test/core/end2end/tests/empty_batch.c @@ -45,8 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -99,7 +97,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void empty_batch_body(grpc_end2end_test_fixture f) { +static void empty_batch_body(grpc_end2end_test_config config, + grpc_end2end_test_fixture f) { grpc_call *c; gpr_timespec deadline = five_seconds_time(); cq_verifier *cqv = cq_verifier_create(f.cq); @@ -107,7 +106,7 @@ static void empty_batch_body(grpc_end2end_test_fixture f) { grpc_op *op = NULL; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); error = grpc_call_start_batch(c, op, 0, tag(1), NULL); @@ -124,13 +123,12 @@ static void test_invoke_empty_body(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; f = begin_test(config, "test_invoke_empty_body", NULL, NULL); - empty_batch_body(f); + empty_batch_body(config, f); end_test(&f); config.tear_down_data(&f); } void empty_batch(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); test_invoke_empty_body(config); } diff --git a/test/core/end2end/tests/filter_call_init_fails.c b/test/core/end2end/tests/filter_call_init_fails.c index 892e92e764..4255e75814 100644 --- a/test/core/end2end/tests/filter_call_init_fails.c +++ b/test/core/end2end/tests/filter_call_init_fails.c @@ -49,8 +49,6 @@ enum { TIMEOUT = 200000 }; -static const char *authority; - static bool g_enable_filter = false; static void *tag(intptr_t t) { return (void *)t; } @@ -130,7 +128,7 @@ static void test_request(grpc_end2end_test_config config) { size_t details_capacity = 0; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -265,7 +263,6 @@ static void init_plugin(void) { static void destroy_plugin(void) {} void filter_call_init_fails(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); g_enable_filter = true; test_request(config); g_enable_filter = false; diff --git a/test/core/end2end/tests/filter_causes_close.c b/test/core/end2end/tests/filter_causes_close.c index 163dbf87f0..210c464cf1 100644 --- a/test/core/end2end/tests/filter_causes_close.c +++ b/test/core/end2end/tests/filter_causes_close.c @@ -46,8 +46,6 @@ #include "src/core/lib/surface/channel_init.h" #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static bool g_enable_filter = false; static void *tag(intptr_t t) { return (void *)t; } @@ -126,7 +124,7 @@ static void test_request(grpc_end2end_test_config config) { size_t details_capacity = 0; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -284,7 +282,6 @@ static void init_plugin(void) { static void destroy_plugin(void) {} void filter_causes_close(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); g_enable_filter = true; test_request(config); g_enable_filter = false; diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c index 5204c90b27..45892b8824 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.c +++ b/test/core/end2end/tests/graceful_server_shutdown.c @@ -43,8 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -114,7 +112,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -212,7 +210,6 @@ static void test_early_server_shutdown_finishes_inflight_calls( } void graceful_server_shutdown(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); test_early_server_shutdown_finishes_inflight_calls(config); } diff --git a/test/core/end2end/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.c index b9cfbd8b71..96d58d4787 100644 --- a/test/core/end2end/tests/high_initial_seqno.c +++ b/test/core/end2end/tests/high_initial_seqno.c @@ -47,8 +47,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -101,7 +99,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_fixture f) { +static void simple_request_body(grpc_end2end_test_config config, + grpc_end2end_test_fixture f) { grpc_call *c; grpc_call *s; gpr_timespec deadline = five_seconds_time(); @@ -119,7 +118,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -232,7 +231,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config, initial_sequence_number); f = begin_test(config, name, &client_args, NULL); for (i = 0; i < 10; i++) { - simple_request_body(f); + simple_request_body(config, f); gpr_log(GPR_INFO, "Passed simple request %d", i); } end_test(&f); @@ -241,7 +240,6 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config, } void high_initial_seqno(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr:1234", config); test_invoke_10_simple_requests(config, 16777213); if (config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION) { test_invoke_10_simple_requests(config, 2147483645); diff --git a/test/core/end2end/tests/hpack_size.c b/test/core/end2end/tests/hpack_size.c index 5b23d6b1e7..c400134e1f 100644 --- a/test/core/end2end/tests/hpack_size.c +++ b/test/core/end2end/tests/hpack_size.c @@ -47,8 +47,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } const char *hobbits[][2] = { @@ -241,7 +239,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_fixture f, size_t index) { +static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f, size_t index) { grpc_call *c; grpc_call *s; gpr_timespec deadline = five_seconds_time(); @@ -271,7 +269,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t index) { extra_metadata[2].value_length = strlen(extra_metadata[2].value); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -386,7 +384,7 @@ static void test_size(grpc_end2end_test_config config, int encode_size, f = begin_test(config, name, encode_size != 4096 ? &client_args : NULL, decode_size != 4096 ? &server_args : NULL); for (i = 0; i < 4 * GPR_ARRAY_SIZE(hobbits); i++) { - simple_request_body(f, i); + simple_request_body(config, f, i); } end_test(&f); config.tear_down_data(&f); @@ -398,7 +396,6 @@ void hpack_size(grpc_end2end_test_config config) { 1000, 32768, 4 * 1024 * 1024}; size_t i, j; - authority = get_host_override_string("foo.test.google.fr:1234", config); for (i = 0; i < GPR_ARRAY_SIZE(interesting_sizes); i++) { for (j = 0; j < GPR_ARRAY_SIZE(interesting_sizes); j++) { test_size(config, interesting_sizes[i], interesting_sizes[j]); diff --git a/test/core/end2end/tests/idempotent_request.c b/test/core/end2end/tests/idempotent_request.c index 5b02e4410a..bbde35b5df 100644 --- a/test/core/end2end/tests/idempotent_request.c +++ b/test/core/end2end/tests/idempotent_request.c @@ -45,8 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -99,7 +97,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_fixture f) { +static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { grpc_call *c; grpc_call *s; gpr_timespec deadline = five_seconds_time(); @@ -118,7 +116,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { char *peer; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); peer = grpc_call_get_peer(c); @@ -225,7 +223,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; f = begin_test(config, "test_invoke_simple_request", NULL, NULL); - simple_request_body(f); + simple_request_body(config, f); end_test(&f); config.tear_down_data(&f); } @@ -235,7 +233,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { grpc_end2end_test_fixture f = begin_test(config, "test_invoke_10_simple_requests", NULL, NULL); for (i = 0; i < 10; i++) { - simple_request_body(f); + simple_request_body(config, f); gpr_log(GPR_INFO, "Passed simple request %d", i); } end_test(&f); @@ -244,7 +242,6 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { void idempotent_request(grpc_end2end_test_config config) { int i; - authority = get_host_override_string("foo.test.google.fr:1234", config); for (i = 0; i < 10; i++) { test_invoke_simple_request(config); } diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index c55bac4830..67dc2c8f0a 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -44,8 +44,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -147,7 +145,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config, int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -274,7 +272,6 @@ static void test_invoke_large_request(grpc_end2end_test_config config, } void invoke_large_request(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); test_invoke_large_request(config, 16384, 65536); test_invoke_large_request(config, 32768, 65536); diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c index b19b6f8b80..618e849770 100644 --- a/test/core/end2end/tests/large_metadata.c +++ b/test/core/end2end/tests/large_metadata.c @@ -43,8 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -128,7 +126,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); meta.key = "key"; @@ -257,7 +255,6 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { } void large_metadata(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); test_request_with_large_metadata(config); } diff --git a/test/core/end2end/tests/load_reporting_hook.c b/test/core/end2end/tests/load_reporting_hook.c index 1f353ce7c9..652eedf717 100644 --- a/test/core/end2end/tests/load_reporting_hook.c +++ b/test/core/end2end/tests/load_reporting_hook.c @@ -48,8 +48,6 @@ #include "src/core/lib/channel/channel_args.h" #include "src/core/lib/transport/static_metadata.h" -static const char *authority; - enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } @@ -123,7 +121,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void request_response_with_payload(grpc_end2end_test_fixture f, +static void request_response_with_payload(grpc_end2end_test_config config, + grpc_end2end_test_fixture f, const char *method_name, const char *request_msg, const char *response_msg, @@ -154,7 +153,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f, int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - method_name, authority, deadline, NULL); + method_name, get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -308,15 +307,13 @@ static void test_load_reporting_hook(grpc_end2end_test_config config) { memset(&trailing_lr_metadata.internal_data, 0, sizeof(trailing_lr_metadata.internal_data)); - request_response_with_payload(f, method_name, request_msg, response_msg, - &initial_lr_metadata, &trailing_lr_metadata); + request_response_with_payload(config, f, method_name, request_msg, response_msg, &initial_lr_metadata, &trailing_lr_metadata); end_test(&f); grpc_channel_args_destroy(lr_server_args); config.tear_down_data(&f); } void load_reporting_hook(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); test_load_reporting_hook(config); } diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index 707be0950a..78c0237a66 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -43,8 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -97,7 +95,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_fixture f) { +static void simple_request_body(grpc_end2end_test_config config, + grpc_end2end_test_fixture f) { grpc_call *c; grpc_call *s; gpr_timespec deadline = five_seconds_time(); @@ -115,7 +114,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -253,18 +252,18 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { /* perform a ping-pong to ensure that settings have had a chance to round trip */ - simple_request_body(f); + simple_request_body(config, f); /* perform another one to make sure that the one stream case still works */ - simple_request_body(f); + simple_request_body(config, f); /* start two requests - ensuring that the second is not accepted until the first completes */ deadline = n_seconds_time(1000); c1 = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/alpha", authority, deadline, NULL); + "/alpha", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c1); c2 = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/beta", authority, deadline, NULL); + "/beta", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c2); GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( @@ -441,7 +440,6 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { } void max_concurrent_streams(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr:1234", config); test_max_concurrent_streams(config); } diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index 62e4cb35db..c98f52fed8 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -43,8 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -143,7 +141,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, cqv = cq_verifier_create(f.cq); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, + "/foo", get_host_override_string("foo.test.google.fr:1234", config), gpr_inf_future(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(c); @@ -397,7 +395,6 @@ static void test_max_message_length_on_response(grpc_end2end_test_config config, } void max_message_length(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr:1234", config); test_max_message_length_on_request(config, false /* send_limit */); test_max_message_length_on_request(config, true /* send_limit */); test_max_message_length_on_response(config, false /* send_limit */); diff --git a/test/core/end2end/tests/negative_deadline.c b/test/core/end2end/tests/negative_deadline.c index a715c434bd..62490608fb 100644 --- a/test/core/end2end/tests/negative_deadline.c +++ b/test/core/end2end/tests/negative_deadline.c @@ -45,8 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -99,7 +97,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) { +static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f, size_t num_ops) { grpc_call *c; gpr_timespec deadline = gpr_inf_past(GPR_CLOCK_REALTIME); cq_verifier *cqv = cq_verifier_create(f.cq); @@ -115,7 +113,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, size_t num_ops) { gpr_log(GPR_DEBUG, "test with %" PRIuPTR " ops", num_ops); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -168,14 +166,13 @@ static void test_invoke_simple_request(grpc_end2end_test_config config, grpc_end2end_test_fixture f; f = begin_test(config, "test_invoke_simple_request", NULL, NULL); - simple_request_body(f, num_ops); + simple_request_body(config, f, num_ops); end_test(&f); config.tear_down_data(&f); } void negative_deadline(grpc_end2end_test_config config) { size_t i; - authority = get_host_override_string("foo.test.google.fr:1234", config); for (i = 1; i <= 4; i++) { test_invoke_simple_request(config, i); } diff --git a/test/core/end2end/tests/network_status_change.c b/test/core/end2end/tests/network_status_change.c index b55bebbf0f..bf02e6a9fc 100644 --- a/test/core/end2end/tests/network_status_change.c +++ b/test/core/end2end/tests/network_status_change.c @@ -43,8 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - /* this is a private API but exposed here for testing*/ extern void grpc_network_status_shutdown_all_endpoints(); @@ -125,7 +123,7 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -238,7 +236,6 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) { } void network_status_change(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); test_invoke_network_status_change(config); } diff --git a/test/core/end2end/tests/no_logging.c b/test/core/end2end/tests/no_logging.c index e299abe599..99f2b46686 100644 --- a/test/core/end2end/tests/no_logging.c +++ b/test/core/end2end/tests/no_logging.c @@ -47,8 +47,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static const char *authority; - enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } @@ -127,7 +125,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_fixture f) { +static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { grpc_call *c; grpc_call *s; gpr_timespec deadline = five_seconds_time(); @@ -146,7 +144,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { char *peer; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); peer = grpc_call_get_peer(c); @@ -251,7 +249,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) { f = begin_test(config, "test_invoke_simple_request_with_no_error_logging", NULL, NULL); - simple_request_body(f); + simple_request_body(config, f); end_test(&f); config.tear_down_data(&f); } @@ -262,10 +260,10 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { begin_test(config, "test_invoke_10_simple_requests_with_no_error_logging", NULL, NULL); for (i = 0; i < 10; i++) { - simple_request_body(f); + simple_request_body(config, f); gpr_log(GPR_INFO, "Passed simple request %d", i); } - simple_request_body(f); + simple_request_body(config, f); end_test(&f); config.tear_down_data(&f); } @@ -286,17 +284,16 @@ static void test_no_logging_in_one_request(grpc_end2end_test_config config) { grpc_end2end_test_fixture f = begin_test(config, "test_no_logging_in_last_request", NULL, NULL); for (i = 0; i < 10; i++) { - simple_request_body(f); + simple_request_body(config, f); } gpr_atm_no_barrier_store(&g_log_func, (gpr_atm)test_no_log); - simple_request_body(f); + simple_request_body(config, f); gpr_atm_no_barrier_store(&g_log_func, (gpr_atm)gpr_default_log); end_test(&f); config.tear_down_data(&f); } void no_logging(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr:1234", config); gpr_set_log_function(log_dispatcher_func); test_no_logging_in_one_request(config); test_no_error_logging_in_entire_process(config); diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c index 9d593617ed..96a565db5a 100644 --- a/test/core/end2end/tests/payload.c +++ b/test/core/end2end/tests/payload.c @@ -43,8 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -97,7 +95,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void request_response_with_payload(grpc_end2end_test_fixture f) { +static void request_response_with_payload(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); grpc_call *c; @@ -123,7 +121,7 @@ static void request_response_with_payload(grpc_end2end_test_fixture f) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -252,7 +250,7 @@ static void test_invoke_request_response_with_payload( grpc_end2end_test_config config) { grpc_end2end_test_fixture f = begin_test( config, "test_invoke_request_response_with_payload", NULL, NULL); - request_response_with_payload(f); + request_response_with_payload(config, f); end_test(&f); config.tear_down_data(&f); } @@ -263,14 +261,13 @@ static void test_invoke_10_request_response_with_payload( grpc_end2end_test_fixture f = begin_test( config, "test_invoke_10_request_response_with_payload", NULL, NULL); for (i = 0; i < 10; i++) { - request_response_with_payload(f); + request_response_with_payload(config, f); } end_test(&f); config.tear_down_data(&f); } void payload(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); test_invoke_request_response_with_payload(config); test_invoke_10_request_response_with_payload(config); } diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index f53a288890..a33ce5f862 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -43,8 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -126,7 +124,7 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -277,7 +275,6 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, void ping_pong_streaming(grpc_end2end_test_config config) { int i; - authority = get_host_override_string("foo.test.google.fr:1234", config); for (i = 1; i < 10; i++) { test_pingpong_streaming(config, i); } diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c index fd1557a5d9..05582f9682 100644 --- a/test/core/end2end/tests/registered_call.c +++ b/test/core/end2end/tests/registered_call.c @@ -45,8 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -208,7 +206,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) { static void test_invoke_simple_request(grpc_end2end_test_config config) { grpc_end2end_test_fixture f = begin_test(config, "test_invoke_simple_request", NULL, NULL); - void *rc = grpc_channel_register_call(f.client, "/foo", authority, NULL); + void *rc = grpc_channel_register_call(f.client, "/foo", get_host_override_string("foo.test.google.fr:1234", config), NULL); simple_request_body(f, rc); end_test(&f); @@ -219,7 +217,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { int i; grpc_end2end_test_fixture f = begin_test(config, "test_invoke_10_simple_requests", NULL, NULL); - void *rc = grpc_channel_register_call(f.client, "/foo", authority, NULL); + void *rc = grpc_channel_register_call(f.client, "/foo", get_host_override_string("foo.test.google.fr:1234", config), NULL); for (i = 0; i < 10; i++) { simple_request_body(f, rc); @@ -230,7 +228,6 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { } void registered_call(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr:1234", config); test_invoke_simple_request(config); test_invoke_10_simple_requests(config); } diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c index 1ef0dbeb3f..c8489fb8c7 100644 --- a/test/core/end2end/tests/request_with_flags.c +++ b/test/core/end2end/tests/request_with_flags.c @@ -44,8 +44,6 @@ #include "src/core/lib/transport/byte_stream.h" #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -123,7 +121,7 @@ static void test_invoke_request_with_flags( grpc_call_error expectation; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -188,7 +186,6 @@ static void test_invoke_request_with_flags( void request_with_flags(grpc_end2end_test_config config) { size_t i; - authority = get_host_override_string("foo.test.google.fr", config); uint32_t flags_for_op[GRPC_OP_RECV_CLOSE_ON_SERVER + 1]; { diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index 9cbe9869f8..5755d20fe5 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -43,8 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -122,7 +120,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -235,7 +233,6 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { } void request_with_payload(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); test_invoke_request_with_payload(config); } diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c index a85e9d425b..313b0c3324 100644 --- a/test/core/end2end/tests/server_finishes_request.c +++ b/test/core/end2end/tests/server_finishes_request.c @@ -45,8 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -99,7 +97,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_fixture f) { +static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { grpc_call *c; grpc_call *s; gpr_timespec deadline = five_seconds_time(); @@ -117,7 +115,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -205,13 +203,12 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; f = begin_test(config, "test_invoke_simple_request", NULL, NULL); - simple_request_body(f); + simple_request_body(config, f); end_test(&f); config.tear_down_data(&f); } void server_finishes_request(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr:1234", config); test_invoke_simple_request(config); } diff --git a/test/core/end2end/tests/shutdown_finishes_calls.c b/test/core/end2end/tests/shutdown_finishes_calls.c index 62fe068fa9..26d61f2dcf 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.c +++ b/test/core/end2end/tests/shutdown_finishes_calls.c @@ -43,8 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -107,7 +105,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -194,7 +192,6 @@ static void test_early_server_shutdown_finishes_inflight_calls( } void shutdown_finishes_calls(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); test_early_server_shutdown_finishes_inflight_calls(config); } diff --git a/test/core/end2end/tests/simple_cacheable_request.c b/test/core/end2end/tests/simple_cacheable_request.c index c1fef2768c..166ee638b9 100644 --- a/test/core/end2end/tests/simple_cacheable_request.c +++ b/test/core/end2end/tests/simple_cacheable_request.c @@ -43,8 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - enum { TIMEOUT = 200000 }; static void *tag(intptr_t t) { return (void *)t; } @@ -136,7 +134,7 @@ static void test_cacheable_request_response_with_metadata_and_payload( int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -274,7 +272,6 @@ static void test_cacheable_request_response_with_metadata_and_payload( } void simple_cacheable_request(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); test_cacheable_request_response_with_metadata_and_payload(config); } diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c index b76a53eb68..b19c798608 100644 --- a/test/core/end2end/tests/simple_delayed_request.c +++ b/test/core/end2end/tests/simple_delayed_request.c @@ -43,8 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static gpr_timespec n_seconds_time(int n) { @@ -109,7 +107,7 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, config.init_client(f, client_args); c = grpc_channel_create_call(f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -221,7 +219,6 @@ static void test_simple_delayed_request_long(grpc_end2end_test_config config) { } void simple_delayed_request(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); GPR_ASSERT(config.feature_mask & FEATURE_MASK_SUPPORTS_DELAYED_CONNECTION); test_simple_delayed_request_short(config); test_simple_delayed_request_long(config); diff --git a/test/core/end2end/tests/simple_metadata.c b/test/core/end2end/tests/simple_metadata.c index ede19b6a14..c8370b4b15 100644 --- a/test/core/end2end/tests/simple_metadata.c +++ b/test/core/end2end/tests/simple_metadata.c @@ -43,8 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -133,7 +131,7 @@ static void test_request_response_with_metadata_and_payload( int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -266,7 +264,6 @@ static void test_request_response_with_metadata_and_payload( } void simple_metadata(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); test_request_response_with_metadata_and_payload(config); } diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c index bdda097878..a87a455a8d 100644 --- a/test/core/end2end/tests/simple_request.c +++ b/test/core/end2end/tests/simple_request.c @@ -45,8 +45,6 @@ #include "src/core/lib/support/string.h" #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -99,7 +97,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_fixture f) { +static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { grpc_call *c; grpc_call *s; gpr_timespec deadline = five_seconds_time(); @@ -118,7 +116,7 @@ static void simple_request_body(grpc_end2end_test_fixture f) { char *peer; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); peer = grpc_call_get_peer(c); @@ -225,7 +223,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) { grpc_end2end_test_fixture f; f = begin_test(config, "test_invoke_simple_request", NULL, NULL); - simple_request_body(f); + simple_request_body(config, f); end_test(&f); config.tear_down_data(&f); } @@ -235,7 +233,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { grpc_end2end_test_fixture f = begin_test(config, "test_invoke_10_simple_requests", NULL, NULL); for (i = 0; i < 10; i++) { - simple_request_body(f); + simple_request_body(config, f); gpr_log(GPR_INFO, "Passed simple request %d", i); } end_test(&f); @@ -244,7 +242,6 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { void simple_request(grpc_end2end_test_config config) { int i; - authority = get_host_override_string("foo.test.google.fr:1234", config); for (i = 0; i < 10; i++) { test_invoke_simple_request(config); } diff --git a/test/core/end2end/tests/streaming_error_response.c b/test/core/end2end/tests/streaming_error_response.c index 2eaa4a4d1b..b6167aa135 100644 --- a/test/core/end2end/tests/streaming_error_response.c +++ b/test/core/end2end/tests/streaming_error_response.c @@ -43,8 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -128,7 +126,7 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -273,7 +271,6 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { } void streaming_error_response(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); test(config, false); test(config, true); } diff --git a/test/core/end2end/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.c index 892a424777..39a90d17e1 100644 --- a/test/core/end2end/tests/trailing_metadata.c +++ b/test/core/end2end/tests/trailing_metadata.c @@ -43,8 +43,6 @@ #include #include "test/core/end2end/cq_verifier.h" -static const char *authority; - static void *tag(intptr_t t) { return (void *)t; } static grpc_end2end_test_fixture begin_test(grpc_end2end_test_config config, @@ -136,7 +134,7 @@ static void test_request_response_with_metadata_and_payload( int was_cancelled = 2; c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", authority, deadline, NULL); + "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -271,7 +269,6 @@ static void test_request_response_with_metadata_and_payload( } void trailing_metadata(grpc_end2end_test_config config) { - authority = get_host_override_string("foo.test.google.fr", config); test_request_response_with_metadata_and_payload(config); } -- cgit v1.2.3 From ea3b568b8fef498f6aeec4349702c588afe709da Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Sun, 30 Oct 2016 23:39:41 -0700 Subject: Put validation of host name in a function --- test/core/end2end/end2end_nosec_tests.c | 6 ++++++ test/core/end2end/end2end_tests.c | 6 ++++++ test/core/end2end/end2end_tests.h | 2 ++ test/core/end2end/tests/binary_metadata.c | 4 +--- test/core/end2end/tests/call_creds.c | 4 +--- test/core/end2end/tests/compressed_payload.c | 8 ++------ test/core/end2end/tests/disappearing_server.c | 4 +--- test/core/end2end/tests/graceful_server_shutdown.c | 4 +--- test/core/end2end/tests/high_initial_seqno.c | 4 +--- test/core/end2end/tests/hpack_size.c | 4 +--- test/core/end2end/tests/idempotent_request.c | 4 +--- test/core/end2end/tests/invoke_large_request.c | 4 +--- test/core/end2end/tests/large_metadata.c | 4 +--- test/core/end2end/tests/max_concurrent_streams.c | 4 +--- test/core/end2end/tests/max_message_length.c | 4 +--- test/core/end2end/tests/network_status_change.c | 4 +--- test/core/end2end/tests/no_logging.c | 4 +--- test/core/end2end/tests/payload.c | 4 +--- test/core/end2end/tests/registered_call.c | 10 ++++------ test/core/end2end/tests/request_with_payload.c | 4 +--- test/core/end2end/tests/server_finishes_request.c | 4 +--- test/core/end2end/tests/shutdown_finishes_calls.c | 4 +--- test/core/end2end/tests/simple_cacheable_request.c | 4 +--- test/core/end2end/tests/simple_delayed_request.c | 4 +--- test/core/end2end/tests/simple_metadata.c | 4 +--- test/core/end2end/tests/simple_request.c | 4 +--- test/core/end2end/tests/streaming_error_response.c | 4 +--- test/core/end2end/tests/trailing_metadata.c | 4 +--- 28 files changed, 43 insertions(+), 81 deletions(-) (limited to 'test/core/end2end/tests') diff --git a/test/core/end2end/end2end_nosec_tests.c b/test/core/end2end/end2end_nosec_tests.c index 00ee3ef9bc..4cd424f8fe 100644 --- a/test/core/end2end/end2end_nosec_tests.c +++ b/test/core/end2end/end2end_nosec_tests.c @@ -412,3 +412,9 @@ void grpc_end2end_tests(int argc, char **argv, const char *get_host_override_string(const char *str, grpc_end2end_test_config config) { return (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER ? str : NULL); } + +void validate_host_override_string(const char *pattern, const char *str, grpc_end2end_test_config config) { + if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) { + GPR_ASSERT(0 == strcmp(str, pattern)); + } +} diff --git a/test/core/end2end/end2end_tests.c b/test/core/end2end/end2end_tests.c index 9ec3b6f3fa..d779e82e33 100644 --- a/test/core/end2end/end2end_tests.c +++ b/test/core/end2end/end2end_tests.c @@ -420,3 +420,9 @@ void grpc_end2end_tests(int argc, char **argv, const char *get_host_override_string(const char *str, grpc_end2end_test_config config) { return (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER ? str : NULL); } + +void validate_host_override_string(const char *pattern, const char *str, grpc_end2end_test_config config) { + if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) { + GPR_ASSERT(0 == strcmp(str, pattern)); + } +} diff --git a/test/core/end2end/end2end_tests.h b/test/core/end2end/end2end_tests.h index d1758063a7..1e78012ed9 100644 --- a/test/core/end2end/end2end_tests.h +++ b/test/core/end2end/end2end_tests.h @@ -71,4 +71,6 @@ void grpc_end2end_tests(int argc, char **argv, grpc_end2end_test_config config); const char *get_host_override_string(const char *str, grpc_end2end_test_config config); +void validate_host_override_string(const char *pattern, const char *str, grpc_end2end_test_config config); + #endif /* GRPC_TEST_CORE_END2END_END2END_TESTS_H */ diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.c index f2038d7cbc..1629b5d023 100644 --- a/test/core/end2end/tests/binary_metadata.c +++ b/test/core/end2end/tests/binary_metadata.c @@ -248,9 +248,7 @@ static void test_request_response_with_metadata_and_payload( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index 027c5fdfd5..cb99e7454e 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -294,9 +294,7 @@ static void request_response_with_payload_and_call_creds( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index 5925ce7b81..b1869c5945 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -242,9 +242,7 @@ static void request_for_disabled_algorithm( GPR_ASSERT(0 == strcmp(details, expected_details)); gpr_free(expected_details); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); gpr_free(details); grpc_metadata_array_destroy(&initial_metadata_recv); @@ -493,9 +491,7 @@ static void request_with_payload_template( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 0); gpr_free(details); diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c index 6b32b36d2c..ba3297323e 100644 --- a/test/core/end2end/tests/disappearing_server.c +++ b/test/core/end2end/tests/disappearing_server.c @@ -174,9 +174,7 @@ static void do_request_and_shutdown_server(grpc_end2end_test_config config, GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c index 45892b8824..121e81b6f8 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.c +++ b/test/core/end2end/tests/graceful_server_shutdown.c @@ -190,9 +190,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.c index 96d58d4787..61fda409ec 100644 --- a/test/core/end2end/tests/high_initial_seqno.c +++ b/test/core/end2end/tests/high_initial_seqno.c @@ -189,9 +189,7 @@ static void simple_request_body(grpc_end2end_test_config config, GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/hpack_size.c b/test/core/end2end/tests/hpack_size.c index c400134e1f..6784e2243d 100644 --- a/test/core/end2end/tests/hpack_size.c +++ b/test/core/end2end/tests/hpack_size.c @@ -341,9 +341,7 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/idempotent_request.c b/test/core/end2end/tests/idempotent_request.c index bbde35b5df..6355405ed2 100644 --- a/test/core/end2end/tests/idempotent_request.c +++ b/test/core/end2end/tests/idempotent_request.c @@ -201,9 +201,7 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST == call_details.flags); GPR_ASSERT(was_cancelled == 1); diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index 67dc2c8f0a..927e4ac2fa 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -244,9 +244,7 @@ static void test_invoke_large_request(grpc_end2end_test_config config, GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c index 618e849770..9b139f57fd 100644 --- a/test/core/end2end/tests/large_metadata.c +++ b/test/core/end2end/tests/large_metadata.c @@ -227,9 +227,7 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); GPR_ASSERT(contains_metadata(&request_metadata_recv, "key", meta.value)); diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index 78c0237a66..2f29c9a721 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -185,9 +185,7 @@ static void simple_request_body(grpc_end2end_test_config config, GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index c98f52fed8..1a7f383a3d 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -215,9 +215,7 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, cq_verify(cqv); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); done: diff --git a/test/core/end2end/tests/network_status_change.c b/test/core/end2end/tests/network_status_change.c index bf02e6a9fc..fa64057d08 100644 --- a/test/core/end2end/tests/network_status_change.c +++ b/test/core/end2end/tests/network_status_change.c @@ -212,9 +212,7 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) { // Expected behavior of a RPC when network is lost. GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 0); gpr_free(details); diff --git a/test/core/end2end/tests/no_logging.c b/test/core/end2end/tests/no_logging.c index 99f2b46686..6e8d424429 100644 --- a/test/core/end2end/tests/no_logging.c +++ b/test/core/end2end/tests/no_logging.c @@ -226,9 +226,7 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(0 == call_details.flags); GPR_ASSERT(was_cancelled == 1); diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c index 96a565db5a..ed6f816cf0 100644 --- a/test/core/end2end/tests/payload.c +++ b/test/core/end2end/tests/payload.c @@ -220,9 +220,7 @@ static void request_response_with_payload(grpc_end2end_test_config config, grpc_ GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c index 05582f9682..c97f6e3a02 100644 --- a/test/core/end2end/tests/registered_call.c +++ b/test/core/end2end/tests/registered_call.c @@ -97,7 +97,7 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_fixture f, void *rc) { +static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f, void *rc) { grpc_call *c; grpc_call *s; gpr_timespec deadline = five_seconds_time(); @@ -186,9 +186,7 @@ static void simple_request_body(grpc_end2end_test_fixture f, void *rc) { GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); @@ -208,7 +206,7 @@ static void test_invoke_simple_request(grpc_end2end_test_config config) { begin_test(config, "test_invoke_simple_request", NULL, NULL); void *rc = grpc_channel_register_call(f.client, "/foo", get_host_override_string("foo.test.google.fr:1234", config), NULL); - simple_request_body(f, rc); + simple_request_body(config, f, rc); end_test(&f); config.tear_down_data(&f); } @@ -220,7 +218,7 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { void *rc = grpc_channel_register_call(f.client, "/foo", get_host_override_string("foo.test.google.fr:1234", config), NULL); for (i = 0; i < 10; i++) { - simple_request_body(f, rc); + simple_request_body(config, f, rc); gpr_log(GPR_INFO, "Passed simple request %d", i); } end_test(&f); diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index 5755d20fe5..0c18256549 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -208,9 +208,7 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c index 313b0c3324..e78a4aebe7 100644 --- a/test/core/end2end/tests/server_finishes_request.c +++ b/test/core/end2end/tests/server_finishes_request.c @@ -182,9 +182,7 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/shutdown_finishes_calls.c b/test/core/end2end/tests/shutdown_finishes_calls.c index 26d61f2dcf..68876d9166 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.c +++ b/test/core/end2end/tests/shutdown_finishes_calls.c @@ -171,9 +171,7 @@ static void test_early_server_shutdown_finishes_inflight_calls( GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/simple_cacheable_request.c b/test/core/end2end/tests/simple_cacheable_request.c index 166ee638b9..8c8360d8ab 100644 --- a/test/core/end2end/tests/simple_cacheable_request.c +++ b/test/core/end2end/tests/simple_cacheable_request.c @@ -235,9 +235,7 @@ static void test_cacheable_request_response_with_metadata_and_payload( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); if (config.feature_mask & FEATURE_MASK_SUPPORTS_REQUEST_PROXYING) { // Our simple proxy does not support cacheable requests } else { diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c index b19c798608..7b2c169093 100644 --- a/test/core/end2end/tests/simple_delayed_request.c +++ b/test/core/end2end/tests/simple_delayed_request.c @@ -180,9 +180,7 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/simple_metadata.c b/test/core/end2end/tests/simple_metadata.c index c8370b4b15..d618221362 100644 --- a/test/core/end2end/tests/simple_metadata.c +++ b/test/core/end2end/tests/simple_metadata.c @@ -232,9 +232,7 @@ static void test_request_response_with_metadata_and_payload( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c index a87a455a8d..4e6f32ea30 100644 --- a/test/core/end2end/tests/simple_request.c +++ b/test/core/end2end/tests/simple_request.c @@ -201,9 +201,7 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, "foo.test.google.fr:1234")); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(0 == call_details.flags); GPR_ASSERT(was_cancelled == 1); diff --git a/test/core/end2end/tests/streaming_error_response.c b/test/core/end2end/tests/streaming_error_response.c index b6167aa135..dc6228857a 100644 --- a/test/core/end2end/tests/streaming_error_response.c +++ b/test/core/end2end/tests/streaming_error_response.c @@ -245,9 +245,7 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { GPR_ASSERT(status == GRPC_STATUS_FAILED_PRECONDITION); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.c index 39a90d17e1..094fbb2d9a 100644 --- a/test/core/end2end/tests/trailing_metadata.c +++ b/test/core/end2end/tests/trailing_metadata.c @@ -236,9 +236,7 @@ static void test_request_response_with_metadata_and_payload( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - if (authority) { - GPR_ASSERT(0 == strcmp(call_details.host, authority)); - } + validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); GPR_ASSERT(contains_metadata(&request_metadata_recv, "key1", "val1")); -- cgit v1.2.3 From 5ebd327cf59cafdf129e33d5885cf31cc75ac737 Mon Sep 17 00:00:00 2001 From: Muxi Yan Date: Mon, 31 Oct 2016 07:27:07 -0700 Subject: Clean with clang-format --- test/core/end2end/end2end_nosec_tests.c | 9 ++++++--- test/core/end2end/end2end_tests.c | 9 ++++++--- test/core/end2end/end2end_tests.h | 6 ++++-- test/core/end2end/tests/binary_metadata.c | 9 ++++++--- test/core/end2end/tests/call_creds.c | 15 ++++++++++----- test/core/end2end/tests/cancel_after_accept.c | 7 ++++--- test/core/end2end/tests/cancel_after_client_done.c | 6 ++++-- test/core/end2end/tests/cancel_after_invoke.c | 6 ++++-- test/core/end2end/tests/cancel_before_invoke.c | 6 ++++-- test/core/end2end/tests/cancel_in_a_vacuum.c | 6 ++++-- test/core/end2end/tests/cancel_with_status.c | 9 ++++++--- test/core/end2end/tests/compressed_payload.c | 18 ++++++++++++------ test/core/end2end/tests/disappearing_server.c | 9 ++++++--- test/core/end2end/tests/empty_batch.c | 6 ++++-- test/core/end2end/tests/filter_call_init_fails.c | 6 ++++-- test/core/end2end/tests/filter_causes_close.c | 6 ++++-- test/core/end2end/tests/graceful_server_shutdown.c | 9 ++++++--- test/core/end2end/tests/high_initial_seqno.c | 9 ++++++--- test/core/end2end/tests/hpack_size.c | 12 ++++++++---- test/core/end2end/tests/idempotent_request.c | 12 ++++++++---- test/core/end2end/tests/invoke_large_request.c | 9 ++++++--- test/core/end2end/tests/large_metadata.c | 9 ++++++--- test/core/end2end/tests/load_reporting_hook.c | 21 +++++++++++---------- test/core/end2end/tests/max_concurrent_streams.c | 21 ++++++++++++++------- test/core/end2end/tests/max_message_length.c | 10 ++++++---- test/core/end2end/tests/negative_deadline.c | 9 ++++++--- test/core/end2end/tests/network_status_change.c | 9 ++++++--- test/core/end2end/tests/no_logging.c | 12 ++++++++---- test/core/end2end/tests/payload.c | 12 ++++++++---- test/core/end2end/tests/ping_pong_streaming.c | 6 ++++-- test/core/end2end/tests/registered_call.c | 14 ++++++++++---- test/core/end2end/tests/request_with_flags.c | 6 ++++-- test/core/end2end/tests/request_with_payload.c | 9 ++++++--- test/core/end2end/tests/server_finishes_request.c | 12 ++++++++---- test/core/end2end/tests/shutdown_finishes_calls.c | 9 ++++++--- test/core/end2end/tests/simple_cacheable_request.c | 9 ++++++--- test/core/end2end/tests/simple_delayed_request.c | 9 ++++++--- test/core/end2end/tests/simple_metadata.c | 9 ++++++--- test/core/end2end/tests/simple_request.c | 12 ++++++++---- test/core/end2end/tests/streaming_error_response.c | 9 ++++++--- test/core/end2end/tests/trailing_metadata.c | 9 ++++++--- 41 files changed, 263 insertions(+), 137 deletions(-) (limited to 'test/core/end2end/tests') diff --git a/test/core/end2end/end2end_nosec_tests.c b/test/core/end2end/end2end_nosec_tests.c index 6b24ea0308..7e9b6eb233 100644 --- a/test/core/end2end/end2end_nosec_tests.c +++ b/test/core/end2end/end2end_nosec_tests.c @@ -417,11 +417,14 @@ void grpc_end2end_tests(int argc, char **argv, } } -const char *get_host_override_string(const char *str, grpc_end2end_test_config config) { - return (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER ? str : NULL); +const char *get_host_override_string(const char *str, + grpc_end2end_test_config config) { + return (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER ? str + : NULL); } -void validate_host_override_string(const char *pattern, const char *str, grpc_end2end_test_config config) { +void validate_host_override_string(const char *pattern, const char *str, + grpc_end2end_test_config config) { if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) { GPR_ASSERT(0 == strcmp(str, pattern)); } diff --git a/test/core/end2end/end2end_tests.c b/test/core/end2end/end2end_tests.c index 5130abd098..0fbad22641 100644 --- a/test/core/end2end/end2end_tests.c +++ b/test/core/end2end/end2end_tests.c @@ -425,11 +425,14 @@ void grpc_end2end_tests(int argc, char **argv, } } -const char *get_host_override_string(const char *str, grpc_end2end_test_config config) { - return (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER ? str : NULL); +const char *get_host_override_string(const char *str, + grpc_end2end_test_config config) { + return (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER ? str + : NULL); } -void validate_host_override_string(const char *pattern, const char *str, grpc_end2end_test_config config) { +void validate_host_override_string(const char *pattern, const char *str, + grpc_end2end_test_config config) { if (config.feature_mask & FEATURE_MASK_SUPPORTS_AUTHORITY_HEADER) { GPR_ASSERT(0 == strcmp(str, pattern)); } diff --git a/test/core/end2end/end2end_tests.h b/test/core/end2end/end2end_tests.h index a6fbca0874..0124787bd0 100644 --- a/test/core/end2end/end2end_tests.h +++ b/test/core/end2end/end2end_tests.h @@ -70,8 +70,10 @@ struct grpc_end2end_test_config { void grpc_end2end_tests_pre_init(void); void grpc_end2end_tests(int argc, char **argv, grpc_end2end_test_config config); -const char *get_host_override_string(const char *str, grpc_end2end_test_config config); +const char *get_host_override_string(const char *str, + grpc_end2end_test_config config); -void validate_host_override_string(const char *pattern, const char *str, grpc_end2end_test_config config); +void validate_host_override_string(const char *pattern, const char *str, + grpc_end2end_test_config config); #endif /* GRPC_TEST_CORE_END2END_END2END_TESTS_H */ diff --git a/test/core/end2end/tests/binary_metadata.c b/test/core/end2end/tests/binary_metadata.c index 108272d296..19796bf7d2 100644 --- a/test/core/end2end/tests/binary_metadata.c +++ b/test/core/end2end/tests/binary_metadata.c @@ -146,8 +146,10 @@ static void test_request_response_with_metadata_and_payload( size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -248,7 +250,8 @@ static void test_request_response_with_metadata_and_payload( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); diff --git a/test/core/end2end/tests/call_creds.c b/test/core/end2end/tests/call_creds.c index 83dfc62c6a..a2c041b156 100644 --- a/test/core/end2end/tests/call_creds.c +++ b/test/core/end2end/tests/call_creds.c @@ -164,8 +164,10 @@ static void request_response_with_payload_and_call_creds( f = begin_test(config, test_name, 0); cqv = cq_verifier_create(f.cq); - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); creds = grpc_google_iam_credentials_create(iam_token, iam_selector, NULL); GPR_ASSERT(creds != NULL); @@ -294,7 +296,8 @@ static void request_response_with_payload_and_call_creds( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); @@ -397,8 +400,10 @@ static void test_request_with_server_rejecting_client_creds( f = begin_test(config, "test_request_with_server_rejecting_client_creds", 1); cqv = cq_verifier_create(f.cq); - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); creds = grpc_google_iam_credentials_create(iam_token, iam_selector, NULL); diff --git a/test/core/end2end/tests/cancel_after_accept.c b/test/core/end2end/tests/cancel_after_accept.c index 32aac55a92..6fd7ea2d69 100644 --- a/test/core/end2end/tests/cancel_after_accept.c +++ b/test/core/end2end/tests/cancel_after_accept.c @@ -136,9 +136,10 @@ static void test_cancel_after_accept(grpc_end2end_test_config config, begin_test(config, "cancel_after_accept", NULL, NULL, query_args); cq_verifier *cqv = cq_verifier_create(f.cq); - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/service/method", get_host_override_string("foo.test.google.fr:1234", config), - deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/service/method", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); diff --git a/test/core/end2end/tests/cancel_after_client_done.c b/test/core/end2end/tests/cancel_after_client_done.c index f6b03b03f5..8469633030 100644 --- a/test/core/end2end/tests/cancel_after_client_done.c +++ b/test/core/end2end/tests/cancel_after_client_done.c @@ -125,8 +125,10 @@ static void test_cancel_after_accept_and_writes_closed( grpc_raw_byte_buffer_create(&response_payload_slice, 1); int was_cancelled = 2; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); diff --git a/test/core/end2end/tests/cancel_after_invoke.c b/test/core/end2end/tests/cancel_after_invoke.c index 496235df1e..34bccbd57d 100644 --- a/test/core/end2end/tests/cancel_after_invoke.c +++ b/test/core/end2end/tests/cancel_after_invoke.c @@ -120,8 +120,10 @@ static void test_cancel_after_invoke(grpc_end2end_test_config config, grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); diff --git a/test/core/end2end/tests/cancel_before_invoke.c b/test/core/end2end/tests/cancel_before_invoke.c index 09049e58f0..acd10fe576 100644 --- a/test/core/end2end/tests/cancel_before_invoke.c +++ b/test/core/end2end/tests/cancel_before_invoke.c @@ -118,8 +118,10 @@ static void test_cancel_before_invoke(grpc_end2end_test_config config, grpc_byte_buffer *request_payload = grpc_raw_byte_buffer_create(&request_payload_slice, 1); - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); GPR_ASSERT(GRPC_CALL_OK == grpc_call_cancel(c, NULL)); diff --git a/test/core/end2end/tests/cancel_in_a_vacuum.c b/test/core/end2end/tests/cancel_in_a_vacuum.c index de801ca48d..f74881a592 100644 --- a/test/core/end2end/tests/cancel_in_a_vacuum.c +++ b/test/core/end2end/tests/cancel_in_a_vacuum.c @@ -105,8 +105,10 @@ static void test_cancel_in_a_vacuum(grpc_end2end_test_config config, gpr_timespec deadline = five_seconds_time(); cq_verifier *v_client = cq_verifier_create(f.cq); - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); GPR_ASSERT(GRPC_CALL_OK == mode.initiate_cancel(c, NULL)); diff --git a/test/core/end2end/tests/cancel_with_status.c b/test/core/end2end/tests/cancel_with_status.c index c50af38dc3..34075723f9 100644 --- a/test/core/end2end/tests/cancel_with_status.c +++ b/test/core/end2end/tests/cancel_with_status.c @@ -97,7 +97,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f, size_t num_ops) { +static void simple_request_body(grpc_end2end_test_config config, + grpc_end2end_test_fixture f, size_t num_ops) { grpc_call *c; gpr_timespec deadline = five_seconds_time(); cq_verifier *cqv = cq_verifier_create(f.cq); @@ -112,8 +113,10 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te gpr_log(GPR_DEBUG, "test with %" PRIuPTR " ops", num_ops); - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); diff --git a/test/core/end2end/tests/compressed_payload.c b/test/core/end2end/tests/compressed_payload.c index b249080aa2..80f4c12c4d 100644 --- a/test/core/end2end/tests/compressed_payload.c +++ b/test/core/end2end/tests/compressed_payload.c @@ -146,8 +146,10 @@ static void request_for_disabled_algorithm( f = begin_test(config, test_name, client_args, server_args); cqv = cq_verifier_create(f.cq); - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -242,7 +244,8 @@ static void request_for_disabled_algorithm( GPR_ASSERT(0 == strcmp(details, expected_details)); gpr_free(expected_details); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); gpr_free(details); grpc_metadata_array_destroy(&initial_metadata_recv); @@ -318,8 +321,10 @@ static void request_with_payload_template( f = begin_test(config, test_name, client_args, server_args); cqv = cq_verifier_create(f.cq); - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -491,7 +496,8 @@ static void request_with_payload_template( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 0); gpr_free(details); diff --git a/test/core/end2end/tests/disappearing_server.c b/test/core/end2end/tests/disappearing_server.c index 7e9273f958..838402c6ea 100644 --- a/test/core/end2end/tests/disappearing_server.c +++ b/test/core/end2end/tests/disappearing_server.c @@ -97,8 +97,10 @@ static void do_request_and_shutdown_server(grpc_end2end_test_config config, size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call(f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -174,7 +176,8 @@ static void do_request_and_shutdown_server(grpc_end2end_test_config config, GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/empty_batch.c b/test/core/end2end/tests/empty_batch.c index a482c9eab7..0a22d67f75 100644 --- a/test/core/end2end/tests/empty_batch.c +++ b/test/core/end2end/tests/empty_batch.c @@ -105,8 +105,10 @@ static void empty_batch_body(grpc_end2end_test_config config, grpc_call_error error; grpc_op *op = NULL; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); error = grpc_call_start_batch(c, op, 0, tag(1), NULL); diff --git a/test/core/end2end/tests/filter_call_init_fails.c b/test/core/end2end/tests/filter_call_init_fails.c index 21cf5180dc..0b7d212f58 100644 --- a/test/core/end2end/tests/filter_call_init_fails.c +++ b/test/core/end2end/tests/filter_call_init_fails.c @@ -127,8 +127,10 @@ static void test_request(grpc_end2end_test_config config) { char *details = NULL; size_t details_capacity = 0; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); diff --git a/test/core/end2end/tests/filter_causes_close.c b/test/core/end2end/tests/filter_causes_close.c index 3d9c6f31b2..5a231e59c9 100644 --- a/test/core/end2end/tests/filter_causes_close.c +++ b/test/core/end2end/tests/filter_causes_close.c @@ -123,8 +123,10 @@ static void test_request(grpc_end2end_test_config config) { char *details = NULL; size_t details_capacity = 0; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); diff --git a/test/core/end2end/tests/graceful_server_shutdown.c b/test/core/end2end/tests/graceful_server_shutdown.c index ae850d2ae1..3e0092ec18 100644 --- a/test/core/end2end/tests/graceful_server_shutdown.c +++ b/test/core/end2end/tests/graceful_server_shutdown.c @@ -111,8 +111,10 @@ static void test_early_server_shutdown_finishes_inflight_calls( size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -190,7 +192,8 @@ static void test_early_server_shutdown_finishes_inflight_calls( GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/high_initial_seqno.c b/test/core/end2end/tests/high_initial_seqno.c index 4bf351621b..209aae3eb6 100644 --- a/test/core/end2end/tests/high_initial_seqno.c +++ b/test/core/end2end/tests/high_initial_seqno.c @@ -117,8 +117,10 @@ static void simple_request_body(grpc_end2end_test_config config, size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -189,7 +191,8 @@ static void simple_request_body(grpc_end2end_test_config config, GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/hpack_size.c b/test/core/end2end/tests/hpack_size.c index 903a71500a..cab997432f 100644 --- a/test/core/end2end/tests/hpack_size.c +++ b/test/core/end2end/tests/hpack_size.c @@ -239,7 +239,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f, size_t index) { +static void simple_request_body(grpc_end2end_test_config config, + grpc_end2end_test_fixture f, size_t index) { grpc_call *c; grpc_call *s; gpr_timespec deadline = five_seconds_time(); @@ -268,8 +269,10 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te extra_metadata[2].value = dragons[index % GPR_ARRAY_SIZE(dragons)]; extra_metadata[2].value_length = strlen(extra_metadata[2].value); - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -341,7 +344,8 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/idempotent_request.c b/test/core/end2end/tests/idempotent_request.c index 8174743e25..7dcf3c72e3 100644 --- a/test/core/end2end/tests/idempotent_request.c +++ b/test/core/end2end/tests/idempotent_request.c @@ -97,7 +97,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { +static void simple_request_body(grpc_end2end_test_config config, + grpc_end2end_test_fixture f) { grpc_call *c; grpc_call *s; gpr_timespec deadline = five_seconds_time(); @@ -115,8 +116,10 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te int was_cancelled = 2; char *peer; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); peer = grpc_call_get_peer(c); @@ -201,7 +204,8 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(GRPC_INITIAL_METADATA_IDEMPOTENT_REQUEST == call_details.flags); GPR_ASSERT(was_cancelled == 1); diff --git a/test/core/end2end/tests/invoke_large_request.c b/test/core/end2end/tests/invoke_large_request.c index 7621acf00f..5b9e5c4273 100644 --- a/test/core/end2end/tests/invoke_large_request.c +++ b/test/core/end2end/tests/invoke_large_request.c @@ -144,8 +144,10 @@ static void test_invoke_large_request(grpc_end2end_test_config config, size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -244,7 +246,8 @@ static void test_invoke_large_request(grpc_end2end_test_config config, GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/large_metadata.c b/test/core/end2end/tests/large_metadata.c index 3561ec755c..5403ed078a 100644 --- a/test/core/end2end/tests/large_metadata.c +++ b/test/core/end2end/tests/large_metadata.c @@ -125,8 +125,10 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); meta.key = "key"; @@ -227,7 +229,8 @@ static void test_request_with_large_metadata(grpc_end2end_test_config config) { GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); GPR_ASSERT(contains_metadata(&request_metadata_recv, "key", meta.value)); diff --git a/test/core/end2end/tests/load_reporting_hook.c b/test/core/end2end/tests/load_reporting_hook.c index 9b4bdc3895..217d47e7a8 100644 --- a/test/core/end2end/tests/load_reporting_hook.c +++ b/test/core/end2end/tests/load_reporting_hook.c @@ -121,13 +121,10 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void request_response_with_payload(grpc_end2end_test_config config, - grpc_end2end_test_fixture f, - const char *method_name, - const char *request_msg, - const char *response_msg, - grpc_metadata *initial_lr_metadata, - grpc_metadata *trailing_lr_metadata) { +static void request_response_with_payload( + grpc_end2end_test_config config, grpc_end2end_test_fixture f, + const char *method_name, const char *request_msg, const char *response_msg, + grpc_metadata *initial_lr_metadata, grpc_metadata *trailing_lr_metadata) { gpr_slice request_payload_slice = gpr_slice_from_static_string(request_msg); gpr_slice response_payload_slice = gpr_slice_from_static_string(response_msg); grpc_call *c; @@ -152,8 +149,10 @@ static void request_response_with_payload(grpc_end2end_test_config config, size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - method_name, get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, method_name, + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -307,7 +306,9 @@ static void test_load_reporting_hook(grpc_end2end_test_config config) { memset(&trailing_lr_metadata.internal_data, 0, sizeof(trailing_lr_metadata.internal_data)); - request_response_with_payload(config, f, method_name, request_msg, response_msg, &initial_lr_metadata, &trailing_lr_metadata); + request_response_with_payload(config, f, method_name, request_msg, + response_msg, &initial_lr_metadata, + &trailing_lr_metadata); end_test(&f); grpc_channel_args_destroy(lr_server_args); config.tear_down_data(&f); diff --git a/test/core/end2end/tests/max_concurrent_streams.c b/test/core/end2end/tests/max_concurrent_streams.c index ef3704a428..ffc7f57f80 100644 --- a/test/core/end2end/tests/max_concurrent_streams.c +++ b/test/core/end2end/tests/max_concurrent_streams.c @@ -113,8 +113,10 @@ static void simple_request_body(grpc_end2end_test_config config, size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -185,7 +187,8 @@ static void simple_request_body(grpc_end2end_test_config config, GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); @@ -257,11 +260,15 @@ static void test_max_concurrent_streams(grpc_end2end_test_config config) { /* start two requests - ensuring that the second is not accepted until the first completes */ deadline = n_seconds_time(1000); - c1 = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/alpha", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c1 = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/alpha", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c1); - c2 = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/beta", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c2 = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/beta", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c2); GPR_ASSERT(GRPC_CALL_OK == grpc_server_request_call( diff --git a/test/core/end2end/tests/max_message_length.c b/test/core/end2end/tests/max_message_length.c index 19bf0dddaa..bb7033f6de 100644 --- a/test/core/end2end/tests/max_message_length.c +++ b/test/core/end2end/tests/max_message_length.c @@ -158,9 +158,10 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, server_args, query_args); cqv = cq_verifier_create(f.cq); - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/service/method", get_host_override_string("foo.test.google.fr:1234", config), - gpr_inf_future(GPR_CLOCK_REALTIME), NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/service/method", + get_host_override_string("foo.test.google.fr:1234", config), + gpr_inf_future(GPR_CLOCK_REALTIME), NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -233,7 +234,8 @@ static void test_max_message_length_on_request(grpc_end2end_test_config config, cq_verify(cqv); GPR_ASSERT(0 == strcmp(call_details.method, "/service/method")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 1); done: diff --git a/test/core/end2end/tests/negative_deadline.c b/test/core/end2end/tests/negative_deadline.c index 335608f3f9..267b3f2c42 100644 --- a/test/core/end2end/tests/negative_deadline.c +++ b/test/core/end2end/tests/negative_deadline.c @@ -97,7 +97,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f, size_t num_ops) { +static void simple_request_body(grpc_end2end_test_config config, + grpc_end2end_test_fixture f, size_t num_ops) { grpc_call *c; gpr_timespec deadline = gpr_inf_past(GPR_CLOCK_REALTIME); cq_verifier *cqv = cq_verifier_create(f.cq); @@ -112,8 +113,10 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te gpr_log(GPR_DEBUG, "test with %" PRIuPTR " ops", num_ops); - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); diff --git a/test/core/end2end/tests/network_status_change.c b/test/core/end2end/tests/network_status_change.c index 71a24af53d..c5b953d6af 100644 --- a/test/core/end2end/tests/network_status_change.c +++ b/test/core/end2end/tests/network_status_change.c @@ -122,8 +122,10 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) { size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -212,7 +214,8 @@ static void test_invoke_network_status_change(grpc_end2end_test_config config) { // Expected behavior of a RPC when network is lost. GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); gpr_free(details); grpc_metadata_array_destroy(&initial_metadata_recv); diff --git a/test/core/end2end/tests/no_logging.c b/test/core/end2end/tests/no_logging.c index 1d96efc276..ba21ed69dc 100644 --- a/test/core/end2end/tests/no_logging.c +++ b/test/core/end2end/tests/no_logging.c @@ -125,7 +125,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { +static void simple_request_body(grpc_end2end_test_config config, + grpc_end2end_test_fixture f) { grpc_call *c; grpc_call *s; gpr_timespec deadline = five_seconds_time(); @@ -143,8 +144,10 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te int was_cancelled = 2; char *peer; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); peer = grpc_call_get_peer(c); @@ -226,7 +229,8 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(0 == call_details.flags); GPR_ASSERT(was_cancelled == 1); diff --git a/test/core/end2end/tests/payload.c b/test/core/end2end/tests/payload.c index 341d510297..c5a198bea6 100644 --- a/test/core/end2end/tests/payload.c +++ b/test/core/end2end/tests/payload.c @@ -111,7 +111,8 @@ static gpr_slice generate_random_slice() { return out; } -static void request_response_with_payload(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { +static void request_response_with_payload(grpc_end2end_test_config config, + grpc_end2end_test_fixture f) { /* Create large request and response bodies. These are big enough to require * multiple round trips to deliver to the peer, and their exact contents of * will be verified on completion. */ @@ -140,8 +141,10 @@ static void request_response_with_payload(grpc_end2end_test_config config, grpc_ size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -240,7 +243,8 @@ static void request_response_with_payload(grpc_end2end_test_config config, grpc_ GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_slice(request_payload_recv, request_payload_slice)); GPR_ASSERT( diff --git a/test/core/end2end/tests/ping_pong_streaming.c b/test/core/end2end/tests/ping_pong_streaming.c index 8eca462efd..22a69d0f2f 100644 --- a/test/core/end2end/tests/ping_pong_streaming.c +++ b/test/core/end2end/tests/ping_pong_streaming.c @@ -123,8 +123,10 @@ static void test_pingpong_streaming(grpc_end2end_test_config config, gpr_slice request_payload_slice = gpr_slice_from_copied_string("hello world"); gpr_slice response_payload_slice = gpr_slice_from_copied_string("hello you"); - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); diff --git a/test/core/end2end/tests/registered_call.c b/test/core/end2end/tests/registered_call.c index dc46068e2f..4dbea86fa1 100644 --- a/test/core/end2end/tests/registered_call.c +++ b/test/core/end2end/tests/registered_call.c @@ -97,7 +97,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f, void *rc) { +static void simple_request_body(grpc_end2end_test_config config, + grpc_end2end_test_fixture f, void *rc) { grpc_call *c; grpc_call *s; gpr_timespec deadline = five_seconds_time(); @@ -186,7 +187,8 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); @@ -204,7 +206,9 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te static void test_invoke_simple_request(grpc_end2end_test_config config) { grpc_end2end_test_fixture f = begin_test(config, "test_invoke_simple_request", NULL, NULL); - void *rc = grpc_channel_register_call(f.client, "/foo", get_host_override_string("foo.test.google.fr:1234", config), NULL); + void *rc = grpc_channel_register_call( + f.client, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), NULL); simple_request_body(config, f, rc); end_test(&f); @@ -215,7 +219,9 @@ static void test_invoke_10_simple_requests(grpc_end2end_test_config config) { int i; grpc_end2end_test_fixture f = begin_test(config, "test_invoke_10_simple_requests", NULL, NULL); - void *rc = grpc_channel_register_call(f.client, "/foo", get_host_override_string("foo.test.google.fr:1234", config), NULL); + void *rc = grpc_channel_register_call( + f.client, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), NULL); for (i = 0; i < 10; i++) { simple_request_body(config, f, rc); diff --git a/test/core/end2end/tests/request_with_flags.c b/test/core/end2end/tests/request_with_flags.c index 223566321b..f53d30bd48 100644 --- a/test/core/end2end/tests/request_with_flags.c +++ b/test/core/end2end/tests/request_with_flags.c @@ -120,8 +120,10 @@ static void test_invoke_request_with_flags( size_t details_capacity = 0; grpc_call_error expectation; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); diff --git a/test/core/end2end/tests/request_with_payload.c b/test/core/end2end/tests/request_with_payload.c index 34e8c72b72..fa0d933b59 100644 --- a/test/core/end2end/tests/request_with_payload.c +++ b/test/core/end2end/tests/request_with_payload.c @@ -119,8 +119,10 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -208,7 +210,8 @@ static void test_invoke_request_with_payload(grpc_end2end_test_config config) { GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); diff --git a/test/core/end2end/tests/server_finishes_request.c b/test/core/end2end/tests/server_finishes_request.c index c8eeadef4c..6268aa60b4 100644 --- a/test/core/end2end/tests/server_finishes_request.c +++ b/test/core/end2end/tests/server_finishes_request.c @@ -97,7 +97,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { +static void simple_request_body(grpc_end2end_test_config config, + grpc_end2end_test_fixture f) { grpc_call *c; grpc_call *s; gpr_timespec deadline = five_seconds_time(); @@ -114,8 +115,10 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -182,7 +185,8 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/shutdown_finishes_calls.c b/test/core/end2end/tests/shutdown_finishes_calls.c index 0de706c0e1..bd21cfd7b2 100644 --- a/test/core/end2end/tests/shutdown_finishes_calls.c +++ b/test/core/end2end/tests/shutdown_finishes_calls.c @@ -104,8 +104,10 @@ static void test_early_server_shutdown_finishes_inflight_calls( size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -171,7 +173,8 @@ static void test_early_server_shutdown_finishes_inflight_calls( GPR_ASSERT(status == GRPC_STATUS_UNAVAILABLE); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/simple_cacheable_request.c b/test/core/end2end/tests/simple_cacheable_request.c index 60e286bfad..0775b2fc2f 100644 --- a/test/core/end2end/tests/simple_cacheable_request.c +++ b/test/core/end2end/tests/simple_cacheable_request.c @@ -133,8 +133,10 @@ static void test_cacheable_request_response_with_metadata_and_payload( size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -235,7 +237,8 @@ static void test_cacheable_request_response_with_metadata_and_payload( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); if (config.feature_mask & FEATURE_MASK_SUPPORTS_REQUEST_PROXYING) { // Our simple proxy does not support cacheable requests } else { diff --git a/test/core/end2end/tests/simple_delayed_request.c b/test/core/end2end/tests/simple_delayed_request.c index db4a7e2524..e661a17eff 100644 --- a/test/core/end2end/tests/simple_delayed_request.c +++ b/test/core/end2end/tests/simple_delayed_request.c @@ -106,8 +106,10 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, config.init_client(f, client_args, NULL); - c = grpc_channel_create_call(f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f->client, NULL, GRPC_PROPAGATE_DEFAULTS, f->cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -180,7 +182,8 @@ static void simple_delayed_request_body(grpc_end2end_test_config config, GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/simple_metadata.c b/test/core/end2end/tests/simple_metadata.c index 2f2aa14fab..98a494b171 100644 --- a/test/core/end2end/tests/simple_metadata.c +++ b/test/core/end2end/tests/simple_metadata.c @@ -130,8 +130,10 @@ static void test_request_response_with_metadata_and_payload( size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -232,7 +234,8 @@ static void test_request_response_with_metadata_and_payload( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 0); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); diff --git a/test/core/end2end/tests/simple_request.c b/test/core/end2end/tests/simple_request.c index 40c1192d15..68f6fa5c4a 100644 --- a/test/core/end2end/tests/simple_request.c +++ b/test/core/end2end/tests/simple_request.c @@ -97,7 +97,8 @@ static void end_test(grpc_end2end_test_fixture *f) { grpc_completion_queue_destroy(f->cq); } -static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_test_fixture f) { +static void simple_request_body(grpc_end2end_test_config config, + grpc_end2end_test_fixture f) { grpc_call *c; grpc_call *s; gpr_timespec deadline = five_seconds_time(); @@ -115,8 +116,10 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te int was_cancelled = 2; char *peer; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); peer = grpc_call_get_peer(c); @@ -201,7 +204,8 @@ static void simple_request_body(grpc_end2end_test_config config, grpc_end2end_te GPR_ASSERT(status == GRPC_STATUS_UNIMPLEMENTED); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(0 == call_details.flags); GPR_ASSERT(was_cancelled == 1); diff --git a/test/core/end2end/tests/streaming_error_response.c b/test/core/end2end/tests/streaming_error_response.c index 9513a41e58..05cb920332 100644 --- a/test/core/end2end/tests/streaming_error_response.c +++ b/test/core/end2end/tests/streaming_error_response.c @@ -125,8 +125,10 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -245,7 +247,8 @@ static void test(grpc_end2end_test_config config, bool request_status_early) { GPR_ASSERT(status == GRPC_STATUS_FAILED_PRECONDITION); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(was_cancelled == 1); gpr_free(details); diff --git a/test/core/end2end/tests/trailing_metadata.c b/test/core/end2end/tests/trailing_metadata.c index d67babb64f..a7b2490b99 100644 --- a/test/core/end2end/tests/trailing_metadata.c +++ b/test/core/end2end/tests/trailing_metadata.c @@ -133,8 +133,10 @@ static void test_request_response_with_metadata_and_payload( size_t details_capacity = 0; int was_cancelled = 2; - c = grpc_channel_create_call(f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, - "/foo", get_host_override_string("foo.test.google.fr:1234", config), deadline, NULL); + c = grpc_channel_create_call( + f.client, NULL, GRPC_PROPAGATE_DEFAULTS, f.cq, "/foo", + get_host_override_string("foo.test.google.fr:1234", config), deadline, + NULL); GPR_ASSERT(c); grpc_metadata_array_init(&initial_metadata_recv); @@ -236,7 +238,8 @@ static void test_request_response_with_metadata_and_payload( GPR_ASSERT(status == GRPC_STATUS_OK); GPR_ASSERT(0 == strcmp(details, "xyz")); GPR_ASSERT(0 == strcmp(call_details.method, "/foo")); - validate_host_override_string("foo.test.google.fr:1234", call_details.host, config); + validate_host_override_string("foo.test.google.fr:1234", call_details.host, + config); GPR_ASSERT(byte_buffer_eq_string(request_payload_recv, "hello world")); GPR_ASSERT(byte_buffer_eq_string(response_payload_recv, "hello you")); GPR_ASSERT(contains_metadata(&request_metadata_recv, "key1", "val1")); -- cgit v1.2.3