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 /lib | |
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 'lib')
-rw-r--r-- | lib/agentx.c | 8 | ||||
-rw-r--r-- | lib/bfd.c | 8 | ||||
-rw-r--r-- | lib/frr_pthread.c | 6 | ||||
-rw-r--r-- | lib/frr_zmq.c | 24 | ||||
-rw-r--r-- | lib/libfrr.c | 9 | ||||
-rw-r--r-- | lib/northbound_cli.c | 4 | ||||
-rw-r--r-- | lib/northbound_confd.c | 41 | ||||
-rw-r--r-- | lib/northbound_grpc.cpp | 9 | ||||
-rw-r--r-- | lib/northbound_sysrepo.c | 8 | ||||
-rw-r--r-- | lib/pullwr.c | 11 | ||||
-rw-r--r-- | lib/resolver.c | 15 | ||||
-rw-r--r-- | lib/sigevent.c | 4 | ||||
-rw-r--r-- | lib/spf_backoff.c | 6 | ||||
-rw-r--r-- | lib/systemd.c | 3 | ||||
-rw-r--r-- | lib/thread.c | 21 | ||||
-rw-r--r-- | lib/thread.h | 16 | ||||
-rw-r--r-- | lib/vty.c | 48 | ||||
-rw-r--r-- | lib/wheel.c | 10 | ||||
-rw-r--r-- | lib/workqueue.c | 4 | ||||
-rw-r--r-- | lib/workqueue.h | 2 | ||||
-rw-r--r-- | lib/zclient.c | 34 | ||||
-rw-r--r-- | lib/zlog_5424.c | 5 |
22 files changed, 124 insertions, 172 deletions
diff --git a/lib/agentx.c b/lib/agentx.c index 5f865ca2b..821c573fb 100644 --- a/lib/agentx.c +++ b/lib/agentx.c @@ -46,7 +46,7 @@ static struct list *events = NULL; static void agentx_events_update(void); -static int agentx_timeout(struct thread *t) +static void agentx_timeout(struct thread *t) { timeout_thr = NULL; @@ -54,10 +54,9 @@ static int agentx_timeout(struct thread *t) run_alarms(); netsnmp_check_outstanding_agent_requests(); agentx_events_update(); - return 0; } -static int agentx_read(struct thread *t) +static void agentx_read(struct thread *t) { fd_set fds; int flags, new_flags = 0; @@ -72,7 +71,7 @@ static int agentx_read(struct thread *t) if (-1 == flags) { flog_err(EC_LIB_SYSTEM_CALL, "Failed to get FD settings fcntl: %s(%d)", strerror(errno), errno); - return -1; + return; } if (flags & O_NONBLOCK) @@ -101,7 +100,6 @@ static int agentx_read(struct thread *t) netsnmp_check_outstanding_agent_requests(); agentx_events_update(); - return 0; } static void agentx_events_update(void) @@ -461,14 +461,14 @@ static bool _bfd_sess_valid(const struct bfd_session_params *bsp) return true; } -static int _bfd_sess_send(struct thread *t) +static void _bfd_sess_send(struct thread *t) { struct bfd_session_params *bsp = THREAD_ARG(t); int rv; /* Validate configuration before trying to send bogus data. */ if (!_bfd_sess_valid(bsp)) - return 0; + return; if (bsp->lastev == BSE_INSTALL) { bsp->args.command = bsp->installed ? ZEBRA_BFD_DEST_UPDATE @@ -478,7 +478,7 @@ static int _bfd_sess_send(struct thread *t) /* If not installed and asked for uninstall, do nothing. */ if (!bsp->installed && bsp->args.command == ZEBRA_BFD_DEST_DEREGISTER) - return 0; + return; rv = zclient_bfd_command(bsglobal.zc, &bsp->args); /* Command was sent successfully. */ @@ -504,8 +504,6 @@ static int _bfd_sess_send(struct thread *t) bsp->lastev == BSE_INSTALL ? "installed" : "uninstalled"); } - - return 0; } static void _bfd_sess_remove(struct bfd_session_params *bsp) diff --git a/lib/frr_pthread.c b/lib/frr_pthread.c index 898fe98aa..0f56fbac8 100644 --- a/lib/frr_pthread.c +++ b/lib/frr_pthread.c @@ -237,18 +237,16 @@ void frr_pthread_stop_all(void) */ /* dummy task for sleeper pipe */ -static int fpt_dummy(struct thread *thread) +static void fpt_dummy(struct thread *thread) { - return 0; } /* poison pill task to end event loop */ -static int fpt_finish(struct thread *thread) +static void fpt_finish(struct thread *thread) { struct frr_pthread *fpt = THREAD_ARG(thread); atomic_store_explicit(&fpt->running, false, memory_order_relaxed); - return 0; } /* stop function, called from other threads to halt this one */ diff --git a/lib/frr_zmq.c b/lib/frr_zmq.c index e572558de..db5c4c91a 100644 --- a/lib/frr_zmq.c +++ b/lib/frr_zmq.c @@ -56,7 +56,7 @@ void frrzmq_finish(void) } } -static int frrzmq_read_msg(struct thread *t) +static void frrzmq_read_msg(struct thread *t) { struct frrzmq_cb **cbp = THREAD_ARG(t); struct frrzmq_cb *cb; @@ -67,10 +67,10 @@ static int frrzmq_read_msg(struct thread *t) size_t moresz; if (!cbp) - return 1; + return; cb = (*cbp); if (!cb || !cb->zmqsock) - return 1; + return; while (1) { zmq_pollitem_t polli = {.socket = cb->zmqsock, @@ -97,7 +97,7 @@ static int frrzmq_read_msg(struct thread *t) if (cb->write.cancelled && !cb->write.thread) XFREE(MTYPE_ZEROMQ_CB, *cbp); - return 0; + return; } continue; } @@ -129,7 +129,7 @@ static int frrzmq_read_msg(struct thread *t) if (cb->write.cancelled && !cb->write.thread) XFREE(MTYPE_ZEROMQ_CB, *cbp); - return 0; + return; } /* cb_part may have read additional parts of the @@ -153,14 +153,13 @@ static int frrzmq_read_msg(struct thread *t) thread_add_read(t->master, frrzmq_read_msg, cbp, cb->fd, &cb->read.thread); - return 0; + return; out_err: flog_err(EC_LIB_ZMQ, "ZeroMQ read error: %s(%d)", strerror(errno), errno); if (cb->read.cb_error) cb->read.cb_error(cb->read.arg, cb->zmqsock); - return 1; } int _frrzmq_thread_add_read(const struct xref_threadsched *xref, @@ -215,7 +214,7 @@ int _frrzmq_thread_add_read(const struct xref_threadsched *xref, return 0; } -static int frrzmq_write_msg(struct thread *t) +static void frrzmq_write_msg(struct thread *t) { struct frrzmq_cb **cbp = THREAD_ARG(t); struct frrzmq_cb *cb; @@ -223,10 +222,10 @@ static int frrzmq_write_msg(struct thread *t) int ret; if (!cbp) - return 1; + return; cb = (*cbp); if (!cb || !cb->zmqsock) - return 1; + return; while (1) { zmq_pollitem_t polli = {.socket = cb->zmqsock, @@ -252,7 +251,7 @@ static int frrzmq_write_msg(struct thread *t) if (cb->read.cancelled && !cb->read.thread) XFREE(MTYPE_ZEROMQ_CB, *cbp); - return 0; + return; } continue; } @@ -263,14 +262,13 @@ static int frrzmq_write_msg(struct thread *t) thread_add_write(t->master, frrzmq_write_msg, cbp, cb->fd, &cb->write.thread); - return 0; + return; out_err: flog_err(EC_LIB_ZMQ, "ZeroMQ write error: %s(%d)", strerror(errno), errno); if (cb->write.cb_error) cb->write.cb_error(cb->write.arg, cb->zmqsock); - return 1; } int _frrzmq_thread_add_write(const struct xref_threadsched *xref, diff --git a/lib/libfrr.c b/lib/libfrr.c index d5e326be4..10b3aad89 100644 --- a/lib/libfrr.c +++ b/lib/libfrr.c @@ -962,7 +962,7 @@ static void frr_daemonize(void) * to read the config in after thread execution starts, so that * we can match this behavior. */ -static int frr_config_read_in(struct thread *t) +static void frr_config_read_in(struct thread *t) { hook_call(frr_config_pre, master); @@ -1000,8 +1000,6 @@ static int frr_config_read_in(struct thread *t) } hook_call(frr_config_post, master); - - return 0; } void frr_config_fork(void) @@ -1097,7 +1095,7 @@ static void frr_terminal_close(int isexit) static struct thread *daemon_ctl_thread = NULL; -static int frr_daemon_ctl(struct thread *t) +static void frr_daemon_ctl(struct thread *t) { char buf[1]; ssize_t nr; @@ -1106,7 +1104,7 @@ static int frr_daemon_ctl(struct thread *t) if (nr < 0 && (errno == EINTR || errno == EAGAIN)) goto out; if (nr <= 0) - return 0; + return; switch (buf[0]) { case 'S': /* SIGTSTP */ @@ -1131,7 +1129,6 @@ static int frr_daemon_ctl(struct thread *t) out: thread_add_read(master, frr_daemon_ctl, NULL, daemon_ctl_sock, &daemon_ctl_thread); - return 0; } void frr_detach(void) diff --git a/lib/northbound_cli.c b/lib/northbound_cli.c index 70c71b18c..1e25f6a1e 100644 --- a/lib/northbound_cli.c +++ b/lib/northbound_cli.c @@ -347,7 +347,7 @@ int nb_cli_confirmed_commit_rollback(struct vty *vty) return ret; } -static int nb_cli_confirmed_commit_timeout(struct thread *thread) +static void nb_cli_confirmed_commit_timeout(struct thread *thread) { struct vty *vty = THREAD_ARG(thread); @@ -357,8 +357,6 @@ static int nb_cli_confirmed_commit_timeout(struct thread *thread) nb_cli_confirmed_commit_rollback(vty); nb_cli_confirmed_commit_clean(vty); - - return 0; } static int nb_cli_commit(struct vty *vty, bool force, diff --git a/lib/northbound_confd.c b/lib/northbound_confd.c index e1c8983fc..27eaefd07 100644 --- a/lib/northbound_confd.c +++ b/lib/northbound_confd.c @@ -283,7 +283,7 @@ frr_confd_cdb_diff_iter(confd_hkeypath_t *kp, enum cdb_iter_op cdb_op, return ITER_RECURSE; } -static int frr_confd_cdb_read_cb_prepare(int fd, int *subp, int reslen) +static void frr_confd_cdb_read_cb_prepare(int fd, int *subp, int reslen) { struct nb_context context = {}; struct nb_config *candidate; @@ -313,9 +313,9 @@ static int frr_confd_cdb_read_cb_prepare(int fd, int *subp, int reslen) 0, "Couldn't apply configuration changes") != CONFD_OK) { flog_err_confd("cdb_sub_abort_trans"); - return -1; + return; } - return 0; + return; } /* @@ -346,25 +346,23 @@ static int frr_confd_cdb_read_cb_prepare(int fd, int *subp, int reslen) errmsg) != CONFD_OK) { flog_err_confd("cdb_sub_abort_trans"); - return -1; + return; } } else { /* Acknowledge the notification. */ if (cdb_sync_subscription_socket(fd, CDB_DONE_PRIORITY) != CONFD_OK) { flog_err_confd("cdb_sync_subscription_socket"); - return -1; + return; } /* No configuration changes. */ if (!transaction) nb_config_free(candidate); } - - return 0; } -static int frr_confd_cdb_read_cb_commit(int fd, int *subp, int reslen) +static void frr_confd_cdb_read_cb_commit(int fd, int *subp, int reslen) { /* * No need to process the configuration changes again as we're already @@ -385,10 +383,8 @@ static int frr_confd_cdb_read_cb_commit(int fd, int *subp, int reslen) /* Acknowledge the notification. */ if (cdb_sync_subscription_socket(fd, CDB_DONE_PRIORITY) != CONFD_OK) { flog_err_confd("cdb_sync_subscription_socket"); - return -1; + return; } - - return 0; } static int frr_confd_cdb_read_cb_abort(int fd, int *subp, int reslen) @@ -417,7 +413,7 @@ static int frr_confd_cdb_read_cb_abort(int fd, int *subp, int reslen) return 0; } -static int frr_confd_cdb_read_cb(struct thread *thread) +static void frr_confd_cdb_read_cb(struct thread *thread) { int fd = THREAD_FD(thread); enum cdb_sub_notification cdb_ev; @@ -430,19 +426,22 @@ static int frr_confd_cdb_read_cb(struct thread *thread) if (cdb_read_subscription_socket2(fd, &cdb_ev, &flags, &subp, &reslen) != CONFD_OK) { flog_err_confd("cdb_read_subscription_socket2"); - return -1; + return; } switch (cdb_ev) { case CDB_SUB_PREPARE: - return frr_confd_cdb_read_cb_prepare(fd, subp, reslen); + frr_confd_cdb_read_cb_prepare(fd, subp, reslen); + break; case CDB_SUB_COMMIT: - return frr_confd_cdb_read_cb_commit(fd, subp, reslen); + frr_confd_cdb_read_cb_commit(fd, subp, reslen); + break; case CDB_SUB_ABORT: - return frr_confd_cdb_read_cb_abort(fd, subp, reslen); + frr_confd_cdb_read_cb_abort(fd, subp, reslen); + break; default: flog_err_confd("unknown CDB event"); - return -1; + break; } } @@ -1186,7 +1185,7 @@ static int frr_confd_dp_read(struct confd_daemon_ctx *dctx, int fd) return 0; } -static int frr_confd_dp_ctl_read(struct thread *thread) +static void frr_confd_dp_ctl_read(struct thread *thread) { struct confd_daemon_ctx *dctx = THREAD_ARG(thread); int fd = THREAD_FD(thread); @@ -1194,11 +1193,9 @@ static int frr_confd_dp_ctl_read(struct thread *thread) thread_add_read(master, frr_confd_dp_ctl_read, dctx, fd, &t_dp_ctl); frr_confd_dp_read(dctx, fd); - - return 0; } -static int frr_confd_dp_worker_read(struct thread *thread) +static void frr_confd_dp_worker_read(struct thread *thread) { struct confd_daemon_ctx *dctx = THREAD_ARG(thread); int fd = THREAD_FD(thread); @@ -1206,8 +1203,6 @@ static int frr_confd_dp_worker_read(struct thread *thread) thread_add_read(master, frr_confd_dp_worker_read, dctx, fd, &t_dp_worker); frr_confd_dp_read(dctx, fd); - - return 0; } static int frr_confd_subscribe_state(const struct lysc_node *snode, void *arg) diff --git a/lib/northbound_grpc.cpp b/lib/northbound_grpc.cpp index e227d0385..34bb1e498 100644 --- a/lib/northbound_grpc.cpp +++ b/lib/northbound_grpc.cpp @@ -206,7 +206,7 @@ template <typename Q, typename S> class NewRpcState : RpcStateBase } - static int c_callback(struct thread *thread) + static void c_callback(struct thread *thread) { auto _tag = static_cast<NewRpcState<Q, S> *>(thread->arg); /* @@ -225,7 +225,7 @@ template <typename Q, typename S> class NewRpcState : RpcStateBase pthread_cond_signal(&_tag->cond); pthread_mutex_unlock(&_tag->cmux); - return 0; + return; } NewRpcState<Q, S> *orig; @@ -1368,7 +1368,7 @@ static int frr_grpc_finish(void) * fork. This is done by scheduling this init function as an event task, since * the event loop doesn't run until after fork. */ -static int frr_grpc_module_very_late_init(struct thread *thread) +static void frr_grpc_module_very_late_init(struct thread *thread) { const char *args = THIS_MODULE->load_args; uint port = GRPC_DEFAULT_PORT; @@ -1386,11 +1386,10 @@ static int frr_grpc_module_very_late_init(struct thread *thread) if (frr_grpc_init(port) < 0) goto error; - return 0; + return; error: flog_err(EC_LIB_GRPC_INIT, "failed to initialize the gRPC module"); - return -1; } static int frr_grpc_module_late_init(struct thread_master *tm) diff --git a/lib/northbound_sysrepo.c b/lib/northbound_sysrepo.c index 86a159e50..0158d8ea0 100644 --- a/lib/northbound_sysrepo.c +++ b/lib/northbound_sysrepo.c @@ -41,7 +41,7 @@ static sr_session_ctx_t *session; static sr_conn_ctx_t *connection; static struct nb_transaction *transaction; -static int frr_sr_read_cb(struct thread *thread); +static void frr_sr_read_cb(struct thread *thread); static int frr_sr_finish(void); /* Convert FRR YANG data value to sysrepo YANG data value. */ @@ -526,7 +526,7 @@ static int frr_sr_notification_send(const char *xpath, struct list *arguments) return NB_OK; } -static int frr_sr_read_cb(struct thread *thread) +static void frr_sr_read_cb(struct thread *thread) { struct yang_module *module = THREAD_ARG(thread); int fd = THREAD_FD(thread); @@ -536,12 +536,10 @@ static int frr_sr_read_cb(struct thread *thread) if (ret != SR_ERR_OK) { flog_err(EC_LIB_LIBSYSREPO, "%s: sr_fd_event_process(): %s", __func__, sr_strerror(ret)); - return -1; + return; } thread_add_read(master, frr_sr_read_cb, module, fd, &module->sr_thread); - - return 0; } static void frr_sr_subscribe_config(struct yang_module *module) diff --git a/lib/pullwr.c b/lib/pullwr.c index 15563d247..5e836984b 100644 --- a/lib/pullwr.c +++ b/lib/pullwr.c @@ -51,7 +51,7 @@ struct pullwr { DEFINE_MTYPE_STATIC(LIB, PULLWR_HEAD, "pull-driven write controller"); DEFINE_MTYPE_STATIC(LIB, PULLWR_BUF, "pull-driven write buffer"); -static int pullwr_run(struct thread *t); +static void pullwr_run(struct thread *t); struct pullwr *_pullwr_new(struct thread_master *tm, int fd, void *arg, @@ -189,7 +189,7 @@ void pullwr_write(struct pullwr *pullwr, const void *data, size_t len) pullwr_bump(pullwr); } -static int pullwr_run(struct thread *t) +static void pullwr_run(struct thread *t) { struct pullwr *pullwr = THREAD_ARG(t); struct iovec iov[2]; @@ -222,7 +222,7 @@ static int pullwr_run(struct thread *t) * into idle, i.e. no calling thread_add_write() */ pullwr_resize(pullwr, 0); - return 0; + return; } niov = pullwr_iov(pullwr, iov); @@ -233,12 +233,12 @@ static int pullwr_run(struct thread *t) if (errno == EAGAIN || errno == EWOULDBLOCK) break; pullwr->err(pullwr->arg, pullwr, false); - return 0; + return; } if (nwr == 0) { pullwr->err(pullwr->arg, pullwr, true); - return 0; + return; } pullwr->total_written += nwr; @@ -258,7 +258,6 @@ static int pullwr_run(struct thread *t) */ if (!maxspun) pullwr_resize(pullwr, 0); - return 0; } void pullwr_stats(struct pullwr *pullwr, uint64_t *total_written, diff --git a/lib/resolver.c b/lib/resolver.c index 29138bbc8..93fa84bbe 100644 --- a/lib/resolver.c +++ b/lib/resolver.c @@ -104,17 +104,15 @@ static void resolver_fd_drop_maybe(struct resolver_fd *resfd) static void resolver_update_timeouts(struct resolver_state *r); -static int resolver_cb_timeout(struct thread *t) +static void resolver_cb_timeout(struct thread *t) { struct resolver_state *r = THREAD_ARG(t); ares_process(r->channel, NULL, NULL); resolver_update_timeouts(r); - - return 0; } -static int resolver_cb_socket_readable(struct thread *t) +static void resolver_cb_socket_readable(struct thread *t) { struct resolver_fd *resfd = THREAD_ARG(t); struct resolver_state *r = resfd->state; @@ -127,11 +125,9 @@ static int resolver_cb_socket_readable(struct thread *t) */ ares_process_fd(r->channel, resfd->fd, ARES_SOCKET_BAD); resolver_update_timeouts(r); - - return 0; } -static int resolver_cb_socket_writable(struct thread *t) +static void resolver_cb_socket_writable(struct thread *t) { struct resolver_fd *resfd = THREAD_ARG(t); struct resolver_state *r = resfd->state; @@ -144,8 +140,6 @@ static int resolver_cb_socket_writable(struct thread *t) */ ares_process_fd(r->channel, ARES_SOCKET_BAD, resfd->fd); resolver_update_timeouts(r); - - return 0; } static void resolver_update_timeouts(struct resolver_state *r) @@ -232,7 +226,7 @@ static void ares_address_cb(void *arg, int status, int timeouts, callback(query, NULL, i, &addr[0]); } -static int resolver_cb_literal(struct thread *t) +static void resolver_cb_literal(struct thread *t) { struct resolver_query *query = THREAD_ARG(t); void (*callback)(struct resolver_query *, const char *, int, @@ -242,7 +236,6 @@ static int resolver_cb_literal(struct thread *t) query->callback = NULL; callback(query, ARES_SUCCESS, 1, &query->literal_addr); - return 0; } void resolver_resolve(struct resolver_query *query, int af, vrf_id_t vrf_id, diff --git a/lib/sigevent.c b/lib/sigevent.c index 00bc31f51..0f20bc027 100644 --- a/lib/sigevent.c +++ b/lib/sigevent.c @@ -143,7 +143,7 @@ int frr_sigevent_process(void) #ifdef SIGEVENT_SCHEDULE_THREAD /* timer thread to check signals. shouldn't be needed */ -int frr_signal_timer(struct thread *t) +void frr_signal_timer(struct thread *t) { struct frr_sigevent_master_t *sigm; @@ -151,7 +151,7 @@ int frr_signal_timer(struct thread *t) sigm->t = NULL; thread_add_timer(sigm->t->master, frr_signal_timer, &sigmaster, FRR_SIGNAL_TIMER_INTERVAL, &sigm->t); - return frr_sigevent_process(); + frr_sigevent_process(); } #endif /* SIGEVENT_SCHEDULE_THREAD */ diff --git a/lib/spf_backoff.c b/lib/spf_backoff.c index a273e9346..117b7d3e8 100644 --- a/lib/spf_backoff.c +++ b/lib/spf_backoff.c @@ -117,17 +117,16 @@ void spf_backoff_free(struct spf_backoff *backoff) XFREE(MTYPE_SPF_BACKOFF, backoff); } -static int spf_backoff_timetolearn_elapsed(struct thread *thread) +static void spf_backoff_timetolearn_elapsed(struct thread *thread) { struct spf_backoff *backoff = THREAD_ARG(thread); backoff->state = SPF_BACKOFF_LONG_WAIT; backoff_debug("SPF Back-off(%s) TIMETOLEARN elapsed, move to state %s", backoff->name, spf_backoff_state2str(backoff->state)); - return 0; } -static int spf_backoff_holddown_elapsed(struct thread *thread) +static void spf_backoff_holddown_elapsed(struct thread *thread) { struct spf_backoff *backoff = THREAD_ARG(thread); @@ -136,7 +135,6 @@ static int spf_backoff_holddown_elapsed(struct thread *thread) backoff->state = SPF_BACKOFF_QUIET; backoff_debug("SPF Back-off(%s) HOLDDOWN elapsed, move to state %s", backoff->name, spf_backoff_state2str(backoff->state)); - return 0; } long spf_backoff_schedule(struct spf_backoff *backoff) diff --git a/lib/systemd.c b/lib/systemd.c index 2238dc9f3..1c9a6f122 100644 --- a/lib/systemd.c +++ b/lib/systemd.c @@ -80,14 +80,13 @@ void systemd_send_stopping(void) static struct thread_master *systemd_master = NULL; -static int systemd_send_watchdog(struct thread *t) +static void systemd_send_watchdog(struct thread *t) { systemd_send_information("WATCHDOG=1"); assert(watchdog_msec > 0); thread_add_timer_msec(systemd_master, systemd_send_watchdog, NULL, watchdog_msec, NULL); - return 1; } void systemd_send_started(struct thread_master *m) diff --git a/lib/thread.c b/lib/thread.c index ada7a9cc8..58b8e206f 100644 --- a/lib/thread.c +++ b/lib/thread.c @@ -773,7 +773,7 @@ char *thread_timer_to_hhmmss(char *buf, int buf_size, /* Get new thread. */ static struct thread *thread_get(struct thread_master *m, uint8_t type, - int (*func)(struct thread *), void *arg, + void (*func)(struct thread *), void *arg, const struct xref_threadsched *xref) { struct thread *thread = thread_list_pop(&m->unuse); @@ -930,7 +930,7 @@ done: /* Add new read thread. */ void _thread_add_read_write(const struct xref_threadsched *xref, struct thread_master *m, - int (*func)(struct thread *), void *arg, int fd, + void (*func)(struct thread *), void *arg, int fd, struct thread **t_ptr) { int dir = xref->thread_type; @@ -1010,7 +1010,7 @@ void _thread_add_read_write(const struct xref_threadsched *xref, static void _thread_add_timer_timeval(const struct xref_threadsched *xref, struct thread_master *m, - int (*func)(struct thread *), void *arg, + void (*func)(struct thread *), void *arg, struct timeval *time_relative, struct thread **t_ptr) { @@ -1057,7 +1057,7 @@ static void _thread_add_timer_timeval(const struct xref_threadsched *xref, /* Add timer event thread. */ void _thread_add_timer(const struct xref_threadsched *xref, - struct thread_master *m, int (*func)(struct thread *), + struct thread_master *m, void (*func)(struct thread *), void *arg, long timer, struct thread **t_ptr) { struct timeval trel; @@ -1073,8 +1073,8 @@ void _thread_add_timer(const struct xref_threadsched *xref, /* Add timer event thread with "millisecond" resolution */ void _thread_add_timer_msec(const struct xref_threadsched *xref, struct thread_master *m, - int (*func)(struct thread *), void *arg, long timer, - struct thread **t_ptr) + void (*func)(struct thread *), void *arg, + long timer, struct thread **t_ptr) { struct timeval trel; @@ -1088,15 +1088,16 @@ void _thread_add_timer_msec(const struct xref_threadsched *xref, /* Add timer event thread with "timeval" resolution */ void _thread_add_timer_tv(const struct xref_threadsched *xref, - struct thread_master *m, int (*func)(struct thread *), - void *arg, struct timeval *tv, struct thread **t_ptr) + struct thread_master *m, + void (*func)(struct thread *), void *arg, + struct timeval *tv, struct thread **t_ptr) { _thread_add_timer_timeval(xref, m, func, arg, tv, t_ptr); } /* Add simple event thread. */ void _thread_add_event(const struct xref_threadsched *xref, - struct thread_master *m, int (*func)(struct thread *), + struct thread_master *m, void (*func)(struct thread *), void *arg, int val, struct thread **t_ptr) { struct thread *thread = NULL; @@ -2008,7 +2009,7 @@ void thread_call(struct thread *thread) /* Execute thread */ void _thread_execute(const struct xref_threadsched *xref, - struct thread_master *m, int (*func)(struct thread *), + struct thread_master *m, void (*func)(struct thread *), void *arg, int val) { struct thread *thread; diff --git a/lib/thread.h b/lib/thread.h index 0c2a4ba86..a2049ae52 100644 --- a/lib/thread.h +++ b/lib/thread.h @@ -114,7 +114,7 @@ struct thread { struct thread_timer_list_item timeritem; struct thread **ref; /* external reference (if given) */ struct thread_master *master; /* pointer to the struct thread_master */ - int (*func)(struct thread *); /* event function */ + void (*func)(struct thread *); /* event function */ void *arg; /* event argument */ union { int val; /* second argument of the event. */ @@ -134,7 +134,7 @@ struct thread { #endif struct cpu_thread_history { - int (*func)(struct thread *); + void (*func)(struct thread *); atomic_size_t total_cpu_warn; atomic_size_t total_wall_warn; atomic_size_t total_starv_warn; @@ -227,32 +227,32 @@ extern void thread_master_free_unused(struct thread_master *); extern void _thread_add_read_write(const struct xref_threadsched *xref, struct thread_master *master, - int (*fn)(struct thread *), void *arg, + void (*fn)(struct thread *), void *arg, int fd, struct thread **tref); extern void _thread_add_timer(const struct xref_threadsched *xref, struct thread_master *master, - int (*fn)(struct thread *), void *arg, long t, + void (*fn)(struct thread *), void *arg, long t, struct thread **tref); extern void _thread_add_timer_msec(const struct xref_threadsched *xref, struct thread_master *master, - int (*fn)(struct thread *), void *arg, + void (*fn)(struct thread *), void *arg, long t, struct thread **tref); extern void _thread_add_timer_tv(const struct xref_threadsched *xref, struct thread_master *master, - int (*fn)(struct thread *), void *arg, + void (*fn)(struct thread *), void *arg, struct timeval *tv, struct thread **tref); extern void _thread_add_event(const struct xref_threadsched *xref, struct thread_master *master, - int (*fn)(struct thread *), void *arg, int val, + void (*fn)(struct thread *), void *arg, int val, struct thread **tref); extern void _thread_execute(const struct xref_threadsched *xref, struct thread_master *master, - int (*fn)(struct thread *), void *arg, int val); + void (*fn)(struct thread *), void *arg, int val); extern void thread_cancel(struct thread **event); extern void thread_cancel_async(struct thread_master *, struct thread **, @@ -1299,7 +1299,7 @@ static void vty_buffer_reset(struct vty *vty) } /* Read data via vty socket. */ -static int vty_read(struct thread *thread) +static void vty_read(struct thread *thread) { int i; int nbytes; @@ -1312,7 +1312,7 @@ static int vty_read(struct thread *thread) if (nbytes < 0) { if (ERRNO_IO_RETRY(errno)) { vty_event(VTY_READ, vty); - return 0; + return; } vty->monitor = 0; /* disable monitoring to avoid infinite recursion */ @@ -1496,11 +1496,10 @@ static int vty_read(struct thread *thread) vty_event(VTY_WRITE, vty); vty_event(VTY_READ, vty); } - return 0; } /* Flush buffer to the vty. */ -static int vty_flush(struct thread *thread) +static void vty_flush(struct thread *thread) { int erase; buffer_status_t flushrc; @@ -1532,7 +1531,7 @@ static int vty_flush(struct thread *thread) buffer_reset(vty->lbuf); buffer_reset(vty->obuf); vty_close(vty); - return 0; + return; case BUFFER_EMPTY: if (vty->status == VTY_CLOSE) vty_close(vty); @@ -1549,8 +1548,6 @@ static int vty_flush(struct thread *thread) vty_event(VTY_WRITE, vty); break; } - - return 0; } /* Allocate new vty struct. */ @@ -1753,7 +1750,7 @@ struct vty *vty_stdio(void (*atclose)(int isexit)) } /* Accept connection from the network. */ -static int vty_accept(struct thread *thread) +static void vty_accept(struct thread *thread) { struct vty_serv *vtyserv = THREAD_ARG(thread); int vty_sock; @@ -1774,7 +1771,7 @@ static int vty_accept(struct thread *thread) if (vty_sock < 0) { flog_err(EC_LIB_SOCKET, "can't accept vty socket : %s", safe_strerror(errno)); - return -1; + return; } set_nonblocking(vty_sock); set_cloexec(vty_sock); @@ -1783,7 +1780,7 @@ static int vty_accept(struct thread *thread) close(vty_sock); zlog_info("Vty unable to convert prefix from sockunion %pSU", &su); - return -1; + return; } /* VTY's accesslist apply. */ @@ -1792,7 +1789,7 @@ static int vty_accept(struct thread *thread) && (access_list_apply(acl, &p) == FILTER_DENY)) { zlog_info("Vty connection refused from %pSU", &su); close(vty_sock); - return 0; + return; } } @@ -1803,7 +1800,7 @@ static int vty_accept(struct thread *thread) && (access_list_apply(acl, &p) == FILTER_DENY)) { zlog_info("Vty connection refused from %pSU", &su); close(vty_sock); - return 0; + return; } } @@ -1817,8 +1814,6 @@ static int vty_accept(struct thread *thread) zlog_info("Vty connection from %pSU", &su); vty_create(vty_sock, &su); - - return 0; } static void vty_serv_sock_addrinfo(const char *hostname, unsigned short port) @@ -1968,7 +1963,7 @@ static void vty_serv_un(const char *path) /* #define VTYSH_DEBUG 1 */ -static int vtysh_accept(struct thread *thread) +static void vtysh_accept(struct thread *thread) { struct vty_serv *vtyserv = THREAD_ARG(thread); int accept_sock = vtyserv->sock; @@ -1988,7 +1983,7 @@ static int vtysh_accept(struct thread *thread) if (sock < 0) { flog_err(EC_LIB_SOCKET, "can't accept vty socket : %s", safe_strerror(errno)); - return -1; + return; } if (set_nonblocking(sock) < 0) { @@ -1997,7 +1992,7 @@ static int vtysh_accept(struct thread *thread) "vtysh_accept: could not set vty socket %d to non-blocking, %s, closing", sock, safe_strerror(errno)); close(sock); - return -1; + return; } set_cloexec(sock); @@ -2013,8 +2008,6 @@ static int vtysh_accept(struct thread *thread) vtys_add_tail(vtysh_sessions, vty); vty_event(VTYSH_READ, vty); - - return 0; } static int vtysh_flush(struct vty *vty) @@ -2038,7 +2031,7 @@ static int vtysh_flush(struct vty *vty) return 0; } -static int vtysh_read(struct thread *thread) +static void vtysh_read(struct thread *thread) { int ret; int sock; @@ -2055,7 +2048,7 @@ static int vtysh_read(struct thread *thread) if (nbytes < 0) { if (ERRNO_IO_RETRY(errno)) { vty_event(VTYSH_READ, vty); - return 0; + return; } vty->monitor = 0; /* disable monitoring to avoid infinite recursion */ @@ -2070,7 +2063,7 @@ static int vtysh_read(struct thread *thread) #ifdef VTYSH_DEBUG printf("close vtysh\n"); #endif /* VTYSH_DEBUG */ - return 0; + return; } #ifdef VTYSH_DEBUG @@ -2112,7 +2105,7 @@ static int vtysh_read(struct thread *thread) if (!vty->t_write && (vtysh_flush(vty) < 0)) /* Try to flush results; exit if a write * error occurs. */ - return 0; + return; } } } @@ -2121,16 +2114,13 @@ static int vtysh_read(struct thread *thread) vty_close(vty); else vty_event(VTYSH_READ, vty); - - return 0; } -static int vtysh_write(struct thread *thread) +static void vtysh_write(struct thread *thread) { struct vty *vty = THREAD_ARG(thread); vtysh_flush(vty); - return 0; } #endif /* VTYSH */ @@ -2221,7 +2211,7 @@ void vty_close(struct vty *vty) } /* When time out occur output message then close connection. */ -static int vty_timeout(struct thread *thread) +static void vty_timeout(struct thread *thread) { struct vty *vty; @@ -2236,8 +2226,6 @@ static int vty_timeout(struct thread *thread) /* Close connection. */ vty->status = VTY_CLOSE; vty_close(vty); - - return 0; } /* Read up configuration file from file_name. */ diff --git a/lib/wheel.c b/lib/wheel.c index 1a0469b25..463410bea 100644 --- a/lib/wheel.c +++ b/lib/wheel.c @@ -29,9 +29,9 @@ DEFINE_MTYPE_STATIC(LIB, TIMER_WHEEL_LIST, "Timer Wheel Slot List"); static int debug_timer_wheel = 0; -static int wheel_timer_thread(struct thread *t); +static void wheel_timer_thread(struct thread *t); -static int wheel_timer_thread_helper(struct thread *t) +static void wheel_timer_thread_helper(struct thread *t) { struct listnode *node, *nextnode; unsigned long long curr_slot; @@ -63,19 +63,15 @@ static int wheel_timer_thread_helper(struct thread *t) wheel->slots_to_skip = slots_to_skip; thread_add_timer_msec(wheel->master, wheel_timer_thread, wheel, wheel->nexttime * slots_to_skip, &wheel->timer); - - return 0; } -static int wheel_timer_thread(struct thread *t) +static void wheel_timer_thread(struct thread *t) { struct timer_wheel *wheel; wheel = THREAD_ARG(t); thread_execute(wheel->master, wheel_timer_thread_helper, wheel, 0); - - return 0; } struct timer_wheel *wheel_init(struct thread_master *master, int period, diff --git a/lib/workqueue.c b/lib/workqueue.c index 86afe4082..92869594d 100644 --- a/lib/workqueue.c +++ b/lib/workqueue.c @@ -238,7 +238,7 @@ void work_queue_unplug(struct work_queue *wq) * will reschedule itself if required, * otherwise work_queue_item_add */ -int work_queue_run(struct thread *thread) +void work_queue_run(struct thread *thread) { struct work_queue *wq; struct work_queue_item *item, *titem; @@ -388,6 +388,4 @@ stats: } else if (wq->spec.completion_func) wq->spec.completion_func(wq); - - return 0; } diff --git a/lib/workqueue.h b/lib/workqueue.h index b076ed0d2..39202dcda 100644 --- a/lib/workqueue.h +++ b/lib/workqueue.h @@ -177,7 +177,7 @@ extern void work_queue_unplug(struct work_queue *wq); bool work_queue_is_scheduled(struct work_queue *); /* Helpers, exported for thread.c and command.c */ -extern int work_queue_run(struct thread *); +extern void work_queue_run(struct thread *); extern void workqueue_cmd_init(void); diff --git a/lib/zclient.c b/lib/zclient.c index ab2dd0989..cfccb2166 100644 --- a/lib/zclient.c +++ b/lib/zclient.c @@ -263,20 +263,21 @@ static enum zclient_send_status zclient_failed(struct zclient *zclient) return ZCLIENT_SEND_FAILURE; } -static int zclient_flush_data(struct thread *thread) +static void zclient_flush_data(struct thread *thread) { struct zclient *zclient = THREAD_ARG(thread); zclient->t_write = NULL; if (zclient->sock < 0) - return -1; + return; switch (buffer_flush_available(zclient->wb, zclient->sock)) { case BUFFER_ERROR: flog_err( EC_LIB_ZAPI_SOCKET, "%s: buffer_flush_available failed on zclient fd %d, closing", __func__, zclient->sock); - return zclient_failed(zclient); + zclient_failed(zclient); + return; case BUFFER_PENDING: zclient->t_write = NULL; thread_add_write(zclient->master, zclient_flush_data, zclient, @@ -287,7 +288,6 @@ static int zclient_flush_data(struct thread *thread) (*zclient->zebra_buffer_write_ready)(); break; } - return 0; } /* @@ -754,7 +754,7 @@ void zclient_init(struct zclient *zclient, int redist_default, /* This function is a wrapper function for calling zclient_start from timer or event thread. */ -static int zclient_connect(struct thread *t) +static void zclient_connect(struct thread *t) { struct zclient *zclient; @@ -764,7 +764,7 @@ static int zclient_connect(struct thread *t) if (zclient_debug) zlog_debug("zclient_connect is called"); - return zclient_start(zclient); + zclient_start(zclient); } enum zclient_send_status zclient_send_rnh(struct zclient *zclient, int command, @@ -3864,7 +3864,7 @@ static zclient_handler *const lib_handlers[] = { }; /* Zebra client message read function. */ -static int zclient_read(struct thread *thread) +static void zclient_read(struct thread *thread) { size_t already; uint16_t length, command; @@ -3888,11 +3888,12 @@ static int zclient_read(struct thread *thread) zlog_debug( "zclient connection closed socket [%d].", zclient->sock); - return zclient_failed(zclient); + zclient_failed(zclient); + return; } if (nbyte != (ssize_t)(ZEBRA_HEADER_SIZE - already)) { zclient_event(ZCLIENT_READ, zclient); - return 0; + return; } already = ZEBRA_HEADER_SIZE; } @@ -3912,14 +3913,16 @@ static int zclient_read(struct thread *thread) EC_LIB_ZAPI_MISSMATCH, "%s: socket %d version mismatch, marker %d, version %d", __func__, zclient->sock, marker, version); - return zclient_failed(zclient); + zclient_failed(zclient); + return; } if (length < ZEBRA_HEADER_SIZE) { flog_err(EC_LIB_ZAPI_MISSMATCH, "%s: socket %d message length %u is less than %d ", __func__, zclient->sock, length, ZEBRA_HEADER_SIZE); - return zclient_failed(zclient); + zclient_failed(zclient); + return; } /* Length check. */ @@ -3947,12 +3950,13 @@ static int zclient_read(struct thread *thread) zlog_debug( "zclient connection closed socket [%d].", zclient->sock); - return zclient_failed(zclient); + zclient_failed(zclient); + return; } if (nbyte != (ssize_t)(length - already)) { /* Try again later. */ zclient_event(ZCLIENT_READ, zclient); - return 0; + return; } } @@ -3969,13 +3973,11 @@ static int zclient_read(struct thread *thread) if (zclient->sock < 0) /* Connection was closed during packet processing. */ - return -1; + return; /* Register read thread. */ stream_reset(zclient->ibuf); zclient_event(ZCLIENT_READ, zclient); - - return 0; } void zclient_redistribute(int command, struct zclient *zclient, afi_t afi, diff --git a/lib/zlog_5424.c b/lib/zlog_5424.c index 740d6bfba..9da7c55fc 100644 --- a/lib/zlog_5424.c +++ b/lib/zlog_5424.c @@ -799,7 +799,7 @@ static void zlog_5424_cycle(struct zlog_cfg_5424 *zcf, int fd) rcu_free(MTYPE_LOG_5424, oldt, zt.rcu_head); } -static int zlog_5424_reconnect(struct thread *t) +static void zlog_5424_reconnect(struct thread *t) { struct zlog_cfg_5424 *zcf = THREAD_ARG(t); int fd = THREAD_FD(t); @@ -812,7 +812,7 @@ static int zlog_5424_reconnect(struct thread *t) /* logger is sending us something?!?! */ thread_add_read(t->master, zlog_5424_reconnect, zcf, fd, &zcf->t_reconnect); - return 0; + return; } if (ret == 0) @@ -832,7 +832,6 @@ static int zlog_5424_reconnect(struct thread *t) frr_with_mutex (&zcf->cfg_mtx) { zlog_5424_cycle(zcf, fd); } - return 0; } static int zlog_5424_unix(struct sockaddr_un *suna, int sock_type) |