aboutsummaryrefslogtreecommitdiff
path: root/src/drivers/mpu6000
diff options
context:
space:
mode:
authorAndrew Tridgell <tridge@samba.org>2013-09-09 17:16:12 +1000
committerLorenz Meier <lm@inf.ethz.ch>2013-09-12 00:52:13 +0200
commit815ccee0e7f642b2471084296c893a4dd49e5dfb (patch)
tree134d3e703171146be3b8d27ab470190a0895dd9a /src/drivers/mpu6000
parent37d09f09448a274d5f9c55674fd6734709f8a383 (diff)
downloadpx4-firmware-815ccee0e7f642b2471084296c893a4dd49e5dfb.tar.gz
px4-firmware-815ccee0e7f642b2471084296c893a4dd49e5dfb.tar.bz2
px4-firmware-815ccee0e7f642b2471084296c893a4dd49e5dfb.zip
mpu6000: fixed race condition in buffer increment
Diffstat (limited to 'src/drivers/mpu6000')
-rw-r--r--src/drivers/mpu6000/mpu6000.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/src/drivers/mpu6000/mpu6000.cpp b/src/drivers/mpu6000/mpu6000.cpp
index 81612aee7..66d36826a 100644
--- a/src/drivers/mpu6000/mpu6000.cpp
+++ b/src/drivers/mpu6000/mpu6000.cpp
@@ -668,9 +668,10 @@ MPU6000::read(struct file *filp, char *buffer, size_t buflen)
_accel_report *arp = reinterpret_cast<_accel_report *>(buffer);
int transferred = 0;
while (count--) {
- if (!_accel_reports->get(*arp++))
+ if (!_accel_reports->get(*arp))
break;
transferred++;
+ arp++;
}
/* return the number of bytes transferred */
@@ -758,12 +759,13 @@ MPU6000::gyro_read(struct file *filp, char *buffer, size_t buflen)
return -EAGAIN;
/* copy reports out of our buffer to the caller */
- _gyro_report *arp = reinterpret_cast<_gyro_report *>(buffer);
+ _gyro_report *grp = reinterpret_cast<_gyro_report *>(buffer);
int transferred = 0;
while (count--) {
- if (!_gyro_reports->get(*arp++))
+ if (!_gyro_reports->get(*grp))
break;
transferred++;
+ grp++;
}
/* return the number of bytes transferred */