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 /pathd | |
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 'pathd')
-rw-r--r-- | pathd/path_pcep_controller.c | 65 | ||||
-rw-r--r-- | pathd/path_pcep_controller.h | 4 | ||||
-rw-r--r-- | pathd/path_pcep_lib.c | 16 | ||||
-rw-r--r-- | pathd/path_ted.c | 13 | ||||
-rw-r--r-- | pathd/pathd.c | 12 |
5 files changed, 46 insertions, 64 deletions
diff --git a/pathd/path_pcep_controller.c b/pathd/path_pcep_controller.c index 162c53590..b9f2ba3c6 100644 --- a/pathd/path_pcep_controller.c +++ b/pathd/path_pcep_controller.c @@ -92,10 +92,10 @@ struct get_pcep_session_args { /* Internal Functions Called From Main Thread */ static int pcep_ctrl_halt_cb(struct frr_pthread *fpt, void **res); -static int pcep_refine_path_event_cb(struct thread *thread); +static void pcep_refine_path_event_cb(struct thread *thread); /* Internal Functions Called From Controller Thread */ -static int pcep_thread_finish_event_handler(struct thread *thread); +static void pcep_thread_finish_event_handler(struct thread *thread); /* Controller Thread Timer Handler */ static int schedule_thread_timer(struct ctrl_state *ctrl_state, int pcc_id, @@ -108,7 +108,7 @@ static int schedule_thread_timer_with_cb( enum pcep_ctrl_timer_type timer_type, enum pcep_ctrl_timeout_type timeout_type, uint32_t delay, void *payload, struct thread **thread, pcep_ctrl_thread_callback timer_cb); -static int pcep_thread_timer_handler(struct thread *thread); +static void pcep_thread_timer_handler(struct thread *thread); /* Controller Thread Socket read/write Handler */ static int schedule_thread_socket(struct ctrl_state *ctrl_state, int pcc_id, @@ -124,7 +124,7 @@ static int send_to_thread_with_cb(struct ctrl_state *ctrl_state, int pcc_id, enum pcep_ctrl_event_type type, uint32_t sub_type, void *payload, pcep_ctrl_thread_callback event_cb); -static int pcep_thread_event_handler(struct thread *thread); +static void pcep_thread_event_handler(struct thread *thread); static int pcep_thread_event_update_pcc_options(struct ctrl_state *ctrl_state, struct pcc_opts *opts); static int pcep_thread_event_update_pce_options(struct ctrl_state *ctrl_state, @@ -149,7 +149,7 @@ pcep_thread_path_refined_event(struct ctrl_state *ctrl_state, /* Main Thread Event Handler */ static int send_to_main(struct ctrl_state *ctrl_state, int pcc_id, enum pcep_main_event_type type, void *payload); -static int pcep_main_event_handler(struct thread *thread); +static void pcep_main_event_handler(struct thread *thread); /* Helper functions */ static void set_ctrl_state(struct frr_pthread *fpt, @@ -340,7 +340,7 @@ int pcep_ctrl_halt_cb(struct frr_pthread *fpt, void **res) return 0; } -int pcep_refine_path_event_cb(struct thread *thread) +void pcep_refine_path_event_cb(struct thread *thread) { struct pcep_refine_path_event_data *data = THREAD_ARG(thread); assert(data != NULL); @@ -351,7 +351,7 @@ int pcep_refine_path_event_cb(struct thread *thread) path_pcep_refine_path(path); - return send_to_thread(ctrl_state, pcc_id, EV_PATH_REFINED, 0, data); + send_to_thread(ctrl_state, pcc_id, EV_PATH_REFINED, 0, data); } @@ -507,7 +507,7 @@ void pcep_thread_path_refined_event(struct ctrl_state *ctrl_state, /* ------------ Internal Functions Called From Controller Thread ------------ */ -int pcep_thread_finish_event_handler(struct thread *thread) +void pcep_thread_finish_event_handler(struct thread *thread) { int i; struct frr_pthread *fpt = THREAD_ARG(thread); @@ -527,7 +527,6 @@ int pcep_thread_finish_event_handler(struct thread *thread) fpt->data = NULL; atomic_store_explicit(&fpt->running, false, memory_order_relaxed); - return 0; } /* ------------ Controller Thread Timer Handler ------------ */ @@ -566,7 +565,7 @@ int schedule_thread_timer(struct ctrl_state *ctrl_state, int pcc_id, thread, pcep_thread_timer_handler); } -int pcep_thread_timer_handler(struct thread *thread) +void pcep_thread_timer_handler(struct thread *thread) { /* data unpacking */ struct pcep_ctrl_timer_data *data = THREAD_ARG(thread); @@ -579,26 +578,25 @@ int pcep_thread_timer_handler(struct thread *thread) void *param = data->payload; XFREE(MTYPE_PCEP, data); - int ret = 0; struct pcc_state *pcc_state = NULL; switch (timer_type) { case TM_RECONNECT_PCC: pcc_state = pcep_pcc_get_pcc_by_id(ctrl_state->pcc, pcc_id); if (!pcc_state) - return ret; + return; pcep_pcc_reconnect(ctrl_state, pcc_state); break; case TM_TIMEOUT: pcc_state = pcep_pcc_get_pcc_by_id(ctrl_state->pcc, pcc_id); if (!pcc_state) - return ret; + return; pcep_pcc_timeout_handler(ctrl_state, pcc_state, timeout_type, param); break; case TM_CALCULATE_BEST_PCE: /* Previous best disconnect so new best should be synced */ - ret = pcep_pcc_timer_update_best_pce(ctrl_state, pcc_id); + pcep_pcc_timer_update_best_pce(ctrl_state, pcc_id); break; case TM_SESSION_TIMEOUT_PCC: pcc_state = pcep_pcc_get_pcc_by_id(ctrl_state->pcc, pcc_id); @@ -610,11 +608,9 @@ int pcep_thread_timer_handler(struct thread *thread) "Unknown controller timer triggered: %u", timer_type); break; } - - return ret; } -int pcep_thread_pcep_event(struct thread *thread) +void pcep_thread_pcep_event(struct thread *thread) { struct pcep_ctrl_event_data *data = THREAD_ARG(thread); assert(data != NULL); @@ -634,8 +630,6 @@ int pcep_thread_pcep_event(struct thread *thread) } } destroy_pcep_event(event); - - return 0; } /* ------------ Controller Thread Socket Functions ------------ */ @@ -725,7 +719,7 @@ int send_to_thread_with_cb(struct ctrl_state *ctrl_state, int pcc_id, return 0; } -int pcep_thread_event_handler(struct thread *thread) +void pcep_thread_event_handler(struct thread *thread) { /* data unpacking */ struct pcep_ctrl_event_data *data = THREAD_ARG(thread); @@ -738,8 +732,6 @@ int pcep_thread_event_handler(struct thread *thread) void *payload = data->payload; XFREE(MTYPE_PCEP, data); - int ret = 0; - /* Possible sub-type values */ enum pcep_pathd_event_type path_event_type = PCEP_PATH_UNDEFINED; @@ -757,29 +749,26 @@ int pcep_thread_event_handler(struct thread *thread) case EV_UPDATE_PCC_OPTS: assert(payload != NULL); pcc_opts = (struct pcc_opts *)payload; - ret = pcep_thread_event_update_pcc_options(ctrl_state, - pcc_opts); + pcep_thread_event_update_pcc_options(ctrl_state, pcc_opts); break; case EV_UPDATE_PCE_OPTS: assert(payload != NULL); pce_opts = (struct pce_opts *)payload; - ret = pcep_thread_event_update_pce_options(ctrl_state, pcc_id, - pce_opts); + pcep_thread_event_update_pce_options(ctrl_state, pcc_id, + pce_opts); break; case EV_REMOVE_PCC: pce_opts = (struct pce_opts *)payload; - ret = pcep_thread_event_remove_pcc(ctrl_state, pce_opts); - if (ret == 0) { - ret = pcep_pcc_multi_pce_remove_pcc(ctrl_state, - ctrl_state->pcc); - } + if (pcep_thread_event_remove_pcc(ctrl_state, pce_opts) == 0) + pcep_pcc_multi_pce_remove_pcc(ctrl_state, + ctrl_state->pcc); break; case EV_PATHD_EVENT: assert(payload != NULL); path_event_type = (enum pcep_pathd_event_type)sub_type; path = (struct path *)payload; - ret = pcep_thread_event_pathd_event(ctrl_state, path_event_type, - path); + pcep_thread_event_pathd_event(ctrl_state, path_event_type, + path); break; case EV_SYNC_PATH: assert(payload != NULL); @@ -789,14 +778,14 @@ int pcep_thread_event_handler(struct thread *thread) pcep_thread_event_sync_path(ctrl_state, pcc_id, path); break; case EV_SYNC_DONE: - ret = pcep_thread_event_sync_done(ctrl_state, pcc_id); + pcep_thread_event_sync_done(ctrl_state, pcc_id); break; case EV_RESET_PCC_SESSION: pcc_state = pcep_pcc_get_pcc_by_name(ctrl_state->pcc, (const char *)payload); if (pcc_state) { pcep_pcc_disable(ctrl_state, pcc_state); - ret = pcep_pcc_enable(ctrl_state, pcc_state); + pcep_pcc_enable(ctrl_state, pcc_state); } else { flog_warn(EC_PATH_PCEP_RECOVERABLE_INTERNAL_ERROR, "Cannot reset state for PCE: %s", @@ -840,8 +829,6 @@ int pcep_thread_event_handler(struct thread *thread) type); break; } - - return ret; } int pcep_thread_event_update_pcc_options(struct ctrl_state *ctrl_state, @@ -994,7 +981,7 @@ int send_to_main(struct ctrl_state *ctrl_state, int pcc_id, return 0; } -int pcep_main_event_handler(struct thread *thread) +void pcep_main_event_handler(struct thread *thread) { /* data unpacking */ struct pcep_main_event_data *data = THREAD_ARG(thread); @@ -1005,7 +992,7 @@ int pcep_main_event_handler(struct thread *thread) void *payload = data->payload; XFREE(MTYPE_PCEP, data); - return handler(type, pcc_id, payload); + handler(type, pcc_id, payload); } diff --git a/pathd/path_pcep_controller.h b/pathd/path_pcep_controller.h index f55cc0db7..de113feee 100644 --- a/pathd/path_pcep_controller.h +++ b/pathd/path_pcep_controller.h @@ -90,7 +90,7 @@ struct pcep_ctrl_socket_data { void *payload; }; -typedef int (*pcep_ctrl_thread_callback)(struct thread *); +typedef void (*pcep_ctrl_thread_callback)(struct thread *); /* PCC connection information, populated in a thread-safe * manner with pcep_ctrl_get_pcc_info() */ @@ -174,7 +174,7 @@ int pcep_thread_socket_write(void *fpt, void **thread, int fd, void *payload, int pcep_thread_send_ctrl_event(void *fpt, void *payload, pcep_ctrl_thread_callback cb); -int pcep_thread_pcep_event(struct thread *thread); +void pcep_thread_pcep_event(struct thread *thread); int pcep_thread_pcc_count(struct ctrl_state *ctrl_state); /* Called by the PCC to refine a path in the main thread */ int pcep_thread_refine_path(struct ctrl_state *ctrl_state, int pcc_id, diff --git a/pathd/path_pcep_lib.c b/pathd/path_pcep_lib.c index 9fc8c091f..8e3565d72 100644 --- a/pathd/path_pcep_lib.c +++ b/pathd/path_pcep_lib.c @@ -45,8 +45,8 @@ static int pcep_lib_pceplib_socket_read_cb(void *fpt, void **thread, int fd, void *payload); static int pcep_lib_pceplib_socket_write_cb(void *fpt, void **thread, int fd, void *payload); -static int pcep_lib_socket_read_ready(struct thread *thread); -static int pcep_lib_socket_write_ready(struct thread *thread); +static void pcep_lib_socket_read_ready(struct thread *thread); +static void pcep_lib_socket_write_ready(struct thread *thread); /* pceplib pcep_event callbacks */ static void pcep_lib_pceplib_event_cb(void *fpt, pcep_event *event); @@ -241,26 +241,22 @@ int pcep_lib_pceplib_socket_read_cb(void *fpt, void **thread, int fd, /* Callbacks called by path_pcep_controller when a socket is ready to read/write */ -int pcep_lib_socket_write_ready(struct thread *thread) +void pcep_lib_socket_write_ready(struct thread *thread) { struct pcep_ctrl_socket_data *data = THREAD_ARG(thread); assert(data != NULL); - int retval = pceplib_external_socket_write(data->fd, data->payload); + pceplib_external_socket_write(data->fd, data->payload); XFREE(MTYPE_PCEP, data); - - return retval; } -int pcep_lib_socket_read_ready(struct thread *thread) +void pcep_lib_socket_read_ready(struct thread *thread) { struct pcep_ctrl_socket_data *data = THREAD_ARG(thread); assert(data != NULL); - int retval = pceplib_external_socket_read(data->fd, data->payload); + pceplib_external_socket_read(data->fd, data->payload); XFREE(MTYPE_PCEP, data); - - return retval; } /* Callback passed to pceplib when a pcep_event is ready */ diff --git a/pathd/path_ted.c b/pathd/path_ted.c index ff9bc82f3..3440b9339 100644 --- a/pathd/path_ted.c +++ b/pathd/path_ted.c @@ -39,8 +39,8 @@ static void path_ted_unregister_vty(void); static uint32_t path_ted_start_importing_igp(const char *daemon_str); static uint32_t path_ted_stop_importing_igp(void); static enum zclient_send_status path_ted_link_state_sync(void); -static int path_ted_timer_handler_sync(struct thread *thread); -static int path_ted_timer_handler_refresh(struct thread *thread); +static void path_ted_timer_handler_sync(struct thread *thread); +static void path_ted_timer_handler_refresh(struct thread *thread); static int path_ted_cli_debug_config_write(struct vty *vty); static int path_ted_cli_debug_set_all(uint32_t flags, bool set); @@ -602,14 +602,14 @@ enum zclient_send_status path_ted_link_state_sync(void) * * @return status */ -int path_ted_timer_handler_sync(struct thread *thread) +void path_ted_timer_handler_sync(struct thread *thread) { /* data unpacking */ struct ted_state *data = THREAD_ARG(thread); assert(data != NULL); /* Retry the sync */ - return path_ted_link_state_sync(); + path_ted_link_state_sync(); } /** @@ -639,10 +639,10 @@ int path_ted_segment_list_refresh(void) * * @return status */ -int path_ted_timer_handler_refresh(struct thread *thread) +void path_ted_timer_handler_refresh(struct thread *thread) { if (!path_ted_is_initialized()) - return MPLS_LABEL_NONE; + return; PATH_TED_DEBUG("%s: PATHD-TED: Refresh sid from current TED", __func__); /* data unpacking */ @@ -651,7 +651,6 @@ int path_ted_timer_handler_refresh(struct thread *thread) assert(data != NULL); srte_policy_update_ted_sid(); - return 0; } /** diff --git a/pathd/pathd.c b/pathd/pathd.c index f56da37b5..be2cfe8b0 100644 --- a/pathd/pathd.c +++ b/pathd/pathd.c @@ -45,9 +45,9 @@ DEFINE_HOOK(pathd_candidate_removed, (struct srte_candidate * candidate), (candidate)); static void trigger_pathd_candidate_created(struct srte_candidate *candidate); -static int trigger_pathd_candidate_created_timer(struct thread *thread); +static void trigger_pathd_candidate_created_timer(struct thread *thread); static void trigger_pathd_candidate_updated(struct srte_candidate *candidate); -static int trigger_pathd_candidate_updated_timer(struct thread *thread); +static void trigger_pathd_candidate_updated_timer(struct thread *thread); static void trigger_pathd_candidate_removed(struct srte_candidate *candidate); static const char * srte_candidate_metric_name(enum srte_candidate_metric_type type); @@ -1240,11 +1240,11 @@ void trigger_pathd_candidate_created(struct srte_candidate *candidate) (void *)candidate, HOOK_DELAY, &candidate->hook_timer); } -int trigger_pathd_candidate_created_timer(struct thread *thread) +void trigger_pathd_candidate_created_timer(struct thread *thread) { struct srte_candidate *candidate = THREAD_ARG(thread); candidate->hook_timer = NULL; - return hook_call(pathd_candidate_created, candidate); + hook_call(pathd_candidate_created, candidate); } void trigger_pathd_candidate_updated(struct srte_candidate *candidate) @@ -1260,11 +1260,11 @@ void trigger_pathd_candidate_updated(struct srte_candidate *candidate) (void *)candidate, HOOK_DELAY, &candidate->hook_timer); } -int trigger_pathd_candidate_updated_timer(struct thread *thread) +void trigger_pathd_candidate_updated_timer(struct thread *thread) { struct srte_candidate *candidate = THREAD_ARG(thread); candidate->hook_timer = NULL; - return hook_call(pathd_candidate_updated, candidate); + hook_call(pathd_candidate_updated, candidate); } void trigger_pathd_candidate_removed(struct srte_candidate *candidate) |