[XS] Change in libosmo-netif[master]: stream: Allow null ptr in destroy() functions
laforge has submitted this change. ( https://gerrit.osmocom.org/c/libosmo-netif/+/38972?usp=email ) Change subject: stream: Allow null ptr in destroy() functions .. stream: Allow null ptr in destroy() functions It's common pattern that free/destroy functions allow NULL pointers. Let's accept it here to make life easier for users. Change-Id: I99e23db6617af8261b512efffc62336b63b38516 --- M src/stream_cli.c M src/stream_srv.c 2 files changed, 8 insertions(+), 0 deletions(-) Approvals: laforge: Looks good to me, approved Jenkins Builder: Verified diff --git a/src/stream_cli.c b/src/stream_cli.c index a00f32a..89681b0 100644 --- a/src/stream_cli.c +++ b/src/stream_cli.c @@ -962,6 +962,9 @@ * \param[in] cli Stream Client to destroy */ void osmo_stream_cli_destroy(struct osmo_stream_cli *cli) { + if (!cli) + return; + LOGSCLI(cli, LOGL_DEBUG, "destroy()\n"); OSMO_ASSERT(!stream_cli_close(cli)); osmo_timer_del(&cli->timer); diff --git a/src/stream_srv.c b/src/stream_srv.c index 4f9323b..c74f7b0 100644 --- a/src/stream_srv.c +++ b/src/stream_srv.c @@ -510,6 +510,8 @@ * \param[in] link Stream Server Link */ void osmo_stream_srv_link_destroy(struct osmo_stream_srv_link *link) { + if (!link) + return; osmo_stream_srv_link_close(link); talloc_free(link); } @@ -1140,6 +1142,9 @@ * \param[in] conn Stream Server to be destroyed */ void osmo_stream_srv_destroy(struct osmo_stream_srv *conn) { + if (!conn) + return; + switch (conn->mode) { case OSMO_STREAM_MODE_OSMO_FD: osmo_fd_unregister(&conn->ofd); -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/38972?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: merged Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: I99e23db6617af8261b512efffc62336b63b38516 Gerrit-Change-Number: 38972 Gerrit-PatchSet: 1 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith
[XS] Change in libosmo-netif[master]: stream: Allow null ptr in destroy() functions
Attention is currently required from: fixeria, osmith, pespin. laforge has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/libosmo-netif/+/38972?usp=email ) Change subject: stream: Allow null ptr in destroy() functions .. Patch Set 1: Code-Review+2 -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/38972?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: I99e23db6617af8261b512efffc62336b63b38516 Gerrit-Change-Number: 38972 Gerrit-PatchSet: 1 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: fixeria Gerrit-Reviewer: laforge Gerrit-Reviewer: osmith Gerrit-Attention: osmith Gerrit-Attention: pespin Gerrit-Attention: fixeria Gerrit-Comment-Date: Thu, 28 Nov 2024 17:04:50 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes
[XS] Change in libosmo-netif[master]: stream: Allow null ptr in destroy() functions
Attention is currently required from: pespin. laforge has posted comments on this change by pespin. ( https://gerrit.osmocom.org/c/libosmo-netif/+/38972?usp=email ) Change subject: stream: Allow null ptr in destroy() functions .. Patch Set 1: Code-Review+1 -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/38972?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: comment Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: I99e23db6617af8261b512efffc62336b63b38516 Gerrit-Change-Number: 38972 Gerrit-PatchSet: 1 Gerrit-Owner: pespin Gerrit-Reviewer: Jenkins Builder Gerrit-Reviewer: laforge Gerrit-Attention: pespin Gerrit-Comment-Date: Thu, 28 Nov 2024 14:47:54 + Gerrit-HasComments: No Gerrit-Has-Labels: Yes
[XS] Change in libosmo-netif[master]: stream: Allow null ptr in destroy() functions
pespin has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmo-netif/+/38972?usp=email ) Change subject: stream: Allow null ptr in destroy() functions .. stream: Allow null ptr in destroy() functions It's common pattern that free/destroy functions allow NULL pointers. Let's accept it here to make life easier for users. Change-Id: I99e23db6617af8261b512efffc62336b63b38516 --- M src/stream_cli.c M src/stream_srv.c 2 files changed, 8 insertions(+), 0 deletions(-) git pull ssh://gerrit.osmocom.org:29418/libosmo-netif refs/changes/72/38972/1 diff --git a/src/stream_cli.c b/src/stream_cli.c index a00f32a..89681b0 100644 --- a/src/stream_cli.c +++ b/src/stream_cli.c @@ -962,6 +962,9 @@ * \param[in] cli Stream Client to destroy */ void osmo_stream_cli_destroy(struct osmo_stream_cli *cli) { + if (!cli) + return; + LOGSCLI(cli, LOGL_DEBUG, "destroy()\n"); OSMO_ASSERT(!stream_cli_close(cli)); osmo_timer_del(&cli->timer); diff --git a/src/stream_srv.c b/src/stream_srv.c index 4f9323b..c74f7b0 100644 --- a/src/stream_srv.c +++ b/src/stream_srv.c @@ -510,6 +510,8 @@ * \param[in] link Stream Server Link */ void osmo_stream_srv_link_destroy(struct osmo_stream_srv_link *link) { + if (!link) + return; osmo_stream_srv_link_close(link); talloc_free(link); } @@ -1140,6 +1142,9 @@ * \param[in] conn Stream Server to be destroyed */ void osmo_stream_srv_destroy(struct osmo_stream_srv *conn) { + if (!conn) + return; + switch (conn->mode) { case OSMO_STREAM_MODE_OSMO_FD: osmo_fd_unregister(&conn->ofd); -- To view, visit https://gerrit.osmocom.org/c/libosmo-netif/+/38972?usp=email To unsubscribe, or for help writing mail filters, visit https://gerrit.osmocom.org/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: libosmo-netif Gerrit-Branch: master Gerrit-Change-Id: I99e23db6617af8261b512efffc62336b63b38516 Gerrit-Change-Number: 38972 Gerrit-PatchSet: 1 Gerrit-Owner: pespin