From: Lars Brinkhoff <lars@nocrew.org>
Date: Tue, 12 Jan 2016 08:43:15 +0100
Subject: Fix most warnings.

Applied-Upstream: commit:914b372d806b525d2b8fa091ee8ebf8c6d29175b
---
 base64.c |  4 ++--
 htc.c    |  1 +
 http.c   | 12 ++++++------
 tunnel.c | 26 +++++++++++++++-----------
 4 files changed, 24 insertions(+), 19 deletions(-)

diff --git a/base64.c b/base64.c
index fd37608..f5bcb53 100644
--- a/base64.c
+++ b/base64.c
@@ -41,7 +41,7 @@ encode_base64 (const void *data, size_t length, char **code)
   if (length == 0)
     return 0;
 
-  end = (char *)data + length - 3;
+  end = (unsigned char *)data + length - 3;
 
   buf = malloc (4 * ((length + 2) / 3) + 1);
   if (buf == NULL)
@@ -88,6 +88,6 @@ encode_base64 (const void *data, size_t length, char **code)
 
   *buf = 0;
 
-  *code = buf - n;
+  *code = (char *)buf - n;
   return n;
 }
diff --git a/htc.c b/htc.c
index 62a0d6c..2fdd301 100644
--- a/htc.c
+++ b/htc.c
@@ -8,6 +8,7 @@ two-way data path tunneled in HTTP requests.
 */
 
 #include <stdio.h>
+#include <time.h>
 #include <stdlib.h>
 #include <unistd_.h>
 #include <signal.h>
diff --git a/http.c b/http.c
index f640f5d..ec153b7 100644
--- a/http.c
+++ b/http.c
@@ -42,7 +42,7 @@ http_method (int fd, Http_destination *dest,
 
   if (length >= 0)
     {
-      sprintf (str, "%d", length);
+      sprintf (str, "%ld", length);
       http_add_header (&request->header, "Content-Length", str);
     }
 
@@ -190,9 +190,9 @@ http_method_to_string (Http_method method)
 }
 
 static ssize_t
-read_until (int fd, int ch, unsigned char **data)
+read_until (int fd, int ch, char **data)
 {
-  unsigned char *buf, *buf2;
+  char *buf, *buf2;
   ssize_t n, len, buf_size;
 
   *data = NULL;
@@ -290,7 +290,7 @@ static ssize_t
 parse_header (int fd, Http_header **header)
 {
   unsigned char buf[2];
-  unsigned char *data;
+  char *data;
   Http_header *h;
   size_t len;
   ssize_t n;
@@ -461,7 +461,7 @@ ssize_t
 http_parse_response (int fd, Http_response **response_)
 {
   Http_response *response;
-  unsigned char *data;
+  char *data;
   size_t len;
   ssize_t n;
 
@@ -626,7 +626,7 @@ ssize_t
 http_parse_request (int fd, Http_request **request_)
 {
   Http_request *request;
-  unsigned char *data;
+  char *data;
   size_t len;
   ssize_t n;
 
diff --git a/tunnel.c b/tunnel.c
index 6e5fc9b..370bfc0 100644
--- a/tunnel.c
+++ b/tunnel.c
@@ -140,7 +140,8 @@ static int
 tunnel_in_setsockopts (int fd)
 {
 #ifdef SO_RCVLOWAT
-  int i, n;
+  socklen_t n;
+  int i;
 
   i = 1;
   if (setsockopt (fd,
@@ -150,7 +151,7 @@ tunnel_in_setsockopts (int fd)
 		  sizeof i) == -1)
     {
       log_debug ("tunnel_in_setsockopts: non-fatal SO_RCVLOWAT error: %s",
-		  strerror (errno));
+		 strerror (errno));
     }
   n = sizeof i;
   getsockopt (fd,
@@ -169,7 +170,8 @@ tunnel_out_setsockopts (int fd)
 {
 #ifdef SO_SNDLOWAT
   {
-    int i, n;
+    socklen_t n;
+    int i;
 
     i = 1;
     if (setsockopt (fd,
@@ -179,8 +181,8 @@ tunnel_out_setsockopts (int fd)
 		    sizeof i) == -1)
       {
 	log_debug ("tunnel_out_setsockopts: "
-		    "non-fatal SO_SNDLOWAT error: %s",
-		    strerror (errno));
+		   "non-fatal SO_SNDLOWAT error: %s",
+		   strerror (errno));
       }
     n = sizeof i;
     getsockopt (fd,
@@ -195,7 +197,7 @@ tunnel_out_setsockopts (int fd)
 #ifdef SO_LINGER
   {
     struct linger l;
-    int n;
+    socklen_t n;
 
     l.l_onoff = 1;
     l.l_linger = 20 * 100; /* linger for 20 seconds */
@@ -222,7 +224,8 @@ tunnel_out_setsockopts (int fd)
 #ifdef TCP_NODELAY
   {
     int tcp = get_proto_number ("tcp");
-    int i, n;
+    socklen_t n;
+    int i;
 
     if (tcp != -1)
       {
@@ -274,7 +277,8 @@ tunnel_out_setsockopts (int fd)
 
 #ifdef SO_KEEPALIVE
   {
-    int i, n;
+    socklen_t n;
+    int i;
 
     i = 1;
     if (setsockopt (fd,
@@ -796,7 +800,7 @@ tunnel_close (Tunnel *tunnel)
 
 static int
 tunnel_read_request (Tunnel *tunnel, enum tunnel_request *request,
-		     unsigned char *buf, size_t *length)
+		     char *buf, size_t *length)
 {
   Request req;
   Length len;
@@ -1083,7 +1087,7 @@ tunnel_accept (Tunnel *tunnel)
       Http_request *request;
       struct pollfd p;
       ssize_t m;
-      int len;
+      socklen_t len;
       int n;
       int s;
 
@@ -1171,7 +1175,7 @@ tunnel_accept (Tunnel *tunnel)
 /* "Last-Modified: %s\r\n" */
 /* "ETag: %s\r\n" */
 /* "Accept-Ranges: %s\r\n" */
-"Content-Length: %d\r\n"
+"Content-Length: %lu\r\n"
 "Connection: close\r\n"
 "Pragma: no-cache\r\n"
 "Cache-Control: no-cache, no-store, must-revalidate\r\n"
