aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorHarald Welte <laforge@osmocom.org>2024-03-07 10:41:57 +0100
committerHarald Welte <laforge@osmocom.org>2024-03-07 15:51:50 +0100
commit8b7af448d624fba187834c833e8ea8d316a36369 (patch)
tree343d703432accfcee1c3a58969ab08b5e60955a4 /src
parent257e7898c5d40039731712fc7a4948476701be64 (diff)
osmo_io: Avoid implementing non-existant situations
Both of our back-ends have a register_fd and unregister_fd back-end. Let's simplify the code by not treating them as optional, which introduces code paths that we never take, adds small runtime overhead and makes the code harder to follow. Should we ever introduce more backends which might not need those call-backs, we can either have empty functions or think about how to make them optional. Change-Id: I0077151eb676f61320b3fa2124448852aa8fd4a9
Diffstat (limited to 'src')
-rw-r--r--src/core/osmo_io.c11
1 files changed, 4 insertions, 7 deletions
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c
index d52d6012..57eba6cb 100644
--- a/src/core/osmo_io.c
+++ b/src/core/osmo_io.c
@@ -106,6 +106,8 @@ static __attribute__((constructor(103))) void on_dso_load_osmo_io(void)
}
OSMO_ASSERT(osmo_iofd_ops.close);
+ OSMO_ASSERT(osmo_iofd_ops.register_fd);
+ OSMO_ASSERT(osmo_iofd_ops.unregister_fd);
OSMO_ASSERT(osmo_iofd_ops.write_enable);
OSMO_ASSERT(osmo_iofd_ops.write_disable);
OSMO_ASSERT(osmo_iofd_ops.read_enable);
@@ -695,8 +697,7 @@ int osmo_iofd_register(struct osmo_io_fd *iofd, int fd)
return -EBADF;
}
- if (osmo_iofd_ops.register_fd)
- rc = osmo_iofd_ops.register_fd(iofd);
+ rc = osmo_iofd_ops.register_fd(iofd);
if (rc)
return rc;
@@ -720,11 +721,7 @@ int osmo_iofd_register(struct osmo_io_fd *iofd, int fd)
*/
int osmo_iofd_unregister(struct osmo_io_fd *iofd)
{
- if (osmo_iofd_ops.unregister_fd)
- return osmo_iofd_ops.unregister_fd(iofd);
- IOFD_FLAG_SET(iofd, IOFD_FLAG_CLOSED);
-
- return 0;
+ return osmo_iofd_ops.unregister_fd(iofd);
}
/*! Get the number of messages in the tx queue.