Core compiles with -Wsign-conversion

pull/3322/head
Craig Tiller 10 years ago
parent be947697d7
commit 32ca48ce0b
  1. 21
      src/core/iomgr/tcp_posix.c
  2. 2
      src/core/iomgr/tcp_server.h
  3. 7
      src/core/iomgr/tcp_server_posix.c
  4. 9
      src/core/iomgr/udp_server.c
  5. 4
      src/core/iomgr/udp_server.h
  6. 2
      src/core/support/stack_lockfree.c
  7. 4
      src/core/support/stack_lockfree.h
  8. 6
      src/core/surface/channel.c
  9. 2
      src/core/surface/channel_create.c
  10. 11
      src/core/surface/server.c
  11. 14
      src/core/transport/chttp2/bin_encoder.c
  12. 16
      src/core/transport/chttp2/frame_data.c
  13. 2
      src/core/transport/chttp2/frame_goaway.c
  14. 4
      src/core/transport/chttp2/frame_settings.c
  15. 4
      src/core/transport/chttp2/hpack_parser.c
  16. 2
      src/core/transport/chttp2/hpack_parser.h
  17. 2
      src/core/transport/chttp2/hpack_table.c
  18. 2
      src/core/transport/chttp2/incoming_metadata.c
  19. 25
      src/core/transport/chttp2/internal.h
  20. 22
      src/core/transport/chttp2/parsing.c
  21. 34
      src/core/transport/chttp2/stream_encoder.c
  22. 6
      src/core/transport/chttp2/timeout_encoding.c
  23. 5
      src/core/transport/chttp2/varint.c
  24. 9
      src/core/transport/chttp2/varint.h
  25. 5
      src/core/transport/chttp2_transport.c
  26. 3
      src/core/transport/metadata.c
  27. 11
      test/core/channel/channel_args_test.c
  28. 4
      test/core/end2end/dualstack_socket_test.c
  29. 4
      test/core/end2end/no_server_test.c
  30. 7
      test/core/fling/client.c
  31. 4
      test/core/fling/fling_stream_test.c
  32. 2
      test/core/fling/fling_test.c
  33. 2
      test/core/fling/server.c
  34. 2
      test/core/httpcli/httpcli_test.c
  35. 65
      test/core/iomgr/alarm_heap_test.c
  36. 36
      test/core/iomgr/tcp_posix_test.c
  37. 26
      test/core/json/json_rewrite.c
  38. 28
      test/core/json/json_rewrite_test.c
  39. 16
      test/core/profiling/timers_test.c
  40. 4
      test/core/security/base64_test.c
  41. 11
      test/core/security/json_token_test.c
  42. 4
      test/core/support/murmur_hash_test.c
  43. 10
      test/core/support/slice_test.c
  44. 14
      test/core/support/stack_lockfree_test.c
  45. 18
      test/core/support/time_test.c
  46. 8
      test/core/surface/byte_buffer_reader_test.c
  47. 8
      test/core/surface/completion_queue_test.c
  48. 2
      test/core/surface/lame_client_test.c
  49. 4
      test/core/transport/chttp2/hpack_table_test.c
  50. 10
      test/core/transport/chttp2/stream_encoder_test.c
  51. 6
      test/core/transport/chttp2/stream_map_test.c
  52. 12
      test/core/transport/metadata_test.c

@ -67,8 +67,8 @@ typedef struct {
grpc_endpoint base; grpc_endpoint base;
grpc_fd *em_fd; grpc_fd *em_fd;
int fd; int fd;
int iov_size; /* Number of slices to allocate per read attempt */
int finished_edge; int finished_edge;
size_t iov_size; /* Number of slices to allocate per read attempt */
size_t slice_size; size_t slice_size;
gpr_refcount refcount; gpr_refcount refcount;
@ -215,8 +215,9 @@ static void tcp_continue_read(grpc_tcp *tcp) {
} else { } else {
GPR_ASSERT((size_t)read_bytes <= tcp->incoming_buffer->length); GPR_ASSERT((size_t)read_bytes <= tcp->incoming_buffer->length);
if ((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, gpr_slice_buffer_trim_end(
tcp->incoming_buffer->length - read_bytes); tcp->incoming_buffer,
tcp->incoming_buffer->length - (size_t)read_bytes);
} else if (tcp->iov_size < MAX_READ_IOVEC) { } else if (tcp->iov_size < MAX_READ_IOVEC) {
++tcp->iov_size; ++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) { static grpc_endpoint_op_status tcp_flush(grpc_tcp *tcp) {
struct msghdr msg; struct msghdr msg;
struct iovec iov[MAX_WRITE_IOVEC]; struct iovec iov[MAX_WRITE_IOVEC];
int iov_size; size_t iov_size;
ssize_t sent_length; ssize_t sent_length;
ssize_t sending_length; size_t sending_length;
ssize_t trailing; size_t trailing;
ssize_t unwind_slice_idx; size_t unwind_slice_idx;
ssize_t unwind_byte_idx; size_t unwind_byte_idx;
for (;;) { for (;;) {
sending_length = 0; sending_length = 0;
@ -319,9 +320,9 @@ static grpc_endpoint_op_status tcp_flush(grpc_tcp *tcp) {
} }
GPR_ASSERT(tcp->outgoing_byte_idx == 0); GPR_ASSERT(tcp->outgoing_byte_idx == 0);
trailing = sending_length - sent_length; trailing = sending_length - (size_t)sent_length;
while (trailing > 0) { while (trailing > 0) {
ssize_t slice_length; size_t slice_length;
tcp->outgoing_slice_idx--; tcp->outgoing_slice_idx--;
slice_length = GPR_SLICE_LENGTH( slice_length = GPR_SLICE_LENGTH(

@ -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 /* TODO(ctiller): deprecate this, and make grpc_tcp_server_add_ports to handle
all of the multiple socket port matching logic in one place */ 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 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, /* Returns the file descriptor of the Nth listening socket on this server,
or -1 if the index is out of bounds. or -1 if the index is out of bounds.

@ -256,7 +256,8 @@ static int get_max_accept_queue_size(void) {
} }
/* Prepare a recently-created socket for listening. */ /* 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; struct sockaddr_storage sockname_temp;
socklen_t sockname_len; socklen_t sockname_len;
@ -365,7 +366,7 @@ error:
} }
static int add_socket_to_server(grpc_tcp_server *s, int fd, 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; server_port *sp;
int port; int port;
char *addr_str; 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 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_port1 = -1;
int allocated_port2 = -1; int allocated_port2 = -1;
unsigned i; unsigned i;

@ -221,7 +221,8 @@ void grpc_udp_server_destroy(
} }
/* Prepare a recently-created socket for listening. */ /* 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; struct sockaddr_storage sockname_temp;
socklen_t sockname_len; socklen_t sockname_len;
int get_local_ip; 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, 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) { grpc_udp_server_read_cb read_cb) {
server_port *sp; server_port *sp;
int port; int port;
@ -319,8 +320,8 @@ static int add_socket_to_server(grpc_udp_server *s, int fd,
return port; return port;
} }
int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr, int addr_len, int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr,
grpc_udp_server_read_cb read_cb) { size_t addr_len, grpc_udp_server_read_cb read_cb) {
int allocated_port1 = -1; int allocated_port1 = -1;
int allocated_port2 = -1; int allocated_port2 = -1;
unsigned i; unsigned i;

@ -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 /* TODO(ctiller): deprecate this, and make grpc_udp_server_add_ports to handle
all of the multiple socket port matching logic in one place */ 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, int grpc_udp_server_add_port(grpc_udp_server *s, const void *addr,
grpc_udp_server_read_cb read_cb); size_t addr_len, grpc_udp_server_read_cb read_cb);
void grpc_udp_server_destroy(grpc_udp_server *server, void grpc_udp_server_destroy(grpc_udp_server *server,
void (*shutdown_done)(void *shutdown_done_arg), void (*shutdown_done)(void *shutdown_done_arg),

@ -79,7 +79,7 @@ struct gpr_stack_lockfree {
#endif #endif
}; };
gpr_stack_lockfree *gpr_stack_lockfree_create(int entries) { gpr_stack_lockfree *gpr_stack_lockfree_create(size_t entries) {
gpr_stack_lockfree *stack; gpr_stack_lockfree *stack;
stack = gpr_malloc(sizeof(*stack)); stack = gpr_malloc(sizeof(*stack));
/* Since we only allocate 16 bits to represent an entry number, /* Since we only allocate 16 bits to represent an entry number,

@ -34,11 +34,13 @@
#ifndef GRPC_INTERNAL_CORE_SUPPORT_STACK_LOCKFREE_H #ifndef GRPC_INTERNAL_CORE_SUPPORT_STACK_LOCKFREE_H
#define 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; typedef struct gpr_stack_lockfree gpr_stack_lockfree;
/* This stack must specify the maximum number of entries to track. /* This stack must specify the maximum number of entries to track.
The current implementation only allows up to 65534 entries */ 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); void gpr_stack_lockfree_destroy(gpr_stack_lockfree* stack);
/* Pass in a valid entry number for the next stack entry */ /* Pass in a valid entry number for the next stack entry */

@ -113,7 +113,7 @@ grpc_channel *grpc_channel_create_from_filters(
grpc_mdstr_from_string(mdctx, "grpc-message", 0); grpc_mdstr_from_string(mdctx, "grpc-message", 0);
for (i = 0; i < NUM_CACHED_STATUS_ELEMS; i++) { for (i = 0; i < NUM_CACHED_STATUS_ELEMS; i++) {
char buf[GPR_LTOA_MIN_BUFSIZE]; 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( channel->grpc_status_elem[i] = grpc_mdelem_from_metadata_strings(
mdctx, GRPC_MDSTR_REF(channel->grpc_status_string), mdctx, GRPC_MDSTR_REF(channel->grpc_status_string),
grpc_mdstr_from_string(mdctx, buf, 0)); 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", gpr_log(GPR_ERROR, "%s ignored: it must be >= 0",
GRPC_ARG_MAX_MESSAGE_LENGTH); GRPC_ARG_MAX_MESSAGE_LENGTH);
} else { } 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)) { } else if (0 == strcmp(args->args[i].key, GRPC_ARG_DEFAULT_AUTHORITY)) {
if (args->args[i].type != GRPC_ARG_STRING) { 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_completion_queue *cq, grpc_mdelem *path_mdelem,
grpc_mdelem *authority_mdelem, gpr_timespec deadline) { grpc_mdelem *authority_mdelem, gpr_timespec deadline) {
grpc_mdelem *send_metadata[2]; grpc_mdelem *send_metadata[2];
int num_metadata = 0; size_t num_metadata = 0;
GPR_ASSERT(channel->is_client); GPR_ASSERT(channel->is_client);

@ -164,7 +164,7 @@ grpc_channel *grpc_insecure_channel_create(const char *target,
grpc_resolver *resolver; grpc_resolver *resolver;
subchannel_factory *f; subchannel_factory *f;
grpc_mdctx *mdctx = grpc_mdctx_create(); grpc_mdctx *mdctx = grpc_mdctx_create();
int n = 0; size_t n = 0;
GPR_ASSERT(!reserved); GPR_ASSERT(!reserved);
if (grpc_channel_args_is_census_enabled(args)) { if (grpc_channel_args_is_census_enabled(args)) {
filters[n++] = &grpc_client_census_filter; filters[n++] = &grpc_client_census_filter;

@ -203,7 +203,7 @@ struct grpc_server {
gpr_stack_lockfree *request_freelist; gpr_stack_lockfree *request_freelist;
/** requested call backing data */ /** requested call backing data */
requested_call *requested_calls; requested_call *requested_calls;
int max_requested_calls; size_t max_requested_calls;
gpr_atm shutdown_flag; gpr_atm shutdown_flag;
gpr_uint8 shutdown_published; 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, static void request_matcher_init(request_matcher *request_matcher,
int entries) { size_t entries) {
memset(request_matcher, 0, sizeof(*request_matcher)); memset(request_matcher, 0, sizeof(*request_matcher));
request_matcher->requests = gpr_stack_lockfree_create(entries); 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 grpc_server_census_filter (optional) - for stats collection and tracing
{passed in filter stack} {passed in filter stack}
grpc_connected_channel_filter - for interfacing with transports */ 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 = server->channel_filters =
gpr_malloc(server->channel_filter_count * sizeof(grpc_channel_filter *)); gpr_malloc(server->channel_filter_count * sizeof(grpc_channel_filter *));
server->channel_filters[0] = &server_surface_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; server->channel_filters[1] = &grpc_server_census_filter;
} }
for (i = 0; i < filter_count; i++) { 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); 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_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) { static void done_request_event(void *req, grpc_cq_completion *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]; size_t output_length = input_triplets * 4 + tail_xtra[tail_case];
gpr_slice output = gpr_slice_malloc(output_length); gpr_slice output = gpr_slice_malloc(output_length);
gpr_uint8 *in = GPR_SLICE_START_PTR(input); 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; size_t i;
/* encode full triplets */ /* encode full triplets */
@ -100,7 +100,7 @@ gpr_slice grpc_chttp2_base64_encode(gpr_slice input) {
break; 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)); GPR_ASSERT(in == GPR_SLICE_END_PTR(input));
return output; return output;
} }
@ -133,7 +133,7 @@ gpr_slice grpc_chttp2_huffman_compress(gpr_slice input) {
} }
if (temp_length) { 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)); 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) { static void enc_add2(huff_out *out, gpr_uint8 a, gpr_uint8 b) {
b64_huff_sym sa = huff_alphabet[a]; b64_huff_sym sa = huff_alphabet[a];
b64_huff_sym sb = huff_alphabet[b]; b64_huff_sym sb = huff_alphabet[b];
out->temp = out->temp = (out->temp << (sa.length + sb.length)) |
(out->temp << (sa.length + sb.length)) | (sa.bits << sb.length) | sb.bits; ((gpr_uint32)sa.bits << sb.length) | sb.bits;
out->temp_length += sa.length + sb.length; out->temp_length += (gpr_uint32)sa.length + (gpr_uint32)sb.length;
enc_flush_some(out); enc_flush_some(out);
} }
@ -211,7 +211,7 @@ gpr_slice grpc_chttp2_base64_encode_and_huffman_compress(gpr_slice input) {
if (out.temp_length) { if (out.temp_length) {
*out.out++ = *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)); GPR_ASSERT(out.out <= GPR_SLICE_END_PTR(output));

@ -146,19 +146,21 @@ grpc_chttp2_parse_error grpc_chttp2_data_parser_parse(
grpc_chttp2_list_add_parsing_seen_stream(transport_parsing, grpc_chttp2_list_add_parsing_seen_stream(transport_parsing,
stream_parsing); stream_parsing);
if ((gpr_uint32)(end - cur) == p->frame_size) { if ((gpr_uint32)(end - cur) == p->frame_size) {
grpc_sopb_add_slice(&p->incoming_sopb, grpc_sopb_add_slice(
gpr_slice_sub(slice, cur - beg, end - beg)); &p->incoming_sopb,
gpr_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
p->state = GRPC_CHTTP2_DATA_FH_0; p->state = GRPC_CHTTP2_DATA_FH_0;
return GRPC_CHTTP2_PARSE_OK; return GRPC_CHTTP2_PARSE_OK;
} else if ((gpr_uint32)(end - cur) > p->frame_size) { } else if ((gpr_uint32)(end - cur) > p->frame_size) {
grpc_sopb_add_slice( grpc_sopb_add_slice(&p->incoming_sopb,
&p->incoming_sopb, gpr_slice_sub(slice, (size_t)(cur - beg),
gpr_slice_sub(slice, cur - beg, cur + p->frame_size - beg)); (size_t)(cur + p->frame_size - beg)));
cur += p->frame_size; cur += p->frame_size;
goto fh_0; /* loop */ goto fh_0; /* loop */
} else { } else {
grpc_sopb_add_slice(&p->incoming_sopb, grpc_sopb_add_slice(
gpr_slice_sub(slice, cur - beg, end - beg)); &p->incoming_sopb,
gpr_slice_sub(slice, (size_t)(cur - beg), (size_t)(end - beg)));
p->frame_size -= (end - cur); p->frame_size -= (end - cur);
return GRPC_CHTTP2_PARSE_OK; return GRPC_CHTTP2_PARSE_OK;
} }

@ -136,7 +136,7 @@ grpc_chttp2_parse_error grpc_chttp2_goaway_parser_parse(
++cur; ++cur;
/* fallthrough */ /* fallthrough */
case GRPC_CHTTP2_GOAWAY_DEBUG: 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->debug_pos += end - cur;
p->state = GRPC_CHTTP2_GOAWAY_DEBUG; p->state = GRPC_CHTTP2_GOAWAY_DEBUG;
if (is_last) { if (is_last) {

@ -81,14 +81,14 @@ gpr_slice grpc_chttp2_settings_create(gpr_uint32 *old, const gpr_uint32 *new,
gpr_uint8 *p; gpr_uint8 *p;
for (i = 0; i < count; i++) { 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); output = gpr_slice_malloc(9 + 6 * n);
p = fill_header(GPR_SLICE_START_PTR(output), 6 * n, 0); p = fill_header(GPR_SLICE_START_PTR(output), 6 * n, 0);
for (i = 0; i < count; i++) { 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); GPR_ASSERT(i);
*p++ = i >> 8; *p++ = i >> 8;
*p++ = i; *p++ = i;

@ -1099,7 +1099,7 @@ static int append_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
gpr_uint8 decoded[3]; gpr_uint8 decoded[3];
switch ((binary_state)p->binary) { switch ((binary_state)p->binary) {
case NOT_BINARY: case NOT_BINARY:
append_bytes(str, cur, end - cur); append_bytes(str, cur, (size_t)(end - cur));
return 1; return 1;
b64_byte0: b64_byte0:
case 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, static int parse_string(grpc_chttp2_hpack_parser *p, const gpr_uint8 *cur,
const gpr_uint8 *end) { const gpr_uint8 *end) {
size_t remaining = p->strlen - p->strgot; size_t remaining = p->strlen - p->strgot;
size_t given = end - cur; size_t given = (size_t)(end - cur);
if (remaining <= given) { if (remaining <= given) {
return add_str_bytes(p, cur, cur + remaining) && finish_str(p) && return add_str_bytes(p, cur, cur + remaining) && finish_str(p) &&
parse_next(p, cur + remaining, end); parse_next(p, cur + remaining, end);

@ -79,7 +79,7 @@ struct grpc_chttp2_hpack_parser {
/* number of source bytes read for the currently parsing string */ /* number of source bytes read for the currently parsing string */
gpr_uint32 strgot; gpr_uint32 strgot;
/* huffman decoding state */ /* huffman decoding state */
gpr_uint16 huff_state; gpr_int16 huff_state;
/* is the string being decoded binary? */ /* is the string being decoded binary? */
gpr_uint8 binary; gpr_uint8 binary;
/* is the current string huffman encoded? */ /* is the current string huffman encoded? */

@ -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 */ /* Otherwise, find the value in the list of valid entries */
index -= (GRPC_CHTTP2_LAST_STATIC_ENTRY + 1); index -= (GRPC_CHTTP2_LAST_STATIC_ENTRY + 1);
if (index < tbl->num_ents) { 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; GRPC_CHTTP2_MAX_TABLE_COUNT;
return tbl->ents[offset]; return tbl->ents[offset];
} }

@ -122,7 +122,7 @@ void grpc_incoming_metadata_buffer_move_to_referencing_sopb(
for (i = 0; i < sopb->nops; i++) { for (i = 0; i < sopb->nops; i++) {
if (sopb->ops[i].type != GRPC_OP_METADATA) continue; if (sopb->ops[i].type != GRPC_OP_METADATA) continue;
sopb->ops[i].data.metadata.list.tail = 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; src->count = 0;
} }

@ -609,20 +609,21 @@ extern int grpc_flowctl_trace;
else \ else \
stmt stmt
#define GRPC_CHTTP2_FLOWCTL_TRACE_STREAM(reason, transport, context, var, \ #define GRPC_CHTTP2_FLOWCTL_TRACE_STREAM(reason, transport, context, var, \
delta) \ delta) \
if (!(grpc_flowctl_trace)) { \ if (!(grpc_flowctl_trace)) { \
} else { \ } else { \
grpc_chttp2_flowctl_trace(__FILE__, __LINE__, reason, #context, #var, \ grpc_chttp2_flowctl_trace(__FILE__, __LINE__, reason, #context, #var, \
transport->is_client, context->id, context->var, \ transport->is_client, context->id, \
delta); \ (gpr_int64)(context->var), (gpr_int64)(delta)); \
} }
#define GRPC_CHTTP2_FLOWCTL_TRACE_TRANSPORT(reason, context, var, delta) \ #define GRPC_CHTTP2_FLOWCTL_TRACE_TRANSPORT(reason, context, var, delta) \
if (!(grpc_flowctl_trace)) { \ if (!(grpc_flowctl_trace)) { \
} else { \ } else { \
grpc_chttp2_flowctl_trace(__FILE__, __LINE__, reason, #context, #var, \ grpc_chttp2_flowctl_trace(__FILE__, __LINE__, reason, #context, #var, \
context->is_client, 0, context->var, delta); \ context->is_client, 0, \
(gpr_int64)(context->var), (gpr_int64)(delta)); \
} }
void grpc_chttp2_flowctl_trace(const char *file, int line, const char *reason, void grpc_chttp2_flowctl_trace(const char *file, int line, const char *reason,

@ -194,7 +194,8 @@ void grpc_chttp2_publish_reads(
GRPC_CHTTP2_FLOWCTL_TRACE_STREAM( GRPC_CHTTP2_FLOWCTL_TRACE_STREAM(
"parsed", transport_parsing, stream_parsing, outgoing_window_update, "parsed", transport_parsing, stream_parsing, outgoing_window_update,
-(gpr_int64)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; stream_parsing->outgoing_window_update = 0;
is_zero = stream_global->outgoing_window <= 0; is_zero = stream_global->outgoing_window <= 0;
if (was_zero && !is_zero) { if (was_zero && !is_zero) {
@ -379,9 +380,10 @@ int grpc_chttp2_perform_read(grpc_chttp2_transport_parsing *transport_parsing,
case GRPC_DTS_FRAME: case GRPC_DTS_FRAME:
GPR_ASSERT(cur < end); GPR_ASSERT(cur < end);
if ((gpr_uint32)(end - cur) == transport_parsing->incoming_frame_size) { if ((gpr_uint32)(end - cur) == transport_parsing->incoming_frame_size) {
if (!parse_frame_slice( if (!parse_frame_slice(transport_parsing,
transport_parsing, gpr_slice_sub_no_ref(slice, (size_t)(cur - beg),
gpr_slice_sub_no_ref(slice, cur - beg, end - beg), 1)) { (size_t)(end - beg)),
1)) {
return 0; return 0;
} }
transport_parsing->deframe_state = GRPC_DTS_FH_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; return 1;
} else if ((gpr_uint32)(end - cur) > } else if ((gpr_uint32)(end - cur) >
transport_parsing->incoming_frame_size) { transport_parsing->incoming_frame_size) {
size_t cur_offset = (size_t)(cur - beg);
if (!parse_frame_slice( if (!parse_frame_slice(
transport_parsing, transport_parsing,
gpr_slice_sub_no_ref( gpr_slice_sub_no_ref(
slice, cur - beg, slice, cur_offset,
cur + transport_parsing->incoming_frame_size - beg), cur_offset + transport_parsing->incoming_frame_size),
1)) { 1)) {
return 0; return 0;
} }
@ -401,9 +404,10 @@ int grpc_chttp2_perform_read(grpc_chttp2_transport_parsing *transport_parsing,
transport_parsing->incoming_stream = NULL; transport_parsing->incoming_stream = NULL;
goto dts_fh_0; /* loop */ goto dts_fh_0; /* loop */
} else { } else {
if (!parse_frame_slice( if (!parse_frame_slice(transport_parsing,
transport_parsing, gpr_slice_sub_no_ref(slice, (size_t)(cur - beg),
gpr_slice_sub_no_ref(slice, cur - beg, end - beg), 0)) { (size_t)(end - beg)),
0)) {
return 0; return 0;
} }
transport_parsing->incoming_frame_size -= (end - cur); transport_parsing->incoming_frame_size -= (end - cur);

@ -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 space to add at least about_to_add bytes -- finishes the current frame if
needed */ needed */
static void ensure_frame_type(framer_state *st, frame_type type, static void ensure_frame_type(framer_state *st, frame_type type,
int need_bytes) { size_t need_bytes) {
if (st->cur_frame_type == type && if (st->cur_frame_type == type &&
st->output->length - st->output_length_at_start_of_frame + need_bytes <= st->output->length - st->output_length_at_start_of_frame + need_bytes <=
GRPC_CHTTP2_MAX_PAYLOAD_LENGTH) { 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); ensure_frame_type(st, HEADER, len);
return gpr_slice_buffer_tiny_add(st->output, 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, static void emit_indexed(grpc_chttp2_hpack_compressor *c, gpr_uint32 index,
framer_state *st) { 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); 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, static void emit_lithdr_incidx(grpc_chttp2_hpack_compressor *c,
gpr_uint32 key_index, grpc_mdelem *elem, gpr_uint32 key_index, grpc_mdelem *elem,
framer_state *st) { 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_uint8 huffman_prefix;
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix); gpr_slice value_slice = get_wire_value(elem, &huffman_prefix);
int len_val = GPR_SLICE_LENGTH(value_slice); gpr_uint32 len_val = GPR_SLICE_LENGTH(value_slice);
int len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); gpr_uint32 len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
GRPC_CHTTP2_WRITE_VARINT(key_index, 2, 0x40, GRPC_CHTTP2_WRITE_VARINT(key_index, 2, 0x40,
add_tiny_header_data(st, len_pfx), len_pfx); add_tiny_header_data(st, len_pfx), len_pfx);
GRPC_CHTTP2_WRITE_VARINT(len_val, 1, 0x00, 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, static void emit_lithdr_noidx(grpc_chttp2_hpack_compressor *c,
gpr_uint32 key_index, grpc_mdelem *elem, gpr_uint32 key_index, grpc_mdelem *elem,
framer_state *st) { 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_uint8 huffman_prefix;
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix); gpr_slice value_slice = get_wire_value(elem, &huffman_prefix);
int len_val = GPR_SLICE_LENGTH(value_slice); gpr_uint32 len_val = GPR_SLICE_LENGTH(value_slice);
int len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1); gpr_uint32 len_val_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
GRPC_CHTTP2_WRITE_VARINT(key_index, 4, 0x00, GRPC_CHTTP2_WRITE_VARINT(key_index, 4, 0x00,
add_tiny_header_data(st, len_pfx), len_pfx); add_tiny_header_data(st, len_pfx), len_pfx);
GRPC_CHTTP2_WRITE_VARINT(len_val, 1, 0x00, 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, static void emit_lithdr_incidx_v(grpc_chttp2_hpack_compressor *c,
grpc_mdelem *elem, framer_state *st) { 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_uint8 huffman_prefix;
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix); gpr_slice value_slice = get_wire_value(elem, &huffman_prefix);
int len_val = GPR_SLICE_LENGTH(value_slice); gpr_uint32 len_val = GPR_SLICE_LENGTH(value_slice);
int len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); gpr_uint32 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_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
*add_tiny_header_data(st, 1) = 0x40; *add_tiny_header_data(st, 1) = 0x40;
GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00,
add_tiny_header_data(st, len_key_len), len_key_len); 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, static void emit_lithdr_noidx_v(grpc_chttp2_hpack_compressor *c,
grpc_mdelem *elem, framer_state *st) { 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_uint8 huffman_prefix;
gpr_slice value_slice = get_wire_value(elem, &huffman_prefix); gpr_slice value_slice = get_wire_value(elem, &huffman_prefix);
int len_val = GPR_SLICE_LENGTH(value_slice); gpr_uint32 len_val = GPR_SLICE_LENGTH(value_slice);
int len_key_len = GRPC_CHTTP2_VARINT_LENGTH(len_key, 1); gpr_uint32 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_len = GRPC_CHTTP2_VARINT_LENGTH(len_val, 1);
*add_tiny_header_data(st, 1) = 0x00; *add_tiny_header_data(st, 1) = 0x00;
GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00, GRPC_CHTTP2_WRITE_VARINT(len_key, 1, 0x00,
add_tiny_header_data(st, len_key_len), len_key_len); add_tiny_header_data(st, len_key_len), len_key_len);

@ -137,14 +137,14 @@ static int is_all_whitespace(const char *p) {
int grpc_chttp2_decode_timeout(const char *buffer, gpr_timespec *timeout) { int grpc_chttp2_decode_timeout(const char *buffer, gpr_timespec *timeout) {
gpr_uint32 x = 0; gpr_uint32 x = 0;
const char *p = buffer; const gpr_uint8 *p = (const gpr_uint8 *)buffer;
int have_digit = 0; int have_digit = 0;
/* skip whitespace */ /* skip whitespace */
for (; *p == ' '; p++) for (; *p == ' '; p++)
; ;
/* decode numeric part */ /* decode numeric part */
for (; *p >= '0' && *p <= '9'; p++) { 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; have_digit = 1;
if (xp < x) { if (xp < x) {
*timeout = gpr_inf_future(GPR_CLOCK_REALTIME); *timeout = gpr_inf_future(GPR_CLOCK_REALTIME);
@ -180,5 +180,5 @@ int grpc_chttp2_decode_timeout(const char *buffer, gpr_timespec *timeout) {
return 0; return 0;
} }
p++; p++;
return is_all_whitespace(p); return is_all_whitespace((const char *)p);
} }

@ -33,7 +33,7 @@
#include "src/core/transport/chttp2/varint.h" #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)) { if (tail_value < (1 << 7)) {
return 2; return 2;
} else if (tail_value < (1 << 14)) { } 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, 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) { switch (tail_length) {
case 5: case 5:
target[4] = (gpr_uint8)((tail_value >> 28) | 0x80); target[4] = (gpr_uint8)((tail_value >> 28) | 0x80);

@ -41,10 +41,11 @@
/* length of a value that needs varint tail encoding (it's bigger than can be /* 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 bitpacked into the opcode byte) - returned value includes the length of the
opcode byte */ 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, 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 /* maximum value that can be bitpacked with the opcode if the opcode has a
prefix prefix
@ -54,14 +55,14 @@ void grpc_chttp2_hpack_write_varint_tail(gpr_uint32 tail_value,
/* length required to bitpack a value */ /* length required to bitpack a value */
#define GRPC_CHTTP2_VARINT_LENGTH(n, prefix_bits) \ #define GRPC_CHTTP2_VARINT_LENGTH(n, prefix_bits) \
((n) < GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits) \ ((n) < GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits) \
? 1 \ ? 1u \
: grpc_chttp2_hpack_varint_length( \ : grpc_chttp2_hpack_varint_length( \
(n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits))) (n)-GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits)))
#define GRPC_CHTTP2_WRITE_VARINT(n, prefix_bits, prefix_or, target, length) \ #define GRPC_CHTTP2_WRITE_VARINT(n, prefix_bits, prefix_or, target, length) \
do { \ do { \
gpr_uint8* tgt = target; \ gpr_uint8* tgt = target; \
if ((length) == 1) { \ if ((length) == 1u) { \
(tgt)[0] = (prefix_or) | (n); \ (tgt)[0] = (prefix_or) | (n); \
} else { \ } else { \
(tgt)[0] = (prefix_or) | GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \ (tgt)[0] = (prefix_or) | GRPC_CHTTP2_MAX_IN_PREFIX(prefix_bits); \

@ -306,7 +306,7 @@ static void init_transport(grpc_chttp2_transport *t,
GRPC_ARG_MAX_CONCURRENT_STREAMS); GRPC_ARG_MAX_CONCURRENT_STREAMS);
} else { } else {
push_setting(t, GRPC_CHTTP2_SETTINGS_MAX_CONCURRENT_STREAMS, 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, } else if (0 == strcmp(channel_args->args[i].key,
GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER)) { GRPC_ARG_HTTP2_INITIAL_SEQUENCE_NUMBER)) {
@ -320,7 +320,8 @@ static void init_transport(grpc_chttp2_transport *t,
t->global.next_stream_id & 1, t->global.next_stream_id & 1,
is_client ? "client" : "server"); is_client ? "client" : "server");
} else { } 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;
} }
} }
} }

@ -186,7 +186,8 @@ grpc_mdctx *grpc_mdctx_create(void) {
/* This seed is used to prevent remote connections from controlling hash table /* This seed is used to prevent remote connections from controlling hash table
* collisions. It needs to be somewhat unpredictable to a remote connection. * 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) { static void discard_metadata(grpc_mdctx *ctx) {

@ -85,12 +85,13 @@ static void test_set_compression_algorithm(void) {
static void test_compression_algorithm_states(void) { static void test_compression_algorithm_states(void) {
grpc_channel_args *ch_args, *ch_args_wo_gzip, *ch_args_wo_gzip_deflate; grpc_channel_args *ch_args, *ch_args_wo_gzip, *ch_args_wo_gzip_deflate;
int states_bitset; unsigned states_bitset;
size_t i; size_t i;
ch_args = grpc_channel_args_copy_and_add(NULL, NULL, 0); ch_args = grpc_channel_args_copy_and_add(NULL, NULL, 0);
/* by default, all enabled */ /* 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++) { for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
GPR_ASSERT(GPR_BITGET(states_bitset, 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); &ch_args_wo_gzip, GRPC_COMPRESS_DEFLATE, 0);
GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate); 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); ch_args_wo_gzip_deflate);
for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) { for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
if (i == GRPC_COMPRESS_GZIP || i == GRPC_COMPRESS_DEFLATE) { 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); &ch_args_wo_gzip_deflate, GRPC_COMPRESS_GZIP, 1);
GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate); GPR_ASSERT(ch_args_wo_gzip == ch_args_wo_gzip_deflate);
states_bitset = states_bitset = (unsigned)grpc_channel_args_compression_algorithm_get_states(
grpc_channel_args_compression_algorithm_get_states(ch_args_wo_gzip); ch_args_wo_gzip);
for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) { for (i = 0; i < GRPC_COMPRESS_ALGORITHMS_COUNT; i++) {
if (i == GRPC_COMPRESS_DEFLATE) { if (i == GRPC_COMPRESS_DEFLATE) {
GPR_ASSERT(GPR_BITGET(states_bitset, i) == 0); GPR_ASSERT(GPR_BITGET(states_bitset, i) == 0);

@ -186,7 +186,7 @@ void test_connect(const char *server_host, const char *client_host, int port,
op->flags = 0; op->flags = 0;
op->reserved = NULL; op->reserved = NULL;
op++; 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); GPR_ASSERT(GRPC_CALL_OK == error);
if (expect_ok) { 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->data.recv_close_on_server.cancelled = &was_cancelled;
op->flags = 0; op->flags = 0;
op++; 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); GPR_ASSERT(GRPC_CALL_OK == error);
cq_expect_completion(cqv, tag(102), 1); cq_expect_completion(cqv, tag(102), 1);

@ -79,8 +79,8 @@ int main(int argc, char **argv) {
op->flags = 0; op->flags = 0;
op->reserved = NULL; op->reserved = NULL;
op++; op++;
GPR_ASSERT(GRPC_CALL_OK == GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(
grpc_call_start_batch(call, ops, op - ops, tag(1), NULL)); call, ops, (size_t)(op - ops), tag(1), NULL));
/* verify that all tags get completed */ /* verify that all tags get completed */
cq_expect_completion(cqv, tag(1), 1); cq_expect_completion(cqv, tag(1), 1);
cq_verify(cqv); cq_verify(cqv);

@ -92,8 +92,9 @@ static void step_ping_pong_request(void) {
call = grpc_channel_create_call(channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq, call = grpc_channel_create_call(channel, NULL, GRPC_PROPAGATE_DEFAULTS, cq,
"/Reflector/reflectUnary", "localhost", "/Reflector/reflectUnary", "localhost",
gpr_inf_future(GPR_CLOCK_REALTIME), NULL); gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
GPR_ASSERT(GRPC_CALL_OK == GPR_ASSERT(GRPC_CALL_OK == grpc_call_start_batch(call, ops,
grpc_call_start_batch(call, ops, op - ops, (void *)1, NULL)); (size_t)(op - ops),
(void *)1, NULL));
grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL); grpc_completion_queue_next(cq, gpr_inf_future(GPR_CLOCK_REALTIME), NULL);
grpc_call_destroy(call); grpc_call_destroy(call);
grpc_byte_buffer_destroy(response_payload_recv); 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); channel = grpc_insecure_channel_create(target, NULL, NULL);
cq = grpc_completion_queue_create(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); histogram = gpr_histogram_create(0.01, 60e9);
sc.init(); sc.init();

@ -60,10 +60,10 @@ int main(int argc, char **argv) {
pid_t svr, cli; pid_t svr, cli;
/* seed rng with pid, so we don't end up with the same random numbers as a /* seed rng with pid, so we don't end up with the same random numbers as a
concurrently running test binary */ concurrently running test binary */
srand(getpid()); srand((unsigned)getpid());
/* figure out where we are */ /* figure out where we are */
if (lslash) { if (lslash) {
memcpy(root, me, lslash - me); memcpy(root, me, (size_t)(lslash - me));
root[lslash - me] = 0; root[lslash - me] = 0;
} else { } else {
strcpy(root, "."); strcpy(root, ".");

@ -51,7 +51,7 @@ int main(int argc, char **argv) {
gpr_subprocess *svr, *cli; gpr_subprocess *svr, *cli;
/* figure out where we are */ /* figure out where we are */
if (lslash) { if (lslash) {
memcpy(root, me, lslash - me); memcpy(root, me, (size_t)(lslash - me));
root[lslash - me] = 0; root[lslash - me] = 0;
} else { } else {
strcpy(root, "."); strcpy(root, ".");

@ -123,7 +123,7 @@ static void handle_unary_method(void) {
op->data.recv_close_on_server.cancelled = &was_cancelled; op->data.recv_close_on_server.cancelled = &was_cancelled;
op++; 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); tag(FLING_SERVER_BATCH_OPS_FOR_UNARY), NULL);
GPR_ASSERT(GRPC_CALL_OK == error); GPR_ASSERT(GRPC_CALL_OK == error);
} }

@ -134,7 +134,7 @@ int main(int argc, char **argv) {
/* figure out where we are */ /* figure out where we are */
if (lslash) { if (lslash) {
memcpy(root, me, lslash - me); memcpy(root, me, (size_t)(lslash - me));
root[lslash - me] = 0; root[lslash - me] = 0;
} else { } else {
strcpy(root, "."); strcpy(root, ".");

@ -48,9 +48,9 @@ static gpr_timespec random_deadline(void) {
return ts; 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)); grpc_alarm *elems = gpr_malloc(num_elements * sizeof(grpc_alarm));
int i; size_t i;
for (i = 0; i < num_elements; i++) { for (i = 0; i < num_elements; i++) {
elems[i].deadline = random_deadline(); elems[i].deadline = random_deadline();
} }
@ -63,24 +63,25 @@ static int cmp_elem(const void *a, const void *b) {
return i - j; return i - j;
} }
static int *all_top(grpc_alarm_heap *pq, int *n) { static size_t *all_top(grpc_alarm_heap *pq, size_t *n) {
int *vec = NULL; size_t *vec = NULL;
int *need_to_check_children; size_t *need_to_check_children;
int num_need_to_check_children = 0; size_t num_need_to_check_children = 0;
*n = 0; *n = 0;
if (pq->alarm_count == 0) return vec; 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; 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) { while (num_need_to_check_children > 0) {
int ind = need_to_check_children[0]; size_t ind = need_to_check_children[0];
int leftchild, rightchild; size_t leftchild, rightchild;
num_need_to_check_children--; num_need_to_check_children--;
memmove(need_to_check_children, need_to_check_children + 1, 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; vec[(*n)++] = ind;
leftchild = 1 + 2 * ind; leftchild = 1u + 2u * ind;
if (leftchild < pq->alarm_count) { if (leftchild < pq->alarm_count) {
if (gpr_time_cmp(pq->alarms[leftchild]->deadline, if (gpr_time_cmp(pq->alarms[leftchild]->deadline,
pq->alarms[ind]->deadline) >= 0) { 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, 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); gpr_timespec max_deadline = gpr_inf_past(GPR_CLOCK_REALTIME);
int *max_deadline_indices = gpr_malloc(num_elements * sizeof(int)); size_t *max_deadline_indices =
int *top_elements; gpr_malloc(num_elements * sizeof(*max_deadline_indices));
int num_max_deadline_indices = 0; size_t *top_elements;
int num_top_elements; size_t num_max_deadline_indices = 0;
int i; size_t num_top_elements;
size_t i;
for (i = 0; i < num_elements; ++i) { for (i = 0; i < num_elements; ++i) {
if (inpq[i] && gpr_time_cmp(elements[i].deadline, max_deadline) >= 0) { if (inpq[i] && gpr_time_cmp(elements[i].deadline, max_deadline) >= 0) {
if (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; 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); top_elements = all_top(pq, &num_top_elements);
GPR_ASSERT(num_top_elements == num_max_deadline_indices); GPR_ASSERT(num_top_elements == num_max_deadline_indices);
for (i = 0; i < num_top_elements; i++) { 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) { static int contains(grpc_alarm_heap *pq, grpc_alarm *el) {
int i; size_t i;
for (i = 0; i < pq->alarm_count; i++) { for (i = 0; i < pq->alarm_count; i++) {
if (pq->alarms[i] == el) return 1; 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) { static void check_valid(grpc_alarm_heap *pq) {
int i; size_t i;
for (i = 0; i < pq->alarm_count; ++i) { for (i = 0; i < pq->alarm_count; ++i) {
int left_child = 1 + 2 * i; size_t left_child = 1u + 2u * i;
int right_child = left_child + 1; size_t right_child = left_child + 1u;
if (left_child < pq->alarm_count) { if (left_child < pq->alarm_count) {
GPR_ASSERT(gpr_time_cmp(pq->alarms[i]->deadline, GPR_ASSERT(gpr_time_cmp(pq->alarms[i]->deadline,
pq->alarms[left_child]->deadline) >= 0); pq->alarms[left_child]->deadline) >= 0);
@ -153,9 +156,9 @@ static void check_valid(grpc_alarm_heap *pq) {
static void test1(void) { static void test1(void) {
grpc_alarm_heap pq; grpc_alarm_heap pq;
const int num_test_elements = 200; const size_t num_test_elements = 200;
const int num_test_operations = 10000; const size_t num_test_operations = 10000;
int i; size_t i;
grpc_alarm *test_elements = create_test_elements(num_test_elements); grpc_alarm *test_elements = create_test_elements(num_test_elements);
gpr_uint8 *inpq = gpr_malloc(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); check_pq_top(test_elements, &pq, inpq, num_test_elements);
for (i = 0; i < num_test_operations; ++i) { 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]; grpc_alarm *el = &test_elements[elem_num];
if (!inpq[elem_num]) { /* not in pq */ if (!inpq[elem_num]) { /* not in pq */
GPR_ASSERT(!contains(&pq, el)); GPR_ASSERT(!contains(&pq, el));
@ -209,11 +212,11 @@ static void test1(void) {
static void shrink_test(void) { static void shrink_test(void) {
grpc_alarm_heap pq; grpc_alarm_heap pq;
int i; size_t i;
int expected_size; size_t expected_size;
/* A large random number to allow for multiple shrinkages, at least 512. */ /* 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); 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. */ 4 times the Size and not less than 2 times, but never goes below 16. */
expected_size = pq.alarm_count; expected_size = pq.alarm_count;
while (pq.alarm_count > 0) { 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 *te = pq.alarms[which];
grpc_alarm_heap_remove(&pq, te); grpc_alarm_heap_remove(&pq, te);
gpr_free(te); gpr_free(te);

@ -105,7 +105,7 @@ static size_t fill_socket_partial(int fd, size_t bytes) {
do { do {
write_bytes = write(fd, buf, bytes - total_bytes); write_bytes = write(fd, buf, bytes - total_bytes);
if (write_bytes > 0) { if (write_bytes > 0) {
total_bytes += write_bytes; total_bytes += (size_t)write_bytes;
} }
} while ((write_bytes >= 0 || errno == EINTR) && bytes > total_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 { struct read_socket_state {
grpc_endpoint *ep; grpc_endpoint *ep;
ssize_t read_bytes; size_t read_bytes;
ssize_t target_read_bytes; size_t target_read_bytes;
gpr_slice_buffer incoming; gpr_slice_buffer incoming;
grpc_iomgr_closure read_cb; grpc_iomgr_closure read_cb;
}; };
static ssize_t count_slices(gpr_slice *slices, size_t nslices, static size_t count_slices(gpr_slice *slices, size_t nslices,
int *current_data) { int *current_data) {
ssize_t num_bytes = 0; size_t num_bytes = 0;
unsigned i, j; unsigned i, j;
unsigned char *buf; unsigned char *buf;
for (i = 0; i < nslices; ++i) { 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) { static void read_cb(void *user_data, int success) {
struct read_socket_state *state = (struct read_socket_state *)user_data; struct read_socket_state *state = (struct read_socket_state *)user_data;
ssize_t read_bytes; size_t read_bytes;
int current_data; int current_data;
GPR_ASSERT(success); 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. */ /* 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]; int sv[2];
grpc_endpoint *ep; grpc_endpoint *ep;
struct read_socket_state state; struct read_socket_state state;
ssize_t written_bytes; size_t written_bytes;
gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20); gpr_timespec deadline = GRPC_TIMEOUT_SECONDS_TO_DEADLINE(20);
gpr_log(GPR_INFO, "Read test of size %d, slice size %d", num_bytes, 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 /* Write to a socket until it fills up, then read from it using the grpc_tcp
API. */ API. */
static void large_read_test(ssize_t slice_size) { static void large_read_test(size_t slice_size) {
int sv[2]; int sv[2];
grpc_endpoint *ep; grpc_endpoint *ep;
struct read_socket_state state; struct read_socket_state state;
@ -242,7 +242,7 @@ static void large_read_test(ssize_t slice_size) {
state.ep = ep; state.ep = ep;
state.read_bytes = 0; state.read_bytes = 0;
state.target_read_bytes = written_bytes; state.target_read_bytes = (size_t)written_bytes;
gpr_slice_buffer_init(&state.incoming); gpr_slice_buffer_init(&state.incoming);
grpc_iomgr_closure_init(&state.read_cb, read_cb, &state); grpc_iomgr_closure_init(&state.read_cb, read_cb, &state);
@ -275,11 +275,11 @@ struct write_socket_state {
int write_done; 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 *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); 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 i, j;
unsigned char *buf; unsigned char *buf;
*num_blocks = nslices; *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); GPR_ASSERT(buf[i] == current);
current = (current + 1) % 256; current = (current + 1) % 256;
} }
bytes_left -= bytes_read; bytes_left -= (size_t)bytes_read;
if (bytes_left == 0) break; if (bytes_left == 0) break;
} }
flags = fcntl(fd, F_GETFL, 0); 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. /* 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 Note that if the write does not complete immediately we need to drain the
socket in parallel with the read. */ 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]; int sv[2];
grpc_endpoint *ep; grpc_endpoint *ep;
struct write_socket_state state; 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: case GRPC_ENDPOINT_DONE:
/* Write completed immediately */ /* Write completed immediately */
read_bytes = drain_socket(sv[0]); read_bytes = drain_socket(sv[0]);
GPR_ASSERT(read_bytes == num_bytes); GPR_ASSERT((size_t)read_bytes == num_bytes);
break; break;
case GRPC_ENDPOINT_PENDING: case GRPC_ENDPOINT_PENDING:
drain_socket_blocking(sv[0], num_bytes, num_bytes); 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) { void run_tests(void) {
int i = 0; size_t i = 0;
read_test(100, 8192); read_test(100, 8192);
read_test(10000, 8192); read_test(10000, 8192);

@ -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) { static void check_string(json_reader_userdata* state, size_t needed) {
if (state->free_space >= needed) return; if (state->free_space >= needed) return;
needed -= state->free_space; needed -= state->free_space;
needed = (needed + 0xff) & ~0xff; needed = (needed + 0xffu) & ~0xffu;
state->scratchpad = gpr_realloc(state->scratchpad, state->allocated + needed); state->scratchpad = gpr_realloc(state->scratchpad, state->allocated + needed);
state->free_space += needed; state->free_space += needed;
state->allocated += needed; state->allocated += needed;
@ -103,22 +103,22 @@ static void json_reader_string_add_utf32(void* userdata, gpr_uint32 c) {
if (c <= 0x7f) { if (c <= 0x7f) {
json_reader_string_add_char(userdata, c); json_reader_string_add_char(userdata, c);
} else if (c <= 0x7ff) { } else if (c <= 0x7ff) {
int b1 = 0xc0 | ((c >> 6) & 0x1f); gpr_uint32 b1 = 0xc0u | ((c >> 6u) & 0x1fu);
int b2 = 0x80 | (c & 0x3f); gpr_uint32 b2 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2); json_reader_string_add_char(userdata, b2);
} else if (c <= 0xffff) { } else if (c <= 0xffffu) {
int b1 = 0xe0 | ((c >> 12) & 0x0f); gpr_uint32 b1 = 0xe0u | ((c >> 12u) & 0x0fu);
int b2 = 0x80 | ((c >> 6) & 0x3f); gpr_uint32 b2 = 0x80u | ((c >> 6u) & 0x3fu);
int b3 = 0x80 | (c & 0x3f); gpr_uint32 b3 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2); json_reader_string_add_char(userdata, b2);
json_reader_string_add_char(userdata, b3); json_reader_string_add_char(userdata, b3);
} else if (c <= 0x1fffff) { } else if (c <= 0x1fffffu) {
int b1 = 0xf0 | ((c >> 18) & 0x07); gpr_uint32 b1 = 0xf0u | ((c >> 18u) & 0x07u);
int b2 = 0x80 | ((c >> 12) & 0x3f); gpr_uint32 b2 = 0x80u | ((c >> 12u) & 0x3fu);
int b3 = 0x80 | ((c >> 6) & 0x3f); gpr_uint32 b3 = 0x80u | ((c >> 6u) & 0x3fu);
int b4 = 0x80 | (c & 0x3f); gpr_uint32 b4 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2); json_reader_string_add_char(userdata, b2);
json_reader_string_add_char(userdata, b3); json_reader_string_add_char(userdata, b3);
@ -132,7 +132,7 @@ static gpr_uint32 json_reader_read_char(void* userdata) {
r = fgetc(state->in); r = fgetc(state->in);
if (r == EOF) r = GRPC_JSON_READ_CHAR_EOF; 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) { static void json_reader_container_begins(void* userdata, grpc_json_type type) {

@ -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) { static void check_string(json_reader_userdata* state, size_t needed) {
if (state->free_space >= needed) return; if (state->free_space >= needed) return;
needed -= state->free_space; needed -= state->free_space;
needed = (needed + 0xff) & ~0xff; needed = (needed + 0xffu) & ~0xffu;
state->scratchpad = gpr_realloc(state->scratchpad, state->allocated + needed); state->scratchpad = gpr_realloc(state->scratchpad, state->allocated + needed);
state->free_space += needed; state->free_space += needed;
state->allocated += 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) { static void json_reader_string_add_utf32(void* userdata, gpr_uint32 c) {
if (c <= 0x7f) { if (c <= 0x7f) {
json_reader_string_add_char(userdata, c); json_reader_string_add_char(userdata, c);
} else if (c <= 0x7ff) { } else if (c <= 0x7ffu) {
int b1 = 0xc0 | ((c >> 6) & 0x1f); gpr_uint32 b1 = 0xc0u | ((c >> 6u) & 0x1fu);
int b2 = 0x80 | (c & 0x3f); gpr_uint32 b2 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2); json_reader_string_add_char(userdata, b2);
} else if (c <= 0xffff) { } else if (c <= 0xffffu) {
int b1 = 0xe0 | ((c >> 12) & 0x0f); gpr_uint32 b1 = 0xe0u | ((c >> 12u) & 0x0fu);
int b2 = 0x80 | ((c >> 6) & 0x3f); gpr_uint32 b2 = 0x80u | ((c >> 6u) & 0x3fu);
int b3 = 0x80 | (c & 0x3f); gpr_uint32 b3 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2); json_reader_string_add_char(userdata, b2);
json_reader_string_add_char(userdata, b3); json_reader_string_add_char(userdata, b3);
} else if (c <= 0x1fffff) { } else if (c <= 0x1fffffu) {
int b1 = 0xf0 | ((c >> 18) & 0x07); gpr_uint32 b1 = 0xf0u | ((c >> 18u) & 0x07u);
int b2 = 0x80 | ((c >> 12) & 0x3f); gpr_uint32 b2 = 0x80u | ((c >> 12u) & 0x3fu);
int b3 = 0x80 | ((c >> 6) & 0x3f); gpr_uint32 b3 = 0x80u | ((c >> 6u) & 0x3fu);
int b4 = 0x80 | (c & 0x3f); gpr_uint32 b4 = 0x80u | (c & 0x3fu);
json_reader_string_add_char(userdata, b1); json_reader_string_add_char(userdata, b1);
json_reader_string_add_char(userdata, b2); json_reader_string_add_char(userdata, b2);
json_reader_string_add_char(userdata, b3); json_reader_string_add_char(userdata, b3);
@ -151,7 +151,7 @@ static gpr_uint32 json_reader_read_char(void* userdata) {
r = fgetc(state->in); r = fgetc(state->in);
if (r == EOF) r = GRPC_JSON_READ_CHAR_EOF; 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) { static void json_reader_container_begins(void* userdata, grpc_json_type type) {

@ -35,22 +35,22 @@
#include <stdlib.h> #include <stdlib.h>
#include "test/core/util/test_config.h" #include "test/core/util/test_config.h"
void test_log_events(int num_seqs) { void test_log_events(size_t num_seqs) {
int start = 0; size_t start = 0;
int *state; size_t *state;
state = calloc(num_seqs, sizeof(state[0])); state = calloc(num_seqs, sizeof(state[0]));
while (start < num_seqs) { while (start < num_seqs) {
int i; size_t i;
int row; size_t row;
if (state[start] == 3) { /* Already done with this posn */ if (state[start] == 3) { /* Already done with this posn */
start++; start++;
continue; 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++) { for (i = start; (i < start + row) && (i < num_seqs); i++) {
int j; size_t j;
int advance = 1 + rand() % 3; /* how many to advance by */ size_t advance = 1 + (size_t)rand() % 3; /* how many to advance by */
for (j = 0; j < advance; j++) { for (j = 0; j < advance; j++) {
switch (state[i]) { switch (state[i]) {
case 0: case 0:

@ -70,7 +70,7 @@ static void test_full_range_encode_decode_b64(int url_safe, int multiline) {
size_t i; size_t i;
char *b64; char *b64;
gpr_slice orig_decoded; 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. */ /* Try all the different paddings. */
for (i = 0; i < 3; i++) { for (i = 0; i < 3; i++) {
@ -122,7 +122,7 @@ static void test_url_safe_unsafe_mismtach_failure(void) {
char *b64; char *b64;
gpr_slice orig_decoded; gpr_slice orig_decoded;
int url_safe = 1; 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); b64 = grpc_base64_encode(orig, sizeof(orig), url_safe, 0);
orig_decoded = grpc_base64_decode(b64, !url_safe); orig_decoded = grpc_base64_decode(b64, !url_safe);

@ -391,20 +391,21 @@ static void test_jwt_encode_and_sign(
char *jwt = jwt_encode_and_sign_func(&json_key); char *jwt = jwt_encode_and_sign_func(&json_key);
const char *dot = strchr(jwt, '.'); const char *dot = strchr(jwt, '.');
GPR_ASSERT(dot != NULL); 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); GPR_ASSERT(parsed_header != NULL);
check_jwt_header(parsed_header); check_jwt_header(parsed_header);
offset = dot - jwt + 1; offset = (size_t)(dot - jwt) + 1;
grpc_json_destroy(parsed_header); grpc_json_destroy(parsed_header);
gpr_free(scratchpad); gpr_free(scratchpad);
dot = strchr(jwt + offset, '.'); dot = strchr(jwt + offset, '.');
GPR_ASSERT(dot != NULL); GPR_ASSERT(dot != NULL);
parsed_claim = parsed_claim = parse_json_part_from_jwt(
parse_json_part_from_jwt(jwt + offset, dot - (jwt + offset), &scratchpad); jwt + offset, (size_t)(dot - (jwt + offset)), &scratchpad);
GPR_ASSERT(parsed_claim != NULL); GPR_ASSERT(parsed_claim != NULL);
check_jwt_claim_func(parsed_claim); check_jwt_claim_func(parsed_claim);
offset = dot - jwt + 1; offset = (size_t)(dot - jwt) + 1;
grpc_json_destroy(parsed_claim); grpc_json_destroy(parsed_claim);
gpr_free(scratchpad); gpr_free(scratchpad);

@ -48,7 +48,7 @@ static void verification_test(hash_func hash, gpr_uint32 expected) {
gpr_uint8 key[256]; gpr_uint8 key[256];
gpr_uint32 hashes[256]; gpr_uint32 hashes[256];
gpr_uint32 final = 0; gpr_uint32 final = 0;
int i; size_t i;
memset(key, 0, sizeof(key)); memset(key, 0, sizeof(key));
memset(hashes, 0, sizeof(hashes)); 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++) { for (i = 0; i < 256; i++) {
key[i] = (uint8_t)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 */ /* Then hash the result array */

@ -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 */ /* We must be able to write to every byte of the data */
for (i = 0; i < length; i++) { 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 */ /* And finally we must succeed in destroying the slice */
gpr_slice_unref(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))); 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 slice;
gpr_slice head, tail; gpr_slice head, tail;
int i; size_t i;
LOG_TEST_NAME("test_slice_split_head_works"); LOG_TEST_NAME("test_slice_split_head_works");
gpr_log(GPR_INFO, "length=%d", length); gpr_log(GPR_INFO, "length=%d", length);
@ -171,10 +171,10 @@ static void test_slice_split_head_works(int length) {
gpr_slice_unref(slice); 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 slice;
gpr_slice head, tail; gpr_slice head, tail;
int i; size_t i;
LOG_TEST_NAME("test_slice_split_tail_works"); LOG_TEST_NAME("test_slice_split_tail_works");
gpr_log(GPR_INFO, "length=%d", length); gpr_log(GPR_INFO, "length=%d", length);

@ -46,9 +46,10 @@
#define MAX_THREADS 32 #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); gpr_stack_lockfree *stack = gpr_stack_lockfree_create(size);
int i; size_t i;
size_t j;
/* First try popping empty */ /* First try popping empty */
GPR_ASSERT(gpr_stack_lockfree_pop(stack) == -1); 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 */ /* Now add repeatedly more items and check them */
for (i = 1; i < size; i *= 2) { for (i = 1; i < size; i *= 2) {
int j;
for (j = 0; j <= i; j++) { for (j = 0; j <= i; j++) {
GPR_ASSERT(gpr_stack_lockfree_push(stack, j) == (j == 0)); GPR_ASSERT(gpr_stack_lockfree_push(stack, j) == (j == 0));
} }
for (j = 0; j <= i; j++) { 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); GPR_ASSERT(gpr_stack_lockfree_pop(stack) == -1);
} }
@ -74,7 +74,7 @@ static void test_serial_sized(int size) {
} }
static void test_serial() { static void test_serial() {
int i; size_t i;
for (i = 128; i < MAX_STACK_SIZE; i *= 2) { for (i = 128; i < MAX_STACK_SIZE; i *= 2) {
test_serial_sized(i); 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; gpr_stack_lockfree *stack;
struct test_arg args[MAX_THREADS]; struct test_arg args[MAX_THREADS];
gpr_thd_id thds[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() { static void test_mt() {
int size, nth; size_t size, nth;
for (nth = 1; nth < MAX_THREADS; nth++) { for (nth = 1; nth < MAX_THREADS; nth++) {
for (size = 128; size < MAX_STACK_SIZE; size *= 2) { for (size = 128; size < MAX_STACK_SIZE; size *= 2) {
test_mt_sized(size, nth); test_mt_sized(size, nth);

@ -43,14 +43,14 @@
#include <grpc/support/time.h> #include <grpc/support/time.h>
#include "test/core/util/test_config.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); fwrite(buf, 1, len, (FILE *)arg);
} }
/* Convert gpr_uintmax x to ascii base b (2..16), and write with /* Convert gpr_uintmax x to ascii base b (2..16), and write with
(*writer)(arg, ...), zero padding to "chars" digits). */ (*writer)(arg, ...), zero padding to "chars" digits). */
static void u_to_s(gpr_uintmax x, unsigned base, int chars, 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) { void *arg) {
char buf[64]; char buf[64];
char *p = buf + sizeof(buf); char *p = buf + sizeof(buf);
@ -59,25 +59,25 @@ static void u_to_s(gpr_uintmax x, unsigned base, int chars,
x /= base; x /= base;
chars--; chars--;
} while (x != 0 || chars > 0); } 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 /* Convert gpr_intmax x to ascii base b (2..16), and write with
(*writer)(arg, ...), zero padding to "chars" digits). */ (*writer)(arg, ...), zero padding to "chars" digits). */
static void i_to_s(gpr_intmax x, unsigned base, int chars, 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) { void *arg) {
if (x < 0) { if (x < 0) {
(*writer)(arg, "-", 1); (*writer)(arg, "-", 1);
u_to_s(-x, base, chars - 1, writer, arg); u_to_s((gpr_uintmax)-x, base, chars - 1, writer, arg);
} else { } 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, ...). */ /* Convert ts to ascii, and write with (*writer)(arg, ...). */
static void ts_to_s(gpr_timespec t, 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) { void *arg) {
if (t.tv_sec < 0 && t.tv_nsec != 0) { if (t.tv_sec < 0 && t.tv_nsec != 0) {
t.tv_sec++; t.tv_sec++;
@ -96,7 +96,7 @@ static void test_values(void) {
x = gpr_inf_future(GPR_CLOCK_REALTIME); x = gpr_inf_future(GPR_CLOCK_REALTIME);
fprintf(stderr, "far future "); 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"); fprintf(stderr, "\n");
GPR_ASSERT(x.tv_sec >= INT_MAX); GPR_ASSERT(x.tv_sec >= INT_MAX);
fprintf(stderr, "far future "); fprintf(stderr, "far future ");
@ -105,7 +105,7 @@ static void test_values(void) {
x = gpr_inf_past(GPR_CLOCK_REALTIME); x = gpr_inf_past(GPR_CLOCK_REALTIME);
fprintf(stderr, "far past "); 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"); fprintf(stderr, "\n");
GPR_ASSERT(x.tv_sec <= INT_MIN); GPR_ASSERT(x.tv_sec <= INT_MIN);
fprintf(stderr, "far past "); fprintf(stderr, "far past ");

@ -113,14 +113,14 @@ static void test_read_none_compressed_slice(void) {
} }
static void read_compressed_slice(grpc_compression_algorithm algorithm, static void read_compressed_slice(grpc_compression_algorithm algorithm,
int input_size) { size_t input_size) {
gpr_slice input_slice; gpr_slice input_slice;
gpr_slice_buffer sliceb_in; gpr_slice_buffer sliceb_in;
gpr_slice_buffer sliceb_out; gpr_slice_buffer sliceb_out;
grpc_byte_buffer *buffer; grpc_byte_buffer *buffer;
grpc_byte_buffer_reader reader; grpc_byte_buffer_reader reader;
gpr_slice read_slice; gpr_slice read_slice;
int read_count = 0; size_t read_count = 0;
gpr_slice_buffer_init(&sliceb_in); gpr_slice_buffer_init(&sliceb_in);
gpr_slice_buffer_init(&sliceb_out); 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) { 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"); LOG_TEST("test_read_gzip_compressed_slice");
read_compressed_slice(GRPC_COMPRESS_GZIP, INPUT_SIZE); read_compressed_slice(GRPC_COMPRESS_GZIP, INPUT_SIZE);
} }
static void test_read_deflate_compressed_slice(void) { 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"); LOG_TEST("test_read_deflate_compressed_slice");
read_compressed_slice(GRPC_COMPRESS_DEFLATE, INPUT_SIZE); read_compressed_slice(GRPC_COMPRESS_DEFLATE, INPUT_SIZE);
} }

@ -177,7 +177,7 @@ typedef struct test_thread_options {
gpr_event on_phase1_done; gpr_event on_phase1_done;
gpr_event *phase2; gpr_event *phase2;
gpr_event on_finished; gpr_event on_finished;
int events_triggered; size_t events_triggered;
int id; int id;
grpc_completion_queue *cc; grpc_completion_queue *cc;
} test_thread_options; } 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 = test_thread_options *options =
gpr_malloc((producers + consumers) * sizeof(test_thread_options)); gpr_malloc((producers + consumers) * sizeof(test_thread_options));
gpr_event phase1 = GPR_EVENT_INIT; gpr_event phase1 = GPR_EVENT_INIT;
gpr_event phase2 = GPR_EVENT_INIT; gpr_event phase2 = GPR_EVENT_INIT;
grpc_completion_queue *cc = grpc_completion_queue_create(NULL); grpc_completion_queue *cc = grpc_completion_queue_create(NULL);
int i; size_t i;
int total_consumed = 0; size_t total_consumed = 0;
static int optid = 101; static int optid = 101;
gpr_log(GPR_INFO, "%s: %d producers, %d consumers", "test_threading", gpr_log(GPR_INFO, "%s: %d producers, %d consumers", "test_threading",

@ -82,7 +82,7 @@ int main(int argc, char **argv) {
op->flags = 0; op->flags = 0;
op->reserved = NULL; op->reserved = NULL;
op++; 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); GPR_ASSERT(GRPC_CALL_OK == error);
/* the call should immediately fail */ /* the call should immediately fail */

@ -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); GPR_ASSERT(gpr_slice_str_cmp(mdstr->slice, str) == 0);
} }
static void assert_index(const grpc_chttp2_hptbl *tbl, int idx, const char *key, static void assert_index(const grpc_chttp2_hptbl *tbl, size_t idx,
const char *value) { const char *key, const char *value) {
grpc_mdelem *md = grpc_chttp2_hptbl_lookup(tbl, idx); grpc_mdelem *md = grpc_chttp2_hptbl_lookup(tbl, idx);
assert_str(tbl, md->key, key); assert_str(tbl, md->key, key);
assert_str(tbl, md->value, value); assert_str(tbl, md->value, value);

@ -52,8 +52,8 @@ int g_failure = 0;
grpc_stream_op_buffer g_sopb; grpc_stream_op_buffer g_sopb;
void **to_delete = NULL; void **to_delete = NULL;
int num_to_delete = 0; size_t num_to_delete = 0;
int cap_to_delete = 0; size_t cap_to_delete = 0;
static gpr_slice create_test_slice(size_t length) { static gpr_slice create_test_slice(size_t length) {
gpr_slice slice = gpr_slice_malloc(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"); verify_sopb(10, 0, 5, "000005 0000 deadbeef 00000000ff");
} }
static void add_sopb_headers(int n, ...) { static void add_sopb_headers(size_t n, ...) {
int i; size_t i;
grpc_metadata_batch b; grpc_metadata_batch b;
va_list l; va_list l;
grpc_linked_mdelem *e = gpr_malloc(sizeof(*e) * n); 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 main(int argc, char **argv) {
int i; size_t i;
grpc_test_init(argc, argv); grpc_test_init(argc, argv);
TEST(test_small_data_framing); TEST(test_small_data_framing);
TEST(test_basic_headers); TEST(test_basic_headers);

@ -203,9 +203,9 @@ static void test_periodic_compaction(size_t n) {
} }
int main(int argc, char **argv) { int main(int argc, char **argv) {
int n = 1; size_t n = 1;
int prev = 1; size_t prev = 1;
int tmp; size_t tmp;
grpc_test_init(argc, argv); grpc_test_init(argc, argv);

@ -177,11 +177,11 @@ static void test_spin_creating_the_same_thing(void) {
static void test_things_stick_around(void) { static void test_things_stick_around(void) {
grpc_mdctx *ctx; grpc_mdctx *ctx;
int i, j; size_t i, j;
char *buffer; char *buffer;
int nstrs = 1000; size_t nstrs = 1000;
grpc_mdstr **strs = gpr_malloc(sizeof(grpc_mdstr *) * nstrs); 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; grpc_mdstr *test;
LOG_TEST("test_things_stick_around"); LOG_TEST("test_things_stick_around");
@ -201,9 +201,9 @@ static void test_things_stick_around(void) {
} }
for (i = 0; i < nstrs; i++) { for (i = 0; i < nstrs; i++) {
int p = rand() % nstrs; size_t p = (size_t)rand() % nstrs;
int q = rand() % nstrs; size_t q = (size_t)rand() % nstrs;
int temp = shuf[p]; size_t temp = shuf[p];
shuf[p] = shuf[q]; shuf[p] = shuf[q];
shuf[q] = temp; shuf[q] = temp;
} }

Loading…
Cancel
Save