arehbein has uploaded this change for review. ( https://gerrit.osmocom.org/c/libosmocore/+/33345 )
Change subject: core/osmo_io: Rename variables for readability ......................................................................
core/osmo_io: Rename variables for readability
Rename msg_len -> received_len, len -> expected_len so the variable names have a consistent scheme. For instance, extra_len = msg_len - len becomes extra_len = received_len - expected_len
Change-Id: I3d752ce91a1b16c855522f643d10a52ef28a8a84 --- M src/core/osmo_io.c 1 file changed, 26 insertions(+), 9 deletions(-)
git pull ssh://gerrit.osmocom.org:29418/libosmocore refs/changes/45/33345/1
diff --git a/src/core/osmo_io.c b/src/core/osmo_io.c index d260da4..b0287ec 100644 --- a/src/core/osmo_io.c +++ b/src/core/osmo_io.c @@ -219,28 +219,29 @@ */ static enum iofd_seg_act iofd_handle_segmentation(struct osmo_io_fd *iofd, struct msgb *msg, struct msgb **pending_out) { - int extra_len, msg_len; + int extra_len, received_len; struct msgb *msg_pending;
- msg_len = msgb_length(msg); + received_len = msgb_length(msg);
if (!iofd->io_ops.segmentation_cb) { *pending_out = NULL; return IOFD_SEG_ACT_HANDLE_ONE; }
- int len = iofd->io_ops.segmentation_cb(msg); - if (len == -EAGAIN) { + int expected_len = iofd->io_ops.segmentation_cb(msg); + if (expected_len == -EAGAIN) { goto defer; - } else if (len < 0) { + } else if (expected_len < 0) { /* Something is wrong, skip this msgb */ - LOGPIO(iofd, LOGL_ERROR, "segmentation_cb returned error (%d), skipping msg of size %d\n", len, msg_len); + LOGPIO(iofd, LOGL_ERROR, "segmentation_cb returned error (%d), skipping msg of size %d\n", + expected_len, received_len); *pending_out = NULL; msgb_free(msg); return IOFD_SEG_ACT_DEFER; }
- extra_len = msg_len - len; + extra_len = received_len - expected_len; /* No segmentation needed, return the whole msgb */ if (extra_len == 0) { *pending_out = NULL; @@ -253,12 +254,12 @@ /* msgb contains more than one segment */ /* Copy the trailing data over */ msg_pending = iofd_msgb_alloc(iofd); - memcpy(msgb_data(msg_pending), msgb_data(msg) + len, extra_len); + memcpy(msgb_data(msg_pending), msgb_data(msg) + expected_len, extra_len); msgb_put(msg_pending, extra_len); *pending_out = msg_pending;
/* Trim the original msgb to size */ - msgb_trim(msg, len); + msgb_trim(msg, expected_len); return IOFD_SEG_ACT_HANDLE_MORE;
defer: