aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal/src
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2015-12-23 10:46:59 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2015-12-23 10:46:59 +0000
commitf81ca1be704585918bcb42e78a970bb1fefb2650 (patch)
treef2d1eb9a2f6af83623719181307a957e38d0da84 /os/hal/src
parentcceb9c2691fe879f933db1d5546e0c5642689e16 (diff)
downloadChibiOS-f81ca1be704585918bcb42e78a970bb1fefb2650.tar.gz
ChibiOS-f81ca1be704585918bcb42e78a970bb1fefb2650.tar.bz2
ChibiOS-f81ca1be704585918bcb42e78a970bb1fefb2650.zip
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@8633 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/hal/src')
-rw-r--r--os/hal/src/hal_buffers.c21
1 files changed, 10 insertions, 11 deletions
diff --git a/os/hal/src/hal_buffers.c b/os/hal/src/hal_buffers.c
index cd052912f..2f47cd649 100644
--- a/os/hal/src/hal_buffers.c
+++ b/os/hal/src/hal_buffers.c
@@ -127,13 +127,15 @@ uint8_t *ibqGetEmptyBufferI(input_buffers_queue_t *ibqp) {
* @brief Posts a new filled buffer to the queue.
*
* @param[in] ibqp pointer to the @p input_buffers_queue_t object
- * @param[in] size used size of the buffer
+ * @param[in] size used size of the buffer, cannot be zero
*
* @iclass
*/
void ibqPostFullBufferI(input_buffers_queue_t *ibqp, size_t size) {
osalDbgCheckClassI();
+
+ osalDbgCheck(size > 0);
osalDbgAssert(!ibqIsFullI(ibqp), "buffers queue full");
/* Writing size field in the buffer.*/
@@ -256,6 +258,7 @@ msg_t ibqGetTimeout(input_buffers_queue_t *ibqp, systime_t timeout) {
if (ibqp->ptr == NULL) {
msg = ibqGetFullBufferTimeout(ibqp, timeout);
if (msg != MSG_OK) {
+ ibqp->accessed = false;
return msg;
}
}
@@ -340,16 +343,14 @@ size_t ibqReadTimeout(input_buffers_queue_t *ibqp, uint8_t *bp,
memcpy(bp, ibqp->ptr, size);
/* Updating the pointers and the counter.*/
- r += size;
- bp += size;
+ r += size;
+ bp += size;
+ ibqp->ptr += size;
/* Has the current data buffer been finished? if so then release it.*/
if (ibqp->ptr >= ibqp->top) {
ibqReleaseEmptyBuffer(ibqp);
}
- else {
- ibqp->ptr += size;
- }
}
ibqp->accessed = false;
@@ -656,16 +657,14 @@ size_t obqWriteTimeout(output_buffers_queue_t *obqp, const uint8_t *bp,
memcpy(obqp->ptr, bp, size);
/* Updating the pointers and the counter.*/
- r += size;
- bp += size;
+ r += size;
+ bp += size;
+ obqp->ptr += size;
/* Has the current data buffer been finished? if so then release it.*/
if (obqp->ptr >= obqp->top) {
obqPostFullBuffer(obqp, obqp->bsize - sizeof (size_t));
}
- else {
- obqp->ptr += size;
- }
}
obqp->accessed = false;