Skip to contentSkip to conversation

remove some "unused variable" warnings

PATCH In review Gert Doering 3 participants 7 messages Jan 10, 2014 – Jan 11, 2014

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 remove some "unused variable" warnings

---
 src/openvpn/comp-lz4.c | 1 -
 src/openvpn/options.c  | 2 ++
 src/openvpn/ssl.c      | 3 +--
 3 files changed, 3 insertions(+), 3 deletions(-)
src/openvpn/comp-lz4.c +0 -1
index afa43b1..4651148 100644
@@ -64,7 +64,6 @@ lz4_compress (struct buffer *buf, struct buffer work,
 	       struct compress_context *compctx,
 	       const struct frame* frame)
 {
-  int result;
   bool compressed = false;
 
   if (buf->len <= 0)
src/openvpn/options.c +2 -0
index 0803da7..9e21d5a 100644
@@ -2425,7 +2425,9 @@ options_postprocess_mutate_ce (struct options *o, struct connection_entry *ce)
 static void
 options_postprocess_mutate_invariant (struct options *options)
 {
+#ifdef WIN32
   const int dev = dev_type_enum (options->dev, options->dev_type);
+#endif
 
   /*
    * In forking TCP server mode, you don't need to ifconfig
src/openvpn/ssl.c +1 -2
index 15518ca..c61701a 100644
@@ -1331,7 +1331,7 @@ tls1_P_hash(const md_kt_t *md_kt,
 	    int olen)
 {
   struct gc_arena gc = gc_new ();
-  int chunk,n;
+  int chunk;
   hmac_ctx_t ctx;
   hmac_ctx_t ctx_tmp;
   uint8_t A1[MAX_HMAC_KEY_LENGTH];
@@ -1357,7 +1357,6 @@ tls1_P_hash(const md_kt_t *md_kt,
   hmac_ctx_update(&ctx,seed,seed_len);
   hmac_ctx_final(&ctx, A1);
 
-  n=0;
   for (;;)
     {
       hmac_ctx_reset(&ctx);
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH 2/2 Cleanup ir6->netbits handling.

Get rid of all "if (ir6->netbits>=0)" checks, as those are always true (unlike ir->netbits for IPv4, we don't do the special case for "if it's a host, put -1 in there" for IPv6).

Merge mroute_helper_{add,del}_iroute and mroute_helper_{add,del}_iroute6 into unified mroute_helper_{add,del}_iroute46() function as they did the same thing anyway, just with slightly different parameters.

Make Arne happy.

---
 src/openvpn/mroute.c | 56 +++++++++++-----------------------------------------
 src/openvpn/mroute.h |  6 ++----
 src/openvpn/multi.c  | 15 +++++---------
 3 files changed, 18 insertions(+), 59 deletions(-)
src/openvpn/mroute.c +11 -45
index 850e336..ba4ef46 100644
@@ -487,62 +487,28 @@ mroute_helper_regenerate (struct mroute_helper *mh)
 }
 
 void
-mroute_helper_add_iroute (struct mroute_helper *mh, const struct iroute *ir)
+mroute_helper_add_iroute46 (struct mroute_helper *mh, int netbits)
 {
-  if (ir->netbits >= 0)
+  if (netbits >= 0)
     {
-      ASSERT (ir->netbits < MR_HELPER_NET_LEN);
+      ASSERT (netbits < MR_HELPER_NET_LEN);
       ++mh->cache_generation;
-      ++mh->net_len_refcount[ir->netbits];
-      if (mh->net_len_refcount[ir->netbits] == 1)
+      ++mh->net_len_refcount[netbits];
+      if (mh->net_len_refcount[netbits] == 1)
 	mroute_helper_regenerate (mh);
     }
 }
 
 void
-mroute_helper_del_iroute (struct mroute_helper *mh, const struct iroute *ir)
+mroute_helper_del_iroute46 (struct mroute_helper *mh, int netbits)
 {
-  if (ir->netbits >= 0)
+  if (netbits >= 0)
     {
-      ASSERT (ir->netbits < MR_HELPER_NET_LEN);
+      ASSERT (netbits < MR_HELPER_NET_LEN);
       ++mh->cache_generation;
-      --mh->net_len_refcount[ir->netbits];
-      ASSERT (mh->net_len_refcount[ir->netbits] >= 0);
-      if (!mh->net_len_refcount[ir->netbits])
-	mroute_helper_regenerate (mh);
-    }
-}
-
-/* this is a bit inelegant, we really should have a helper to that 
- * is only passed the netbits value, and not the whole struct iroute *
- * - thus one helper could do IPv4 and IPv6.  For the sake of "not change
- * code unrelated to IPv4" this is left for later cleanup, for now.
- */
-void
-mroute_helper_add_iroute6 (struct mroute_helper *mh, 
-                           const struct iroute_ipv6 *ir6)
-{
-  if (ir6->netbits >= 0)
-    {
-      ASSERT (ir6->netbits < MR_HELPER_NET_LEN);
-      ++mh->cache_generation;
-      ++mh->net_len_refcount[ir6->netbits];
-      if (mh->net_len_refcount[ir6->netbits] == 1)
-	mroute_helper_regenerate (mh);
-    }
-}
-
-void
-mroute_helper_del_iroute6 (struct mroute_helper *mh, 
-			   const struct iroute_ipv6 *ir6)
-{
-  if (ir6->netbits >= 0)
-    {
-      ASSERT (ir6->netbits < MR_HELPER_NET_LEN);
-      ++mh->cache_generation;
-      --mh->net_len_refcount[ir6->netbits];
-      ASSERT (mh->net_len_refcount[ir6->netbits] >= 0);
-      if (!mh->net_len_refcount[ir6->netbits])
+      --mh->net_len_refcount[netbits];
+      ASSERT (mh->net_len_refcount[netbits] >= 0);
+      if (!mh->net_len_refcount[netbits])
 	mroute_helper_regenerate (mh);
     }
 }
src/openvpn/mroute.h +2 -4
index b72b5ff..608f70b 100644
@@ -125,10 +125,8 @@ void mroute_addr_mask_host_bits (struct mroute_addr *ma);
 
 struct mroute_helper *mroute_helper_init (int ageable_ttl_secs);
 void mroute_helper_free (struct mroute_helper *mh);
-void mroute_helper_add_iroute (struct mroute_helper *mh, const struct iroute *ir);
-void mroute_helper_del_iroute (struct mroute_helper *mh, const struct iroute *ir);
-void mroute_helper_add_iroute6 (struct mroute_helper *mh, const struct iroute_ipv6 *ir6);
-void mroute_helper_del_iroute6 (struct mroute_helper *mh, const struct iroute_ipv6 *ir6);
+void mroute_helper_add_iroute46 (struct mroute_helper *mh, int netbits);
+void mroute_helper_del_iroute46 (struct mroute_helper *mh, int netbits);
 
 /*
  * Given a raw packet in buf, return the src and dest
src/openvpn/multi.c +5 -10
index f016b14..2839b30 100644
@@ -450,10 +450,10 @@ multi_del_iroutes (struct multi_context *m,
   if (TUNNEL_TYPE (mi->context.c1.tuntap) == DEV_TYPE_TUN)
     {
       for (ir = mi->context.options.iroutes; ir != NULL; ir = ir->next)
-	mroute_helper_del_iroute (m->route_helper, ir);
+	mroute_helper_del_iroute46 (m->route_helper, ir->netbits);
 
       for ( ir6 = mi->context.options.iroutes_ipv6; ir6 != NULL; ir6 = ir6->next )
-	mroute_helper_del_iroute6 (m->route_helper, ir6);
+	mroute_helper_del_iroute46 (m->route_helper, ir6->netbits);
     }
 }
 
@@ -1169,23 +1169,18 @@ multi_add_iroutes (struct multi_context *m,
 		 print_in_addr_t (ir->network, 0, &gc),
 		 multi_instance_string (mi, false, &gc));
 
-	  mroute_helper_add_iroute (m->route_helper, ir);
+	  mroute_helper_add_iroute46 (m->route_helper, ir->netbits);
       
 	  multi_learn_in_addr_t (m, mi, ir->network, ir->netbits, false);
 	}
       for ( ir6 = mi->context.options.iroutes_ipv6; ir6 != NULL; ir6 = ir6->next )
 	{
-	  if (ir6->netbits >= 0)
-	    msg (D_MULTI_LOW, "MULTI: internal route %s/%d -> %s",
+	  msg (D_MULTI_LOW, "MULTI: internal route %s/%d -> %s",
 		 print_in6_addr (ir6->network, 0, &gc),
 		 ir6->netbits,
 		 multi_instance_string (mi, false, &gc));
-	  else
-	    msg (D_MULTI_LOW, "MULTI: internal route %s -> %s",
-		 print_in6_addr (ir6->network, 0, &gc),
-		 multi_instance_string (mi, false, &gc));
 
-	  mroute_helper_add_iroute6 (m->route_helper, ir6);
+	  mroute_helper_add_iroute46 (m->route_helper, ir6->netbits);
       
 	  multi_learn_in6_addr (m, mi, ir6->network, ir6->netbits, false);
 	}
Signature · 1 line
1.8.3.2
#2 lore raw

Re: [Openvpn-devel] [PATCH 2/2] Cleanup ir6->netbits handling.

Am 10.01.14 17:25, schrieb Gert Doering:

Quoted 11 lines

Get rid of all "if (ir6->netbits>=0)" checks, as those are always true (unlike ir->netbits for IPv4, we don't do the special case for "if it's a host, put -1 in there" for IPv6).

Merge mroute_helper_{add,del}_iroute and mroute_helper_{add,del}_iroute6 into unified mroute_helper_{add,del}_iroute46() function as they did the same thing anyway, just with slightly different parameters.

Make Arne happy.

:)

ACK

Arne

#3 lore raw

[Openvpn-devel] [PATCH applied] Re: Cleanup ir6->netbits handling.

In reply to Gert Doering

Patch has been applied to the master branch.

commit 432ca2b8f15e4bb4d6fcf72b4b48b1a371247e7b (master)

Author: Gert Doering
Date:   Fri Jan 10 17:25:42 2014 +0100
     Cleanup ir6->netbits handling.

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

--
kind regards,

Gert Doering

#4 lore raw
In reply to Gert Doering

Am 10.01.14 17:25, schrieb Gert Doering:

Quoted 12 lines
---
 src/openvpn/comp-lz4.c | 1 -
 src/openvpn/options.c  | 2 ++
 src/openvpn/ssl.c      | 3 +--
 3 files changed, 3 insertions(+), 3 deletions(-)
src/openvpn/comp-lz4.c +0 -0
index afa43b1..4651148 100644

src/openvpn/comp-lz4.c lz4_compress (struct buffer *buf, struct buffer work, · line 69

Quoted 7 lines
src/openvpn/comp-lz4.c +0 -1
@@ -64,7 +64,6 @@ lz4_compress (struct buffer *buf, struct buffer work,
 	       struct compress_context *compctx,
 	       const struct frame* frame)
 {
-  int result;
   bool compressed = false;
 
 

ACK. I should have noticed that but it was buried under the other warnings :(

Arne

#5 lore raw
In reply to Gert Doering
Quoted 48 lines · Gert Doering
---
 src/openvpn/comp-lz4.c | 1 -
 src/openvpn/options.c  | 2 ++
 src/openvpn/ssl.c      | 3 +--
 3 files changed, 3 insertions(+), 3 deletions(-)
src/openvpn/comp-lz4.c +0 -1
index afa43b1..4651148 100644
@@ -64,7 +64,6 @@ lz4_compress (struct buffer *buf, struct buffer work,
 	       struct compress_context *compctx,
 	       const struct frame* frame)
 {
-  int result;
   bool compressed = false;
 
   if (buf->len <= 0)
src/openvpn/options.c +2 -0
index 0803da7..9e21d5a 100644
@@ -2425,7 +2425,9 @@ options_postprocess_mutate_ce (struct options *o, struct connection_entry *ce)
 static void
 options_postprocess_mutate_invariant (struct options *options)
 {
+#ifdef WIN32
   const int dev = dev_type_enum (options->dev, options->dev_type);
+#endif
 
   /*
    * In forking TCP server mode, you don't need to ifconfig
src/openvpn/ssl.c +1 -1
index 15518ca..c61701a 100644
@@ -1331,7 +1331,7 @@ tls1_P_hash(const md_kt_t *md_kt,
 	    int olen)
 {
   struct gc_arena gc = gc_new ();
-  int chunk,n;
+  int chunk;
   hmac_ctx_t ctx;
   hmac_ctx_t ctx_tmp;
   uint8_t A1[MAX_HMAC_KEY_LENGTH];

src/openvpn/ssl.c tls1_P_hash(const md_kt_t *md_kt, · line 1362

Quoted 7 lines
src/openvpn/ssl.c +0 -1
@@ -1357,7 +1357,6 @@ tls1_P_hash(const md_kt_t *md_kt,
   hmac_ctx_update(&ctx,seed,seed_len);
   hmac_ctx_final(&ctx, A1);
 
-  n=0;
   for (;;)
     {
       hmac_ctx_reset(&ctx);

ACK. Compiles nicely on one of my systems, changes are quite obvious too.

Signature · 3 lines
kind regards,

David Sommerseth
#6 lore raw

[Openvpn-devel] [PATCH applied] Re: remove some 'unused variable' warnings

In reply to Gert Doering

Patch has been applied to the master branch.

commit 672943fbef58c444913a6d378fbd532f9a0c8605 (master)

Author: Gert Doering
Date:   Fri Jan 10 17:25:41 2014 +0100
     remove some 'unused variable' warnings

     Signed-off-by: Gert Doering <[email protected]...>
     Acked-by: David Sommerseth <[email protected]...>
     Acked-by: Arne Schwabe <[email protected]...>
     Message-Id: <[email protected]...>
     URL: http://article.gmane.org/gmane.network.openvpn.devel/8197

--
kind regards,

Gert Doering