mirror of https://gerrit.osmocom.org/libosmocore
osmo_io: avoid OSMO_ASSERT one each API call
There's only one way to set the osmo_iofd_ops, which is by environment variable during the constructor time at shared library load time. There's hence no point in doing OSMO_ASSERT() on each and every call to osmo_iofd_notify_connected() at runtime. We can move those kind of asserts to the one-time load-time constructor instead. At the same time, we can extend those asserts to all the mandatory call-backs to be provided by the backend. Change-Id: Id9005ac6bb260236c88670373816bf7ee6a627f1
This commit is contained in:
parent
e1d4858277
commit
257e7898c5
|
@ -105,6 +105,13 @@ static __attribute__((constructor(103))) void on_dso_load_osmo_io(void)
|
|||
exit(1);
|
||||
}
|
||||
|
||||
OSMO_ASSERT(osmo_iofd_ops.close);
|
||||
OSMO_ASSERT(osmo_iofd_ops.write_enable);
|
||||
OSMO_ASSERT(osmo_iofd_ops.write_disable);
|
||||
OSMO_ASSERT(osmo_iofd_ops.read_enable);
|
||||
OSMO_ASSERT(osmo_iofd_ops.read_disable);
|
||||
OSMO_ASSERT(osmo_iofd_ops.notify_connected);
|
||||
|
||||
osmo_iofd_init();
|
||||
}
|
||||
|
||||
|
@ -787,7 +794,6 @@ int osmo_iofd_close(struct osmo_io_fd *iofd)
|
|||
|
||||
iofd->pending = NULL;
|
||||
|
||||
OSMO_ASSERT(osmo_iofd_ops.close);
|
||||
rc = osmo_iofd_ops.close(iofd);
|
||||
iofd->fd = -1;
|
||||
return rc;
|
||||
|
@ -927,7 +933,6 @@ void osmo_iofd_notify_connected(struct osmo_io_fd *iofd)
|
|||
{
|
||||
OSMO_ASSERT(iofd->mode == OSMO_IO_FD_MODE_READ_WRITE ||
|
||||
iofd->mode == OSMO_IO_FD_MODE_RECVMSG_SENDMSG);
|
||||
OSMO_ASSERT(osmo_iofd_ops.notify_connected);
|
||||
osmo_iofd_ops.notify_connected(iofd);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue