Skip to contentSkip to conversation

Fix some compiler warnings

PATCH New Steffan Karger 2 participants 7 messages Jan 12, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix some compiler warnings

The following three patches fix some compiler warnings. Changes are rather small and should not change behaviour (except for a little extra logging).

-Steffan

#1 lore raw

PATCH 1/3 Fix compiler warning for unused result of write()

Issue a warning instead of ignoring a failed write() completely.

---
 src/openvpn/ps.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
src/openvpn/ps.c +2 -1
index b22653b..901a094 100644
@@ -340,7 +340,8 @@ journal_add (const char *journal_dir, struct proxy_connection *pc, struct proxy_
       fd = platform_open (jfn, O_CREAT | O_TRUNC | O_WRONLY, S_IRUSR | S_IWUSR | S_IRGRP);
       if (fd != -1)
 	{
-	  write(fd, f, strlen(f));
+	  if (write(fd, f, strlen(f)) != strlen(f))
+	    msg(M_WARN, "PORT SHARE: writing to journal file (%s) failed", jfn);
 	  close (fd);
 	  cp->jfn = jfn;
 	}
Signature · 1 line
1.8.3.2
#2 lore raw

[Openvpn-devel] [PATCH applied] Re: Fix compiler warning for unused result of write()

ACK.

Your patch has been applied to the master branch.

commit 3173787a0beea7c335b1aaedcd2ca5303b17bc22

Author: Steffan Karger
Date:   Sun Jan 12 20:39:30 2014 +0100
     Fix compiler warning for unused result of write()

     Signed-off-by: Steffan Karger <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/8223
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#3 lore raw

PATCH 2/3 Remove unused variables from ssl_verify_polarssl.c's x509_get_serial()

In reply to Steffan Karger
---
 src/openvpn/ssl_verify_polarssl.c | 2 --
 1 file changed, 2 deletions(-)
src/openvpn/ssl_verify_polarssl.c +0 -2
index 5db4f02..e5ccd90 100644
@@ -125,8 +125,6 @@ x509_get_username (char *cn, int cn_len,
 char *
 x509_get_serial (x509_cert *cert, struct gc_arena *gc)
 {
-  int ret = 0;
-  int i = 0;
   char *buf = NULL;
   size_t len = cert->serial.len * 3 + 1;
 
Signature · 1 line
1.8.3.2
#4 lore raw

[Openvpn-devel] [PATCH applied] Re: Remove unused variables from ssl_verify_polarssl.c's x509_get_serial()

ACK.

Your patch has been applied to the master branch.

commit 7a85a6fafacba186ae2fc495d32e159ea9a57e0e

Author: Steffan Karger
Date:   Sun Jan 12 20:39:31 2014 +0100
     Remove unused variables from ssl_verify_polarssl.c's x509_get_serial()

     Signed-off-by: Steffan Karger <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/8222
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering

#5 lore raw

PATCH 3/3 Fix compiler warnings in ssl_polarssl.c

In reply to Steffan Karger

* Made some type casts explicit.
* Changed type of sha256_hash to unsigned char[], because polar expects that.
* Added missing error.h include.

---
 src/openvpn/ssl_polarssl.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)
src/openvpn/ssl_polarssl.c +8 -5
index 47fb62a..9dc4e87 100644
@@ -49,6 +49,7 @@
 #include <polarssl/havege.h>
 
 #include "ssl_verify_polarssl.h"
+#include <polarssl/error.h>
 #include <polarssl/pem.h>
 
 void
@@ -284,7 +285,7 @@ tls_ctx_load_priv_file (struct tls_root_ctx *ctx, const char *priv_key_file,
 	  pem_password_callback(passbuf, 512, 0, NULL);
 	  status = x509parse_key(ctx->priv_key,
 	      priv_key_file_inline, strlen(priv_key_file_inline),
-	      passbuf, strlen(passbuf));
+	      (unsigned char *) passbuf, strlen(passbuf));
 	}
     }
   else
@@ -481,7 +482,8 @@ void tls_ctx_load_ca (struct tls_root_ctx *ctx, const char *ca_file,
 
   if (ca_file && !strcmp (ca_file, INLINE_FILE_TAG) && ca_file_inline)
     {
-      if (0 != x509parse_crt(ctx->ca_chain, ca_file_inline, strlen(ca_file_inline)))
+      if (0 != x509parse_crt(ctx->ca_chain, (unsigned char *) ca_file_inline,
+          strlen(ca_file_inline)))
 	msg (M_FATAL, "Cannot load inline CA certificates");
     }
   else
@@ -501,8 +503,9 @@ tls_ctx_load_extra_certs (struct tls_root_ctx *ctx, const char *extra_certs_file
 
   if (!strcmp (extra_certs_file, INLINE_FILE_TAG) && extra_certs_file_inline)
     {
-      if (0 != x509parse_crt(ctx->crt_chain, extra_certs_file_inline,
-	  strlen(extra_certs_file_inline)))
+      if (0 != x509parse_crt(ctx->crt_chain,
+          (unsigned char *) extra_certs_file_inline,
+          strlen(extra_certs_file_inline)))
         msg (M_FATAL, "Cannot load inline extra-certs file");
     }
   else
@@ -625,7 +628,7 @@ static void my_debug( void *ctx, int level, const char *str )
 void tls_ctx_personalise_random(struct tls_root_ctx *ctx)
 {
   static char old_sha256_hash[32] = {0};
-  char sha256_hash[32] = {0};
+  unsigned char sha256_hash[32] = {0};
   ctr_drbg_context *cd_ctx = rand_ctx_get();
 
   if (NULL != ctx->crt_chain)
Signature · 1 line
1.8.3.2
#6 lore raw

[Openvpn-devel] [PATCH applied] Re: Fix compiler warnings in ssl_polarssl.c

ACK.

Your patch has been applied to the master branch.

commit 860d4d06cd66ed1fcbaea41c239962ab9316832d

Author: Steffan Karger
Date:   Sun Jan 12 20:39:32 2014 +0100
     Fix compiler warnings in ssl_polarssl.c

     Signed-off-by: Steffan Karger <[email protected]...>
     Acked-by: Gert Doering <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/8225
     Signed-off-by: Gert Doering <[email protected]...>

--
kind regards,

Gert Doering