]> git.puffer.fish Git - matthieu/frr.git/commitdiff
bgpd: zlog_warn to assert for code that must be executed first
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 16 Aug 2018 00:44:31 +0000 (20:44 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 16 Aug 2018 12:24:22 +0000 (08:24 -0400)
In bgp_keepalives.c, it was noticed that we were
ensuring that we called an intialization function first,
but this is a development escape in that once this
was fixed we never see it.  So if a developer moves
this assumption around, let's crash the program and
lead them to this spot instead of silently ignoring
the problem.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
bgpd/bgp_keepalives.c

index 3216683a54878d264f7ba17742031d778a02716e..f81836cc836083558c9cacae1b03d5c4c22ec1e2 100644 (file)
@@ -239,10 +239,10 @@ void bgp_keepalives_on(struct peer *peer)
        /* placeholder bucket data to use for fast key lookups */
        static struct pkat holder = {0};
 
-       if (!peerhash_mtx) {
-               zlog_warn("%s: call bgp_keepalives_init() first", __func__);
-               return;
-       }
+       /*
+        * We need to ensure that bgp_keepalives_init was called first
+        */
+       assert(peerhash_mtx);
 
        pthread_mutex_lock(peerhash_mtx);
        {
@@ -269,10 +269,10 @@ void bgp_keepalives_off(struct peer *peer)
        /* placeholder bucket data to use for fast key lookups */
        static struct pkat holder = {0};
 
-       if (!peerhash_mtx) {
-               zlog_warn("%s: call bgp_keepalives_init() first", __func__);
-               return;
-       }
+       /*
+        * We need to ensure that bgp_keepalives_init was called first
+        */
+       assert(peerhash_mtx);
 
        pthread_mutex_lock(peerhash_mtx);
        {