|  | @@ -82,7 +82,7 @@ typedef struct thread_args {
 | 
	
		
			
				|  |  |  /* Basic call to read() */
 | 
	
		
			
				|  |  |  static int read_bytes(int fd, char *buf, size_t read_size, int spin) {
 | 
	
		
			
				|  |  |    size_t bytes_read = 0;
 | 
	
		
			
				|  |  | -  int err;
 | 
	
		
			
				|  |  | +  ssize_t err;
 | 
	
		
			
				|  |  |    do {
 | 
	
		
			
				|  |  |      err = read(fd, buf + bytes_read, read_size - bytes_read);
 | 
	
		
			
				|  |  |      if (err < 0) {
 | 
	
	
		
			
				|  | @@ -96,7 +96,7 @@ static int read_bytes(int fd, char *buf, size_t read_size, int spin) {
 | 
	
		
			
				|  |  |          return -1;
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |      } else {
 | 
	
		
			
				|  |  | -      bytes_read += err;
 | 
	
		
			
				|  |  | +      bytes_read += (size_t)err;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    } while (bytes_read < read_size);
 | 
	
		
			
				|  |  |    return 0;
 | 
	
	
		
			
				|  | @@ -115,6 +115,7 @@ static int poll_read_bytes(int fd, char *buf, size_t read_size, int spin) {
 | 
	
		
			
				|  |  |    struct pollfd pfd;
 | 
	
		
			
				|  |  |    size_t bytes_read = 0;
 | 
	
		
			
				|  |  |    int err;
 | 
	
		
			
				|  |  | +  ssize_t err2;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    pfd.fd = fd;
 | 
	
		
			
				|  |  |    pfd.events = POLLIN;
 | 
	
	
		
			
				|  | @@ -132,13 +133,13 @@ static int poll_read_bytes(int fd, char *buf, size_t read_size, int spin) {
 | 
	
		
			
				|  |  |      GPR_ASSERT(err == 1);
 | 
	
		
			
				|  |  |      GPR_ASSERT(pfd.revents == POLLIN);
 | 
	
		
			
				|  |  |      do {
 | 
	
		
			
				|  |  | -      err = read(fd, buf + bytes_read, read_size - bytes_read);
 | 
	
		
			
				|  |  | -    } while (err < 0 && errno == EINTR);
 | 
	
		
			
				|  |  | -    if (err < 0 && errno != EAGAIN) {
 | 
	
		
			
				|  |  | +      err2 = read(fd, buf + bytes_read, read_size - bytes_read);
 | 
	
		
			
				|  |  | +    } while (err2 < 0 && errno == EINTR);
 | 
	
		
			
				|  |  | +    if (err2 < 0 && errno != EAGAIN) {
 | 
	
		
			
				|  |  |        gpr_log(GPR_ERROR, "Read failed: %s", strerror(errno));
 | 
	
		
			
				|  |  |        return -1;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  | -    bytes_read += err;
 | 
	
		
			
				|  |  | +    bytes_read += (size_t) err2;
 | 
	
		
			
				|  |  |    } while (bytes_read < read_size);
 | 
	
		
			
				|  |  |    return 0;
 | 
	
		
			
				|  |  |  }
 | 
	
	
		
			
				|  | @@ -157,6 +158,7 @@ static int epoll_read_bytes(struct thread_args *args, char *buf, int spin) {
 | 
	
		
			
				|  |  |    struct epoll_event ev;
 | 
	
		
			
				|  |  |    size_t bytes_read = 0;
 | 
	
		
			
				|  |  |    int err;
 | 
	
		
			
				|  |  | +  ssize_t err2;
 | 
	
		
			
				|  |  |    size_t read_size = args->msg_size;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    do {
 | 
	
	
		
			
				|  | @@ -172,10 +174,11 @@ static int epoll_read_bytes(struct thread_args *args, char *buf, int spin) {
 | 
	
		
			
				|  |  |      GPR_ASSERT(ev.data.fd == args->fds.read_fd);
 | 
	
		
			
				|  |  |      do {
 | 
	
		
			
				|  |  |        do {
 | 
	
		
			
				|  |  | -        err = read(args->fds.read_fd, buf + bytes_read, read_size - bytes_read);
 | 
	
		
			
				|  |  | -      } while (err < 0 && errno == EINTR);
 | 
	
		
			
				|  |  | +        err2 = read(args->fds.read_fd, buf + bytes_read,
 | 
	
		
			
				|  |  | +		    read_size - bytes_read);
 | 
	
		
			
				|  |  | +      } while (err2 < 0 && errno == EINTR);
 | 
	
		
			
				|  |  |        if (errno == EAGAIN) break;
 | 
	
		
			
				|  |  | -      bytes_read += err;
 | 
	
		
			
				|  |  | +      bytes_read += (size_t) err2;
 | 
	
		
			
				|  |  |        /* TODO(klempner): This should really be doing an extra call after we are
 | 
	
		
			
				|  |  |           done to ensure we see an EAGAIN */
 | 
	
		
			
				|  |  |      } while (bytes_read < read_size);
 | 
	
	
		
			
				|  | @@ -199,7 +202,7 @@ static int epoll_read_bytes_spin(struct thread_args *args, char *buf) {
 | 
	
		
			
				|  |  |   */
 | 
	
		
			
				|  |  |  static int blocking_write_bytes(struct thread_args *args, char *buf) {
 | 
	
		
			
				|  |  |    size_t bytes_written = 0;
 | 
	
		
			
				|  |  | -  int err;
 | 
	
		
			
				|  |  | +  ssize_t err;
 | 
	
		
			
				|  |  |    size_t write_size = args->msg_size;
 | 
	
		
			
				|  |  |    do {
 | 
	
		
			
				|  |  |      err = write(args->fds.write_fd, buf + bytes_written,
 | 
	
	
		
			
				|  | @@ -212,7 +215,7 @@ static int blocking_write_bytes(struct thread_args *args, char *buf) {
 | 
	
		
			
				|  |  |          return -1;
 | 
	
		
			
				|  |  |        }
 | 
	
		
			
				|  |  |      } else {
 | 
	
		
			
				|  |  | -      bytes_written += err;
 | 
	
		
			
				|  |  | +      bytes_written += (size_t)err;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |    } while (bytes_written < write_size);
 | 
	
		
			
				|  |  |    return 0;
 | 
	
	
		
			
				|  | @@ -373,7 +376,7 @@ error:
 | 
	
		
			
				|  |  |    return -1;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -static int connect_client(struct sockaddr *addr, int len) {
 | 
	
		
			
				|  |  | +static int connect_client(struct sockaddr *addr, socklen_t len) {
 | 
	
		
			
				|  |  |    int fd = socket(addr->sa_family, SOCK_STREAM, 0);
 | 
	
		
			
				|  |  |    int err;
 | 
	
		
			
				|  |  |    if (fd < 0) {
 | 
	
	
		
			
				|  | @@ -586,7 +589,7 @@ static int run_benchmark(char *socket_type, thread_args *client_args,
 | 
	
		
			
				|  |  |    return 0;
 | 
	
		
			
				|  |  |  }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -static int run_all_benchmarks(int msg_size) {
 | 
	
		
			
				|  |  | +static int run_all_benchmarks(size_t msg_size) {
 | 
	
		
			
				|  |  |    int error = 0;
 | 
	
		
			
				|  |  |    size_t i;
 | 
	
		
			
				|  |  |    for (i = 0; i < GPR_ARRAY_SIZE(test_strategies); ++i) {
 | 
	
	
		
			
				|  | @@ -643,7 +646,7 @@ int main(int argc, char **argv) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    if (read_strategy == NULL) {
 | 
	
		
			
				|  |  |      gpr_log(GPR_INFO, "No strategy specified, running all benchmarks");
 | 
	
		
			
				|  |  | -    return run_all_benchmarks(msg_size);
 | 
	
		
			
				|  |  | +    return run_all_benchmarks((size_t)msg_size);
 | 
	
		
			
				|  |  |    }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    if (socket_type == NULL) {
 | 
	
	
		
			
				|  | @@ -668,12 +671,12 @@ int main(int argc, char **argv) {
 | 
	
		
			
				|  |  |    client_args->read_bytes = test_strategy->read_strategy;
 | 
	
		
			
				|  |  |    client_args->write_bytes = blocking_write_bytes;
 | 
	
		
			
				|  |  |    client_args->setup = test_strategy->setup;
 | 
	
		
			
				|  |  | -  client_args->msg_size = msg_size;
 | 
	
		
			
				|  |  | +  client_args->msg_size = (size_t)msg_size;
 | 
	
		
			
				|  |  |    client_args->strategy_name = read_strategy;
 | 
	
		
			
				|  |  |    server_args->read_bytes = test_strategy->read_strategy;
 | 
	
		
			
				|  |  |    server_args->write_bytes = blocking_write_bytes;
 | 
	
		
			
				|  |  |    server_args->setup = test_strategy->setup;
 | 
	
		
			
				|  |  | -  server_args->msg_size = msg_size;
 | 
	
		
			
				|  |  | +  server_args->msg_size = (size_t)msg_size;
 | 
	
		
			
				|  |  |    server_args->strategy_name = read_strategy;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |    error = run_benchmark(socket_type, client_args, server_args);
 |