laforge has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/36193?usp=email )
Change subject: osmo_io: Avoid implementing non-existant situations ......................................................................
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 --- M src/core/osmo_io.c 1 file changed, 23 insertions(+), 7 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/93/36193/1
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c index 0b639fb..222f728 100644 --- a/src/core/osmo_io.c +++ b/src/core/osmo_io.c @@ -99,6 +99,8 @@ }
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); @@ -689,8 +691,7 @@ 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;
@@ -714,11 +715,7 @@ */ 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.