-simplify logic, convert breaks into asserts
authorChristian Grothoff <christian@grothoff.org>
Sun, 8 Feb 2015 17:40:57 +0000 (17:40 +0000)
committerChristian Grothoff <christian@grothoff.org>
Sun, 8 Feb 2015 17:40:57 +0000 (17:40 +0000)
src/ats/plugin_ats_proportional.c

index 87afb400e839f00fe1fdef6415e7f914c5ca1a36..7f0fcd0427401413ac7a5576809bf9bbe72bfbbc 100644 (file)
@@ -840,7 +840,7 @@ get_best_address (struct GAS_PROPORTIONAL_Handle *s,
 
 
 /**
- * Decrease address count in network
+ * Decrease number of active addresses in network.
  *
  * @param s the solver handle
  * @param net the network type
@@ -849,28 +849,18 @@ static void
 address_decrement_active (struct GAS_PROPORTIONAL_Handle *s,
                           struct Network *net)
 {
-  if (net->active_addresses < 1)
-  {
-    GNUNET_break (0);
-  }
-  else
-  {
-    net->active_addresses--;
-    GNUNET_STATISTICS_update (s->env->stats,
-                              net->stat_active, -1, GNUNET_NO);
-  }
-  if (s->active_addresses < 1)
-  {
-    GNUNET_break (0);
-  }
-  else
-  {
-    s->active_addresses--;
-    GNUNET_STATISTICS_update (s->env->stats,
-                              "# ATS addresses total",
-                              -1,
-                              GNUNET_NO);
-  }
+  GNUNET_assert (net->active_addresses > 0);
+  net->active_addresses--;
+  GNUNET_STATISTICS_update (s->env->stats,
+                            net->stat_active,
+                            -1,
+                            GNUNET_NO);
+  GNUNET_assert (s->active_addresses > 0);
+  s->active_addresses--;
+  GNUNET_STATISTICS_update (s->env->stats,
+                            "# ATS addresses total",
+                            -1,
+                            GNUNET_NO);
 }