diff options
author | Donald Sharp <sharpd@nvidia.com> | 2022-02-23 01:04:25 +0100 |
---|---|---|
committer | Donald Sharp <sharpd@nvidia.com> | 2022-02-24 01:56:04 +0100 |
commit | cc9f21da2218d95567eff1501482ce58e6600f54 (patch) | |
tree | d579c9754161d874bad6eb09c67821b65fb559ca /bfdd | |
parent | Merge pull request #10621 from donaldsharp/cov_fun (diff) | |
download | frr-cc9f21da2218d95567eff1501482ce58e6600f54.tar.xz frr-cc9f21da2218d95567eff1501482ce58e6600f54.zip |
*: Change thread->func to return void instead of int
The int return value is never used. Modify the code
base to just return a void instead.
Signed-off-by: Donald Sharp <sharpd@nvidia.com>
Diffstat (limited to 'bfdd')
-rw-r--r-- | bfdd/bfd.c | 16 | ||||
-rw-r--r-- | bfdd/bfd.h | 12 | ||||
-rw-r--r-- | bfdd/bfd_packet.c | 22 | ||||
-rw-r--r-- | bfdd/control.c | 40 | ||||
-rw-r--r-- | bfdd/dplane.c | 21 |
5 files changed, 44 insertions, 67 deletions
diff --git a/bfdd/bfd.c b/bfdd/bfd.c index 588c9fc00..455dd9fe8 100644 --- a/bfdd/bfd.c +++ b/bfdd/bfd.c @@ -609,27 +609,23 @@ struct bfd_session *ptm_bfd_sess_find(struct bfd_pkt *cp, return bfd_key_lookup(key); } -int bfd_xmt_cb(struct thread *t) +void bfd_xmt_cb(struct thread *t) { struct bfd_session *bs = THREAD_ARG(t); ptm_bfd_xmt_TO(bs, 0); - - return 0; } -int bfd_echo_xmt_cb(struct thread *t) +void bfd_echo_xmt_cb(struct thread *t) { struct bfd_session *bs = THREAD_ARG(t); if (bs->echo_xmt_TO > 0) ptm_bfd_echo_xmt_TO(bs); - - return 0; } /* Was ptm_bfd_detect_TO() */ -int bfd_recvtimer_cb(struct thread *t) +void bfd_recvtimer_cb(struct thread *t) { struct bfd_session *bs = THREAD_ARG(t); @@ -639,12 +635,10 @@ int bfd_recvtimer_cb(struct thread *t) ptm_bfd_sess_dn(bs, BD_CONTROL_EXPIRED); break; } - - return 0; } /* Was ptm_bfd_echo_detect_TO() */ -int bfd_echo_recvtimer_cb(struct thread *t) +void bfd_echo_recvtimer_cb(struct thread *t) { struct bfd_session *bs = THREAD_ARG(t); @@ -654,8 +648,6 @@ int bfd_echo_recvtimer_cb(struct thread *t) ptm_bfd_sess_dn(bs, BD_ECHO_FAILED); break; } - - return 0; } struct bfd_session *bfd_session_new(void) diff --git a/bfdd/bfd.h b/bfdd/bfd.h index 473886901..7ab5ef13b 100644 --- a/bfdd/bfd.h +++ b/bfdd/bfd.h @@ -426,7 +426,7 @@ int control_init(const char *path); void control_shutdown(void); int control_notify(struct bfd_session *bs, uint8_t notify_state); int control_notify_config(const char *op, struct bfd_session *bs); -int control_accept(struct thread *t); +void control_accept(struct thread *t); /* @@ -556,7 +556,7 @@ int bp_echov6_socket(const struct vrf *vrf); void ptm_bfd_snd(struct bfd_session *bfd, int fbit); void ptm_bfd_echo_snd(struct bfd_session *bfd); -int bfd_recv_cb(struct thread *t); +void bfd_recv_cb(struct thread *t); /* @@ -690,10 +690,10 @@ unsigned long bfd_get_session_count(void); /* Export callback functions for `event.c`. */ extern struct thread_master *master; -int bfd_recvtimer_cb(struct thread *t); -int bfd_echo_recvtimer_cb(struct thread *t); -int bfd_xmt_cb(struct thread *t); -int bfd_echo_xmt_cb(struct thread *t); +void bfd_recvtimer_cb(struct thread *t); +void bfd_echo_recvtimer_cb(struct thread *t); +void bfd_xmt_cb(struct thread *t); +void bfd_echo_xmt_cb(struct thread *t); extern struct in6_addr zero_addr; diff --git a/bfdd/bfd_packet.c b/bfdd/bfd_packet.c index 8eda78ebd..34b171f40 100644 --- a/bfdd/bfd_packet.c +++ b/bfdd/bfd_packet.c @@ -531,7 +531,7 @@ static void cp_debug(bool mhop, struct sockaddr_any *peer, mhop ? "yes" : "no", peerstr, localstr, portstr, vrfstr); } -int bfd_recv_cb(struct thread *t) +void bfd_recv_cb(struct thread *t) { int sd = THREAD_FD(t); struct bfd_session *bfd; @@ -552,7 +552,7 @@ int bfd_recv_cb(struct thread *t) /* Handle echo packets. */ if (sd == bvrf->bg_echo || sd == bvrf->bg_echov6) { ptm_bfd_process_echo_pkt(bvrf, sd); - return 0; + return; } /* Sanitize input/output. */ @@ -590,14 +590,14 @@ int bfd_recv_cb(struct thread *t) if (mlen < BFD_PKT_LEN) { cp_debug(is_mhop, &peer, &local, ifindex, vrfid, "too small (%ld bytes)", mlen); - return 0; + return; } /* Validate single hop packet TTL. */ if ((!is_mhop) && (ttl != BFD_TTL_VAL)) { cp_debug(is_mhop, &peer, &local, ifindex, vrfid, "invalid TTL: %d expected %d", ttl, BFD_TTL_VAL); - return 0; + return; } /* @@ -611,24 +611,24 @@ int bfd_recv_cb(struct thread *t) if (BFD_GETVER(cp->diag) != BFD_VERSION) { cp_debug(is_mhop, &peer, &local, ifindex, vrfid, "bad version %d", BFD_GETVER(cp->diag)); - return 0; + return; } if (cp->detect_mult == 0) { cp_debug(is_mhop, &peer, &local, ifindex, vrfid, "detect multiplier set to zero"); - return 0; + return; } if ((cp->len < BFD_PKT_LEN) || (cp->len > mlen)) { cp_debug(is_mhop, &peer, &local, ifindex, vrfid, "too small"); - return 0; + return; } if (cp->discrs.my_discr == 0) { cp_debug(is_mhop, &peer, &local, ifindex, vrfid, "'my discriminator' is zero"); - return 0; + return; } /* Find the session that this packet belongs. */ @@ -636,7 +636,7 @@ int bfd_recv_cb(struct thread *t) if (bfd == NULL) { cp_debug(is_mhop, &peer, &local, ifindex, vrfid, "no session found"); - return 0; + return; } /* @@ -648,7 +648,7 @@ int bfd_recv_cb(struct thread *t) cp_debug(is_mhop, &peer, &local, ifindex, vrfid, "exceeded max hop count (expected %d, got %d)", bfd->mh_ttl, ttl); - return 0; + return; } } else if (bfd->local_address.sa_sin.sin_family == AF_UNSPEC) { bfd->local_address = local; @@ -733,8 +733,6 @@ int bfd_recv_cb(struct thread *t) /* Send the control packet with the final bit immediately. */ ptm_bfd_snd(bfd, 1); } - - return 0; } /* diff --git a/bfdd/control.c b/bfdd/control.c index e772aadfc..473843fe2 100644 --- a/bfdd/control.c +++ b/bfdd/control.c @@ -52,8 +52,8 @@ struct bfd_notify_peer *control_notifypeer_find(struct bfd_control_socket *bcs, struct bfd_control_socket *control_new(int sd); static void control_free(struct bfd_control_socket *bcs); static void control_reset_buf(struct bfd_control_buffer *bcb); -static int control_read(struct thread *t); -static int control_write(struct thread *t); +static void control_read(struct thread *t); +static void control_write(struct thread *t); static void control_handle_request_add(struct bfd_control_socket *bcs, struct bfd_control_msg *bcm); @@ -155,21 +155,19 @@ void control_shutdown(void) } } -int control_accept(struct thread *t) +void control_accept(struct thread *t) { int csock, sd = THREAD_FD(t); csock = accept(sd, NULL, 0); if (csock == -1) { zlog_warn("%s: accept: %s", __func__, strerror(errno)); - return 0; + return; } control_new(csock); thread_add_read(master, control_accept, NULL, sd, &bglobal.bg_csockev); - - return 0; } @@ -394,7 +392,7 @@ static void control_reset_buf(struct bfd_control_buffer *bcb) bcb->bcb_left = 0; } -static int control_read(struct thread *t) +static void control_read(struct thread *t) { struct bfd_control_socket *bcs = THREAD_ARG(t); struct bfd_control_buffer *bcb = &bcs->bcs_bin; @@ -417,7 +415,7 @@ static int control_read(struct thread *t) bread = read(sd, &bcm, sizeof(bcm)); if (bread == 0) { control_free(bcs); - return 0; + return; } if (bread < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) @@ -425,7 +423,7 @@ static int control_read(struct thread *t) zlog_warn("%s: read: %s", __func__, strerror(errno)); control_free(bcs); - return 0; + return; } /* Validate header fields. */ @@ -434,14 +432,14 @@ static int control_read(struct thread *t) zlog_debug("%s: client closed due small message length: %d", __func__, bcm.bcm_length); control_free(bcs); - return 0; + return; } if (bcm.bcm_ver != BMV_VERSION_1) { zlog_debug("%s: client closed due bad version: %d", __func__, bcm.bcm_ver); control_free(bcs); - return 0; + return; } /* Prepare the buffer to load the message. */ @@ -456,7 +454,7 @@ static int control_read(struct thread *t) zlog_warn("%s: not enough memory for message size: %zu", __func__, bcb->bcb_left); control_free(bcs); - return 0; + return; } memcpy(bcb->bcb_buf, &bcm, sizeof(bcm)); @@ -469,7 +467,7 @@ skip_header: bread = read(sd, &bcb->bcb_buf[bcb->bcb_pos], bcb->bcb_left); if (bread == 0) { control_free(bcs); - return 0; + return; } if (bread < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) @@ -477,7 +475,7 @@ skip_header: zlog_warn("%s: read: %s", __func__, strerror(errno)); control_free(bcs); - return 0; + return; } bcb->bcb_pos += bread; @@ -518,11 +516,9 @@ skip_header: schedule_next_read: bcs->bcs_ev = NULL; thread_add_read(master, control_read, bcs, sd, &bcs->bcs_ev); - - return 0; } -static int control_write(struct thread *t) +static void control_write(struct thread *t) { struct bfd_control_socket *bcs = THREAD_ARG(t); struct bfd_control_buffer *bcb = bcs->bcs_bout; @@ -532,19 +528,19 @@ static int control_write(struct thread *t) bwrite = write(sd, &bcb->bcb_buf[bcb->bcb_pos], bcb->bcb_left); if (bwrite == 0) { control_free(bcs); - return 0; + return; } if (bwrite < 0) { if (errno == EAGAIN || errno == EWOULDBLOCK || errno == EINTR) { bcs->bcs_outev = NULL; thread_add_write(master, control_write, bcs, bcs->bcs_sd, &bcs->bcs_outev); - return 0; + return; } zlog_warn("%s: write: %s", __func__, strerror(errno)); control_free(bcs); - return 0; + return; } bcb->bcb_pos += bwrite; @@ -553,12 +549,10 @@ static int control_write(struct thread *t) bcs->bcs_outev = NULL; thread_add_write(master, control_write, bcs, bcs->bcs_sd, &bcs->bcs_outev); - return 0; + return; } control_queue_dequeue(bcs); - - return 0; } diff --git a/bfdd/dplane.c b/bfdd/dplane.c index 9dee2a558..c1081643e 100644 --- a/bfdd/dplane.c +++ b/bfdd/dplane.c @@ -107,7 +107,7 @@ struct bfd_dplane_ctx { */ typedef void (*bfd_dplane_expect_cb)(struct bfddp_message *msg, void *arg); -static int bfd_dplane_client_connect(struct thread *t); +static void bfd_dplane_client_connect(struct thread *t); static bool bfd_dplane_client_connecting(struct bfd_dplane_ctx *bdc); static void bfd_dplane_ctx_free(struct bfd_dplane_ctx *bdc); static int _bfd_dplane_add_session(struct bfd_dplane_ctx *bdc, @@ -325,17 +325,15 @@ static ssize_t bfd_dplane_flush(struct bfd_dplane_ctx *bdc) return total; } -static int bfd_dplane_write(struct thread *t) +static void bfd_dplane_write(struct thread *t) { struct bfd_dplane_ctx *bdc = THREAD_ARG(t); /* Handle connection stage. */ if (bdc->connecting && bfd_dplane_client_connecting(bdc)) - return 0; + return; bfd_dplane_flush(bdc); - - return 0; } static void @@ -614,18 +612,17 @@ skip_read: return 0; } -static int bfd_dplane_read(struct thread *t) +static void bfd_dplane_read(struct thread *t) { struct bfd_dplane_ctx *bdc = THREAD_ARG(t); int rv; rv = bfd_dplane_expect(bdc, 0, bfd_dplane_handle_message, NULL); if (rv == -1) - return 0; + return; stream_pulldown(bdc->inbuf); thread_add_read(master, bfd_dplane_read, bdc, bdc->sock, &bdc->inbufev); - return 0; } static void _bfd_session_register_dplane(struct hash_bucket *hb, void *arg) @@ -835,7 +832,7 @@ static uint16_t bfd_dplane_request_counters(const struct bfd_session *bs) /* * Data plane listening socket. */ -static int bfd_dplane_accept(struct thread *t) +static void bfd_dplane_accept(struct thread *t) { struct bfd_global *bg = THREAD_ARG(t); struct bfd_dplane_ctx *bdc; @@ -858,7 +855,6 @@ static int bfd_dplane_accept(struct thread *t) reschedule_and_return: thread_add_read(master, bfd_dplane_accept, bg, bg->bg_dplane_sock, &bglobal.bg_dplane_sockev); - return 0; } /* @@ -916,7 +912,7 @@ static bool bfd_dplane_client_connecting(struct bfd_dplane_ctx *bdc) } } -static int bfd_dplane_client_connect(struct thread *t) +static void bfd_dplane_client_connect(struct thread *t) { struct bfd_dplane_ctx *bdc = THREAD_ARG(t); int rv, sock; @@ -965,15 +961,12 @@ static int bfd_dplane_client_connect(struct thread *t) _bfd_dplane_client_bootstrap(bdc); } - return 0; - reschedule_connect: THREAD_OFF(bdc->inbufev); THREAD_OFF(bdc->outbufev); socket_close(&sock); thread_add_timer(master, bfd_dplane_client_connect, bdc, 3, &bdc->connectev); - return 0; } static void bfd_dplane_client_init(const struct sockaddr *sa, socklen_t salen) |