net: trickle: Misc changes
* Fix the indentation which was caused by uint32_t -> u8_t changes.
* Make sure there is no unused variable warning if debugging is
enabled but debug level is low.
* Add assert that checks that Imax_abs is > 0 which it should be.
Signed-off-by: Jukka Rissanen <jukka.rissanen@linux.intel.com>
diff --git a/include/net/trickle.h b/include/net/trickle.h
index 5a318f5..72bf580 100644
--- a/include/net/trickle.h
+++ b/include/net/trickle.h
@@ -36,13 +36,13 @@
struct net_trickle {
u32_t Imin; /* Min interval size in ms */
u8_t Imax; /* Max number of doublings */
- u8_t k; /* Redundancy constant */
+ u8_t k; /* Redundancy constant */
u32_t I; /* Current interval size */
- u32_t Istart; /* Start of the interval in ms */
- u8_t c; /* Consistency counter */
+ u32_t Istart; /* Start of the interval in ms */
+ u8_t c; /* Consistency counter */
- u32_t Imax_abs; /* Max interval size in ms (not doublings)
+ u32_t Imax_abs; /* Max interval size in ms (not doublings)
*/
struct k_delayed_work timer;
diff --git a/subsys/net/ip/trickle.c b/subsys/net/ip/trickle.c
index ad7405b..551c1f5 100644
--- a/subsys/net/ip/trickle.c
+++ b/subsys/net/ip/trickle.c
@@ -56,7 +56,7 @@
timer);
u32_t rand_time;
-#if defined(CONFIG_NET_DEBUG_TRICKLE)
+#if defined(CONFIG_NET_DEBUG_TRICKLE) && (CONFIG_SYS_LOG_NET_LEVEL > 2)
u32_t last_end = get_end(trickle);
#endif
@@ -163,6 +163,8 @@
trickle->Imax_abs = Imin << Imax;
trickle->k = k;
+ NET_ASSERT(trickle->Imax_abs);
+
NET_DBG("Imin %d Imax %u k %u Imax_abs %d",
trickle->Imin, trickle->Imax, trickle->k,
trickle->Imax_abs);