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 <pespin(a)sysmocom.de>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: fixeria <vyanitskiy(a)sysmocom.de>
Gerrit-Reviewer: laforge <laforge(a)osmocom.org>
Gerrit-Reviewer: osmith <osmith(a)sysmocom.de>