pespin has uploaded this change for review. ( 
https://gerrit.osmocom.org/c/libosmocore/+/41989?usp=email )


Change subject: osmo_io: Allow fetching maximum value allowed by 
osmo_iofd_set_io_buffers()
......................................................................

osmo_io: Allow fetching maximum value allowed by osmo_iofd_set_io_buffers()

Before this patch, there's no way for a user of the API to know whether
a requested buffers value is actually going to be accepted or not.

Change-Id: Id3d8413c119eb3d9b60aa068295a59561236938c
---
M src/core/osmo_io.c
1 file changed, 9 insertions(+), 1 deletion(-)



  git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/89/41989/1

diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c
index 7c931d3..8ee6967 100644
--- a/src/core/osmo_io.c
+++ b/src/core/osmo_io.c
@@ -915,15 +915,23 @@
  *  \param[in] op the osmo_io_op (read or write) to set the number of IO 
buffers for
  *  \param[in] buffers the number of IO buffer for each specified operation
  *  \returns zero on success, a negative value on error
+ *
+ * The minimum valid buffers to set is always 1.
+ * The maximum valid buffers is implementation defined, and trying to set a
+ * value greater than the maximum will return an error.
+ * Passing \ref buffers with a value of 0 can be used to fetch the maximum 
value allowed.
  */
 int osmo_iofd_set_io_buffers(struct osmo_io_fd *iofd, enum osmo_io_op op, 
uint8_t buffers)
 {
        if (iofd->mode != OSMO_IO_FD_MODE_READ_WRITE)
                return -EINVAL;

-       if (buffers < 1 || buffers > IOFD_MSGHDR_IO_BUFFERS)
+       if (buffers > IOFD_MSGHDR_IO_BUFFERS)
                return -EINVAL;

+       if (buffers == 0)
+               return IOFD_MSGHDR_IO_BUFFERS;
+
        switch (op) {
        case OSMO_IO_OP_READ:
                iofd->io_read_buffers = buffers;

--
To view, visit https://gerrit.osmocom.org/c/libosmocore/+/41989?usp=email
To unsubscribe, or for help writing mail filters, visit 
https://gerrit.osmocom.org/settings?usp=email

Gerrit-MessageType: newchange
Gerrit-Project: libosmocore
Gerrit-Branch: master
Gerrit-Change-Id: Id3d8413c119eb3d9b60aa068295a59561236938c
Gerrit-Change-Number: 41989
Gerrit-PatchSet: 1
Gerrit-Owner: pespin <[email protected]>

Reply via email to