[Openvpn-devel] fix compilation issues with small and w/o debug

Message ID 20220617041326.2744668-1-i.ponetaev@ndmsystems.com
State Accepted
Headers show
Series [Openvpn-devel] fix compilation issues with small and w/o debug | expand

Commit Message

Ilya Ponetayev June 17, 2022, 4:13 a.m. UTC
---
 src/openvpn/init.c      | 2 +-
 src/openvpn/mtcp.c      | 2 ++
 src/openvpn/packet_id.c | 2 ++
 src/openvpn/reliable.c  | 2 ++
 4 files changed, 7 insertions(+), 1 deletion(-)

Comments

Frank Lichtenheld June 20, 2022, 1:19 p.m. UTC | #1
Acked-By: Frank Lichtenheld <frank@lichtenheld.com>

I can confirm that this fixes issues seen with

./configure --enable-small --disable-debug --enable-werror

(compile tested on Debian 11 amd64, gcc 10.2.1)

The init.c change did not fix a warning for my compiler, but it looks correct
and might be a warning with different compilers.

Regards,
  Frank

> Ilya Ponetayev <i.ponetaev@ndmsystems.com> hat am 17.06.2022 06:13 CEST geschrieben:
> 
>  
> ---
>  src/openvpn/init.c      | 2 +-
>  src/openvpn/mtcp.c      | 2 ++
>  src/openvpn/packet_id.c | 2 ++
>  src/openvpn/reliable.c  | 2 ++
>  4 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/src/openvpn/init.c b/src/openvpn/init.c
> index b0c62a85..f06afc29 100644
> --- a/src/openvpn/init.c
> +++ b/src/openvpn/init.c
> @@ -2491,7 +2491,7 @@ frame_finalize_options(struct context *c, const struct options *o)
>      size_t tailroom = headroom;
>  
>  #ifdef USE_COMP
> -    msg(D_MTU_DEBUG, "MTU: adding %lu buffer tailroom for compression for %lu "
> +    msg(D_MTU_DEBUG, "MTU: adding %zu buffer tailroom for compression for %zu "
>          "bytes of payload",
>          COMP_EXTRA_BUFFER(payload_size), payload_size);
>      tailroom += COMP_EXTRA_BUFFER(payload_size);
> diff --git a/src/openvpn/mtcp.c b/src/openvpn/mtcp.c
> index b725bebb..b3c153fe 100644
> --- a/src/openvpn/mtcp.c
> +++ b/src/openvpn/mtcp.c
> @@ -72,6 +72,7 @@ struct ta_iow_flags
>      unsigned int sock;
>  };
>  
> +#ifdef ENABLE_DEBUG
>  static const char *
>  pract(int action)
>  {
> @@ -114,6 +115,7 @@ pract(int action)
>              return "?";
>      }
>  }
> +#endif /* ENABLE_DEBUG */
>  
>  static struct multi_instance *
>  multi_create_instance_tcp(struct multi_context *m)
> diff --git a/src/openvpn/packet_id.c b/src/openvpn/packet_id.c
> index e357909d..851b506c 100644
> --- a/src/openvpn/packet_id.c
> +++ b/src/openvpn/packet_id.c
> @@ -53,11 +53,13 @@
>  #define SEQ_UNSEEN  ((time_t)0)
>  #define SEQ_EXPIRED ((time_t)1)
>  
> +#ifdef ENABLE_DEBUG
>  static void packet_id_debug_print(int msglevel,
>                                    const struct packet_id_rec *p,
>                                    const struct packet_id_net *pin,
>                                    const char *message,
>                                    int value);
> +#endif /* ENABLE_DEBUG */
>  
>  static inline void
>  packet_id_debug(int msglevel,
> diff --git a/src/openvpn/reliable.c b/src/openvpn/reliable.c
> index 37244435..73473625 100644
> --- a/src/openvpn/reliable.c
> +++ b/src/openvpn/reliable.c
> @@ -394,6 +394,7 @@ reliable_send_purge(struct reliable *rel, const struct reliable_ack *ack)
>      }
>  }
>  
> +#ifdef ENABLE_DEBUG
>  /* print the current sequence of active packet IDs */
>  static const char *
>  reliable_print_ids(const struct reliable *rel, struct gc_arena *gc)
> @@ -412,6 +413,7 @@ reliable_print_ids(const struct reliable *rel, struct gc_arena *gc)
>      }
>      return BSTR(&out);
>  }
> +#endif /* ENABLE_DEBUG */
>  
>  /* true if at least one free buffer available */
>  bool
> -- 
> 2.34.1
> 
> 
> 
> _______________________________________________
> Openvpn-devel mailing list
> Openvpn-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/openvpn-devel

--
Frank Lichtenheld
Gert Doering June 21, 2022, 12:17 p.m. UTC | #2
I discussed the use of "%zu" and Windows/MinGW builds with Selva, who
said this will work (it will create warnings, thus no -Werror builds,
but since release builds are MSVC, this should be acceptable).

Uncrustify said I have to add a newline before one of the #endif lines,
so I did.

Generally speaking: we're adding #ifdef again - maybe we should see how
much of a difference this creates if we *remove* "--disable-debug" and
all the ENABLE_DEBUG conditionals.  Resulting binary size, and runtime.

Your patch has been applied to the master branch.

commit 8c815699ba616151e6bc5074cd150f3ebf053d4a
Author: Ilya Ponetayev
Date:   Fri Jun 17 07:13:26 2022 +0300

     fix compilation issues with small and w/o debug

     Acked-by: Frank Lichtenheld <frank@lichtenheld.com>
     Message-Id: <20220617041326.2744668-1-i.ponetaev@ndmsystems.com>
     URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg24476.html
     Signed-off-by: Gert Doering <gert@greenie.muc.de>


--
kind regards,

Gert Doering

Patch

diff --git a/src/openvpn/init.c b/src/openvpn/init.c
index b0c62a85..f06afc29 100644
--- a/src/openvpn/init.c
+++ b/src/openvpn/init.c
@@ -2491,7 +2491,7 @@  frame_finalize_options(struct context *c, const struct options *o)
     size_t tailroom = headroom;
 
 #ifdef USE_COMP
-    msg(D_MTU_DEBUG, "MTU: adding %lu buffer tailroom for compression for %lu "
+    msg(D_MTU_DEBUG, "MTU: adding %zu buffer tailroom for compression for %zu "
         "bytes of payload",
         COMP_EXTRA_BUFFER(payload_size), payload_size);
     tailroom += COMP_EXTRA_BUFFER(payload_size);
diff --git a/src/openvpn/mtcp.c b/src/openvpn/mtcp.c
index b725bebb..b3c153fe 100644
--- a/src/openvpn/mtcp.c
+++ b/src/openvpn/mtcp.c
@@ -72,6 +72,7 @@  struct ta_iow_flags
     unsigned int sock;
 };
 
+#ifdef ENABLE_DEBUG
 static const char *
 pract(int action)
 {
@@ -114,6 +115,7 @@  pract(int action)
             return "?";
     }
 }
+#endif /* ENABLE_DEBUG */
 
 static struct multi_instance *
 multi_create_instance_tcp(struct multi_context *m)
diff --git a/src/openvpn/packet_id.c b/src/openvpn/packet_id.c
index e357909d..851b506c 100644
--- a/src/openvpn/packet_id.c
+++ b/src/openvpn/packet_id.c
@@ -53,11 +53,13 @@ 
 #define SEQ_UNSEEN  ((time_t)0)
 #define SEQ_EXPIRED ((time_t)1)
 
+#ifdef ENABLE_DEBUG
 static void packet_id_debug_print(int msglevel,
                                   const struct packet_id_rec *p,
                                   const struct packet_id_net *pin,
                                   const char *message,
                                   int value);
+#endif /* ENABLE_DEBUG */
 
 static inline void
 packet_id_debug(int msglevel,
diff --git a/src/openvpn/reliable.c b/src/openvpn/reliable.c
index 37244435..73473625 100644
--- a/src/openvpn/reliable.c
+++ b/src/openvpn/reliable.c
@@ -394,6 +394,7 @@  reliable_send_purge(struct reliable *rel, const struct reliable_ack *ack)
     }
 }
 
+#ifdef ENABLE_DEBUG
 /* print the current sequence of active packet IDs */
 static const char *
 reliable_print_ids(const struct reliable *rel, struct gc_arena *gc)
@@ -412,6 +413,7 @@  reliable_print_ids(const struct reliable *rel, struct gc_arena *gc)
     }
     return BSTR(&out);
 }
+#endif /* ENABLE_DEBUG */
 
 /* true if at least one free buffer available */
 bool