From 00b35e71808ba9c17a5edabd2390deed594f80b9 Mon Sep 17 00:00:00 2001 From: jiangtaoli2016 Date: Tue, 1 Aug 2017 12:17:08 -0700 Subject: [PATCH] Make tsi handshaker result unused bytes const --- src/core/lib/security/transport/security_handshaker.c | 2 +- src/core/tsi/fake_transport_security.c | 2 +- src/core/tsi/transport_security.c | 2 +- src/core/tsi/transport_security.h | 3 ++- src/core/tsi/transport_security_adapter.c | 2 +- src/core/tsi/transport_security_interface.h | 2 +- 6 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/core/lib/security/transport/security_handshaker.c b/src/core/lib/security/transport/security_handshaker.c index 239a211c0b5..b9da6e16b25 100644 --- a/src/core/lib/security/transport/security_handshaker.c +++ b/src/core/lib/security/transport/security_handshaker.c @@ -147,7 +147,7 @@ static void on_peer_checked(grpc_exec_ctx *exec_ctx, void *arg, goto done; } // Get unused bytes. - unsigned char *unused_bytes = NULL; + const unsigned char *unused_bytes = NULL; size_t unused_bytes_size = 0; result = tsi_handshaker_result_get_unused_bytes( h->handshaker_result, &unused_bytes, &unused_bytes_size); diff --git a/src/core/tsi/fake_transport_security.c b/src/core/tsi/fake_transport_security.c index 1280680663f..810447313c5 100644 --- a/src/core/tsi/fake_transport_security.c +++ b/src/core/tsi/fake_transport_security.c @@ -391,7 +391,7 @@ static tsi_result fake_handshaker_result_create_frame_protector( } static tsi_result fake_handshaker_result_get_unused_bytes( - const tsi_handshaker_result *self, unsigned char **bytes, + const tsi_handshaker_result *self, const unsigned char **bytes, size_t *bytes_size) { fake_handshaker_result *result = (fake_handshaker_result *)self; *bytes_size = result->unused_bytes_size; diff --git a/src/core/tsi/transport_security.c b/src/core/tsi/transport_security.c index be11d644721..2b1f4310c14 100644 --- a/src/core/tsi/transport_security.c +++ b/src/core/tsi/transport_security.c @@ -240,7 +240,7 @@ tsi_result tsi_handshaker_result_create_frame_protector( } tsi_result tsi_handshaker_result_get_unused_bytes( - const tsi_handshaker_result *self, unsigned char **bytes, + const tsi_handshaker_result *self, const unsigned char **bytes, size_t *bytes_size) { if (self == NULL || bytes == NULL || bytes_size == NULL) { return TSI_INVALID_ARGUMENT; diff --git a/src/core/tsi/transport_security.h b/src/core/tsi/transport_security.h index 4a56c25602a..2c7db6bca92 100644 --- a/src/core/tsi/transport_security.h +++ b/src/core/tsi/transport_security.h @@ -90,7 +90,8 @@ typedef struct { size_t *max_output_protected_frame_size, tsi_frame_protector **protector); tsi_result (*get_unused_bytes)(const tsi_handshaker_result *self, - unsigned char **bytes, size_t *bytes_size); + const unsigned char **bytes, + size_t *bytes_size); void (*destroy)(tsi_handshaker_result *self); } tsi_handshaker_result_vtable; diff --git a/src/core/tsi/transport_security_adapter.c b/src/core/tsi/transport_security_adapter.c index a0564945e47..b6dc660c475 100644 --- a/src/core/tsi/transport_security_adapter.c +++ b/src/core/tsi/transport_security_adapter.c @@ -50,7 +50,7 @@ static tsi_result adapter_result_create_frame_protector( } static tsi_result adapter_result_get_unused_bytes( - const tsi_handshaker_result *self, unsigned char **bytes, + const tsi_handshaker_result *self, const unsigned char **bytes, size_t *byte_size) { tsi_adapter_handshaker_result *impl = (tsi_adapter_handshaker_result *)self; *bytes = impl->unused_bytes; diff --git a/src/core/tsi/transport_security_interface.h b/src/core/tsi/transport_security_interface.h index 137f8ee5c33..39ba8addc49 100644 --- a/src/core/tsi/transport_security_interface.h +++ b/src/core/tsi/transport_security_interface.h @@ -221,7 +221,7 @@ tsi_result tsi_handshaker_result_create_frame_protector( Ownership of the bytes is retained by the handshaker result. As a consequence, the caller must not free the bytes. */ tsi_result tsi_handshaker_result_get_unused_bytes( - const tsi_handshaker_result *self, unsigned char **bytes, + const tsi_handshaker_result *self, const unsigned char **bytes, size_t *byte_size); /* This method releases the tsi_handshaker_handshaker object. After this method