]> git.puffer.fish Git - mirror/frr.git/commitdiff
pimd: Fix use of 0 for NULL
authorDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 14 Jul 2016 21:19:00 +0000 (17:19 -0400)
committerDonald Sharp <sharpd@cumulusnetworks.com>
Thu, 22 Dec 2016 01:26:02 +0000 (20:26 -0500)
pimd uses allot of 0's to represent NULL.  Not a good
programming practice.

Signed-off-by: Donald Sharp <sharpd@cumulusnetworks.com>
pimd/pim_assert.c
pimd/pim_iface.c
pimd/pim_ifchannel.c
pimd/pim_igmp.c
pimd/pim_neighbor.c
pimd/pim_pim.c
pimd/pim_static.c
pimd/pimd.c

index d3df6a11021893f51dacc7184168d67349061ca5..590a7e1da5bce7ee3f6bbc5b619b62667b102a6d 100644 (file)
@@ -552,7 +552,7 @@ static int on_assert_timer(struct thread *t)
               src_str, grp_str, ifp->name);
   }
 
-  ch->t_ifassert_timer = 0;
+  ch->t_ifassert_timer = NULL;
 
   switch (ch->ifassert_state) {
   case PIM_IFASSERT_I_AM_WINNER:
index 6739ce17be9ef695a077e045d1b82d0ccbc5b985..65b51d2b567012ad88f842ab02248d87ca68905f 100644 (file)
@@ -111,10 +111,10 @@ struct pim_interface *pim_if_new(struct interface *ifp, int igmp, int pim)
   PIM_IF_DO_IGMP_LISTEN_ALLROUTERS(pim_ifp->options);
 #endif
 
-  pim_ifp->igmp_join_list = 0;
-  pim_ifp->igmp_socket_list = 0;
-  pim_ifp->pim_neighbor_list = 0;
-  pim_ifp->pim_ifchannel_list = 0;
+  pim_ifp->igmp_join_list = NULL;
+  pim_ifp->igmp_socket_list = NULL;
+  pim_ifp->pim_neighbor_list = NULL;
+  pim_ifp->pim_ifchannel_list = NULL;
   pim_ifp->pim_generation_id = 0;
 
   /* list of struct igmp_sock */
@@ -187,7 +187,7 @@ void pim_if_delete(struct interface *ifp)
 
   XFREE(MTYPE_PIM_INTERFACE, pim_ifp);
 
-  ifp->info = 0;
+  ifp->info = NULL;
 }
 
 void pim_if_update_could_assert(struct interface *ifp)
index abfa5cc2b7bf844c9974cd171f3c1605bdb905b9..a3d827f1e0c37091b4c16be6aa0315999daebff2 100644 (file)
@@ -202,14 +202,14 @@ static struct pim_ifchannel *pim_ifchannel_new(struct interface *ifp,
     zlog_err("%s: could not attach upstream (S,G)=(%s,%s) on interface %s",
             __PRETTY_FUNCTION__,
             src_str, grp_str, ifp->name);
-    return 0;
+    return NULL;
   }
 
   ch = XMALLOC(MTYPE_PIM_IFCHANNEL, sizeof(*ch));
   if (!ch) {
     zlog_err("%s: PIM XMALLOC(%zu) failure",
             __PRETTY_FUNCTION__, sizeof(*ch));
-    return 0;
+    return NULL;
   }
 
   ch->flags                        = 0;
@@ -220,8 +220,8 @@ static struct pim_ifchannel *pim_ifchannel_new(struct interface *ifp,
   ch->local_ifmembership           = PIM_IFMEMBERSHIP_NOINFO;
 
   ch->ifjoin_state                 = PIM_IFJOIN_NOINFO;
-  ch->t_ifjoin_expiry_timer        = 0;
-  ch->t_ifjoin_prune_pending_timer = 0;
+  ch->t_ifjoin_expiry_timer        = NULL;
+  ch->t_ifjoin_prune_pending_timer = NULL;
   ch->ifjoin_creation              = 0;
 
   ch->ifassert_my_metric = pim_macro_ch_my_assert_metric_eval(ch);
@@ -230,7 +230,7 @@ static struct pim_ifchannel *pim_ifchannel_new(struct interface *ifp,
   ch->ifassert_winner.s_addr = 0;
 
   /* Assert state */
-  ch->t_ifassert_timer   = 0;
+  ch->t_ifassert_timer   = NULL;
   reset_ifassert_state(ch);
   if (pim_macro_ch_could_assert_eval(ch))
     PIM_IF_FLAG_SET_COULD_ASSERT(ch->flags);
@@ -363,7 +363,7 @@ struct pim_ifchannel *pim_ifchannel_add(struct interface *ifp,
            __PRETTY_FUNCTION__,
            src_str, grp_str, ifp->name);
 
-  return 0;
+  return NULL;
 }
 
 static void ifjoin_to_noinfo(struct pim_ifchannel *ch)
@@ -381,7 +381,7 @@ static int on_ifjoin_expiry_timer(struct thread *t)
   ch = THREAD_ARG(t);
   zassert(ch);
 
-  ch->t_ifjoin_expiry_timer = 0;
+  ch->t_ifjoin_expiry_timer = NULL;
 
   zassert(ch->ifjoin_state == PIM_IFJOIN_JOIN);
 
@@ -431,7 +431,7 @@ static int on_ifjoin_prune_pending_timer(struct thread *t)
   ch = THREAD_ARG(t);
   zassert(ch);
 
-  ch->t_ifjoin_prune_pending_timer = 0;
+  ch->t_ifjoin_prune_pending_timer = NULL;
 
   zassert(ch->ifjoin_state == PIM_IFJOIN_PRUNE_PENDING);
 
index 3b63b10e0d92badae91425b6c5f36a4975643b15..189f40ff51a2efdd56a4b207b8b66e979e21a8d9 100644 (file)
@@ -171,7 +171,7 @@ static int pim_igmp_other_querier_expire(struct thread *t)
               ifaddr_str);
   }
 
-  igmp->t_other_querier_timer = 0;
+  igmp->t_other_querier_timer = NULL;
 
   /*
     We are the current querier, then
@@ -212,7 +212,7 @@ void pim_igmp_other_querier_timer_on(struct igmp_sock *igmp)
   else {
     /*
       We are the current querier, then stop sending general queries:
-      igmp->t_igmp_query_timer = 0;
+      igmp->t_igmp_query_timer = NULL;
     */
     pim_igmp_general_query_off(igmp);
   }
@@ -864,7 +864,7 @@ void pim_igmp_general_query_on(struct igmp_sock *igmp)
               startup_mode ? "startup" : "non-startup",
               igmp->fd);
   }
-  igmp->t_igmp_query_timer = 0;
+  igmp->t_igmp_query_timer = NULL;
   zassert(!igmp->t_igmp_query_timer);
   THREAD_TIMER_ON(master, igmp->t_igmp_query_timer,
                  pim_igmp_general_query,
@@ -956,7 +956,7 @@ static void igmp_read_on(struct igmp_sock *igmp)
     zlog_debug("Scheduling READ event on IGMP socket fd=%d",
               igmp->fd);
   }
-  igmp->t_igmp_read = 0;
+  igmp->t_igmp_read = NULL;
   zassert(!igmp->t_igmp_read);
   THREAD_READ_ON(master, igmp->t_igmp_read, pim_igmp_read, igmp, igmp->fd);
 }
@@ -1202,9 +1202,9 @@ static struct igmp_sock *igmp_sock_new(int fd,
   igmp->fd                          = fd;
   igmp->interface                   = ifp;
   igmp->ifaddr                      = ifaddr;
-  igmp->t_igmp_read                 = 0;
-  igmp->t_igmp_query_timer          = 0;
-  igmp->t_other_querier_timer       = 0; /* no other querier present */
+  igmp->t_igmp_read                 = NULL;
+  igmp->t_igmp_query_timer          = NULL;
+  igmp->t_other_querier_timer       = NULL; /* no other querier present */
   igmp->querier_robustness_variable = pim_ifp->igmp_default_robustness_variable;
   igmp->sock_creation               = pim_time_monotonic_sec();
 
index 7e7cbc0d116c02fe9eb12c7915fe3594e5bd99b7..90fdc35473fc6256545565905ca4c2c1a1fdbf73 100644 (file)
@@ -222,7 +222,7 @@ static int on_neighbor_timer(struct thread *t)
               neigh->holdtime, src_str, ifp->name);
   }
 
-  neigh->t_expire_timer = 0;
+  neigh->t_expire_timer = NULL;
 
   snprintf(msg, sizeof(msg), "%d-sec holdtime expired", neigh->holdtime);
   pim_neighbor_delete(ifp, neigh, msg);
@@ -313,7 +313,7 @@ static struct pim_neighbor *pim_neighbor_new(struct interface *ifp,
   neigh->dr_priority            = dr_priority;
   neigh->generation_id          = generation_id;
   neigh->prefix_list            = addr_list;
-  neigh->t_expire_timer         = 0;
+  neigh->t_expire_timer         = NULL;
   neigh->interface              = ifp;
 
   pim_neighbor_timer_reset(neigh, holdtime);
index f0db822cb42de41a73bc68a234bdb9cd40d9d368..60bba9e9ba7b86d5856c1efdd7d9f3ab87c6ce68 100644 (file)
@@ -377,7 +377,7 @@ static void pim_sock_read_on(struct interface *ifp)
     zlog_debug("Scheduling READ event on PIM socket fd=%d",
               pim_ifp->pim_sock_fd);
   }
-  pim_ifp->t_pim_sock_read = 0;
+  pim_ifp->t_pim_sock_read = NULL;
   zassert(!pim_ifp->t_pim_sock_read);
   THREAD_READ_ON(master, pim_ifp->t_pim_sock_read, pim_sock_read, ifp,
                 pim_ifp->pim_sock_fd);
@@ -430,9 +430,9 @@ void pim_sock_reset(struct interface *ifp)
 
   pim_ifp->pim_sock_fd       = -1;
   pim_ifp->pim_sock_creation = 0;
-  pim_ifp->t_pim_sock_read   = 0;
+  pim_ifp->t_pim_sock_read   = NULL;
 
-  pim_ifp->t_pim_hello_timer          = 0;
+  pim_ifp->t_pim_hello_timer          = NULL;
   pim_ifp->pim_hello_period           = PIM_DEFAULT_HELLO_PERIOD;
   pim_ifp->pim_default_holdtime       = -1; /* unset: means 3.5 * pim_hello_period */
   pim_ifp->pim_triggered_hello_delay  = PIM_DEFAULT_TRIGGERED_HELLO_DELAY;
@@ -634,7 +634,7 @@ static int on_pim_hello_send(struct thread *t)
   /*
    * Schedule next hello
    */
-  pim_ifp->t_pim_hello_timer = 0;
+  pim_ifp->t_pim_hello_timer = NULL;
   hello_resched(ifp);
 
   /*
@@ -701,9 +701,8 @@ void pim_hello_restart_triggered(struct interface *ifp)
     }
 
     THREAD_OFF(pim_ifp->t_pim_hello_timer);
-    pim_ifp->t_pim_hello_timer = 0;
+    pim_ifp->t_pim_hello_timer = NULL;
   }
-  zassert(!pim_ifp->t_pim_hello_timer);
 
   random_msec = random() % (triggered_hello_delay_msec + 1);
 
@@ -741,7 +740,7 @@ int pim_sock_add(struct interface *ifp)
     return -2;
   }
 
-  pim_ifp->t_pim_sock_read   = 0;
+  pim_ifp->t_pim_sock_read   = NULL;
   pim_ifp->pim_sock_creation = pim_time_monotonic_sec();
 
   /*
index 5882142b3213837cc93372013971140d921c508e..98c74caab5e962838c476fff2cfbe15fa951a3ac 100644 (file)
@@ -80,11 +80,11 @@ static struct static_route *static_route_new(unsigned int   iif,
 
 int pim_static_add(struct interface *iif, struct interface *oif, struct in_addr group, struct in_addr source)
 {
-   struct listnode *node = 0;
-   struct static_route *s_route = 0;
-   struct static_route *original_s_route = 0;
-   struct pim_interface *pim_iif = iif ? iif->info : 0;
-   struct pim_interface *pim_oif = oif ? oif->info : 0;
+   struct listnode *node = NULL;
+   struct static_route *s_route = NULL;
+   struct static_route *original_s_route = NULL;
+   struct pim_interface *pim_iif = iif ? iif->info : NULL;
+   struct pim_interface *pim_oif = oif ? oif->info : NULL;
    ifindex_t iif_index = pim_iif ? pim_iif->mroute_vif_index : 0;
    ifindex_t oif_index = pim_oif ? pim_oif->mroute_vif_index : 0;
 
@@ -228,9 +228,9 @@ int pim_static_add(struct interface *iif, struct interface *oif, struct in_addr
 
 int pim_static_del(struct interface *iif, struct interface *oif, struct in_addr group, struct in_addr source)
 {
-   struct listnode *node = 0;
-   struct listnode *nextnode = 0;
-   struct static_route *s_route = 0;
+   struct listnode *node = NULL;
+   struct listnode *nextnode = NULL;
+   struct static_route *s_route = NULL;
    struct pim_interface *pim_iif = iif ? iif->info : 0;
    struct pim_interface *pim_oif = oif ? oif->info : 0;
    ifindex_t iif_index = pim_iif ? pim_iif->mroute_vif_index : 0;
index 91d8d56afc0d6188737e6c6879ddd97ddb72baef..4ec9023f0a8bea222ccfdf0f59e0a2d860467cf7 100644 (file)
@@ -47,21 +47,21 @@ struct thread_master     *master = NULL;
 uint32_t                  qpim_debugs = 0;
 int                       qpim_mroute_socket_fd = -1;
 int64_t                   qpim_mroute_socket_creation = 0; /* timestamp of creation */
-struct thread            *qpim_mroute_socket_reader = 0;
+struct thread            *qpim_mroute_socket_reader = NULL;
 int                       qpim_mroute_oif_highest_vif_index = -1;
-struct list              *qpim_channel_oil_list = 0;
+struct list              *qpim_channel_oil_list = NULL;
 int                       qpim_t_periodic = PIM_DEFAULT_T_PERIODIC; /* Period between Join/Prune Messages */
-struct list              *qpim_upstream_list = 0;
-struct zclient           *qpim_zclient_update = 0;
-struct zclient           *qpim_zclient_lookup = 0;
+struct list              *qpim_upstream_list = NULL;
+struct zclient           *qpim_zclient_update = NULL;
+struct zclient           *qpim_zclient_lookup = NULL;
 struct pim_assert_metric  qpim_infinite_assert_metric;
 long                      qpim_rpf_cache_refresh_delay_msec = 10000;
-struct thread            *qpim_rpf_cache_refresher = 0;
+struct thread            *qpim_rpf_cache_refresher = NULL;
 int64_t                   qpim_rpf_cache_refresh_requests = 0;
 int64_t                   qpim_rpf_cache_refresh_events = 0;
 int64_t                   qpim_rpf_cache_refresh_last =  0;
 struct in_addr            qpim_inaddr_any;
-struct list              *qpim_ssmpingd_list = 0;
+struct list              *qpim_ssmpingd_list = NULL;
 struct in_addr            qpim_ssmpingd_group_addr;
 int64_t                   qpim_scan_oil_events = 0;
 int64_t                   qpim_scan_oil_last = 0;
@@ -69,7 +69,7 @@ int64_t                   qpim_mroute_add_events = 0;
 int64_t                   qpim_mroute_add_last = 0;
 int64_t                   qpim_mroute_del_events = 0;
 int64_t                   qpim_mroute_del_last = 0;
-struct list              *qpim_static_route_list = 0;
+struct list              *qpim_static_route_list = NULL;
 struct pim_rpf            qpim_rp = { .rpf_addr.s_addr = INADDR_NONE };
 
 int32_t qpim_register_suppress_time = PIM_REGISTER_SUPPRESSION_TIME_DEFAULT;