[Openvpn-devel] Print lzo_init() return code in case of errors

Message ID 20180713081951.31174-1-gert@greenie.muc.de
State Accepted
Headers show
Series [Openvpn-devel] Print lzo_init() return code in case of errors | expand

Commit Message

Gert Doering July 12, 2018, 10:19 p.m. UTC
This can help pinpointing what exactly went wrong in case of
init failures (library version mismatch, memory issues, ...)

Signed-off-by: Gert Doering <gert@greenie.muc.de>
---
 src/openvpn/lzo.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Arne Schwabe July 12, 2018, 10:43 p.m. UTC | #1
Am 13.07.18 um 10:19 schrieb Gert Doering:
> This can help pinpointing what exactly went wrong in case of
> init failures (library version mismatch, memory issues, ...)
> 
> Signed-off-by: Gert Doering <gert@greenie.muc.de>
> ---
>  src/openvpn/lzo.c |    6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/src/openvpn/lzo.c b/src/openvpn/lzo.c
> index 8d9efea..e3be6ad 100644
> --- a/src/openvpn/lzo.c
> +++ b/src/openvpn/lzo.c
> @@ -103,9 +103,11 @@ lzo_compress_init(struct compress_context *compctx)
>      msg(D_INIT_MEDIUM, "LZO compression initializing");
>      ASSERT(!(compctx->flags & COMP_F_SWAP));
>      compctx->wu.lzo.wmem_size = LZO_WORKSPACE;
> -    if (lzo_init() != LZO_E_OK)
> +
> +    int lzo_status = lzo_init();
> +    if (lzo_status != LZO_E_OK)
>      {
> -        msg(M_FATAL, "Cannot initialize LZO compression library");
> +        msg(M_FATAL, "Cannot initialize LZO compression library (lzo_init() returns %d)", lzo_status);
>      }
>      compctx->wu.lzo.wmem = (lzo_voidp) lzo_malloc(compctx->wu.lzo.wmem_size);
>      check_malloc_return(compctx->wu.lzo.wmem);
> 

ACK.

(I have not compile tested it but it looks good enough to me that I skip
that on this one.

Ane

------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
Gert Doering July 12, 2018, 10:56 p.m. UTC | #2
Patch has been applied to the master branch.

commit 2cf21ecfca336d19a5bf203792fb7c7fe7f4a49d
Author: Gert Doering
Date:   Fri Jul 13 10:19:51 2018 +0200

     Print lzo_init() return code in case of errors

     Signed-off-by: Gert Doering <gert@greenie.muc.de>
     Acked-by: Arne Schwabe <arne@rfc2549.org>
     Message-Id: <20180713081951.31174-1-gert@greenie.muc.de>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg17248.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot

Patch

diff --git a/src/openvpn/lzo.c b/src/openvpn/lzo.c
index 8d9efea..e3be6ad 100644
--- a/src/openvpn/lzo.c
+++ b/src/openvpn/lzo.c
@@ -103,9 +103,11 @@  lzo_compress_init(struct compress_context *compctx)
     msg(D_INIT_MEDIUM, "LZO compression initializing");
     ASSERT(!(compctx->flags & COMP_F_SWAP));
     compctx->wu.lzo.wmem_size = LZO_WORKSPACE;
-    if (lzo_init() != LZO_E_OK)
+
+    int lzo_status = lzo_init();
+    if (lzo_status != LZO_E_OK)
     {
-        msg(M_FATAL, "Cannot initialize LZO compression library");
+        msg(M_FATAL, "Cannot initialize LZO compression library (lzo_init() returns %d)", lzo_status);
     }
     compctx->wu.lzo.wmem = (lzo_voidp) lzo_malloc(compctx->wu.lzo.wmem_size);
     check_malloc_return(compctx->wu.lzo.wmem);