Skip to content

Commit

Permalink
csp_if_zmqhub: Handle return value of csp_iflist_add for error checking
Browse files Browse the repository at this point in the history
Update the code to capture the return value of `csp_iflist_add` in the
variable `ret`.
This allows for proper error handling by ensuring that the
result of `csp_iflist_add` is returned by the function.

Previously, the return value was ignored, which could lead to missing critical
error information.

The return value is now used to confirm successful interface addition, and if an
error occurs, it can be properly propagated.

Signed-off-by: Gaetan Perrot <[email protected]>
  • Loading branch information
moonlight83340 committed Sep 2, 2024
1 parent 57e2a68 commit 2d61cac
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/interfaces/csp_if_zmqhub.c
Original file line number Diff line number Diff line change
Expand Up @@ -208,13 +208,13 @@ int csp_zmqhub_init_w_name_endpoints_rxfilter(const char * ifname, uint16_t addr
assert(ret == 0);

/* Register interface */
csp_iflist_add(&drv->iface);
ret = csp_iflist_add(&drv->iface);

if (return_interface) {
*return_interface = &drv->iface;
}

return CSP_ERR_NONE;
return ret;
}

int csp_zmqhub_init_filter2(const char * ifname, const char * host, uint16_t addr, uint16_t netmask, int promisc, csp_iface_t ** return_interface, char * sec_key, uint16_t subport, uint16_t pubport) {
Expand Down Expand Up @@ -310,13 +310,13 @@ int csp_zmqhub_init_filter2(const char * ifname, const char * host, uint16_t add
assert(ret == 0);

/* Register interface */
csp_iflist_add(&drv->iface);
ret = csp_iflist_add(&drv->iface);

if (return_interface) {
*return_interface = &drv->iface;
}

return CSP_ERR_NONE;
return ret;
}


Expand Down

0 comments on commit 2d61cac

Please sign in to comment.