From 9f37770f59fd3f3789f26e3efd996af0dd6f01ce Mon Sep 17 00:00:00 2001 From: Rafael Zalamena Date: Mon, 4 Feb 2019 22:05:39 -0200 Subject: [PATCH] bfdd: fix CI warnings Fix a few checkpatch warnings and a clang analyzer warning of uninitialized variable. Signed-off-by: Rafael Zalamena --- bfdd/bfd.c | 25 +++++++++++++------------ bfdd/bfd.h | 26 ++++++++++++++------------ bfdd/bfd_packet.c | 2 +- bfdd/bfdd_vty.c | 3 +-- 4 files changed, 29 insertions(+), 27 deletions(-) diff --git a/bfdd/bfd.c b/bfdd/bfd.c index f2f63480f7..12ba16bc82 100644 --- a/bfdd/bfd.c +++ b/bfdd/bfd.c @@ -36,7 +36,7 @@ DEFINE_QOBJ_TYPE(bfd_session); /* * Prototypes */ -struct bfd_session *bs_peer_waiting_find(struct bfd_peer_cfg *); +static struct bfd_session *bs_peer_waiting_find(struct bfd_peer_cfg *bpc); static uint32_t ptm_bfd_gen_ID(void); static void ptm_bfd_echo_xmt_TO(struct bfd_session *bfd); @@ -47,11 +47,16 @@ static struct bfd_session *bfd_find_disc(struct sockaddr_any *sa, static int bfd_session_update(struct bfd_session *bs, struct bfd_peer_cfg *bpc); static const char *get_diag_str(int diag); +static void bs_admin_down_handler(struct bfd_session *bs, int nstate); +static void bs_down_handler(struct bfd_session *bs, int nstate); +static void bs_init_handler(struct bfd_session *bs, int nstate); +static void bs_up_handler(struct bfd_session *bs, int nstate); + /* * Functions */ -struct bfd_session *bs_peer_waiting_find(struct bfd_peer_cfg *bpc) +static struct bfd_session *bs_peer_waiting_find(struct bfd_peer_cfg *bpc) { struct bfd_session_observer *bso; struct bfd_session *bs = NULL; @@ -826,13 +831,9 @@ void bfd_set_polling(struct bfd_session *bs) * transition mechanism. `` is the current session state and * the parameter `nstate` is the peer new state. */ -void bs_admin_down_handler(struct bfd_session *bs, int nstate); -void bs_down_handler(struct bfd_session *bs, int nstate); -void bs_init_handler(struct bfd_session *bs, int nstate); -void bs_up_handler(struct bfd_session *bs, int nstate); - -void bs_admin_down_handler(struct bfd_session *bs __attribute__((__unused__)), - int nstate __attribute__((__unused__))) +static void bs_admin_down_handler(struct bfd_session *bs + __attribute__((__unused__)), + int nstate __attribute__((__unused__))) { /* * We are administratively down, there is no state machine @@ -840,7 +841,7 @@ void bs_admin_down_handler(struct bfd_session *bs __attribute__((__unused__)), */ } -void bs_down_handler(struct bfd_session *bs, int nstate) +static void bs_down_handler(struct bfd_session *bs, int nstate) { switch (nstate) { case PTM_BFD_ADM_DOWN: @@ -874,7 +875,7 @@ void bs_down_handler(struct bfd_session *bs, int nstate) } } -void bs_init_handler(struct bfd_session *bs, int nstate) +static void bs_init_handler(struct bfd_session *bs, int nstate) { switch (nstate) { case PTM_BFD_ADM_DOWN: @@ -901,7 +902,7 @@ void bs_init_handler(struct bfd_session *bs, int nstate) } } -void bs_up_handler(struct bfd_session *bs, int nstate) +static void bs_up_handler(struct bfd_session *bs, int nstate) { switch (nstate) { case PTM_BFD_ADM_DOWN: diff --git a/bfdd/bfd.h b/bfdd/bfd.h index 2a0cda570e..a65c47c06f 100644 --- a/bfdd/bfd.h +++ b/bfdd/bfd.h @@ -465,8 +465,8 @@ int bp_udp_shop(void); int bp_udp_mhop(void); int bp_udp6_shop(void); int bp_udp6_mhop(void); -int bp_peer_socket(const struct bfd_session *); -int bp_peer_socketv6(const struct bfd_session *); +int bp_peer_socket(const struct bfd_session *bs); +int bp_peer_socketv6(const struct bfd_session *bs); int bp_echo_socket(void); int bp_echov6_socket(void); @@ -504,8 +504,8 @@ void bfd_echo_xmttimer_assign(struct bfd_session *bs, bfd_ev_cb cb); * * BFD protocol specific code. */ -int bfd_session_enable(struct bfd_session *); -void bfd_session_disable(struct bfd_session *); +int bfd_session_enable(struct bfd_session *bs); +void bfd_session_disable(struct bfd_session *bs); struct bfd_session *ptm_bfd_sess_new(struct bfd_peer_cfg *bpc); int ptm_bfd_ses_del(struct bfd_peer_cfg *bpc); void ptm_bfd_ses_dn(struct bfd_session *bfd, uint8_t diag); @@ -514,16 +514,18 @@ void ptm_bfd_echo_stop(struct bfd_session *bfd); void ptm_bfd_echo_start(struct bfd_session *bfd); void ptm_bfd_xmt_TO(struct bfd_session *bfd, int fbit); void ptm_bfd_start_xmt_timer(struct bfd_session *bfd, bool is_echo); -struct bfd_session *ptm_bfd_sess_find(struct bfd_pkt *, struct sockaddr_any *, - struct sockaddr_any *, ifindex_t, - vrf_id_t, bool); +struct bfd_session *ptm_bfd_sess_find(struct bfd_pkt *cp, + struct sockaddr_any *peer, + struct sockaddr_any *local, + ifindex_t ifindex, vrf_id_t vrfid, + bool is_mhop); struct bfd_session *bs_peer_find(struct bfd_peer_cfg *bpc); int bfd_session_update_label(struct bfd_session *bs, const char *nlabel); void bfd_set_polling(struct bfd_session *bs); -void bs_state_handler(struct bfd_session *, int); -void bs_echo_timer_handler(struct bfd_session *); -void bs_final_handler(struct bfd_session *); +void bs_state_handler(struct bfd_session *bs, int nstate); +void bs_echo_timer_handler(struct bfd_session *bs); +void bs_final_handler(struct bfd_session *bs); void bs_set_slow_timers(struct bfd_session *bs); const char *satostr(struct sockaddr_any *sa); const char *diag2str(uint8_t diag); @@ -531,8 +533,8 @@ int strtosa(const char *addr, struct sockaddr_any *sa); void integer2timestr(uint64_t time, char *buf, size_t buflen); const char *bs_to_string(struct bfd_session *bs); -int bs_observer_add(struct bfd_session *); -void bs_observer_del(struct bfd_session_observer *); +int bs_observer_add(struct bfd_session *bs); +void bs_observer_del(struct bfd_session_observer *bso); /* BFD hash data structures interface */ void bfd_initialize(void); diff --git a/bfdd/bfd_packet.c b/bfdd/bfd_packet.c index 674c9bf9e6..45c5f5dbdc 100644 --- a/bfdd/bfd_packet.c +++ b/bfdd/bfd_packet.c @@ -505,7 +505,7 @@ int bfd_recv_cb(struct thread *t) struct bfd_pkt *cp; bool is_mhop; ssize_t mlen = 0; - uint8_t ttl; + uint8_t ttl = 0; vrf_id_t vrfid = VRF_DEFAULT; ifindex_t ifindex = IFINDEX_INTERNAL; struct sockaddr_any local, peer; diff --git a/bfdd/bfdd_vty.c b/bfdd/bfdd_vty.c index ed1c434c8e..6bdfc384e8 100644 --- a/bfdd/bfdd_vty.c +++ b/bfdd/bfdd_vty.c @@ -293,9 +293,8 @@ DEFPY(bfd_peer_echo, bfd_peer_echo_cmd, "[no] echo-mode", BFD_SET_FLAG(bs->flags, BFD_SESS_FLAG_ECHO); /* Apply setting immediately. */ - if (!BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_SHUTDOWN)) { + if (!BFD_CHECK_FLAG(bs->flags, BFD_SESS_FLAG_SHUTDOWN)) bs_echo_timer_handler(bs); - } } return CMD_SUCCESS; -- 2.39.5