From 5cc620c9c1b128b594fb3bb3a8329d4bf2758802 Mon Sep 17 00:00:00 2001 From: Giovanni Di Sirio Date: Thu, 12 Jul 2018 12:40:59 +0000 Subject: Fixed bug #960. git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12162 110e8d01-0319-4d1e-a829-52ad28d1bb01 --- os/hal/src/hal_queues.c | 16 ++++++++-------- readme.txt | 1 + 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/os/hal/src/hal_queues.c b/os/hal/src/hal_queues.c index 1e2386c2a..6e1814343 100644 --- a/os/hal/src/hal_queues.c +++ b/os/hal/src/hal_queues.c @@ -389,13 +389,13 @@ size_t iqReadI(input_queue_t *iqp, uint8_t *bp, size_t n) { size_t iqReadTimeout(input_queue_t *iqp, uint8_t *bp, size_t n, sysinterval_t timeout) { qnotify_t nfy = iqp->q_notify; - size_t rd = 0; + size_t max = n; osalDbgCheck(n > 0U); osalSysLock(); - while (rd < n) { + while (n > 0U) { size_t done; done = iq_read(iqp, bp, n); @@ -417,7 +417,7 @@ size_t iqReadTimeout(input_queue_t *iqp, uint8_t *bp, /* Giving a preemption chance in a controlled point.*/ osalSysUnlock(); - rd += done; + n -= done; bp += done; osalSysLock(); @@ -425,7 +425,7 @@ size_t iqReadTimeout(input_queue_t *iqp, uint8_t *bp, } osalSysUnlock(); - return rd; + return max - n; } /** @@ -658,13 +658,13 @@ size_t oqWriteI(output_queue_t *oqp, const uint8_t *bp, size_t n) { size_t oqWriteTimeout(output_queue_t *oqp, const uint8_t *bp, size_t n, sysinterval_t timeout) { qnotify_t nfy = oqp->q_notify; - size_t wr = 0; + size_t max = n; osalDbgCheck(n > 0U); osalSysLock(); - while (wr < n) { + while (n > 0U) { size_t done; done = oq_write(oqp, bp, n); @@ -686,7 +686,7 @@ size_t oqWriteTimeout(output_queue_t *oqp, const uint8_t *bp, /* Giving a preemption chance in a controlled point.*/ osalSysUnlock(); - wr += done; + n -= done; bp += done; osalSysLock(); @@ -694,7 +694,7 @@ size_t oqWriteTimeout(output_queue_t *oqp, const uint8_t *bp, } osalSysUnlock(); - return wr; + return max - n; } /** @} */ diff --git a/readme.txt b/readme.txt index 372d71e9d..3e7cba7b8 100644 --- a/readme.txt +++ b/readme.txt @@ -141,6 +141,7 @@ - EX: Updated LIS302DL to 1.1.0 (backported to 18.2.1). - EX: Updated LPS25H to 1.1.0 (backported to 18.2.1). - EX: Updated LSM303DLHC to 1.1.0 (backported to 18.2.1). +- HAL: Fixed issue in hal_queues (bug #960)(backported to 18.2.2). - HAL: Fixed incorrect state change in I2S driver (bug #959)(backported to 18.2.2 and 17.6.5). - HAL: Fixed incorrect TCIE handling in STM32 serial drivers (bug #958) -- cgit v1.2.3