aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--src/core/iomgr/tcp_posix.c21
-rw-r--r--src/core/iomgr/tcp_server.h2
-rw-r--r--src/core/iomgr/tcp_server_posix.c7
-rw-r--r--src/core/iomgr/udp_server.c9
-rw-r--r--src/core/iomgr/udp_server.h4
-rw-r--r--src/core/support/stack_lockfree.c2
-rw-r--r--src/core/support/stack_lockfree.h4
-rw-r--r--src/core/surface/channel.c6
-rw-r--r--src/core/surface/channel_create.c2
-rw-r--r--src/core/surface/server.c11
-rw-r--r--src/core/transport/chttp2/bin_encoder.c14
-rw-r--r--src/core/transport/chttp2/frame_data.c16
-rw-r--r--src/core/transport/chttp2/frame_goaway.c2
-rw-r--r--src/core/transport/chttp2/frame_settings.c4
-rw-r--r--src/core/transport/chttp2/hpack_parser.c4
-rw-r--r--src/core/transport/chttp2/hpack_parser.h2
-rw-r--r--src/core/transport/chttp2/hpack_table.c2
-rw-r--r--src/core/transport/chttp2/incoming_metadata.c2
-rw-r--r--src/core/transport/chttp2/internal.h25
-rw-r--r--src/core/transport/chttp2/parsing.c22
-rw-r--r--src/core/transport/chttp2/stream_encoder.c34
-rw-r--r--src/core/transport/chttp2/timeout_encoding.c6
-rw-r--r--src/core/transport/chttp2/varint.c5
-rw-r--r--src/core/transport/chttp2/varint.h9
-rw-r--r--src/core/transport/chttp2_transport.c5
-rw-r--r--src/core/transport/metadata.c3
-rw-r--r--test/core/channel/channel_args_test.c11
-rw-r--r--test/core/end2end/dualstack_socket_test.c4
-rw-r--r--test/core/end2end/no_server_test.c4
-rw-r--r--test/core/fling/client.c7
-rw-r--r--test/core/fling/fling_stream_test.c4
-rw-r--r--test/core/fling/fling_test.c2
-rw-r--r--test/core/fling/server.c2
-rw-r--r--test/core/httpcli/httpcli_test.c2
-rw-r--r--test/core/iomgr/alarm_heap_test.c65
-rw-r--r--test/core/iomgr/tcp_posix_test.c36
-rw-r--r--test/core/json/json_rewrite.c26
-rw-r--r--test/core/json/json_rewrite_test.c28
-rw-r--r--test/core/profiling/timers_test.c16
-rw-r--r--test/core/security/base64_test.c4
-rw-r--r--test/core/security/json_token_test.c11
-rw-r--r--test/core/support/murmur_hash_test.c4
-rw-r--r--test/core/support/slice_test.c10
-rw-r--r--test/core/support/stack_lockfree_test.c14
-rw-r--r--test/core/support/time_test.c18
-rw-r--r--test/core/surface/byte_buffer_reader_test.c8
-rw-r--r--test/core/surface/completion_queue_test.c8
-rw-r--r--test/core/surface/lame_client_test.c2
-rw-r--r--test/core/transport/chttp2/hpack_table_test.c4
-rw-r--r--test/core/transport/chttp2/stream_encoder_test.c10
-rw-r--r--test/core/transport/chttp2/stream_map_test.c6
-rw-r--r--test/core/transport/metadata_test.c12
52 files changed, 282 insertions, 259 deletions
diff --git a/src/core/iomgr/tcp_posix.c b/src/core/iomgr/tcp_posix.c
index 0db7cd9f0e..81f04494eb 100644
--- a/src/core/iomgr/tcp_posix.c
+++ b/src/core/iomgr/tcp_posix.c
@@ -67,8 +67,8 @@ typedef struct {
grpc_endpoint base;
grpc_fd *em_fd;
int fd;
- int iov_size; /* Number of slices to allocate per read attempt */
int finished_edge;
+ size_t iov_size; /* Number of slices to allocate per read attempt */
size_t slice_size;
gpr_refcount refcount;
@@ -215,8 +215,9 @@ static void tcp_continue_read(grpc_tcp *tcp) {
} 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(tcp->incoming_buffer,
- tcp->incoming_buffer->length - read_bytes);
+ gpr_slice_buffer_trim_end(
+ tcp->incoming_buffer,
+ tcp->incoming_buffer->length - (size_t)read_bytes);
} else if (tcp->iov_size < MAX_READ_IOVEC) {
++tcp->iov_size;
}
@@ -264,12 +265,12 @@ static grpc_endpoint_op_status tcp_read(grpc_endpoint *ep,
static grpc_endpoint_op_status tcp_flush(grpc_tcp *tcp) {
struct msghdr msg;
struct iovec iov[MAX_WRITE_IOVEC];
- int iov_size;
+ size_t iov_size;
ssize_t sent_length;
- ssize_t sending_length;
- ssize_t trailing;
- ssize_t unwind_slice_idx;
- ssize_t unwind_byte_idx;
+ size_t sending_length;
+ size_t trailing;
+ size_t unwind_slice_idx;
+ size_t unwind_byte_idx;
for (;;) {
sending_length = 0;
@@ -319,9 +320,9 @@ static grpc_endpoint_op_status tcp_flush(grpc_tcp *tcp) {
}
GPR_ASSERT(tcp->outgoing_byte_idx == 0);
- trailing = sending_length - sent_length;
+ trailing = sending_length - (size_t)sent_length;
while (trailing > 0) {
- ssize_t slice_length;
+ size_t slice_length;
tcp->outgoing_slice_idx--;
slice_length = GPR_SLICE_LENGTH(
diff --git a/src/core/iomgr/tcp_server.h b/src/core/iomgr/tcp_server.h
index 66bb3ef701..5165f5c5ca 100644
--- a/src/core/iomgr/tcp_server.h
+++ b/src/core/iomgr/tcp_server.h
@@ -62,7 +62,7 @@ void grpc_tcp_server_start(grpc_tcp_server *server, grpc_pollset **pollsets,
/* TODO(ctiller): deprecate this, and make grpc_tcp_server_add_ports to handle
all of the multiple socket port matching logic in one place */
int grpc_tcp_server_add_port(grpc_tcp_server *s, const void *addr,
- int addr_len);
+ size_t addr_len);
/* Returns the file descriptor of the Nth listening socket on this server,
or -1 if the index is out of bounds.
diff --git a/src/core/iomgr/tcp_server_posix.c b/src/core/iomgr/tcp_server_posix.c
index 6399aaadb9..6b81090108 100644
--- a/src/core/iomgr/tcp_server_posix.c
+++ b/src/core/iomgr/tcp_server_posix.c
@@ -256,7 +256,8 @@ static int get_max_accept_queue_size(void) {
}
/* Prepare a recently-created socket for listening. */
-static int prepare_socket(int fd, const struct sockaddr *addr, int addr_len) {
+static int prepare_socket(int fd, const struct sockaddr *addr,
+ size_t addr_len) {
struct sockaddr_storage sockname_temp;
socklen_t sockname_len;
@@ -365,7 +366,7 @@ error:
}
static int add_socket_to_server(grpc_tcp_server *s, int fd,
- const struct sockaddr *addr, int addr_len) {
+ const struct sockaddr *addr, size_t addr_len) {
server_port *sp;
int port;
char *addr_str;
@@ -398,7 +399,7 @@ static int add_socket_to_server(grpc_tcp_server *s, int fd,
}
int grpc_tcp_server_add_port(grpc_tcp_server *s, const void *addr,
- int addr_len) {
+ size_t addr_len) {
int allocated_port1 = -1;
int allocated_port2 = -1;
unsigned i;
diff --git a/src/core/iomgr/udp_server.c b/src/core/iomgr/udp_server.c
index 6429c38b28..95ae698781 100644
--- a/src/core/iomgr/udp_server.c
+++ b/src/core/iomgr/udp_server.c
@@ -221,7 +221,8 @@ void grpc_udp_server_destroy(
}
/* Prepare a recently-created socket for listening. */
-static int prepare_socket(int fd, const struct sockaddr *addr, int addr_len) {
+static int prepare_socket(int fd, const struct sockaddr *addr,
+ size_t addr_len) {
struct sockaddr_storage sockname_temp;
socklen_t sockname_len;
int get_local_ip;
@@ -287,7 +288,7 @@ static void on_read(void *arg, int success) {
}
static int add_socket_to_server(grpc_udp_server *s, int fd,
- const struct sockaddr *addr, int addr_len,
+ const struct sockaddr *addr, size_t addr_len,
grpc_udp_server_read_cb read_cb) {
server_port *sp;
int port;
@@ -319,8 +320,8 @@ static int add_socket_to_server(grpc_udp_server *s, int fd,
return port;
}
-int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr, int addr_len,
- grpc_udp_server_read_cb read_cb) {
+int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr,
+ size_t addr_len, grpc_udp_server_read_cb read_cb) {
int allocated_port1 = -1;
int allocated_port2 = -1;
unsigned i;
diff --git a/src/core/iomgr/udp_server.h b/src/core/iomgr/udp_server.h
index fcc4ba6e97..389f84ecca 100644
--- a/src/core/iomgr/udp_server.h
+++ b/src/core/iomgr/udp_server.h
@@ -67,8 +67,8 @@ int grpc_udp_server_get_fd(grpc_udp_server *s, unsigned index);
/* TODO(ctiller): deprecate this, and make grpc_udp_server_add_ports to handle
all of the multiple socket port matching logic in one place */
-int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr, int addr_len,
- grpc_udp_server_read_cb read_cb);
+int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr,
+ size_t addr_len, grpc_udp_server_read_cb read_cb);
void grpc_udp_server_destroy(grpc_udp_server *server,
void (*shutdown_done)(void *shutdown_done_arg),
diff --git a/src/core/support/stack_lockfree.c b/src/core/support/stack_lockfree.c
index 27ecf62280..0d4b4bedd9 100644
--- a/src/core/support/stack_lockfree.c
+++ b/src/core/support/stack_lockfree.c
@@ -79,7 +79,7 @@ struct gpr_stack_lockfree {
#endif
};
-gpr_stack_lockfree *gpr_stack_lockfree_create(int entries) {
+gpr_stack_lockfree *gpr_stack_lockfree_create(size_t entries) {
gpr_stack_lockfree *stack;
stack = gpr_malloc(sizeof(*stack));
/* Since we only allocate 16 bits to represent an entry number,
diff --git a/src/core/support/stack_lockfree.h b/src/core/support/stack_lockfree.h
index eec960fbb0..2bbbe3bd95 100644
--- a/src/core/support/stack_lockfree.h
+++ b/src/core/support/stack_lockfree.h
@@ -34,11 +34,13 @@
#ifndef GRPC_INTERNAL_CORE_SUPPORT_STACK_LOCKFREE_H
#define GRPC_INTERNAL_CORE_SUPPORT_STACK_LOCKFREE_H
+#include <stddef.h>
+
typedef struct gpr_stack_lockfree gpr_stack_lockfree;
/* This stack must specify the maximum number of entries to track.
The current implementation only allows up to 65534 entries */
-gpr_stack_lockfree* gpr_stack_lockfree_create(int entries);
+gpr_stack_lockfree* gpr_stack_lockfree_create(size_t entries);
void gpr_stack_lockfree_destroy(gpr_stack_lockfree* stack);
/* Pass in a valid entry number for the next stack entry */
diff --git a/src/core/surface/channel.c b/src/core/surface/channel.c
index 586402e21c..a89523b3ab 100644
--- a/src/core/surface/channel.c
+++ b/src/core/surface/channel.c
@@ -113,7 +113,7 @@ grpc_channel *grpc_channel_create_from_filters(
grpc_mdstr_from_string(mdctx, "grpc-message", 0);
for (i = 0; i < NUM_CACHED_STATUS_ELEMS; i++) {
char buf[GPR_LTOA_MIN_BUFSIZE];
- gpr_ltoa(i, buf);
+ gpr_ltoa((long)i, buf);
channel->grpc_status_elem[i] = grpc_mdelem_from_metadata_strings(
mdctx, GRPC_MDSTR_REF(channel->grpc_status_string),
grpc_mdstr_from_string(mdctx, buf, 0));
@@ -134,7 +134,7 @@ grpc_channel *grpc_channel_create_from_filters(
gpr_log(GPR_ERROR, "%s ignored: it must be >= 0",
GRPC_ARG_MAX_MESSAGE_LENGTH);
} else {
- channel->max_message_length = args->args[i].value.integer;
+ channel->max_message_length = (gpr_uint32)args->args[i].value.integer;
}
} else if (0 == strcmp(args->args[i].key, GRPC_ARG_DEFAULT_AUTHORITY)) {
if (args->args[i].type != GRPC_ARG_STRING) {
@@ -193,7 +193,7 @@ static grpc_call *grpc_channel_create_call_internal(
grpc_completion_queue *cq, grpc_mdelem *path_mdelem,
grpc_mdelem *authority_mdelem, gpr_timespec deadline) {
grpc_mdelem *send_metadata[2];
- int num_metadata = 0;
+ size_t num_metadata = 0;
GPR_ASSERT(channel->is_client);
diff --git a/src/core/surface/channel_create.c b/src/core/surface/channel_create.c
index 707251da89..9e2cf1cf66 100644
--- a/src/core/surface/channel_create.c
+++ b/src/core/surface/channel_create.c
@@ -164,7 +164,7 @@ grpc_channel *grpc_insecure_channel_create(const char *target,
grpc_resolver *resolver;
subchannel_factory *f;
grpc_mdctx *mdctx = grpc_mdctx_create();
- int n = 0;
+ size_t n = 0;
GPR_ASSERT(!reserved);
if (grpc_channel_args_is_census_enabled(args)) {
filters[n++] = &grpc_client_census_filter;
diff --git a/src/core/surface/server.c b/src/core/surface/server.c
index 292bf6fab8..c3d8046787 100644
--- a/src/core/surface/server.c
+++ b/src/core/surface/server.c
@@ -203,7 +203,7 @@ struct grpc_server {
gpr_stack_lockfree *request_freelist;
/** requested call backing data */
requested_call *requested_calls;
- int max_requested_calls;
+ size_t max_requested_calls;
gpr_atm shutdown_flag;
gpr_uint8 shutdown_published;
@@ -298,7 +298,7 @@ static void channel_broadcaster_shutdown(channel_broadcaster *cb,
*/
static void request_matcher_init(request_matcher *request_matcher,
- int entries) {
+ size_t entries) {
memset(request_matcher, 0, sizeof(*request_matcher));
request_matcher->requests = gpr_stack_lockfree_create(entries);
}
@@ -817,7 +817,7 @@ grpc_server *grpc_server_create_from_filters(
grpc_server_census_filter (optional) - for stats collection and tracing
{passed in filter stack}
grpc_connected_channel_filter - for interfacing with transports */
- server->channel_filter_count = filter_count + 1 + census_enabled;
+ server->channel_filter_count = filter_count + 1u + (census_enabled ? 1u : 0u);
server->channel_filters =
gpr_malloc(server->channel_filter_count * sizeof(grpc_channel_filter *));
server->channel_filters[0] = &server_surface_filter;
@@ -825,7 +825,7 @@ grpc_server *grpc_server_create_from_filters(
server->channel_filters[1] = &grpc_server_census_filter;
}
for (i = 0; i < filter_count; i++) {
- server->channel_filters[i + 1 + census_enabled] = filters[i];
+ server->channel_filters[i + 1u + (census_enabled ? 1u : 0u)] = filters[i];
}
server->channel_args = grpc_channel_args_copy(args);
@@ -1246,7 +1246,8 @@ static void begin_call(grpc_server *server, call_data *calld,
}
GRPC_CALL_INTERNAL_REF(calld->call, "server");
- grpc_call_start_ioreq_and_call_back(calld->call, req, r - req, publish, rc);
+ grpc_call_start_ioreq_and_call_back(calld->call, req, (size_t)(r - req),
+ publish, rc);
}
static void done_request_event(void *req, grpc_cq_completion *c) {
diff --git a/src/core/transport/chttp2/bin_encoder.c b/src/core/transport/chttp2/bin_encoder.c
index dee6dbec8b..b87d4de04b 100644
--- a/src/core/transport/chttp2/bin_encoder.c
+++ b/src/core/transport/chttp2/bin_encoder.c
@@ -68,7 +68,7 @@ gpr_slice grpc_chttp2_base64_encode(gpr_slice input) {
size_t output_length = input_triplets * 4 + tail_xtra[tail_case];
gpr_slice output = gpr_slice_malloc(output_length);
gpr_uint8 *in = GPR_SLICE_START_PTR(input);
- gpr_uint8 *out = GPR_SLICE_START_PTR(output);
+ char *out = (char *)GPR_SLICE_START_PTR(output);
size_t i;
/* encode full triplets */
@@ -100,7 +100,7 @@ gpr_slice grpc_chttp2_base64_encode(gpr_slice input) {
break;
}
- GPR_ASSERT(out == GPR_SLICE_END_PTR(output));
+ GPR_ASSERT(out == (char *)GPR_SLICE_END_PTR(output));
GPR_ASSERT(in == GPR_SLICE_END_PTR(input));
return output;
}
@@ -133,7 +133,7 @@ gpr_slice grpc_chttp2_huffman_compress(gpr_slice input) {
}
if (temp_length) {
- *out++ = (temp << (8 - temp_length)) | (0xff >> temp_length);
+ *out++ = (temp << (8u - temp_length)) | (0xffu >> temp_length);
}
GPR_ASSERT(out == GPR_SLICE_END_PTR(output));
@@ -157,9 +157,9 @@ static void enc_flush_some(huff_out *out) {
static void enc_add2(huff_out *out, gpr_uint8 a, gpr_uint8 b) {
b64_huff_sym sa = huff_alphabet[a];
b64_huff_sym sb = huff_alphabet[b];
- out->temp =
- (out->temp << (sa.length + sb.length)) | (sa.bits << sb.length) | sb.bits;
- out->temp_length += sa.length + sb.length;
+ out->temp = (out->temp << (sa.length + sb.length)) |
+ ((gpr_uint32)sa.bits << sb.length) | sb.bits;
+ out->temp_length += (gpr_uint32)sa.length + (gpr_uint32)sb.length;
enc_flush_some(out);
}
@@ -211,7 +211,7 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) {
if (out.temp_length) {
*out.out++ =
- (out.temp << (8 - out.temp_length)) | (0xff >> out.temp_length);
+ (out.temp << (8u - out.temp_length)) | (0xffu >> out.temp_length);
}
GPR_ASSERT(out.out <= GPR_SLICE_END_PTR(output));
diff --git a/src/core/transport/chttp2/frame_data.c b/src/core/transport/chttp2/frame_data.c
index 474c3d5ee6..29d19b4e94 100644
--- a/src/core/transport/chttp2/frame_data.c
+++ b/src/core/transport/chttp2/frame_data.c
@@ -146,19 +146,21 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
grpc_chttp2_list_add_parsing_seen_stream(transport_parsing,
stream_parsing);
if ((gpr_uint32)(end - cur) == p->frame_size) {
- grpc_sopb_add_slice(&p->incoming_sopb,
- gpr_slice_sub(slice, cur - beg, end - beg));
+ grpc_sopb_add_slice(
+ &p->incoming_sopb,
+ gpr_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
p->state = GRPC_CHTTP2_DATA_FH_0;
return GRPC_CHTTP2_PARSE_OK;
} else if ((gpr_uint32)(end - cur) > p->frame_size) {
- grpc_sopb_add_slice(
- &p->incoming_sopb,
- gpr_slice_sub(slice, cur - beg, cur + p->frame_size - beg));
+ grpc_sopb_add_slice(&p->incoming_sopb,
+ gpr_slice_sub(slice, (size_t)(cur - beg),
+ (size_t)(cur + p->frame_size - beg)));
cur += p->frame_size;
goto fh_0; /* loop */
} else {
- grpc_sopb_add_slice(&p->incoming_sopb,
- gpr_slice_sub(slice, cur - beg, end - beg));
+ grpc_sopb_add_slice(
+ &p->incoming_sopb,
+ gpr_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
p->frame_size -= (end - cur);
return GRPC_CHTTP2_PARSE_OK;
}
diff --git a/src/core/transport/chttp2/frame_goaway.c b/src/core/transport/chttp2/frame_goaway.c
index 1ccbba840c..d40e6fd03a 100644
--- a/src/core/transport/chttp2/frame_goaway.c
+++ b/src/core/transport/chttp2/frame_goaway.c
@@ -136,7 +136,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
++cur;
/* fallthrough */
case GRPC_CHTTP2_GOAWAY_DEBUG:
- memcpy(p->debug_data + p->debug_pos, cur, end - cur);
+ memcpy(p->debug_data + p->debug_pos, cur, (size_t)(end - cur));
p->debug_pos += end - cur;
p->state = GRPC_CHTTP2_GOAWAY_DEBUG;
if (is_last) {
diff --git a/src/core/transport/chttp2/frame_settings.c b/src/core/transport/chttp2/frame_settings.c
index d42bc000ae..927ae55996 100644
--- a/src/core/transport/chttp2/frame_settings.c
+++ b/src/core/transport/chttp2/frame_settings.c
@@ -81,14 +81,14 @@ gpr_slice grpc_chttp2_settings_create(gpr_uint32 *old, const gpr_uint32 *new,
gpr_uint8 *p;
for (i = 0; i < count; i++) {
- n += (new[i] != old[i] || (force_mask & (1 << i)) != 0);
+ n += (new[i] != old[i] || (force_mask & (1u << i)) != 0);
}
output = gpr_slice_malloc(9 + 6 * n);
p = fill_header(GPR_SLICE_START_PTR(output), 6 * n, 0);
for (i = 0; i < count; i++) {
- if (new[i] != old[i] || (force_mask & (1 << i)) != 0) {
+ if (new[i] != old[i] || (force_mask & (1u << i)) != 0) {
GPR_ASSERT(i);
*p++ = i >> 8;
*p++ = i;
diff --git a/src/core/transport/chttp2/hpack_parser.c b/src/core/transport/chttp2/hpack_parser.c
index f8bff42ed6..f806f59ed7 100644
--- a/src/core/transport/chttp2/hpack_parser.c
+++ b/src/core/transport/chttp2/hpack_parser.c
@@ -1099,7 +1099,7 @@ static int append_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
gpr_uint8 decoded[3];
switch ((binary_state)p->binary) {
case NOT_BINARY:
- append_bytes(str, cur, end - cur);
+ append_bytes(str, cur, (size_t)(end - cur));
return 1;
b64_byte0:
case B64_BYTE0:
@@ -1249,7 +1249,7 @@ static int add_str_bytes(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
static int parse_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
const gpr_uint8 *end) {
size_t remaining = p->strlen - p->strgot;
- size_t given = end - cur;
+ size_t given = (size_t)(end - cur);
if (remaining <= given) {
return add_str_bytes(p, cur, cur + remaining) && finish_str(p) &&
parse_next(p, cur + remaining, end);
diff --git a/src/core/transport/chttp2/hpack_parser.h b/src/core/transport/chttp2/hpack_parser.h
index c1768d9d5d..4f489d67fb 100644
--- a/src/core/transport/chttp2/hpack_parser.h
+++ b/src/core/transport/chttp2/hpack_parser.h
@@ -79,7 +79,7 @@ struct grpc_chttp2_hpack_parser {
/* number of source bytes read for the currently parsing string */
gpr_uint32 strgot;
/* huffman decoding state */
- gpr_uint16 huff_state;
+ gpr_int16 huff_state;
/* is the string being decoded binary? */
gpr_uint8 binary;
/* is the current string huffman encoded? */
diff --git a/src/core/transport/chttp2/hpack_table.c b/src/core/transport/chttp2/hpack_table.c
index 4fc154380e..3aeb4dae94 100644
--- a/src/core/transport/chttp2/hpack_table.c
+++ b/src/core/transport/chttp2/hpack_table.c
@@ -139,7 +139,7 @@ grpc_mdelem *grpc_chttp2_hptbl_lookup(const grpc_chttp2_hptbl *tbl,
/* Otherwise, find the value in the list of valid entries */
index -= (GRPC_CHTTP2_LAST_STATIC_ENTRY + 1);
if (index < tbl->num_ents) {
- gpr_uint32 offset = (tbl->num_ents - 1 - index + tbl->first_ent) %
+ gpr_uint32 offset = (tbl->num_ents - 1u - index + tbl->first_ent) %
GRPC_CHTTP2_MAX_TABLE_COUNT;
return tbl->ents[offset];
}
diff --git a/src/core/transport/chttp2/incoming_metadata.c b/src/core/transport/chttp2/incoming_metadata.c
index 974b864ffb..d216c42113 100644
--- a/src/core/transport/chttp2/incoming_metadata.c
+++ b/src/core/transport/chttp2/incoming_metadata.c
@@ -122,7 +122,7 @@ void grpc_incoming_metadata_buffer_move_to_referencing_sopb(
for (i = 0; i < sopb->nops; i++) {
if (sopb->ops[i].type != GRPC_OP_METADATA) continue;
sopb->ops[i].data.metadata.list.tail =
- (void *)(delta + (gpr_intptr)sopb->ops[i].data.metadata.list.tail);
+ (void *)(delta + (gpr_uintptr)sopb->ops[i].data.metadata.list.tail);
}
src->count = 0;
}
diff --git a/src/core/transport/chttp2/internal.h b/src/core/transport/chttp2/internal.h
index 7a42de9245..125cd744b7 100644
--- a/src/core/transport/chttp2/internal.h
+++ b/src/core/transport/chttp2/internal.h
@@ -609,20 +609,21 @@ extern int grpc_flowctl_trace;
else \
stmt
-#define GRPC_CHTTP2_FLOWCTL_TRACE_STREAM(reason, transport, context, var, \
- delta) \
- if (!(grpc_flowctl_trace)) { \
- } else { \
- grpc_chttp2_flowctl_trace(__FILE__, __LINE__, reason, #context, #var, \
- transport->is_client, context->id, context->var, \
- delta); \
+#define GRPC_CHTTP2_FLOWCTL_TRACE_STREAM(reason, transport, context, var, \
+ delta) \
+ if (!(grpc_flowctl_trace)) { \
+ } else { \
+ grpc_chttp2_flowctl_trace(__FILE__, __LINE__, reason, #context, #var, \
+ transport->is_client, context->id, \
+ (gpr_int64)(context->var), (gpr_int64)(delta)); \
}
-#define GRPC_CHTTP2_FLOWCTL_TRACE_TRANSPORT(reason, context, var, delta) \
- if (!(grpc_flowctl_trace)) { \
- } else { \
- grpc_chttp2_flowctl_trace(__FILE__, __LINE__, reason, #context, #var, \
- context->is_client, 0, context->var, delta); \
+#define GRPC_CHTTP2_FLOWCTL_TRACE_TRANSPORT(reason, context, var, delta) \
+ if (!(grpc_flowctl_trace)) { \
+ } else { \
+ grpc_chttp2_flowctl_trace(__FILE__, __LINE__, reason, #context, #var, \
+ context->is_client, 0, \
+ (gpr_int64)(context->var), (gpr_int64)(delta)); \
}
void grpc_chttp2_flowctl_trace(const char *file, int line, const char *reason,
diff --git a/src/core/transport/chttp2/parsing.c b/src/core/transport/chttp2/parsing.c
index dc5eb18e42..b0f884e258 100644
--- a/src/core/transport/chttp2/parsing.c
+++ b/src/core/transport/chttp2/parsing.c
@@ -194,7 +194,8 @@ void grpc_chttp2_publish_reads(
GRPC_CHTTP2_FLOWCTL_TRACE_STREAM(
"parsed", transport_parsing, stream_parsing, outgoing_window_update,
-(gpr_int64)stream_parsing->outgoing_window_update);
- stream_global->outgoing_window += stream_parsing->outgoing_window_update;
+ stream_global->outgoing_window +=
+ (gpr_uint32)stream_global->outgoing_window;
stream_parsing->outgoing_window_update = 0;
is_zero = stream_global->outgoing_window <= 0;
if (was_zero && !is_zero) {
@@ -379,9 +380,10 @@ int grpc_chttp2_perform_read(grpc_chttp2_transport_parsing *transport_parsing,
case GRPC_DTS_FRAME:
GPR_ASSERT(cur < end);
if ((gpr_uint32)(end - cur) == transport_parsing->incoming_frame_size) {
- if (!parse_frame_slice(
- transport_parsing,
- gpr_slice_sub_no_ref(slice, cur - beg, end - beg), 1)) {
+ if (!parse_frame_slice(transport_parsing,
+ gpr_slice_sub_no_ref(slice, (size_t)(cur - beg),
+ (size_t)(end - beg)),
+ 1)) {
return 0;
}
transport_parsing->deframe_state = GRPC_DTS_FH_0;
@@ -389,11 +391,12 @@ int grpc_chttp2_perform_read(grpc_chttp2_transport_parsing *transport_parsing,
return 1;
} else if ((gpr_uint32)(end - cur) >
transport_parsing->incoming_frame_size) {
+ size_t cur_offset = (size_t)(cur - beg);
if (!parse_frame_slice(
transport_parsing,
gpr_slice_sub_no_ref(
- slice, cur - beg,
- cur + transport_parsing->incoming_frame_size - beg),
+ slice, cur_offset,
+ cur_offset + transport_parsing->incoming_frame_size),
1)) {
return 0;
}
@@ -401,9 +404,10 @@ int grpc_chttp2_perform_read(grpc_chttp2_transport_parsing *transport_parsing,
transport_parsing->incoming_stream = NULL;
goto dts_fh_0; /* loop */
} else {
- if (!parse_frame_slice(
- transport_parsing,
- gpr_slice_sub_no_ref(slice, cur - beg, end - beg), 0)) {
+ if (!parse_frame_slice(transport_parsing,
+ gpr_slice_sub_no_ref(slice, (size_t)(cur - beg),
+ (size_t)(end - beg)),
+ 0)) {
return 0;
}
transport_parsing->incoming_frame_size -= (end - cur);
diff --git a/src/core/transport/chttp2/stream_encoder.c b/src/core/transport/chttp2/stream_encoder.c
index 1ea697f71e..bcae93dc7a 100644
--- a/src/core/transport/chttp2/stream_encoder.c
+++ b/src/core/transport/chttp2/stream_encoder.c
@@ -134,7 +134,7 @@ static void begin_new_frame(framer_state *st, frame_type type) {
space to add at least about_to_add bytes -- finishes the current frame if
needed */
static void ensure_frame_type(framer_state *st, frame_type type,
- int need_bytes) {
+ size_t need_bytes) {
if (st->cur_frame_type == type &&
st->output->length - st->output_length_at_start_of_frame + need_bytes <=
GRPC_CHTTP2_MAX_PAYLOAD_LENGTH) {
@@ -174,7 +174,7 @@ static void add_header_data(framer_state *st, gpr_slice slice) {
}
}
-static gpr_uint8 *add_tiny_header_data(framer_state *st, int len) {
+static gpr_uint8 *add_tiny_header_data(framer_state *st, size_t len) {
ensure_frame_type(st, HEADER, len);
return gpr_slice_buffer_tiny_add(st->output, len);
}
@@ -270,7 +270,7 @@ static grpc_mdelem *add_elem(grpc_chttp2_hpack_compressor *c,
static void emit_indexed(grpc_chttp2_hpack_compressor *c, gpr_uint32 index,
framer_state *st) {
- int len = GRPC_CHTTP2_VARINT_LENGTH(index, 1);
+ size_t len = GRPC_CHTTP2_VARINT_LENGTH(index, 1);
GRPC_CHTTP2_WRITE_VARINT(index, 1, 0x80, add_tiny_header_data(st, len), len);
}
@@ -288,11 +288,11 @@ static gpr_slice get_wire_value(grpc_mdelem *elem, gpr_uint8 *huffman_prefix) {
static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c,
gpr_uint32 key_index, grpc_mdelem *elem,
framer_state *st) {
- int len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2);
+ gpr_uint32 len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 2);
gpr_uint8 huffman_prefix;
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix);
- int len_val = GPR_SLICE_LENGTH(value_slice);
- int len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
+ gpr_uint32 len_val = GPR_SLICE_LENGTH(value_slice);
+ gpr_uint32 len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
GRPC_CHTTP2_WRITE_VARINT(key_index, 2, 0x40,
add_tiny_header_data(st, len_pfx), len_pfx);
GRPC_CHTTP2_WRITE_VARINT(len_val, 1, 0x00,
@@ -303,11 +303,11 @@ static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c,
static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c,
gpr_uint32 key_index, grpc_mdelem *elem,
framer_state *st) {
- int len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4);
+ gpr_uint32 len_pfx = GRPC_CHTTP2_VARINT_LENGTH(key_index, 4);
gpr_uint8 huffman_prefix;
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix);
- int len_val = GPR_SLICE_LENGTH(value_slice);
- int len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
+ gpr_uint32 len_val = GPR_SLICE_LENGTH(value_slice);
+ gpr_uint32 len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
GRPC_CHTTP2_WRITE_VARINT(key_index, 4, 0x00,
add_tiny_header_data(st, len_pfx), len_pfx);
GRPC_CHTTP2_WRITE_VARINT(len_val, 1, 0x00,
@@ -317,12 +317,12 @@ 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) {
- int len_key = GPR_SLICE_LENGTH(elem->key->slice);
+ gpr_uint32 len_key = GPR_SLICE_LENGTH(elem->key->slice);
gpr_uint8 huffman_prefix;
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix);
- int len_val = GPR_SLICE_LENGTH(value_slice);
- int len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
- int len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
+ gpr_uint32 len_val = GPR_SLICE_LENGTH(value_slice);
+ gpr_uint32 len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
+ gpr_uint32 len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
*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,12 +334,12 @@ 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) {
- int len_key = GPR_SLICE_LENGTH(elem->key->slice);
+ gpr_uint32 len_key = GPR_SLICE_LENGTH(elem->key->slice);
gpr_uint8 huffman_prefix;
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix);
- int len_val = GPR_SLICE_LENGTH(value_slice);
- int len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
- int len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
+ gpr_uint32 len_val = GPR_SLICE_LENGTH(value_slice);
+ gpr_uint32 len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1);
+ gpr_uint32 len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
*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);
diff --git a/src/core/transport/chttp2/timeout_encoding.c b/src/core/transport/chttp2/timeout_encoding.c
index 1dd768ada4..40fcdc26dc 100644
--- a/src/core/transport/chttp2/timeout_encoding.c
+++ b/src/core/transport/chttp2/timeout_encoding.c
@@ -137,14 +137,14 @@ static int is_all_whitespace(const char *p) {
int grpc_chttp2_decode_timeout(const char *buffer, gpr_timespec *timeout) {
gpr_uint32 x = 0;
- const char *p = buffer;
+ const gpr_uint8 *p = (const gpr_uint8 *)buffer;
int have_digit = 0;
/* skip whitespace */
for (; *p == ' '; p++)
;
/* decode numeric part */
for (; *p >= '0' && *p <= '9'; p++) {
- gpr_uint32 xp = x * 10 + *p - '0';
+ gpr_uint32 xp = x * 10u + (gpr_uint32)*p - (gpr_uint32)'0';
have_digit = 1;
if (xp < x) {
*timeout = gpr_inf_future(GPR_CLOCK_REALTIME);
@@ -180,5 +180,5 @@ int grpc_chttp2_decode_timeout(const char *buffer, gpr_timespec *timeout) {
return 0;
}
p++;
- return is_all_whitespace(p);
+ return is_all_whitespace((const char *)p);
}
diff --git a/src/core/transport/chttp2/varint.c b/src/core/transport/chttp2/varint.c
index 0722c9ada9..056f68047b 100644
--- a/src/core/transport/chttp2/varint.c
+++ b/src/core/transport/chttp2/varint.c
@@ -33,7 +33,7 @@
#include "src/core/transport/chttp2/varint.h"
-int grpc_chttp2_hpack_varint_length(gpr_uint32 tail_value) {
+gpr_uint32 grpc_chttp2_hpack_varint_length(gpr_uint32 tail_value) {
if (tail_value < (1 << 7)) {
return 2;
} else if (tail_value < (1 << 14)) {
@@ -48,7 +48,8 @@ int grpc_chttp2_hpack_varint_length(gpr_uint32 tail_value) {
}
void grpc_chttp2_hpack_write_varint_tail(gpr_uint32 tail_value,
- gpr_uint8* target, int tail_length) {
+ gpr_uint8* target,
+ gpr_uint32 tail_length) {
switch (tail_length) {
case 5:
target[4] = (gpr_uint8)((tail_value >> 28) | 0x80);
diff --git a/src/core/transport/chttp2/varint.h b/src/core/transport/chttp2/varint.h
index 0a6fb55248..37856913f8 100644
--- a/src/core/transport/chttp2/varint.h
+++ b/src/core/transport/chttp2/varint.h
@@ -41,10 +41,11 @@
/* length of a value that needs varint tail encoding (it's bigger than can be
bitpacked into the opcode byte) - returned value includes the length of the
opcode byte */
-int grpc_chttp2_hpack_varint_length(gpr_uint32 tail_value);
+gpr_uint32 grpc_chttp2_hpack_varint_length(gpr_uint32 tail_value);
void grpc_chttp2_hpack_write_varint_tail(gpr_uint32 tail_value,
- gpr_uint8* target, int tail_length);
+ gpr_uint8* target,
+ gpr_uint32 tail_length);
/* maximum value that can be bitpacked with the opcode if the opcode has a
prefix
@@ -54,14 +55,14 @@ void grpc_chttp2_hpack_write_varint_tail(gpr_uint32 tail_value,
/* length required to bitpack a value */
#define GRPC_CHTTP2_VARINT_LENGTH(n, prefix_bits) \
((n) < GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits) \
- ? 1 \
+ ? 1u \
: grpc_chttp2_hpack_varint_length( \
(n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits)))
#define GRPC_CHTTP2_WRITE_VARINT(n, prefix_bits, prefix_or, target, length) \
do { \
gpr_uint8* tgt = target; \
- if ((length) == 1) { \
+ if ((length) == 1u) { \
(tgt)[0] = (prefix_or) | (n); \
} else { \
(tgt)[0] = (prefix_or) | GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \
diff --git a/src/core/transport/chttp2_transport.c b/src/core/transport/chttp2_transport.c
index 9e3d7dd551..c1a3c0436f 100644
--- a/src/core/transport/chttp2_transport.c
+++ b/src/core/transport/chttp2_transport.c
@@ -306,7 +306,7 @@ static void init_transport(grpc_chttp2_transport *t,
GRPC_ARG_MAX_CONCURRENT_STREAMS);
} else {
push_setting(t, GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS,
- channel_args->args[i].value.integer);
+ (gpr_uint32)channel_args->args[i].value.integer);
}
} else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER)) {
@@ -320,7 +320,8 @@ static void init_transport(grpc_chttp2_transport *t,
t->global.next_stream_id & 1,
is_client ? "client" : "server");
} else {
- t->global.next_stream_id = channel_args->args[i].value.integer;
+ t->global.next_stream_id =
+ (gpr_uint32)channel_args->args[i].value.integer;
}
}
}
diff --git a/src/core/transport/metadata.c b/src/core/transport/metadata.c
index 61638764a6..9b07b980b7 100644
--- a/src/core/transport/metadata.c
+++ b/src/core/transport/metadata.c
@@ -186,7 +186,8 @@ grpc_mdctx *grpc_mdctx_create(void) {
/* This seed is used to prevent remote connections from controlling hash table
* collisions. It needs to be somewhat unpredictable to a remote connection.
*/
- return grpc_mdctx_create_with_seed(gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
+ return grpc_mdctx_create_with_seed(
+ (gpr_uint32)gpr_now(GPR_CLOCK_REALTIME).tv_nsec);
}
static void discard_metadata(grpc_mdctx *ctx) {
diff --git a/test/core/channel/channel_args_test.c b/test/core/channel/channel_args_test.c
index 87f006acde..0b74dee41e 100644
--- a/test/core/channel/channel_args_test.c
+++ b/test/core/channel/channel_args_test.c
@@ -85,12 +85,13 @@ static void test_set_compression_algorithm(void) {
static void test_compression_algorithm_states(void) {
grpc_channel_args *ch_args, *ch_args_wo_gzip, *ch_args_wo_gzip_deflate;
- int states_bitset;
+ unsigned states_bitset;
size_t i;
ch_args = grpc_channel_args_copy_and_add(NULL, NULL, 0);
/* by default, all enabled */
- states_bitset = grpc_channel_args_compression_algorithm_get_states(ch_args);
+ states_bitset =
+ (unsigned)grpc_channel_args_compression_algorithm_get_states(ch_args);
for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
GPR_ASSERT(GPR_BITGET(states_bitset, i));
@@ -104,7 +105,7 @@ static void test_compression_algorithm_states(void) {
&ch_args_wo_gzip, GRPC_COMPRESS_DEFLATE, 0);
GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate);
- states_bitset = grpc_channel_args_compression_algorithm_get_states(
+ states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states(
ch_args_wo_gzip_deflate);
for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
if (i == GRPC_COMPRESS_GZIP || i == GRPC_COMPRESS_DEFLATE) {
@@ -119,8 +120,8 @@ static void test_compression_algorithm_states(void) {
&ch_args_wo_gzip_deflate, GRPC_COMPRESS_GZIP, 1);
GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate);
- states_bitset =
- grpc_channel_args_compression_algorithm_get_states(ch_args_wo_gzip);
+ states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states(
+ ch_args_wo_gzip);
for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
if (i == GRPC_COMPRESS_DEFLATE) {
GPR_ASSERT(GPR_BITGET(states_bitset, i) == 0);
diff --git a/test/core/end2end/dualstack_socket_test.c b/test/core/end2end/dualstack_socket_test.c
index fcc12952bf..2aee333d27 100644
--- a/test/core/end2end/dualstack_socket_test.c
+++ b/test/core/end2end/dualstack_socket_test.c
@@ -186,7 +186,7 @@ void test_connect(const char *server_host, const char *client_host, int port,
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(c, ops, op - ops, tag(1), NULL);
+ error = grpc_call_start_batch(c, ops, (size_t)(op - ops), tag(1), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
if (expect_ok) {
@@ -212,7 +212,7 @@ void test_connect(const char *server_host, const char *client_host, int port,
op->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0;
op++;
- error = grpc_call_start_batch(s, ops, op - ops, tag(102), NULL);
+ error = grpc_call_start_batch(s, ops, (size_t)(op - ops), tag(102), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
cq_expect_completion(cqv, tag(102), 1);
diff --git a/test/core/end2end/no_server_test.c b/test/core/end2end/no_server_test.c
index 619627ddd2..c391003141 100644
--- a/test/core/end2end/no_server_test.c
+++ b/test/core/end2end/no_server_test.c
@@ -79,8 +79,8 @@ int main(int argc, char **argv) {
op->flags = 0;
op->reserved = NULL;
op++;
- GPR_ASSERT(GRPC_CALL_OK ==
- grpc_call_start_batch(call, ops, op - ops, tag(1), NULL));
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(
+ call, ops, (size_t)(op - ops), tag(1), NULL));
/* verify that all tags get completed */
cq_expect_completion(cqv, tag(1), 1);
cq_verify(cqv);
diff --git a/test/core/fling/client.c b/test/core/fling/client.c
index 54c9274510..ed80544e3c 100644
--- a/test/core/fling/client.c
+++ b/test/core/fling/client.c
@@ -92,8 +92,9 @@ static void step_ping_pong_request(void) {
call = grpc_channel_create_call(channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
"/Reflector/reflectUnary", "localhost",
gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
- GPR_ASSERT(GRPC_CALL_OK ==
- grpc_call_start_batch(call, ops, op - ops, (void *)1, NULL));
+ GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops,
+ (size_t)(op - ops),
+ (void *)1, NULL));
grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
grpc_call_destroy(call);
grpc_byte_buffer_destroy(response_payload_recv);
@@ -188,7 +189,7 @@ int main(int argc, char **argv) {
channel = grpc_insecure_channel_create(target, NULL, NULL);
cq = grpc_completion_queue_create(NULL);
- the_buffer = grpc_raw_byte_buffer_create(&slice, payload_size);
+ the_buffer = grpc_raw_byte_buffer_create(&slice, (size_t)payload_size);
histogram = gpr_histogram_create(0.01, 60e9);
sc.init();
diff --git a/test/core/fling/fling_stream_test.c b/test/core/fling/fling_stream_test.c
index 4d9253c0ad..78a73372aa 100644
--- a/test/core/fling/fling_stream_test.c
+++ b/test/core/fling/fling_stream_test.c
@@ -60,10 +60,10 @@ int main(int argc, char **argv) {
pid_t svr, cli;
/* seed rng with pid, so we don't end up with the same random numbers as a
concurrently running test binary */
- srand(getpid());
+ srand((unsigned)getpid());
/* figure out where we are */
if (lslash) {
- memcpy(root, me, lslash - me);
+ memcpy(root, me, (size_t)(lslash - me));
root[lslash - me] = 0;
} else {
strcpy(root, ".");
diff --git a/test/core/fling/fling_test.c b/test/core/fling/fling_test.c
index 29d9050704..cf43ecfd2d 100644
--- a/test/core/fling/fling_test.c
+++ b/test/core/fling/fling_test.c
@@ -51,7 +51,7 @@ int main(int argc, char **argv) {
gpr_subprocess *svr, *cli;
/* figure out where we are */
if (lslash) {
- memcpy(root, me, lslash - me);
+ memcpy(root, me, (size_t)(lslash - me));
root[lslash - me] = 0;
} else {
strcpy(root, ".");
diff --git a/test/core/fling/server.c b/test/core/fling/server.c
index 0430ff9ab7..64f9573084 100644
--- a/test/core/fling/server.c
+++ b/test/core/fling/server.c
@@ -123,7 +123,7 @@ static void handle_unary_method(void) {
op->data.recv_close_on_server.cancelled = &was_cancelled;
op++;
- error = grpc_call_start_batch(call, unary_ops, op - unary_ops,
+ error = grpc_call_start_batch(call, unary_ops, (size_t)(op - unary_ops),
tag(FLING_SERVER_BATCH_OPS_FOR_UNARY), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
}
diff --git a/test/core/httpcli/httpcli_test.c b/test/core/httpcli/httpcli_test.c
index 42b2661c0a..cf2b10c021 100644
--- a/test/core/httpcli/httpcli_test.c
+++ b/test/core/httpcli/httpcli_test.c
@@ -134,7 +134,7 @@ int main(int argc, char **argv) {
/* figure out where we are */
if (lslash) {
- memcpy(root, me, lslash - me);
+ memcpy(root, me, (size_t)(lslash - me));
root[lslash - me] = 0;
} else {
strcpy(root, ".");
diff --git a/test/core/iomgr/alarm_heap_test.c b/test/core/iomgr/alarm_heap_test.c
index 66b6e4cb64..13bf7e43f6 100644
--- a/test/core/iomgr/alarm_heap_test.c
+++ b/test/core/iomgr/alarm_heap_test.c
@@ -48,9 +48,9 @@ static gpr_timespec random_deadline(void) {
return ts;
}
-static grpc_alarm *create_test_elements(int num_elements) {
+static grpc_alarm *create_test_elements(size_t num_elements) {
grpc_alarm *elems = gpr_malloc(num_elements * sizeof(grpc_alarm));
- int i;
+ size_t i;
for (i = 0; i < num_elements; i++) {
elems[i].deadline = random_deadline();
}
@@ -63,24 +63,25 @@ static int cmp_elem(const void *a, const void *b) {
return i - j;
}
-static int *all_top(grpc_alarm_heap *pq, int *n) {
- int *vec = NULL;
- int *need_to_check_children;
- int num_need_to_check_children = 0;
+static size_t *all_top(grpc_alarm_heap *pq, size_t *n) {
+ size_t *vec = NULL;
+ size_t *need_to_check_children;
+ size_t num_need_to_check_children = 0;
*n = 0;
if (pq->alarm_count == 0) return vec;
- need_to_check_children = gpr_malloc(pq->alarm_count * sizeof(int));
+ need_to_check_children =
+ gpr_malloc(pq->alarm_count * sizeof(*need_to_check_children));
need_to_check_children[num_need_to_check_children++] = 0;
- vec = gpr_malloc(pq->alarm_count * sizeof(int));
+ vec = gpr_malloc(pq->alarm_count * sizeof(*vec));
while (num_need_to_check_children > 0) {
- int ind = need_to_check_children[0];
- int leftchild, rightchild;
+ size_t ind = need_to_check_children[0];
+ size_t leftchild, rightchild;
num_need_to_check_children--;
memmove(need_to_check_children, need_to_check_children + 1,
- num_need_to_check_children * sizeof(int));
+ num_need_to_check_children * sizeof(*need_to_check_children));
vec[(*n)++] = ind;
- leftchild = 1 + 2 * ind;
+ leftchild = 1u + 2u * ind;
if (leftchild < pq->alarm_count) {
if (gpr_time_cmp(pq->alarms[leftchild]->deadline,
pq->alarms[ind]->deadline) >= 0) {
@@ -101,13 +102,14 @@ static int *all_top(grpc_alarm_heap *pq, int *n) {
}
static void check_pq_top(grpc_alarm *elements, grpc_alarm_heap *pq,
- gpr_uint8 *inpq, int num_elements) {
+ gpr_uint8 *inpq, size_t num_elements) {
gpr_timespec max_deadline = gpr_inf_past(GPR_CLOCK_REALTIME);
- int *max_deadline_indices = gpr_malloc(num_elements * sizeof(int));
- int *top_elements;
- int num_max_deadline_indices = 0;
- int num_top_elements;
- int i;
+ size_t *max_deadline_indices =
+ gpr_malloc(num_elements * sizeof(*max_deadline_indices));
+ size_t *top_elements;
+ size_t num_max_deadline_indices = 0;
+ size_t num_top_elements;
+ size_t i;
for (i = 0; i < num_elements; ++i) {
if (inpq[i] && gpr_time_cmp(elements[i].deadline, max_deadline) >= 0) {
if (gpr_time_cmp(elements[i].deadline, max_deadline) > 0) {
@@ -117,7 +119,8 @@ static void check_pq_top(grpc_alarm *elements, grpc_alarm_heap *pq,
max_deadline_indices[num_max_deadline_indices++] = elements[i].heap_index;
}
}
- qsort(max_deadline_indices, num_max_deadline_indices, sizeof(int), cmp_elem);
+ qsort(max_deadline_indices, num_max_deadline_indices,
+ sizeof(*max_deadline_indices), cmp_elem);
top_elements = all_top(pq, &num_top_elements);
GPR_ASSERT(num_top_elements == num_max_deadline_indices);
for (i = 0; i < num_top_elements; i++) {
@@ -128,7 +131,7 @@ static void check_pq_top(grpc_alarm *elements, grpc_alarm_heap *pq,
}
static int contains(grpc_alarm_heap *pq, grpc_alarm *el) {
- int i;
+ size_t i;
for (i = 0; i < pq->alarm_count; i++) {
if (pq->alarms[i] == el) return 1;
}
@@ -136,10 +139,10 @@ static int contains(grpc_alarm_heap *pq, grpc_alarm *el) {
}
static void check_valid(grpc_alarm_heap *pq) {
- int i;
+ size_t i;
for (i = 0; i < pq->alarm_count; ++i) {
- int left_child = 1 + 2 * i;
- int right_child = left_child + 1;
+ size_t left_child = 1u + 2u * i;
+ size_t right_child = left_child + 1u;
if (left_child < pq->alarm_count) {
GPR_ASSERT(gpr_time_cmp(pq->alarms[i]->deadline,
pq->alarms[left_child]->deadline) >= 0);
@@ -153,9 +156,9 @@ static void check_valid(grpc_alarm_heap *pq) {
static void test1(void) {
grpc_alarm_heap pq;
- const int num_test_elements = 200;
- const int num_test_operations = 10000;
- int i;
+ const size_t num_test_elements = 200;
+ const size_t num_test_operations = 10000;
+ size_t i;
grpc_alarm *test_elements = create_test_elements(num_test_elements);
gpr_uint8 *inpq = gpr_malloc(num_test_elements);
@@ -182,7 +185,7 @@ static void test1(void) {
check_pq_top(test_elements, &pq, inpq, num_test_elements);
for (i = 0; i < num_test_operations; ++i) {
- int elem_num = rand() % num_test_elements;
+ size_t elem_num = (size_t)rand() % num_test_elements;
grpc_alarm *el = &test_elements[elem_num];
if (!inpq[elem_num]) { /* not in pq */
GPR_ASSERT(!contains(&pq, el));
@@ -209,11 +212,11 @@ static void test1(void) {
static void shrink_test(void) {
grpc_alarm_heap pq;
- int i;
- int expected_size;
+ size_t i;
+ size_t expected_size;
/* A large random number to allow for multiple shrinkages, at least 512. */
- const int num_elements = rand() % 2000 + 512;
+ const size_t num_elements = (size_t)rand() % 2000 + 512;
grpc_alarm_heap_init(&pq);
@@ -243,7 +246,7 @@ static void shrink_test(void) {
4 times the Size and not less than 2 times, but never goes below 16. */
expected_size = pq.alarm_count;
while (pq.alarm_count > 0) {
- const int which = rand() % pq.alarm_count;
+ const size_t which = (size_t)rand() % pq.alarm_count;
grpc_alarm *te = pq.alarms[which];
grpc_alarm_heap_remove(&pq, te);
gpr_free(te);
diff --git a/test/core/iomgr/tcp_posix_test.c b/test/core/iomgr/tcp_posix_test.c
index 8acaa433bb..b94f5987ca 100644
--- a/test/core/iomgr/tcp_posix_test.c
+++ b/test/core/iomgr/tcp_posix_test.c
@@ -105,7 +105,7 @@ static size_t fill_socket_partial(int fd, size_t bytes) {
do {
write_bytes = write(fd, buf, bytes - total_bytes);
if (write_bytes > 0) {
- total_bytes += write_bytes;
+ total_bytes += (size_t)write_bytes;
}
} while ((write_bytes >= 0 || errno == EINTR) && bytes > total_bytes);
@@ -116,15 +116,15 @@ static size_t fill_socket_partial(int fd, size_t bytes) {
struct read_socket_state {
grpc_endpoint *ep;
- ssize_t read_bytes;
- ssize_t target_read_bytes;
+ size_t read_bytes;
+ size_t target_read_bytes;
gpr_slice_buffer incoming;
grpc_iomgr_closure read_cb;
};
-static ssize_t count_slices(gpr_slice *slices, size_t nslices,
- int *current_data) {
- ssize_t num_bytes = 0;
+static size_t count_slices(gpr_slice *slices, size_t nslices,
+ int *current_data) {
+ size_t num_bytes = 0;
unsigned i, j;
unsigned char *buf;
for (i = 0; i < nslices; ++i) {
@@ -140,7 +140,7 @@ static ssize_t count_slices(gpr_slice *slices, size_t nslices,
static void read_cb(void *user_data, int success) {
struct read_socket_state *state = (struct read_socket_state *)user_data;
- ssize_t read_bytes;
+ size_t read_bytes;
int current_data;
GPR_ASSERT(success);
@@ -172,11 +172,11 @@ static void read_cb(void *user_data, int success) {
}
/* Write to a socket, then read from it using the grpc_tcp API. */
-static void read_test(ssize_t num_bytes, ssize_t slice_size) {
+static void read_test(size_t num_bytes, size_t slice_size) {
int sv[2];
grpc_endpoint *ep;
struct read_socket_state state;
- ssize_t written_bytes;
+ size_t written_bytes;
gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20);
gpr_log(GPR_INFO, "Read test of size %d, slice size %d", num_bytes,
@@ -222,7 +222,7 @@ static void read_test(ssize_t num_bytes, ssize_t slice_size) {
/* Write to a socket until it fills up, then read from it using the grpc_tcp
API. */
-static void large_read_test(ssize_t slice_size) {
+static void large_read_test(size_t slice_size) {
int sv[2];
grpc_endpoint *ep;
struct read_socket_state state;
@@ -242,7 +242,7 @@ static void large_read_test(ssize_t slice_size) {
state.ep = ep;
state.read_bytes = 0;
- state.target_read_bytes = written_bytes;
+ state.target_read_bytes = (size_t)written_bytes;
gpr_slice_buffer_init(&state.incoming);
grpc_iomgr_closure_init(&state.read_cb, read_cb, &state);
@@ -275,11 +275,11 @@ struct write_socket_state {
int write_done;
};
-static gpr_slice *allocate_blocks(ssize_t num_bytes, ssize_t slice_size,
+static gpr_slice *allocate_blocks(size_t num_bytes, size_t slice_size,
size_t *num_blocks, int *current_data) {
- size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1 : 0);
+ size_t nslices = num_bytes / slice_size + (num_bytes % slice_size ? 1u : 0u);
gpr_slice *slices = gpr_malloc(sizeof(gpr_slice) * nslices);
- ssize_t num_bytes_left = num_bytes;
+ size_t num_bytes_left = num_bytes;
unsigned i, j;
unsigned char *buf;
*num_blocks = nslices;
@@ -334,7 +334,7 @@ void drain_socket_blocking(int fd, size_t num_bytes, size_t read_size) {
GPR_ASSERT(buf[i] == current);
current = (current + 1) % 256;
}
- bytes_left -= bytes_read;
+ bytes_left -= (size_t)bytes_read;
if (bytes_left == 0) break;
}
flags = fcntl(fd, F_GETFL, 0);
@@ -366,7 +366,7 @@ static ssize_t drain_socket(int fd) {
/* Write to a socket using the grpc_tcp API, then drain it directly.
Note that if the write does not complete immediately we need to drain the
socket in parallel with the read. */
-static void write_test(ssize_t num_bytes, ssize_t slice_size) {
+static void write_test(size_t num_bytes, size_t slice_size) {
int sv[2];
grpc_endpoint *ep;
struct write_socket_state state;
@@ -400,7 +400,7 @@ static void write_test(ssize_t num_bytes, ssize_t slice_size) {
case GRPC_ENDPOINT_DONE:
/* Write completed immediately */
read_bytes = drain_socket(sv[0]);
- GPR_ASSERT(read_bytes == num_bytes);
+ GPR_ASSERT((size_t)read_bytes == num_bytes);
break;
case GRPC_ENDPOINT_PENDING:
drain_socket_blocking(sv[0], num_bytes, num_bytes);
@@ -426,7 +426,7 @@ static void write_test(ssize_t num_bytes, ssize_t slice_size) {
}
void run_tests(void) {
- int i = 0;
+ size_t i = 0;
read_test(100, 8192);
read_test(10000, 8192);
diff --git a/test/core/json/json_rewrite.c b/test/core/json/json_rewrite.c
index 02f60a3163..561bf487b9 100644
--- a/test/core/json/json_rewrite.c
+++ b/test/core/json/json_rewrite.c
@@ -81,7 +81,7 @@ grpc_json_writer_vtable writer_vtable = {json_writer_output_char,
static void check_string(json_reader_userdata* state, size_t needed) {
if (state->free_space >= needed) return;
needed -= state->free_space;
- needed = (needed + 0xff) & ~0xff;
+ needed = (needed + 0xffu) & ~0xffu;
state->scratchpad = gpr_realloc(state->scratchpad, state->allocated + needed);
state->free_space += needed;
state->allocated += needed;
@@ -103,22 +103,22 @@ static void json_reader_string_add_utf32(void* userdata, gpr_uint32 c) {
if (c <= 0x7f) {
json_reader_string_add_char(userdata, c);
} else if (c <= 0x7ff) {
- int b1 = 0xc0 | ((c >> 6) & 0x1f);
- int b2 = 0x80 | (c & 0x3f);
+ gpr_uint32 b1 = 0xc0u | ((c >> 6u) & 0x1fu);
+ gpr_uint32 b2 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2);
- } else if (c <= 0xffff) {
- int b1 = 0xe0 | ((c >> 12) & 0x0f);
- int b2 = 0x80 | ((c >> 6) & 0x3f);
- int b3 = 0x80 | (c & 0x3f);
+ } else if (c <= 0xffffu) {
+ gpr_uint32 b1 = 0xe0u | ((c >> 12u) & 0x0fu);
+ gpr_uint32 b2 = 0x80u | ((c >> 6u) & 0x3fu);
+ gpr_uint32 b3 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2);
json_reader_string_add_char(userdata, b3);
- } else if (c <= 0x1fffff) {
- int b1 = 0xf0 | ((c >> 18) & 0x07);
- int b2 = 0x80 | ((c >> 12) & 0x3f);
- int b3 = 0x80 | ((c >> 6) & 0x3f);
- int b4 = 0x80 | (c & 0x3f);
+ } else if (c <= 0x1fffffu) {
+ gpr_uint32 b1 = 0xf0u | ((c >> 18u) & 0x07u);
+ gpr_uint32 b2 = 0x80u | ((c >> 12u) & 0x3fu);
+ gpr_uint32 b3 = 0x80u | ((c >> 6u) & 0x3fu);
+ gpr_uint32 b4 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2);
json_reader_string_add_char(userdata, b3);
@@ -132,7 +132,7 @@ static gpr_uint32 json_reader_read_char(void* userdata) {
r = fgetc(state->in);
if (r == EOF) r = GRPC_JSON_READ_CHAR_EOF;
- return r;
+ return (gpr_uint32)r;
}
static void json_reader_container_begins(void* userdata, grpc_json_type type) {
diff --git a/test/core/json/json_rewrite_test.c b/test/core/json/json_rewrite_test.c
index f5859322ea..7cf184950e 100644
--- a/test/core/json/json_rewrite_test.c
+++ b/test/core/json/json_rewrite_test.c
@@ -93,7 +93,7 @@ grpc_json_writer_vtable writer_vtable = {json_writer_output_char,
static void check_string(json_reader_userdata* state, size_t needed) {
if (state->free_space >= needed) return;
needed -= state->free_space;
- needed = (needed + 0xff) & ~0xff;
+ needed = (needed + 0xffu) & ~0xffu;
state->scratchpad = gpr_realloc(state->scratchpad, state->allocated + needed);
state->free_space += needed;
state->allocated += needed;
@@ -114,23 +114,23 @@ static void json_reader_string_add_char(void* userdata, gpr_uint32 c) {
static void json_reader_string_add_utf32(void* userdata, gpr_uint32 c) {
if (c <= 0x7f) {
json_reader_string_add_char(userdata, c);
- } else if (c <= 0x7ff) {
- int b1 = 0xc0 | ((c >> 6) & 0x1f);
- int b2 = 0x80 | (c & 0x3f);
+ } else if (c <= 0x7ffu) {
+ gpr_uint32 b1 = 0xc0u | ((c >> 6u) & 0x1fu);
+ gpr_uint32 b2 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2);
- } else if (c <= 0xffff) {
- int b1 = 0xe0 | ((c >> 12) & 0x0f);
- int b2 = 0x80 | ((c >> 6) & 0x3f);
- int b3 = 0x80 | (c & 0x3f);
+ } else if (c <= 0xffffu) {
+ gpr_uint32 b1 = 0xe0u | ((c >> 12u) & 0x0fu);
+ gpr_uint32 b2 = 0x80u | ((c >> 6u) & 0x3fu);
+ gpr_uint32 b3 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2);
json_reader_string_add_char(userdata, b3);
- } else if (c <= 0x1fffff) {
- int b1 = 0xf0 | ((c >> 18) & 0x07);
- int b2 = 0x80 | ((c >> 12) & 0x3f);
- int b3 = 0x80 | ((c >> 6) & 0x3f);
- int b4 = 0x80 | (c & 0x3f);
+ } else if (c <= 0x1fffffu) {
+ gpr_uint32 b1 = 0xf0u | ((c >> 18u) & 0x07u);
+ gpr_uint32 b2 = 0x80u | ((c >> 12u) & 0x3fu);
+ gpr_uint32 b3 = 0x80u | ((c >> 6u) & 0x3fu);
+ gpr_uint32 b4 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2);
json_reader_string_add_char(userdata, b3);
@@ -151,7 +151,7 @@ static gpr_uint32 json_reader_read_char(void* userdata) {
r = fgetc(state->in);
if (r == EOF) r = GRPC_JSON_READ_CHAR_EOF;
- return r;
+ return (gpr_uint32)r;
}
static void json_reader_container_begins(void* userdata, grpc_json_type type) {
diff --git a/test/core/profiling/timers_test.c b/test/core/profiling/timers_test.c
index 12b08c115e..b79cde64bd 100644
--- a/test/core/profiling/timers_test.c
+++ b/test/core/profiling/timers_test.c
@@ -35,22 +35,22 @@
#include <stdlib.h>
#include "test/core/util/test_config.h"
-void test_log_events(int num_seqs) {
- int start = 0;
- int *state;
+void test_log_events(size_t num_seqs) {
+ size_t start = 0;
+ size_t *state;
state = calloc(num_seqs, sizeof(state[0]));
while (start < num_seqs) {
- int i;
- int row;
+ size_t i;
+ size_t row;
if (state[start] == 3) { /* Already done with this posn */
start++;
continue;
}
- row = rand() % 10; /* how many in a row */
+ row = (size_t)rand() % 10; /* how many in a row */
for (i = start; (i < start + row) && (i < num_seqs); i++) {
- int j;
- int advance = 1 + rand() % 3; /* how many to advance by */
+ size_t j;
+ size_t advance = 1 + (size_t)rand() % 3; /* how many to advance by */
for (j = 0; j < advance; j++) {
switch (state[i]) {
case 0:
diff --git a/test/core/security/base64_test.c b/test/core/security/base64_test.c
index f8b7ebf554..6d49b6d1a1 100644
--- a/test/core/security/base64_test.c
+++ b/test/core/security/base64_test.c
@@ -70,7 +70,7 @@ static void test_full_range_encode_decode_b64(int url_safe, int multiline) {
size_t i;
char *b64;
gpr_slice orig_decoded;
- for (i = 0; i < sizeof(orig); i++) orig[i] = (char)i;
+ for (i = 0; i < sizeof(orig); i++) orig[i] = (gpr_uint8)i;
/* Try all the different paddings. */
for (i = 0; i < 3; i++) {
@@ -122,7 +122,7 @@ static void test_url_safe_unsafe_mismtach_failure(void) {
char *b64;
gpr_slice orig_decoded;
int url_safe = 1;
- for (i = 0; i < sizeof(orig); i++) orig[i] = (char)i;
+ for (i = 0; i < sizeof(orig); i++) orig[i] = (gpr_uint8)i;
b64 = grpc_base64_encode(orig, sizeof(orig), url_safe, 0);
orig_decoded = grpc_base64_decode(b64, !url_safe);
diff --git a/test/core/security/json_token_test.c b/test/core/security/json_token_test.c
index 0bac61eb54..740fd018b6 100644
--- a/test/core/security/json_token_test.c
+++ b/test/core/security/json_token_test.c
@@ -391,20 +391,21 @@ static void test_jwt_encode_and_sign(
char *jwt = jwt_encode_and_sign_func(&json_key);
const char *dot = strchr(jwt, '.');
GPR_ASSERT(dot != NULL);
- parsed_header = parse_json_part_from_jwt(jwt, dot - jwt, &scratchpad);
+ parsed_header =
+ parse_json_part_from_jwt(jwt, (size_t)(dot - jwt), &scratchpad);
GPR_ASSERT(parsed_header != NULL);
check_jwt_header(parsed_header);
- offset = dot - jwt + 1;
+ offset = (size_t)(dot - jwt) + 1;
grpc_json_destroy(parsed_header);
gpr_free(scratchpad);
dot = strchr(jwt + offset, '.');
GPR_ASSERT(dot != NULL);
- parsed_claim =
- parse_json_part_from_jwt(jwt + offset, dot - (jwt + offset), &scratchpad);
+ parsed_claim = parse_json_part_from_jwt(
+ jwt + offset, (size_t)(dot - (jwt + offset)), &scratchpad);
GPR_ASSERT(parsed_claim != NULL);
check_jwt_claim_func(parsed_claim);
- offset = dot - jwt + 1;
+ offset = (size_t)(dot - jwt) + 1;
grpc_json_destroy(parsed_claim);
gpr_free(scratchpad);
diff --git a/test/core/support/murmur_hash_test.c b/test/core/support/murmur_hash_test.c
index 2462abf7de..1e5279f462 100644
--- a/test/core/support/murmur_hash_test.c
+++ b/test/core/support/murmur_hash_test.c
@@ -48,7 +48,7 @@ static void verification_test(hash_func hash, gpr_uint32 expected) {
gpr_uint8 key[256];
gpr_uint32 hashes[256];
gpr_uint32 final = 0;
- int i;
+ size_t i;
memset(key, 0, sizeof(key));
memset(hashes, 0, sizeof(hashes));
@@ -58,7 +58,7 @@ static void verification_test(hash_func hash, gpr_uint32 expected) {
for (i = 0; i < 256; i++) {
key[i] = (uint8_t)i;
- hashes[i] = hash(key, i, 256 - i);
+ hashes[i] = hash(key, i, 256u - i);
}
/* Then hash the result array */
diff --git a/test/core/support/slice_test.c b/test/core/support/slice_test.c
index 3ca87427dd..a84ad50cf3 100644
--- a/test/core/support/slice_test.c
+++ b/test/core/support/slice_test.c
@@ -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] = (char)i;
+ GPR_SLICE_START_PTR(slice)[i] = (gpr_uint8)i;
}
/* And finally we must succeed in destroying the slice */
gpr_slice_unref(slice);
@@ -143,10 +143,10 @@ static void check_head_tail(gpr_slice slice, gpr_slice head, gpr_slice tail) {
GPR_SLICE_START_PTR(tail), GPR_SLICE_LENGTH(tail)));
}
-static void test_slice_split_head_works(int length) {
+static void test_slice_split_head_works(size_t length) {
gpr_slice slice;
gpr_slice head, tail;
- int i;
+ size_t i;
LOG_TEST_NAME("test_slice_split_head_works");
gpr_log(GPR_INFO, "length=%d", length);
@@ -171,10 +171,10 @@ static void test_slice_split_head_works(int length) {
gpr_slice_unref(slice);
}
-static void test_slice_split_tail_works(int length) {
+static void test_slice_split_tail_works(size_t length) {
gpr_slice slice;
gpr_slice head, tail;
- int i;
+ size_t i;
LOG_TEST_NAME("test_slice_split_tail_works");
gpr_log(GPR_INFO, "length=%d", length);
diff --git a/test/core/support/stack_lockfree_test.c b/test/core/support/stack_lockfree_test.c
index 02ec3154d5..4a2a0532d8 100644
--- a/test/core/support/stack_lockfree_test.c
+++ b/test/core/support/stack_lockfree_test.c
@@ -46,9 +46,10 @@
#define MAX_THREADS 32
-static void test_serial_sized(int size) {
+static void test_serial_sized(size_t size) {
gpr_stack_lockfree *stack = gpr_stack_lockfree_create(size);
- int i;
+ size_t i;
+ size_t j;
/* First try popping empty */
GPR_ASSERT(gpr_stack_lockfree_pop(stack) == -1);
@@ -60,12 +61,11 @@ static void test_serial_sized(int size) {
/* Now add repeatedly more items and check them */
for (i = 1; i < size; i *= 2) {
- int j;
for (j = 0; j <= i; j++) {
GPR_ASSERT(gpr_stack_lockfree_push(stack, j) == (j == 0));
}
for (j = 0; j <= i; j++) {
- GPR_ASSERT(gpr_stack_lockfree_pop(stack) == i - j);
+ GPR_ASSERT(gpr_stack_lockfree_pop(stack) == (int)(i - j));
}
GPR_ASSERT(gpr_stack_lockfree_pop(stack) == -1);
}
@@ -74,7 +74,7 @@ static void test_serial_sized(int size) {
}
static void test_serial() {
- int i;
+ size_t i;
for (i = 128; i < MAX_STACK_SIZE; i *= 2) {
test_serial_sized(i);
}
@@ -107,7 +107,7 @@ static void test_mt_body(void *v) {
}
}
-static void test_mt_sized(int size, int nth) {
+static void test_mt_sized(size_t size, int nth) {
gpr_stack_lockfree *stack;
struct test_arg args[MAX_THREADS];
gpr_thd_id thds[MAX_THREADS];
@@ -137,7 +137,7 @@ static void test_mt_sized(int size, int nth) {
}
static void test_mt() {
- int size, nth;
+ size_t size, nth;
for (nth = 1; nth < MAX_THREADS; nth++) {
for (size = 128; size < MAX_STACK_SIZE; size *= 2) {
test_mt_sized(size, nth);
diff --git a/test/core/support/time_test.c b/test/core/support/time_test.c
index 594863c278..ce35edd83c 100644
--- a/test/core/support/time_test.c
+++ b/test/core/support/time_test.c
@@ -43,14 +43,14 @@
#include <grpc/support/time.h>
#include "test/core/util/test_config.h"
-static void to_fp(void *arg, const char *buf, int len) {
+static void to_fp(void *arg, const char *buf, size_t len) {
fwrite(buf, 1, len, (FILE *)arg);
}
/* Convert gpr_uintmax x to ascii base b (2..16), and write with
(*writer)(arg, ...), zero padding to "chars" digits). */
static void u_to_s(gpr_uintmax x, unsigned base, int chars,
- void (*writer)(void *arg, const char *buf, int len),
+ void (*writer)(void *arg, const char *buf, size_t len),
void *arg) {
char buf[64];
char *p = buf + sizeof(buf);
@@ -59,25 +59,25 @@ static void u_to_s(gpr_uintmax x, unsigned base, int chars,
x /= base;
chars--;
} while (x != 0 || chars > 0);
- (*writer)(arg, p, buf + sizeof(buf) - p);
+ (*writer)(arg, p, (size_t)(buf + sizeof(buf) - p));
}
/* Convert gpr_intmax x to ascii base b (2..16), and write with
(*writer)(arg, ...), zero padding to "chars" digits). */
static void i_to_s(gpr_intmax x, unsigned base, int chars,
- void (*writer)(void *arg, const char *buf, int len),
+ void (*writer)(void *arg, const char *buf, size_t len),
void *arg) {
if (x < 0) {
(*writer)(arg, "-", 1);
- u_to_s(-x, base, chars - 1, writer, arg);
+ u_to_s((gpr_uintmax)-x, base, chars - 1, writer, arg);
} else {
- u_to_s(x, base, chars, writer, arg);
+ u_to_s((gpr_uintmax)x, base, chars, writer, arg);
}
}
/* Convert ts to ascii, and write with (*writer)(arg, ...). */
static void ts_to_s(gpr_timespec t,
- void (*writer)(void *arg, const char *buf, int len),
+ void (*writer)(void *arg, const char *buf, size_t len),
void *arg) {
if (t.tv_sec < 0 && t.tv_nsec != 0) {
t.tv_sec++;
@@ -96,7 +96,7 @@ static void test_values(void) {
x = gpr_inf_future(GPR_CLOCK_REALTIME);
fprintf(stderr, "far future ");
- u_to_s(x.tv_sec, 16, 16, &to_fp, stderr);
+ i_to_s(x.tv_sec, 16, 16, &to_fp, stderr);
fprintf(stderr, "\n");
GPR_ASSERT(x.tv_sec >= INT_MAX);
fprintf(stderr, "far future ");
@@ -105,7 +105,7 @@ static void test_values(void) {
x = gpr_inf_past(GPR_CLOCK_REALTIME);
fprintf(stderr, "far past ");
- u_to_s(x.tv_sec, 16, 16, &to_fp, stderr);
+ i_to_s(x.tv_sec, 16, 16, &to_fp, stderr);
fprintf(stderr, "\n");
GPR_ASSERT(x.tv_sec <= INT_MIN);
fprintf(stderr, "far past ");
diff --git a/test/core/surface/byte_buffer_reader_test.c b/test/core/surface/byte_buffer_reader_test.c
index d9c60e4212..560e0ac7b2 100644
--- a/test/core/surface/byte_buffer_reader_test.c
+++ b/test/core/surface/byte_buffer_reader_test.c
@@ -113,14 +113,14 @@ static void test_read_none_compressed_slice(void) {
}
static void read_compressed_slice(grpc_compression_algorithm algorithm,
- int input_size) {
+ size_t input_size) {
gpr_slice input_slice;
gpr_slice_buffer sliceb_in;
gpr_slice_buffer sliceb_out;
grpc_byte_buffer *buffer;
grpc_byte_buffer_reader reader;
gpr_slice read_slice;
- int read_count = 0;
+ size_t read_count = 0;
gpr_slice_buffer_init(&sliceb_in);
gpr_slice_buffer_init(&sliceb_out);
@@ -149,13 +149,13 @@ static void read_compressed_slice(grpc_compression_algorithm algorithm,
}
static void test_read_gzip_compressed_slice(void) {
- const int INPUT_SIZE = 2048;
+ const size_t INPUT_SIZE = 2048;
LOG_TEST("test_read_gzip_compressed_slice");
read_compressed_slice(GRPC_COMPRESS_GZIP, INPUT_SIZE);
}
static void test_read_deflate_compressed_slice(void) {
- const int INPUT_SIZE = 2048;
+ const size_t INPUT_SIZE = 2048;
LOG_TEST("test_read_deflate_compressed_slice");
read_compressed_slice(GRPC_COMPRESS_DEFLATE, INPUT_SIZE);
}
diff --git a/test/core/surface/completion_queue_test.c b/test/core/surface/completion_queue_test.c
index c382b2a5aa..0eeb5dac45 100644
--- a/test/core/surface/completion_queue_test.c
+++ b/test/core/surface/completion_queue_test.c
@@ -177,7 +177,7 @@ typedef struct test_thread_options {
gpr_event on_phase1_done;
gpr_event *phase2;
gpr_event on_finished;
- int events_triggered;
+ size_t events_triggered;
int id;
grpc_completion_queue *cc;
} test_thread_options;
@@ -251,14 +251,14 @@ static void consumer_thread(void *arg) {
}
}
-static void test_threading(int producers, int consumers) {
+static void test_threading(size_t producers, size_t consumers) {
test_thread_options *options =
gpr_malloc((producers + consumers) * sizeof(test_thread_options));
gpr_event phase1 = GPR_EVENT_INIT;
gpr_event phase2 = GPR_EVENT_INIT;
grpc_completion_queue *cc = grpc_completion_queue_create(NULL);
- int i;
- int total_consumed = 0;
+ size_t i;
+ size_t total_consumed = 0;
static int optid = 101;
gpr_log(GPR_INFO, "%s: %d producers, %d consumers", "test_threading",
diff --git a/test/core/surface/lame_client_test.c b/test/core/surface/lame_client_test.c
index 96434193c9..0d29bea555 100644
--- a/test/core/surface/lame_client_test.c
+++ b/test/core/surface/lame_client_test.c
@@ -82,7 +82,7 @@ int main(int argc, char **argv) {
op->flags = 0;
op->reserved = NULL;
op++;
- error = grpc_call_start_batch(call, ops, op - ops, tag(1), NULL);
+ error = grpc_call_start_batch(call, ops, (size_t)(op - ops), tag(1), NULL);
GPR_ASSERT(GRPC_CALL_OK == error);
/* the call should immediately fail */
diff --git a/test/core/transport/chttp2/hpack_table_test.c b/test/core/transport/chttp2/hpack_table_test.c
index 15b37d17b6..ec0a569371 100644
--- a/test/core/transport/chttp2/hpack_table_test.c
+++ b/test/core/transport/chttp2/hpack_table_test.c
@@ -49,8 +49,8 @@ static void assert_str(const grpc_chttp2_hptbl *tbl, grpc_mdstr *mdstr,
GPR_ASSERT(gpr_slice_str_cmp(mdstr->slice, str) == 0);
}
-static void assert_index(const grpc_chttp2_hptbl *tbl, int idx, const char *key,
- const char *value) {
+static void assert_index(const grpc_chttp2_hptbl *tbl, size_t idx,
+ const char *key, const char *value) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(tbl, idx);
assert_str(tbl, md->key, key);
assert_str(tbl, md->value, value);
diff --git a/test/core/transport/chttp2/stream_encoder_test.c b/test/core/transport/chttp2/stream_encoder_test.c
index e6731ff195..4bb503b4e9 100644
--- a/test/core/transport/chttp2/stream_encoder_test.c
+++ b/test/core/transport/chttp2/stream_encoder_test.c
@@ -52,8 +52,8 @@ int g_failure = 0;
grpc_stream_op_buffer g_sopb;
void **to_delete = NULL;
-int num_to_delete = 0;
-int cap_to_delete = 0;
+size_t num_to_delete = 0;
+size_t cap_to_delete = 0;
static gpr_slice create_test_slice(size_t length) {
gpr_slice slice = gpr_slice_malloc(length);
@@ -126,8 +126,8 @@ static void test_small_data_framing(void) {
verify_sopb(10, 0, 5, "000005 0000 deadbeef 00000000ff");
}
-static void add_sopb_headers(int n, ...) {
- int i;
+static void add_sopb_headers(size_t n, ...) {
+ size_t i;
grpc_metadata_batch b;
va_list l;
grpc_linked_mdelem *e = gpr_malloc(sizeof(*e) * n);
@@ -336,7 +336,7 @@ static void run_test(void (*test)(), const char *name) {
}
int main(int argc, char **argv) {
- int i;
+ size_t i;
grpc_test_init(argc, argv);
TEST(test_small_data_framing);
TEST(test_basic_headers);
diff --git a/test/core/transport/chttp2/stream_map_test.c b/test/core/transport/chttp2/stream_map_test.c
index b0bb3a8904..72aaafd18d 100644
--- a/test/core/transport/chttp2/stream_map_test.c
+++ b/test/core/transport/chttp2/stream_map_test.c
@@ -203,9 +203,9 @@ static void test_periodic_compaction(size_t n) {
}
int main(int argc, char **argv) {
- int n = 1;
- int prev = 1;
- int tmp;
+ size_t n = 1;
+ size_t prev = 1;
+ size_t tmp;
grpc_test_init(argc, argv);
diff --git a/test/core/transport/metadata_test.c b/test/core/transport/metadata_test.c
index 4a4d4bcb8a..1861442bb1 100644
--- a/test/core/transport/metadata_test.c
+++ b/test/core/transport/metadata_test.c
@@ -177,11 +177,11 @@ static void test_spin_creating_the_same_thing(void) {
static void test_things_stick_around(void) {
grpc_mdctx *ctx;
- int i, j;
+ size_t i, j;
char *buffer;
- int nstrs = 1000;
+ size_t nstrs = 1000;
grpc_mdstr **strs = gpr_malloc(sizeof(grpc_mdstr *) * nstrs);
- int *shuf = gpr_malloc(sizeof(int) * nstrs);
+ size_t *shuf = gpr_malloc(sizeof(size_t) * nstrs);
grpc_mdstr *test;
LOG_TEST("test_things_stick_around");
@@ -201,9 +201,9 @@ static void test_things_stick_around(void) {
}
for (i = 0; i < nstrs; i++) {
- int p = rand() % nstrs;
- int q = rand() % nstrs;
- int temp = shuf[p];
+ size_t p = (size_t)rand() % nstrs;
+ size_t q = (size_t)rand() % nstrs;
+ size_t temp = shuf[p];
shuf[p] = shuf[q];
shuf[q] = temp;
}