aboutsummaryrefslogtreecommitdiffstats
path: root/os/hal
diff options
context:
space:
mode:
authorGiovanni Di Sirio <gdisirio@gmail.com>2018-07-12 12:40:59 +0000
committerGiovanni Di Sirio <gdisirio@gmail.com>2018-07-12 12:40:59 +0000
commit5cc620c9c1b128b594fb3bb3a8329d4bf2758802 (patch)
treea5249a1cb3906c0a02158e9f2cf8797b1d86de21 /os/hal
parentdf2e703e9095baf2c037f80b76ab5e1512d63b81 (diff)
downloadChibiOS-5cc620c9c1b128b594fb3bb3a8329d4bf2758802.tar.gz
ChibiOS-5cc620c9c1b128b594fb3bb3a8329d4bf2758802.tar.bz2
ChibiOS-5cc620c9c1b128b594fb3bb3a8329d4bf2758802.zip
Fixed bug #960.
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@12162 110e8d01-0319-4d1e-a829-52ad28d1bb01
Diffstat (limited to 'os/hal')
-rw-r--r--os/hal/src/hal_queues.c16
1 files changed, 8 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;
}
/** @} */